Il giorno 18/ago/2013, alle ore 15:03, "Gerriet M. Denkmann" <[email protected]> ha scritto:
> I just noticed that the program I use to create Png files creates files with
> twice the number of pixels in each dimension.
> Obviously because since I last used it, I have switched to a Retina Mac Book.
>
> Ok, so I have to fix this program.
>
you can do something like this:
NSSize size = ...;
NSBitmapImageRep *bitmapRep = [[NSBitmapImageRep alloc]
initWithBitmapDataPlanes: NULL
pixelsWide: size.width
pixelsHigh: size.height
bitsPerSample: 8
samplesPerPixel: 4
hasAlpha: YES
isPlanar: NO
colorSpaceName: NSCalibratedRGBColorSpace
bitmapFormat: NSAlphaFirstBitmapFormat
bytesPerRow: 0
bitsPerPixel: 0];
NSGraphicsContext *bmCtx;
NSAffineTransform *transform = [NSAffineTransform transform];
[bitmapRep setSize: size];
bmCtx = [NSGraphicsContext graphicsContextWithBitmapImageRep:
bitmapRep];
bmCtx = [NSGraphicsContext graphicsContextWithGraphicsPort: [bmCtx
graphicsPort]
flipped: YES];
[NSGraphicsContext saveGraphicsState];
[NSGraphicsContext setCurrentContext: bmCtx];
[transform translateXBy: 0
yBy: size.height];
[transform scaleXBy: 1
yBy: -1];
[transform set];
...do some drawing...
[NSGraphicsContext restoreGraphicsState];
data = [bitmapRep representationUsingType: NSPNGFileType properties:
nil];
[bitmapRep release];
--
Simone Tellini
http://tellini.info
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]
