URL:
  <http://savannah.gnu.org/bugs/?38405>

                 Summary: Drawing doesn't work with [NSGraphicsContext
graphicsContextWithBitmapImageRep:]
                 Project: GNUstep
            Submitted by: vmyrik
            Submitted on: Mon 25 Feb 2013 09:58:37 AM GMT
                Category: Backend
                Severity: 3 - Normal
              Item Group: None
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any

    _______________________________________________________

Details:

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];
 




    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?38405>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/


_______________________________________________
Bug-gnustep mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-gnustep

Reply via email to