discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Please help with image rotation and scaling.


From: Tima Vaisburd
Subject: Please help with image rotation and scaling.
Date: Sun, 18 May 2003 17:56:16 -0700
User-agent: KMail/1.4.3

Hello everybody,

I'm learning Objective C and gnustep.

I could not figure out how can I rotate an image in gnustep.

As far as I can get, Apple documentation suggects using
NSAffineTransform and -drawAtPoint: fromRect: operation: fraction
inside -drawRect method of the view, like this:


- (void) drawRect:(NSRect)rect
{
    NSAffineTransform *drawXform = [NSAffineTransform transform];
    [drawXform rotateByDegrees: 30];
    [drawXform concat];

   // _image is NSImage *
        
    NSSize size = [_image size];
    [_image lockFocus];
    [_image drawAtPoint: NSMakePoint(50,50)
                       fromRect: NSMakeRect(0, 0, size.width, size.height)
                      operation: NSCompositeCopy
                         fraction:1.0];
    [_image unlockFocus];
}

After this did not work I realized that
      -drawAtPoint: fromRect: operation: fraction
is not implemented yet (I've checked  core.20030518.tar.bz2).
I tried to play with bounding rectangle, too, but got
only rotated clippings, the image itself did not rotate.

What is the way to do this in current gnustep?

Also, what is the correct way to scale the image?

Thank you,
Tima

P.S. I cc'ed to help-gnustep, please tell me if I'd better not.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]