bugGNUstep - Bugs: bug #34742, NSAffineTransform ignored when...

Group
 
 

bug #34742: NSAffineTransform ignored when drawing on NSImage

Submitter:  julian <julian_>
Submitted:  Thu 03 Nov 2011 10:30:31 PM UTC
   
 
Category:  Gui/AppKit Severity:  3 - Normal
Item Group:  Bug Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 03 Nov 2011 10:30:31 PM UTC, original submission:  

i am using NSAffineTransform in two cases in my application and in both cases gnustep completely ignores it.

first case - drawing into a NSImage flipped - since it doesn't work on gnustep i must produce the flipping through coordinate modification:

    NSImage *theImage = [[NSImage alloc] initWithSize:NSMakeSize(size, size)];
    [theImage lockFocus];
    NSAffineTransform *t = [NSAffineTransform transform];
           [t scaleXBy:1.0 yBy:-1.0];
           [t translateXBy:0.0 yBy:-size];
           [t concat];
        [[NSColor blackColor] setStroke];
        NSBezierPath* aPath = [NSBezierPath bezierPath];
        [aPath setLineJoinStyle:NSRoundLineJoinStyle];
        [aPath setLineWidth:size / 25.0f];
        [aPath moveToPoint:NSMakePoint(10, 10)];
        [aPath lineToPoint:NSMakePoint(20, 20)];
        [aPath lineToPoint:NSMakePoint(10, 30)];
        [aPath stroke];
     
    [theImage unlockFocus];


second case - getting the flipped contents of a NSImage - since the flipping doesn't work i must copy the data row by row in reverse instead:


            NSImage *theImg = [[NSImage alloc] initWithContentsOfURL:_url];
            NSBitmapImageRep *bitmap = [NSBitmapImageRep alloc];
            NSImageRep *rep = [theImg bestRepresentationForDevice: nil];
            [theImg lockFocus];
            NSAffineTransform *t = [NSAffineTransform transform];
            [t scaleXBy:1.0 yBy:-1.0];
            [t translateXBy:0.0 yBy:-imgSize.height];
            [t concat];
            [rep drawInRect:NSMakeRect(0,0,[theImg size].width, [theImg size].height)];
            [bitmap initWithFocusedViewRect:NSMakeRect(0.0, 0.0, [theImg size].width, [theImg size].height)];
            [theImg unlockFocus];
            int bpp = [bitmap bitsPerPixel] / 8;
            int bpp = 4;
            const int rowsize = [theImg size].width * bpp;
            _data = (char )calloc( rowsize [theImg size].height, 1);
            memcpy(_data, [bitmap bitmapData], [theImg size].width bpp [theImg size].height);

julian <julian_>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by FredKiefer (Updated the item)
  • -email is unavailable- added by julian_ (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2012-05-08 FredKiefer SummaryNSAffineTransform ignored in most cases NSAffineTransform ignored when drawing on NSImage

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code