 |
 |
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid..
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
I can't save any changes to the text file settings.txt , but reading the file works.
The code is
private async void LedShow_Loaded(object sender, RoutedEventArgs e)
{
var path = @"settings.txt";
var folder = Windows.ApplicationModel.Package.Current.Installed Location;
var file = await folder.GetFileAsync(path);
var lines = await Windows.Storage.FileIO.ReadLinesAsync(file);
sliderDelay.Value = Convert.ToInt32(lines[0]);
textBlockDelayValue.Text = lines[0] + " seconds";
buttonSave.IsEnabled = false;
}
and the error message is
An exception of type 'System.UnauthorizedAccessException' occurred in System.Private.CoreLib.dll but was not handled in user code
Access is denied. (Excep_FromHResult 0x80070005) occurred
Can someone help me?
|
|
|
|
 |
This would be right. A program normally does not have rights to write to the Program Files folder. In order to do so, you will need to elevate the rights of the application and gain administrative privileges.
The recommendation would be to use the AppData folder. Your best option would be to try and read the file from that location, and if not there, then copy it from the program files folder. Then you can read and write the file to your heart's content.
Cheers,
Mick
------------------------------------------------
It doesn't matter how often or hard you fall on your arse, eventually you'll roll over and land on your feet.
|
|
|
|
 |
I can not compress.I will be mad.I am not good in c#.This is my senior project.Please any body contact with me.İf you want help me please write maila address and ı will send mail my problem with my project
|
|
|
|
 |
Yeah, that's not going to happen. Nobody is going to do your work for you.
The entire point behind this project is to demonstrate what YOU have learned over these courses, not what begging skills you have.
|
|
|
|
 |
Now I need to know how to compress bmp image with huffman if you dont help me why do you write ?
|
|
|
|
 |
Because that's NOT what your "question" said. All it said was "send me your email address...". THAT isn't going to happen.
Why do you need someone to do your research for you? There is a ton of information on the web about compressing data with Huffman. All you have to do is Google for "compress data with huffman" and you'll find everything you need.
|
|
|
|
 |
Still you repeat same things!!!!!!!!!!
I know huffman algorithm ı also coded huffman algorithm .But
BMP is image ı dont have any information about image.AL info about text.
|
|
|
|
 |
If you REALLY knew Huffman, you'd know that you can use it no differently to compress the bytes from ANY file as easily as you feed Text bytes to it.
|
|
|
|
 |
ı know huffman ı reliazed with c# for text but image is problem for me?image int not as text ?
|
|
|
|
 |
You've been given EVERYTHING you need to fix this yourself, REPEATEDLY, and yet you insist on ignoring that.
We're not the ones with the problem.
|
|
|
|
|
 |
Because you dont know how to help !
|
|
|
|
 |
Rıza Berkay Ayçelebi wrote: how to help
You can't help someone that refuses to listen to what people tell them.
Speed of sound - 1100 ft/sec
Speed of light - 186,000 mi/sec
Speed of stupid - instantaneous.
|
|
|
|
 |
I can send you my project .I knwo huffman ı coded this algorithm.But ı didnt compress BMP could you show me how ı can compress bmp file
|
|
|
|
 |
Rıza Berkay Ayçelebi wrote: I can send you my project
Ah ha! Now it makes some sort of sense. You have mistaken us for some "do my homework assignment for me" web site. No, we are not here to do your work for you. You would need to go to a web site where you can hire a programmer to do your work for you.
Speed of sound - 1100 ft/sec
Speed of light - 186,000 mi/sec
Speed of stupid - instantaneous.
|
|
|
|
 |
just you can show me for image why dont want help me
|
|
|
|
 |
Because the code is EXACTLY the same! You say you've already coded it. There really wouldn't be any significant change, other than how you treat the source data you're passing into the algorithm. You're probably treating everything as a char when you should be treating everything as a byte.
modified 10hrs 10mins ago.
|
|
|
|
 |
 Here is Choose file for txt files
