Re: Creating black and white image
Re: Creating black and white image
- Subject: Re: Creating black and white image
- From: Chuck Soper <email@hidden>
- Date: Wed, 22 Dec 2004 10:17:30 -0800
Hello,
I don't know the answer to your question, but you might want to look
at the IconFamily source written by Troy Stephens and others:
<http://homepage.mac.com/troy_stephens/software/objects/IconFamily/>
Find the link to "IconFamily-0.5.1.tgz" for the source.
I'm working on a somewhat related problem, scaling an NSImage then
creating an NSBitmapImageRep.
Chuck
At 3:02 AM +0900 12/23/04, Osamu Shigematsu wrote:
Hello, all.
I'm trying to create black and white (bitmap) image with following
function to print an image to MW-100 USB printer from Brother
Industries.
I call this function with full color image (Created from color
JPEG), imageView (NSImageView) shows a color image.
Is there anyone who are able to explain the reason why?
Currently I use QuickTime (Graphics Importer) and QuickDraw function
and works well, though I would like to learn Cocoa framework.
Thank you very much for your advice.
- (void)bitmapWithImage:(NSImage *)src
{
NSSize size = [src size];
const int bitmapWidth = size.width;
const int bitmapHeight = size.height;
NSBitmapImageRep *rep = [[NSBitmapImageRep alloc]
initWithBitmapDataPlanes:nil
pixelsWide:bitmapWidth
pixelsHigh:bitmapHeight
bitsPerSample:1
samplesPerPixel:1
hasAlpha:NO
isPlanar:NO
colorSpaceName:@"NSCalibratedWhiteColorSpace"
bytesPerRow:(bitmapWidth + 7) / 8
bitsPerPixel:1];
NSImage *dst = [[[NSImage alloc]
initWithSize:NSMakeSize(bitmapWidth, bitmapHeight)] autorelease];
[dst addRepresentation:rep];
[dst lockFocus];
[src compositeToPoint:NSMakePoint(0, 0)
operation:NSCompositeSourceOver
fraction:1];
[dst unlockFocus];
[imageView setImage:dst];
}
--
Osamu Shigematsu
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden