On Mar 23, 2006, at 7:04 AM, Joseph Nastasi wrote:

When loading a picture using OpenAsPicture, the vertical and horizontal resolution shows up fine. When using either LoadPictureFromJPEG or Micono's mic_LoadPictureFromJPEG, the resolution values are always 72 (at least on Mac). I'd prefer not to force the user to run QuickTime on Windows, so is there any way to get this info with out QT?

Here is the JPEG header layout info that I use to get the resolution of the JPEG images. It is referred to as Xdensity and Ydensity below. I simply use a binaryStream, check that the first two bytes contain FFD8 and then get the set the Position property of the binaryStream to 14, and read two shorts getting the resolution values. It has been working great for my purposes. According to the spec the resolution can be in either dots per inch or dots per cm but in my experience I have had no problem just assuming dots per inch. You may want to check the two bytes that give the x and y dots per inch or dots per cm values for what you are doing.


Start of Image (SOI) marker -- two bytes (FFD8)

JFIF marker (FFE0)

•       length -- two bytes
•       identifier -- five bytes: 4A, 46, 49, 46, 00 (the ASCII code
         equivalent of a zero terminated "JFIF" string)
•       version -- two bytes: often 01, 02
     •  the most significant byte is used for major revisions
     •  the least significant byte for minor revisions

• units -- one byte: Units for the X and Y densities (this is one byte each for x and y)
     •  0 => no units, X and Y specify the pixel aspect ratio
     •  1 => X and Y are dots per inch
     •  2 => X and Y are dots per cm
•       Xdensity -- two bytes  ( the resolution 72, 300, etc)
•       Ydensity -- two bytes
•       Xthumbnail -- one byte: 0 = no thumbnail
•       Ythumbnail -- one byte: 0 = no thumbnail
•       (RGB)n -- 3n bytes: packed (24-bit) RGB values for the thumbnail
        pixels, n = Xthumbnail * Ythumbnail


=== A Mac addict in Tennessee ===

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to