bug-gnustep
[Top][All Lists]
Advanced

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

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


From: Vitaliy
Subject: [bug #38405] Drawing doesn't work with [NSGraphicsContext graphicsContextWithBitmapImageRep:]
Date: Mon, 25 Feb 2013 09:58:39 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.79 Safari/537.4

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/




reply via email to

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