Re: Copying raw RGBA image data to NSBitmapImageRep coming out funny
Re: Copying raw RGBA image data to NSBitmapImageRep coming out funny
- Subject: Re: Copying raw RGBA image data to NSBitmapImageRep coming out funny
- From: "E. Wing" <email@hidden>
- Date: Thu, 11 Jan 2007 17:12:39 -0800
On 1/11/07, Heinrich Giesen <email@hidden> wrote:
On 11.01.2007, at 02:00, E. Wing wrote:
> So I was using GL_UNSIGNED_BYTE because I thought it would always be
> in big endian (endian-independent) format. Does NSBitmapImageRep not
> want this, but a platform native endian order?
Bytes are endian-independent and NSBitmapImageRep wants the color
components
almost always (as default RGBA case) first the red, then the green
then the blue
color component. So your decision to use GL_UNSIGNED_BYTE was absolutly
correct. It is platform independent.
Good to know. Thanks.
About the alpha channel you wrote:
> But this did get me thinking about trying just RGB instead of RGBA.
> Using the following code instead:
... code deleted ...
> This fixed all my funny color problems. But now I'm really curious,
> what is it about the alpha and my settings that was causing the
> problem? (And what is the fix so I can use alpha?)
My guess is that your data are not premultiplied but NSBitmapImageRep
assumes premultiplied data, i.e. no color component must have a value
greater than alpha. Otherwise this could lead to "over-saturated"
images.
Changing "bitmapFormat:0" into:
"bitmapFormat: NSAlphaNonpremultipliedBitmapFormat" could do it.
So with the flag, I still get the over-saturated look. However, I just
noticed that the PDF rendering now looks the same as the Pasteboard
rendering (it no longer has the really weird color artifacts). So
that's an improvement. But I still don't understand the other problem.
Here are two screenshots showing the problem in a different way.
http://www.geocities.com/ewing2121/TextActual.png
http://www.geocities.com/ewing2121/TextPasteboard.png
I changed from the fountain model to text because the problem shows up
better here. (The fountain smoke still looks like the old pasteboard
picture I posted which was over-saturated white.)
Each letter is a texture on a polygon. The outline effect is achieved
by drawing the objects multiple times (in black), slightly shifted.
PolygonOffset, Depth Range, or the Stencil Buffer can be used to
handle the overdraw problem (to avoid z-fighting). All three cases
produce the same artifacts.
From the pictures, I' speculating that there is something about the
overlapping elements and how the alpha values combine. But I'm not
sure what I should be doing to make NSBitmapImageRep happy. Any other
ideas?
Thanks,
Eric
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden