Re: Displaying a Raw Mono Image with Cocoa
Re: Displaying a Raw Mono Image with Cocoa
- Subject: Re: Displaying a Raw Mono Image with Cocoa
- From: Nicko van Someren <email@hidden>
- Date: Tue, 2 Aug 2005 19:38:05 +0100
On 2 Aug 2005, at 18:53, email@hidden wrote:
I have a 1392 X 1040 12 bit monochrome image from a Scientific CCD
camera that I am trying to display an image from using a Cocoa
App. I have tried many things - the best that I can get is an
image displayed but the image looks very strange - odd patterns -
you can tell the image is in there - but it is not rendered
correctly.
I am suspecting that because it is a 12 bit per pixel camera - I am
not setting something correctly. Does anyone have any suggestions
or code samples that could help me get this image displayed correctly?
It is a file with a single plane of 1392 x 1040 pixels - each pixel
takes 2 bytes (upper 4 bits are 0 - since it is a 12 bit camera)....
How are you rendering the image at the moment? I'm guessing you want
to use
initWithBitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerP
ixel:hasAlpha:isPlanar:colorSpaceName:bytesPerRow:bitsPerPixel:
If you are using this and there are problems then you may be running
into a byte ordering issue; the camera might be putting out the less
significant byte first whereas I'm pretty sure that this function is
going to want the more significant byte first. Writing a trivial
program to run through and swap byte pairs should tell you if this is
the case.
If this turns out to be the case then, without wanting to incur the
Wrath of JOAR: Scourge of the Premature Optimisers, I suggest you
take a look at the developer notes for the AltiVec instructions and
for inline assembly language in GCC. The AltiVec processors have a
single instruction that can reorder the byte of a 16 byte block in a
single cycle. A trivial loop of a bunch of loads, a bunch of byte
reorders and a bunch of stores will be pushing a couple of orders of
magnitude faster at this sort of byte reorder than writing for
(i=0;i<n;i+=2){t=p[i];p[i+1]=p[i];p[i+1]=t;} and over the space of a
2.5MB image the difference will be measurable.
Cheers,
Nicko
_______________________________________________
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