Re: Most efficient way to get the pixel dimensions of a JPG
Re: Most efficient way to get the pixel dimensions of a JPG
- Subject: Re: Most efficient way to get the pixel dimensions of a JPG
- From: "John C. Randolph" <email@hidden>
- Date: Thu, 6 Jan 2005 15:59:26 -0800
John,
You can just read the dimensions in the header of the JPEG file. No
need to decode the pixels. The format is available many places, like
here:
http://netghost.narod.ru/gff/graphics/summary/jfif.htm
typedef struct _JFIFHeader
{
BYTE SOI[2]; /* 00h Start of Image Marker */
BYTE APP0[2]; /* 02h Application Use Marker */
BYTE Length[2]; /* 04h Length of APP0 Field */
BYTE Identifier[5]; /* 06h "JFIF" (zero terminated) Id String */
BYTE Version[2]; /* 07h JFIF Format Revision */
BYTE Units; /* 09h Units used for Resolution */
BYTE Xdensity[2]; /* 0Ah Horizontal Resolution */
BYTE Ydensity[2]; /* 0Ch Vertical Resolution */
BYTE XThumbnail; /* 0Eh Horizontal Pixel Count */
BYTE YThumbnail; /* 0Fh Vertical Pixel Count */
} JFIFHEAD;
So, read sizeof(JFIFHEAD) from the start of the file.
-jcr
On Jan 6, 2005, at 3:46 PM, John Fox wrote:
Hello:
I'm looking for a really fast and memory efficient way to determine
the pixel height and width of a JPEG image. Can someone help me with
this? Right now I'm creating an NSBitmapImageRep and getting its
pixelsWide and pixelsHigh, but there's a lot of overhead for doing
this.
Any help greatly appreciated.
John C. Randolph <email@hidden> (408) 974-8819
Sr. Cocoa Software Engineer,
Apple Worldwide Developer Relations
http://developer.apple.com/cocoa/index.html
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden