[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Drawing transparent images?
From: |
Björn Giesler |
Subject: |
Drawing transparent images? |
Date: |
Sun, 02 Nov 2003 11:55:22 +0100 |
Hi,
I'm trying to create a transparent NSImage from my program, but all I get is a
grey block, and I can't draw in the resulting NSImage. This is my code:
NSImage *image; NSBitmapImageRep *rep;
NSMutableAttributedString *str;
NSSize size;
str = [[NSAttributedString alloc] initWithString: @"Hello"];
size = [str size];
image = [[[NSImage alloc] initWithSize: size] autorelease];
rep = [[[NSBitmapImageRep alloc] initWithBitmapDataPlanes: NULL
pixelsWide: size.width
pixelsHigh: size.height
bitsPerSample: 8
samplesPerPixel: 4
hasAlpha: YES
isPlanar: YES
colorSpaceName: NSCalibratedRGBColorSpace
bytesPerRow: 0
bitsPerPixel: 0] autorelease];
[image addRepresentation: rep];
[image lockFocus];
[[NSColor clearColor] set];
NSRectFill(NSMakeRect(0, 0, size.width, size.height));
[[NSColor blackColor] set];
[str drawAtPoint: NSZeroPoint];
All I get is a grey box. If I pass hasAlpha: NO, I get a grey box with some
text on it, but it's still grey, not transparent.
Is this a known bug?
Regards,
Björn
- Drawing transparent images?,
Björn Giesler <=