Skip navigation.
 
mlRe: Offscreen cocoa buffers
FROM : paul webb
DATE : Tue Dec 21 19:17:28 2004

for offscreen you can use a

NSImage*        theImage;

// make an instance with size you need (eg 100x100)
theImage=[[NSImage alloc] initWithSize:NSMakeSize(
100, 100)];

to draw to it...

[theImage lockFocus]; // need to lock focus
// do your drawing
[NSBezierPath fillRect:NSMakeRect(20,20,50,50)]; //
etc etc

[theImage unlockFocus]; // then unlock focus

then paste to view in the views drawRect method

[theImage drawAtPoint:NSMakePoint(0,0) fromRect:rect
operation:NSCompositeSourceOver fraction:1.0];


but as said, if you are redrawing everything from
scratch each time you need to draw it won't be anymore
efficient.

paul


--- Miguel Arroz <<email_removed>> wrote:

> Hi!
>
> On 21 de dez de 2004, at 4:16, Jim Thomason wrote:
>
> > There's no magic to it. Just use an appropriate
> offscreen item and
> > draw into that. an NSView that's not visible, or
> an NSImage, or
> > whatever else would be appropriate to you. You can
> then composite in
> > the whole thing.
>
>    I still don't understand... imagine I have a
> class, MyView, that
> subclasses NSView. Where do I draw exactly?
>
>    Thanks for the suggestions about the drawing
> rect, I'll look into
> that. I do a lot of text height and width
> calculations, and I will also
> try to cache those results, and only re-calculate
> them if needed.
>
>    Yours
>
> Miguel Arroz
>
>        "I felt like putting a bullet between
>        the eyes of every Panda that wouldn't
>        scr*w to save its species."      -- Fight
> Club
>
>    Miguel Arroz - <email_removed> -
> http://guiamac.com/bagos
>
> _______________________________________________
> MacOSX-dev mailing list
> <email_removed>
> http://www.omnigroup.com/mailman/listinfo/macosx-dev
>


=====
....................................................................................
http://www.fexia.com
http://www.robotsoftware.co.uk
http://www.nicetoanimals.org
.....................................................................................

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Related mailsAuthorDate
mlOffscreen cocoa buffers Miguel Arroz Dec 21, 16:43
mlRe: Offscreen cocoa buffers Jim Thomason Dec 21, 17:16
mlRe: Offscreen cocoa buffers Miguel Arroz Dec 21, 18:28
mlRe: Offscreen cocoa buffers paul webb Dec 21, 19:17
mlRe: Offscreen cocoa buffers Markus Hitter Dec 21, 19:34