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


You are not allowed to post comments on this tracker with your current authentication level.

bug #34742: NSAffineTransform ignored when drawing on NSImage

Submitted by:  julian <julian_>
Submitted on:  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

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_>


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)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    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.3