NSBitmapImageRep returns wrong bitsPerSample and bitsPerPixel values for 8 & 16-bit BMP's
NSBitmapImageRep returns wrong bitsPerSample and bitsPerPixel values for 8 & 16-bit BMP's
- Subject: NSBitmapImageRep returns wrong bitsPerSample and bitsPerPixel values for 8 & 16-bit BMP's
- From: Wade Tregaskis <email@hidden>
- Date: Tue, 30 Mar 2004 17:31:03 +1000
The subject says it all. bitsPerSample always returns 8, bitsPerPixel
32, irrelevant of the real values for the given BMP. At first I
thought "fantastic, it's converting to standard RGBA automatically",
but then when I looked at the values they appear either (a) corrupt or
(b) in their 8/16-bit format, with strange spacing (word-aligned?).
Is this a known problem, or have I just done something wrong?
Ultimately I'm aiming for very efficient scanning of pixel values
across an image (for histogram & similar purposes), so I thought going
to the byte level would be best; I'm not afraid to write multiple
similar implementations for different depths and pixel formats (e.g.
5-6-5 vs 5-5-5, etc). But it seems I can't [using NSImage stuff] - the
data I'm getting back for all but 24-bit bitmaps is nonsense, so far as
I can tell.
FWIW, I haven't tried any other image formats, since bmp is my only
requirement and thus concern at present. I'm using RLE4/8 compression
as appropriate in the bitmaps, so perhaps the strange data I'm seeing
is the compressed form? If so, how can I convert it to a more
meaningful representation?
I've thought of using the TIFFRepresentation methods, which would be
great for other reasons, but I have no idea what format the returned
data is in; Apple haven't documented it, and any presumptions I make
based on other TIFF format references are likely to have painful sharp
spikes at the end.
For the moment I'm settling for the workaround of using NSReadPixel,
but that will most likely be incredibly slow, thus failing to satisfy
my main aim of speed. I've also considered rendering the bitmaps to
another view of known depth and format (e.g. standard RGBA) and then
parsing that, but it seems like a terrible kludge (and potentially
slow).
Also, while I remember, assuming I do get around the issues presented,
how can I determine the number of bits per sample for each colour?
e.g. if the 16-bit image uses 5-6-5, there's presently no way to know
that, and the resulting decoding of each pixel will be wrong.
Wade Tregaskis
-- Sed quis custodiet ipsos custodes?
P.S. This is for an assignment, so I can't just use someone's existing
code for computing colour histograms & moments. Obviously in other
circumstances I would.
P.P.S. I did try searching the archives of all the relevant Apple
lists, but my queries kept timing out (>60 seconds). Seems like they
need an upgrade. I've been trying for three days. cocoa.mamasam.com
worked fine, but I couldn't find any discussion of this problem, or
anything similar.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.