[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Example for bitmap drawing
From: |
Jamie Ramone |
Subject: |
Re: Example for bitmap drawing |
Date: |
Fri, 17 Feb 2006 23:19:15 -0300 |
On 2/17/06, Stefan Urbanek <stefan@agentfarms.net> wrote:
> Hi again,
>
> Does anyone have a primitive working example for drawing a TIFF image? I want
> to
> use standard drawing methods, such as NSBezierPath.
>
> I suppose there should be some combination of NSBitmapImageRep and
> NSGraphicsContext... But how? Is there any application doing that so I can
> look
> at the code?
>
> Thanks for any hints,
>
> Stefan Urbanek
> --
> http://stefan.agentfarms.net
>
> First they ignore you, then they laugh at you, then they fight you, then
> you win.
> - Mahatma Gandhi
>
>
> _______________________________________________
> Discuss-gnustep mailing list
> Discuss-gnustep@gnu.org
> http://lists.gnu.org/mailman/listinfo/discuss-gnustep
>
Try this:
- (void) someMethodToSaveView: (NSView *) view toTIFF: (NSString *) path
{
NSBitmapImageRep * rep = [NSBitmapImageRep alloc];
NSImage * image = [NSImage alloc];
NSFileHandle * file;
[view lockFocus];
[rep initWithFocusedViewRect: [view frame]];
[view unlockFocus];
[image initWithSize: [view frame].size];
[image addRepresentation: rep];
RELEASE (rep);
file = [NSFileHandle fileHandleForWritingAtPath: path];
[file writeData: [image TIFFRepresentation]];
RELEASE (image);
};
--
Besos, abrazos, confeti y aplausos.
Jamie Ramone
"El Vikingo"