|
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 24-Nov-16 14:24pm.
|
|
|
|
|
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?
|
|
|
|
|
Trying to get someone to "fix" your project for you is not going to get you a passing grade in the class.
So, what if we DID fix this for you? Then what? You still don't understand the basic concepts that you're going to need to get through the next class! You will only end up failing again and blaming other people for it.
|
|
|
|
|
YOU are the one who doesn't understand. You seem to think that Text and Image data are somehow magically different.
WRONG!!
The data that makes up an image is nothing but BYTES. The "text" you're talking about is also NOTHING BUT BYTES in a limited range of values!
Huffman does NOT work exclusively on these values. It works on ALL POSSIBLE BYTE VALUES!
|
|
|
|
|
Because research is the basis of what we do, and it's important to learn several things about it:
1) How to do it, and how to understand what you read when you read it. For example, finding a discussion of an algorithm that tells you how to do something, even if it isn't set up for exactly what you are trying to use it for.
2) That research does not give you exactly the solution you want: this is "development" not "copy'n'paste"! For example, you don't find C# code for compressing images using Huffman compression because nobody does it - you will find code for using Huffman compression on other data types however.
3) The sometimes the research shows you are going down a blind alley and need to change your whole approach because it isn't going to work. For example, you may have the bright idea to run cars on Powdered Cheese but research shows you that cheese doesn't burn very well and tends to clog the fuel injector system - so it isn't going to work in the real world.
Asking the same question over and over again because you don't like the answers so don't want to think about them doesn't change the answer - the cheese still blocks the injection system and the car only ever gets 100m before the engine is trashed.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Hi Experts..
Is there any way, I can convert Decimal (18 Digit) MEID to hexadecimal?
Thanks
|
|
|
|
|
Yes.
If you look at Wikipedia: Mobile equipment identifier - Wikipedia[^] it explains the 56bit (hex) format, and also describes the decimal (18 digit) version under "display formats".
It should be pretty trivial to reverse the decimal version to hex.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Go to Parentis there anyone who can provide me the code?
|
|
|
|
|
I tell you what: you show me the code you wrote to do it, and explain what it does right, what it does wrong, how you tested it, and I'll help you fix it.
But we aren't a code-to-order service: It doesn't quite work like that, we do not do your work for you.
If you want someone to write your code, you have to pay - I suggest you go to Freelancer.com and ask there.
But be aware: you get what you pay for. Pay peanuts, get monkeys.
The idea of "development" is as the word suggests: "The systematic use of scientific and technical knowledge to meet specific objectives or requirements." What is development? definition and meaning - BusinessDictionary.com[^]
That's not the same thing as "have a quick google and give up if I can't find exactly the right code".
So either pay someone to do it, or learn how to write it yourself. We aren't here to do it for you.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
is there anyone who can provide me the code?
|
|
|
|
|
No language should even be able to do this but it works (complies and runs).
public class BaseClass
{
public string Value { get; set; }
public BaseClass(string val) { Value = val; }
}
public class Derived : BaseClass
{
public Derived(string val)
: base(new Func<string>(() =>
{
if (String.IsNullOrEmpty(val))
{
throw new ArgumentNullException("val");
}
else
{
return val;
}
})()){}
} And the error message when the Derived class constructor is passed a null value is equally confusing:
System.ArgumentNullException: Value cannot be null.
Parameter name: val
at TestingApp.Derived.<>c__DisplayClass0_0.<.ctor>b__0()
at TestingApp.Derived..ctor(String val)
at TestingApp.Program.Main(String[] args)
This looks more like a way to program hard to find errors, deliberate back doors, or the hard-to-trace magic self-destruct method then a useful code addition.
Is there any instance this could be useful other than a hack or workaround?
if (Object.DividedByZero == true) { Universe.Implode(); }
Meus ratio ex fortis machina. Simplicitatis de formae ac munus. -Foothill, 2016
|
|
|
|
|
If the base class constructor is doing too much, or allocates a lot of memory, this could prevent that work from taking place if the argument isn't valid. If you move the throw into the Derived constructor, the base class constructor has already run by the time the argument is validated.
It would definitely be cleaner with the validation code extracted to a real method - possibly in a separate class, if it's the sort of thing you use a lot:
public static class Requires
{
public static string NotNullOrEmpty(string value, string parameterName)
{
if (string.IsNullOrWhiteSpace(value)) throw new ArgumentNullException(parameterName);
return value;
}
}
public class Derived
{
public Derived(string val) : base(Requires.NotNullOrEmpty(val, nameof(val)))
{
}
}
System.ArgumentNullException: Value cannot be null.
Parameter name: val
at TestingApp.Requires.NotNullOrEmpty(String value, String parameterName)
at TestingApp.Derived..ctor(String val)
at TestingApp.Program.Main(String[] args)
With C# 7, I believe you'll be able to do something like this:
public class Derived
{
public Derived(string value) : base(string.IsNullOrEmpty(val) ? throw new ArgumentNullException(nameof(val)) : val)
{
}
}
C# 7 Additions – Throw Expressions – Structured Sight[^]
I'm not sure if that makes it any more readable, though.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi
I am developing windows application with MDI form.
if multiple user is using the applicaiton
and any change made by the one user,should be reflected as alert for another user while working in application immediately.
Both user using the same applicaiton with seperate instance.
Please help me sir.
Thanks and regards
Ram
|
|
|
|
|
This would require both users to have access to some common file which the application uses to synchronise.
|
|
|
|
|
"Immediatly" is not possible, there will always be a delay because the information needs to be processed. Usually people work on stale data, and you will be complicating stuff a lot with this 'idea'.
What happens if we both are editing your account? I update your name, you your email-address. What will you save?
There's a good reason most applications don't show live values.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I would expect that a cardiac care unit would like to see "live values"...
How about a nuclear reactor?
The alternative being "dead values"?
|
|
|
|
|
Gerry Schmitz wrote: I would expect that a cardiac care unit would like to see "live values"...
How about a nuclear reactor? Running C#?
Don't go near that hospital, you could die of a NullReferenceException
Gerry Schmitz wrote: The alternative being "dead values"? No, information as it is retrieved on the moment.
He is not building a nuclear system but probably displaying something from a datasource. You may have noticed that most applications display the information as it was the moment they retrieved it.
It is impractical, adds no value and adds a lot of cost. Feel free to write an article proving otherwise
--edit
Implement INotifyPropertyChanged[^] on your BO's, have them send any changes to a central server, and make sure all instances poll said server to get any recent changes.
How to: Implement the INotifyPropertyChanged Interface[^]
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
modified 23-Nov-16 14:11pm.
|
|
|
|
|
I've noticed the opposite:
- the "categories" of apps that would BENEFIT from "real-time" (or near real-time) UI updates is greater, and expanding at a larger rate, than "static" views.
Yes, there are a "larger number of apps" where someone is looking at last years numbers; but that's of limited interest to most consumers. Most consumers expect more than "maybe it's now in the system (?)".
With a little imagination and stepping away from "accounting apps", one can think of any number of apps that would benefit from "more current info". (And it's a skill worth learning)
And yes, I use C# to write mission-critical, including SCADA. What, you have a problem with C# now for writing anything but "accounting apps"? Write an article.
Oh, and regarding: "both editing your account" .... Perhaps you've heard of: "transactions"? "Commits"? Roll-backs? optimistic updates / locks? pessimistic updates / locks? No?
I think OP would like to expand his knowledge base instead catering ONLY to the lowest denominator.
|
|
|
|