Drawing: Transparent Pixels and NSImage

elhochme
Unregistered
 
Post: #1
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
Quote this message in a reply
Moderator
Posts: 916
Joined: 2002.10
Post: #2
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.
Quote this message in a reply
elhochme
Unregistered
 
Post: #3
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.
Quote this message in a reply
Moderator
Posts: 916
Joined: 2002.10
Post: #4
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
Code:
find . -type f -exec tiffutil -cat {} -out {} \;

it will batch convert all troublesome tiffs
Quote this message in a reply
elhochme
Unregistered
 
Post: #5
worked like a charm.

Thanks!
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  A few pixels inside Miglu 3 3,392 Aug 12, 2010 07:41 PM
Last Post: Miglu
  NSImage leaking? Cirdan 5 3,805 Nov 16, 2009 12:02 PM
Last Post: SethWillits
  Sending an NSImage on a Network mindwalkernine 1 3,107 Aug 9, 2006 04:23 AM
Last Post: djork
  Animate An NSImage mindwalkernine 1 4,198 Jun 18, 2006 12:30 AM
Last Post: StealthyCoin
  NSImage and NSView problems Joseph Duchesne 1 3,888 Aug 19, 2005 07:36 AM
Last Post: unknown