bugGNUstep - Bugs: bug #38405, Drawing doesn't work with...

 
 

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

bug #38405: Drawing doesn't work with [NSGraphicsContext graphicsContextWithBitmapImageRep:]

Submitted by:  Vitaliy <vmyrik>
Submitted on:  Mon 25 Feb 2013 09:58:37 AM UTC  
 
Category: BackendSeverity: 3 - Normal
Item Group: NoneStatus: None
Privacy: PublicAssigned to: None
Open/Closed: Open

Mon 25 Feb 2013 09:58:37 AM UTC, original submission:

I'm trying to draw some sample image. If I do it using default graphics context, its ok. But when I switch graphics context to draw directly on NSBitmapImageRep, it doesn't work - the result is an empty image (but works fine on Apple).

Here is example of my code:

[NSApplication sharedApplication];

NSRect imgRect = NSMakeRect(0.0, 0.0, 100.0, 100.0);
NSSize imgSize = imgRect.size;

NSBitmapImageRep *offscreenRep = [[[NSBitmapImageRep alloc]
initWithBitmapDataPlanes:NULL
pixelsWide:imgSize.width
pixelsHigh:imgSize.height
bitsPerSample:8
samplesPerPixel:4
hasAlpha:YES
isPlanar:NO
colorSpaceName:NSDeviceRGBColorSpace
bytesPerRow:0
bitsPerPixel:0] autorelease];

NSGraphicsContext *g = [NSGraphicsContext graphicsContextWithBitmapImageRep:offscreenRep];
NSGraphicsContext saveGraphicsState];
[NSGraphicsContext setCurrentContext:g];

NSBezierPath *path = [NSBezierPath bezierPathWithRect:NSMakeRect(10,10,50,50)];
[path setLineWidth:3.0];
[[NSColor redColor] set];
[path stroke];

[NSGraphicsContext restoreGraphicsState];

NSData *imageData = [offscreenRep representationUsingType:NSPNGFileType properties:nil];
[imageData writeToFile:@"result.png" atomically:YES];

Vitaliy <vmyrik>

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by vmyrik (Submitted the item)
  •  

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

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    No Changes Have Been Made to This Item

    Back to the top


    Powered by Savane 3.1-cleanup