FROM : Daniel Jalkut
DATE : Thu Aug 10 19:42:27 2006
Hi Craig - you need to help it out a little bit by specifying
"bytesPerRow" as 2.
Daniel
On Aug 10, 2006, at 12:01 PM, Craig Dooley wrote:
> I am attempting to take a bitmap, and generate a black/transparent
> NSImage from it. The following example is attempting to draw a 16x16
> square in black, that is transparent in the center. It does create a
> 16x16 NSImage, which i can display, but only the top line and one
> pixel on the second row are black, and the rest is white. Is there
> any way to do this, or do i need to translate the data to another
> format first?
>
> unsigned char pattern[] = {
> 0xff, 0xff,
> 0xff, 0xff,
> 0xc0, 0x03,
> 0xc0, 0x03,
> 0xc0, 0x03,
> 0xc0, 0x03,
> 0xc0, 0x03,
> 0xc0, 0x03,
> 0xc0, 0x03,
> 0xc0, 0x03,
> 0xc0, 0x03,
> 0xc0, 0x03,
> 0xc0, 0x03,
> 0xc0, 0x03,
> 0xff, 0xff,
> 0xff, 0xff
> };
>
> unsigned char *planes[] = ;
> glyph = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:planes
> pixelsWide:16
> pixelsHigh:16
> bitsPerSample:1
> samplesPerPixel:1
> hasAlpha:NO
> isPlanar:NO
> colorSpaceName:NSDeviceBlackColorSpace
> bytesPerRow:0
> bitsPerPixel:0];
> image = [[NSImage alloc] init];
> [image addRepresentation:glyph];
>
> -Craig
> --
> ----------------------------------------------------------------------
> -
> Craig Dooley <<email_removed>>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list (<email_removed>)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>-
> sweater.com
>
> This email sent to <email_removed>
DATE : Thu Aug 10 19:42:27 2006
Hi Craig - you need to help it out a little bit by specifying
"bytesPerRow" as 2.
Daniel
On Aug 10, 2006, at 12:01 PM, Craig Dooley wrote:
> I am attempting to take a bitmap, and generate a black/transparent
> NSImage from it. The following example is attempting to draw a 16x16
> square in black, that is transparent in the center. It does create a
> 16x16 NSImage, which i can display, but only the top line and one
> pixel on the second row are black, and the rest is white. Is there
> any way to do this, or do i need to translate the data to another
> format first?
>
> unsigned char pattern[] = {
> 0xff, 0xff,
> 0xff, 0xff,
> 0xc0, 0x03,
> 0xc0, 0x03,
> 0xc0, 0x03,
> 0xc0, 0x03,
> 0xc0, 0x03,
> 0xc0, 0x03,
> 0xc0, 0x03,
> 0xc0, 0x03,
> 0xc0, 0x03,
> 0xc0, 0x03,
> 0xc0, 0x03,
> 0xc0, 0x03,
> 0xff, 0xff,
> 0xff, 0xff
> };
>
> unsigned char *planes[] = ;
> glyph = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:planes
> pixelsWide:16
> pixelsHigh:16
> bitsPerSample:1
> samplesPerPixel:1
> hasAlpha:NO
> isPlanar:NO
> colorSpaceName:NSDeviceBlackColorSpace
> bytesPerRow:0
> bitsPerPixel:0];
> image = [[NSImage alloc] init];
> [image addRepresentation:glyph];
>
> -Craig
> --
> ----------------------------------------------------------------------
> -
> Craig Dooley <<email_removed>>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list (<email_removed>)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>-
> sweater.com
>
> This email sent to <email_removed>
| Related mails | Author | Date |
|---|---|---|
| Craig Dooley | Aug 10, 18:01 | |
| Daniel Jalkut | Aug 10, 19:42 | |
| Hidetomo Katsura | Aug 10, 19:46 | |
| Craig Dooley | Aug 10, 21:45 | |
| Hidetomo Katsura | Aug 10, 22:01 |






Cocoa mail archive

