[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24208] trunk/blender/source/blender/imbuf /intern/imbuf_cocoa.m: Mac / COCOA :
Damien Plisson
damien.plisson at yahoo.fr
Sun Nov 1 09:23:53 CET 2009
Revision: 24208
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24208
Author: damien78
Date: 2009-11-01 09:23:53 +0100 (Sun, 01 Nov 2009)
Log Message:
-----------
Mac / COCOA :
- fix imbuf Cocoa resolution handling issue
Modified Paths:
--------------
trunk/blender/source/blender/imbuf/intern/imbuf_cocoa.m
Modified: trunk/blender/source/blender/imbuf/intern/imbuf_cocoa.m
===================================================================
--- trunk/blender/source/blender/imbuf/intern/imbuf_cocoa.m 2009-11-01 02:52:38 UTC (rev 24207)
+++ trunk/blender/source/blender/imbuf/intern/imbuf_cocoa.m 2009-11-01 08:23:53 UTC (rev 24208)
@@ -66,7 +66,7 @@
struct ImBuf *imb_cocoaLoadImage(unsigned char *mem, int size, int flags)
{
struct ImBuf *ibuf = NULL;
- uint32_t width, height;
+ NSSize bitmapSize;
uchar *rasterRGB = NULL;
uchar *rasterRGBA = NULL;
uchar *toIBuf = NULL;
@@ -87,11 +87,14 @@
return NULL;
}
- width = [bitmapImage pixelsWide];
- height = [bitmapImage pixelsHigh];
+ bitmapSize.width = [bitmapImage pixelsWide];
+ bitmapSize.height = [bitmapImage pixelsHigh];
+ /* Tell cocoa image resolution is same as current system one */
+ [bitmapImage setSize:bitmapSize];
+
/* allocate the image buffer */
- ibuf = IMB_allocImBuf(width, height, 32/*RGBA*/, 0, 0);
+ ibuf = IMB_allocImBuf(bitmapSize.width, bitmapSize.height, 32/*RGBA*/, 0, 0);
if (!ibuf) {
fprintf(stderr,
"imb_cocoaLoadImage: could not allocate memory for the " \
@@ -113,12 +116,12 @@
/* First get RGB values w/o Alpha to avoid pre-multiplication, 32bit but last byte is unused */
blBitmapFormatImageRGB = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
- pixelsWide:width
- pixelsHigh:height
+ pixelsWide:bitmapSize.width
+ pixelsHigh:bitmapSize.height
bitsPerSample:8 samplesPerPixel:3 hasAlpha:NO isPlanar:NO
colorSpaceName:NSCalibratedRGBColorSpace
bitmapFormat:0
- bytesPerRow:4*width
+ bytesPerRow:4*bitmapSize.width
bitsPerPixel:32/*RGB format padded to 32bits*/];
[NSGraphicsContext saveGraphicsState];
@@ -136,12 +139,12 @@
/* Then get Alpha values by getting the RGBA image (that is premultiplied btw) */
blBitmapFormatImageRGBA = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
- pixelsWide:width
- pixelsHigh:height
+ pixelsWide:bitmapSize.width
+ pixelsHigh:bitmapSize.height
bitsPerSample:8 samplesPerPixel:4 hasAlpha:YES isPlanar:NO
colorSpaceName:NSCalibratedRGBColorSpace
bitmapFormat:0
- bytesPerRow:4*width
+ bytesPerRow:4*bitmapSize.width
bitsPerPixel:32/* RGBA */];
[NSGraphicsContext saveGraphicsState];
@@ -160,10 +163,10 @@
/*Copy the image to ibuf, flipping it vertically*/
toIBuf = (uchar*)ibuf->rect;
- for (x = 0; x < width; x++) {
- for (y = 0; y < height; y++) {
- to_i = (height-y-1)*width + x;
- from_i = y*width + x;
+ for (x = 0; x < bitmapSize.width; x++) {
+ for (y = 0; y < bitmapSize.height; y++) {
+ to_i = (bitmapSize.height-y-1)*bitmapSize.width + x;
+ from_i = y*bitmapSize.width + x;
toIBuf[4*to_i] = rasterRGB[4*from_i]; /* R */
toIBuf[4*to_i+1] = rasterRGB[4*from_i+1]; /* G */
More information about the Bf-blender-cvs
mailing list