Drawing: Transparent Pixels and NSImage
Hi,
I want to draw an NSImage with a white background on top of another NSImage which has already been drawn but I want the white background to be transparent, hence giving the sprite a realistic look rather than a pasted block look. (like a sprite of a person ontop of the background, I want the white background surrounding the person in the sprite to be transparent so then it just looks like a person on top of the background)
How can I do this? I've tried everything with no luck.
I'm doing this in Cocoa/Obj-C.
Thank you for your time,
elhochme
I want to draw an NSImage with a white background on top of another NSImage which has already been drawn but I want the white background to be transparent, hence giving the sprite a realistic look rather than a pasted block look. (like a sprite of a person ontop of the background, I want the white background surrounding the person in the sprite to be transparent so then it just looks like a person on top of the background)
How can I do this? I've tried everything with no luck.
I'm doing this in Cocoa/Obj-C.
Thank you for your time,
elhochme
you could save the image in a format that has an alpha mask (tiff, png) and in that case you could have 8bit alpha (allows for pretty antialiasing) and it would be easier to draw.
I made an alpha mask and saved it to the .tiff that I was using.
Now when I go to display the NSImage, I get this error...
2003-06-17 19:45:18.166 Background[8027] Warning: TIFF image with unknown extra samples assumed to have unassociated alpha. RGB values have been premultiplied. Use tiffutil -cat to fix.
2003-06-17 19:45:21.579 Background[8027] Warning: TIFF image with unknown extra samples assumed to have unassociated alpha. RGB values have been premultiplied. Use tiffutil -cat to fix.
2003-06-17 19:45:21.587 Background[8027] Warning: TIFF image with unknown extra samples assumed to have unassociated alpha. RGB values have been premultiplied. Use tiffutil -cat to fix.
-------
I'm not sure exactly what it wants or why. By the way, what operation constant should I be using with compositeToPoint:fromRect:operation: ? NSCompositeSourceOver?
thanks.
Now when I go to display the NSImage, I get this error...
2003-06-17 19:45:18.166 Background[8027] Warning: TIFF image with unknown extra samples assumed to have unassociated alpha. RGB values have been premultiplied. Use tiffutil -cat to fix.
2003-06-17 19:45:21.579 Background[8027] Warning: TIFF image with unknown extra samples assumed to have unassociated alpha. RGB values have been premultiplied. Use tiffutil -cat to fix.
2003-06-17 19:45:21.587 Background[8027] Warning: TIFF image with unknown extra samples assumed to have unassociated alpha. RGB values have been premultiplied. Use tiffutil -cat to fix.
-------
I'm not sure exactly what it wants or why. By the way, what operation constant should I be using with compositeToPoint:fromRect:operation: ? NSCompositeSourceOver?
thanks.
it means your alpha layer is kind of wonky and not standard, I get this too. So I use a nice command line utility, go to the folder where your tiffs are (in terminal), make sure no other files are there, then use this command
it will batch convert all troublesome tiffs
Code:
find . -type f -exec tiffutil -cat {} -out {} \;it will batch convert all troublesome tiffs
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| UIWEbView transparent background: is possible? | sefiroths | 0 | 2,182 |
Jan 3, 2012 09:48 AM Last Post: sefiroths |
|
| A few pixels inside | Miglu | 3 | 2,965 |
Aug 12, 2010 07:41 PM Last Post: Miglu |
|
| NSImage leaking? | Cirdan | 5 | 3,278 |
Nov 16, 2009 12:02 PM Last Post: SethWillits |
|
| Sending an NSImage on a Network | mindwalkernine | 1 | 2,779 |
Aug 9, 2006 04:23 AM Last Post: djork |
|
| Animate An NSImage | mindwalkernine | 1 | 3,573 |
Jun 18, 2006 12:30 AM Last Post: StealthyCoin |
|

