|
You will need to read the header information from the file then. This link[^] takes you to the specification. Be aware though that there are *many* different versions of JPEG, so you will need to test this thoroughly.
|
|
|
|
|
thank you a lot.
but this site does not offer any C# code and I can't find image dimension obviously in it's jpeg header format.
thank you again.
if any one have more simple answer please send it. thank you again.
|
|
|
|
|
I answered this question a couple of days ago right here.[^]
|
|
|
|
|
thank you very much .
can i trust it completely that it work correctly in any jpeg file?
thank you again.
|
|
|
|
|
Only if you test it to death.
|
|
|
|
|
i dont understand what you say?
|
|
|
|
|
What's not to understand??!! The only way YOU can "trust" any code you use is if YOU exhaustively test it!
|
|
|
|
|
The site isn't intended to show you C# code. It's the jpeg format only.
What you need to do is read in the file, a byte at a time until you read in the Xdensity and Ydensity bytes (each of which is two bytes). If you read in the first 18 bytes, the 14th will tell you the JPEG unit, the next two will be the X density and the last two will be the Y density.
|
|
|
|
|
thank you .
but can you offer a formula between density and unit that result in the height and width in pixel.
if you do it i will thank you very much
|
|
|
|
|
Well, according to the link. If units is zero then Xdensity and Ydensity are already in pixels.
If it is 1 or 2 it is in dots per inch or cm respectively. You will then need to find out the dots per inch/cm on the output device and scale appropriately.
For example, if the image is a photo at 300dpi and it is to be displayed on a screen at 96dpi then you need to reduce the number of pixels by source/destination or 300/96 (3.125)
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
Ready to Give up - Your help will be much appreciated.
My website
|
|
|
|
|
thank you very much .
|
|
|
|
|
it does not give me the height and width in pixel yet.
i want only height and width. unit and density does not help me
thank you again.
|
|
|
|
|
Hi,
I want to save the images into Access database in C#. Please give ne the sample piece of code if you have or give me the related links.
Thanks in Advance,
AR Reddy
|
|
|
|
|
Hi,
to save images in access first transform them in bytes and then insert them in access.
|
|
|
|
|
There's a bazillion examples out on the web. All you have to do is Google for "C# save image access database".
|
|
|
|
|
I looked at some of your previous posts and many are considered 'generic' questions and several people have already told you to try to use Google. This forum is more for people who write their own code and then need help fixing it.
______________________
stuff + cats = awesome
|
|
|
|
|
Has anyone got an example of how to drag and drop into a multi line textbox or rich textbox? I need to be able to drag an item from a listbox and drop that item on the box where the cursor is.
|
|
|
|
|
|
hi
i create an application that user can change design forms at run time.
how can i save a C# form at run time
tanks
|
|
|
|
|
Hello,
Search for Serialization, System.XML for example.
All the best,
Martin
|
|
|
|
|
B.A wrote: i create an application that user can change design forms at run time.
how can i save a C# form at run time
Are you saying you want the form's controls to have the same values the next time the user opens your app? You can save the data to a file or the registry when you exit, and simply read them when you start again.
Cheers,
Vıkram.
After all is said and done, much is said and little is done.
|
|
|
|
|
Why does the following code snippet
MemoryStream stream = new MemoryStream();
XmlTextWriter writer = new XmlTextWriter(stream, Encoding.UTF8);
writer.WriteStartDocument();
writer.WriteElementString("Test", "Test");
writer.WriteEndDocument();
writer.Flush();
stream.Seek(0, SeekOrigin.Begin);
Console.WriteLine(Encoding.UTF8.GetString(stream.ToArray()));
produce the following output:
?<test>Test
The question mark at the beginning is meant.
I've tried different encodings, it does not happen with Default and ASCII.
When I use a StreamReader I can get it to work, but I will understand where the problem is.
|
|
|
|
|
Let me try that piece out... Looks interesting. It has something to do with the number of bytes in a character. The "old" ASCII uses 7 bits, while UTF8, you guessed it uses 8 bits. But it doesn't really explain why you get the weird character at the beginning.
Have you tried looking up some info about text encoding on google?
|
|
|
|
|
Yes, I've tried to find some hints on Google but without success.
Console.WriteLine(new StreamReader(stream).ReadToEnd());
works correct.
|
|
|
|
|
when you create a stream or file in UTF8 or in Unicode, it will start with a 2-byte
indication of the encoding; in your case it is 0xFE 0xBB. Only then will appear the
first "real" character (0x3C for <).
If you write to file, then open the file in a text editor, both cases work just fine,
because the editor consumes the optional 2-byte to understand how it needs to interpret
the remainder.
Your reading code however does not discover the encoding, it has that information baked
into the code, so it treats the 0xFE oxBB as real characters and since they are not
really printable (above 0x7E), it turns them into a single question mark.
|
|
|
|