private void CompressDosyaAc_button_Click(object sender, EventArgs e)
{
try
{
saveFileDialog1.Filter = "Huffman Files (*.huf)|*.huf";
openFileDialog1.Filter = "Text Files (*.txt)|*.txt";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
int[] freq = new int[128];
StreamReader sr = new StreamReader(openFileDialog1.FileName);
iCount = 0;
while (!sr.EndOfStream) {
int ch = sr.Read();
if (ch >= 0 && ch <= 127)
freq[ch]++;
else
{
MessageBox.Show("Dosya ASCII içerikli değil!", "HATA", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
iCount++;
}
sr.Close();
charFreq = new List<CharFreq>(128);
for (int i = 0; i < 128; i++)
{
if (freq[i] != 0)
{
CharFreq cf = new CharFreq();
cf.ch = (char)i;
cf.freq = freq[i];
charFreq.Add(cf);
}
}
Compress();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "HATA",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}
}
Here is compress function ?
<pre lang="c#"> private void
Compress() {
int bitLength = 0, block = 0, bpBlock = 0;
HuffmanTree ht = new HuffmanTree();
BinaryTreeNode<CharFreq> root = ht.Build(charFreq, charFreq.Count);
leafNodes = 0;
textBox1.Text += ("The Huffman ağacı geçişi\r\n\r\n");
InorderTraversal(root);
if (leafNodes != charFreq.Count)
{
MessageBox.Show("Sıkıştırma ağacı sıkıştırma işleminde hata", "HATA!",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
textBox1.Text += ("Toplam girilen karakter sayısı = " + iCount.ToString() + "\r\n");
textBox1.Text += ("Toplam yaprak kısmındaki karakter sayısı= " + leafNodes.ToString() + "\r\n");
if (leafNodes < 2) {
bitLength = 1; block = 8;
bpBlock = 1;
}
else if (leafNodes < 4) {
bitLength = 2; block = 4;
bpBlock = 1;
}
else if (leafNodes < 8) {
bitLength = 3; block = 8;
bpBlock = 3;
}
else if (leafNodes < 16) {
bitLength = 4; block = 2;
bpBlock = 1;
}
else if (leafNodes < 32) {
bitLength = 5; block = 8;
bpBlock = 5;
}
else if (leafNodes < 64) {
bitLength = 6; block = 4;
bpBlock = 3;
}
else if (leafNodes < 128) {
bitLength = 7; block = 8;
bpBlock = 8;
}
int number = (leafNodes * bitLength) / block;
int numberBits = bitLength * iCount;
int numberBlocks = numberBits / (8 * bpBlock);
int remainder = numberBits % (8 * bpBlock);
header = new Header();
header.inputFileLength = iCount;
header.outputDataLength = numberBlocks * bpBlock + remainder / bitLength;
header.tableLength = leafNodes;
header.bitLength = bitLength;
header.chars = new byte[leafNodes];
textBox1.Text += ("Toplam veri miktarı = " + header.outputDataLength.ToString() + "\r\n");
textBox1.Text += ("Toplam bit uzunluğu = " + bitLength.ToString() + "\r\n");
int headerLength = 4 * sizeof(int) + leafNodes * sizeof(byte);
int outputFileLength = headerLength + header.outputDataLength; double percent = 100.0 - 100.0 * ((double)outputFileLength) / iCount;
textBox1.Text += ("Sıkıştırılmış dosyanın boyutu = " + outputFileLength.ToString() + "\r\n");
textBox1.Text += ("Sıkıştırma Oranı: = %" + percent.ToString("F2"));
aquaGauge1.Value = Convert.ToInt16(percent);
aquaGauge1.ThresholdPercent = Convert.ToInt16(percent);
if (percent <= 0.0) {
MessageBox.Show("Sıkıştırma oranı 0 veya 0'ın altında oldu,yani sıkıştırma başarız", "HATA!",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
for (int i = 0; i < charFreq.Count; i++)
header.chars[i] = (byte)charFreq[i].ch;
try
{
if (saveFileDialog1.ShowDialog() == DialogResult.OK) {
FileStream fs = new FileStream(saveFileDialog1.FileName,
FileMode.Create);
BinaryWriter bw = new BinaryWriter(fs);
StreamReader sr = new StreamReader(openFileDialog1.FileName);
byte[] ibuff = new byte[block];
byte[] codes = new byte[block];
bw.Write(header.inputFileLength);
bw.Write(header.tableLength);
bw.Write(header.bitLength);
bw.Write(header.outputDataLength);
bw.Write(header.chars, 0, header.tableLength);
for (int k = 0; k < header.inputFileLength / block; k++)
{
for (int i = 0; i < block; i++)
{
ibuff[i] = (byte)sr.Read();
codes[i] = (byte)255;
for (int j = 0; j < header.tableLength; j++)
{
if (ibuff[i] == header.chars[j])
{
codes[i] = (byte)j;
break;
}
}
if (codes[i] == (byte)255)
{
MessageBox.Show("İşlem başarısız,farklı bir yöntem deneyin", "HATA",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
}
byte[] obuff = new byte[bpBlock];
for (int i = 0; i < block; i++)
{
int c = (int)codes[i];
for (int j = 0; j < bitLength; j++)
{
int bit = (c >> (bitLength - j - 1)) & 1;
SetBit(i * bitLength + j, bit, obuff);
}
}
bw.Write(obuff, 0, bpBlock);
}
if (header.inputFileLength % block != 0)
{
for (int i = 0; i < header.inputFileLength % block; i++)
{
byte ch = (byte)sr.Read();
bw.Write(ch);
}
}
bw.Flush();
sr.Close();
bw.Close();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "HATA",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
|
|
|
|
 |
See, you treat EVERYTHING in the file as a character (integer) in the range of 0 to 127. Change it so you treat everything as a BYTE, that has a range of 0 to 255, LIKE WE'VE BEEN TELLING YOU FOR F***ING DAYS NOW!
|
|
|
|
|
 |
This is not helper for me why dont u understand me huffman is textbased bmp is image !!!!!
Why dont you help me ı dont understand you said always resaech reseach reasech !!
|
|
|
|
 |
No, why don't you understand? It makes no difference what file you try to compress. Every file (text, image, video, audio etc.) is just a stream of bytes. The fact that you still do not understand this simple fact suggests that you need to choose a new course of study.
|
|
|
|
 |
if you know this topic better.I can send you my project and how to bmp comrpess.I coded huffman this is comrpess only text?
|
|
|
|