Incorrect data when using Core Graphics
| Originator: | rafael.espindola | ||
| Number: | rdar://10754359 | Date Originated: | 25-Jan-2012 04:28 PM |
| Status: | Open | Resolved: | |
| Product: | OS X | Product Version: | 10.6 and 10.7 |
| Classification: | Reproducible: | always |
25-Jan-2012 04:28 PM Rafael Espindola:
Build the program with
export MACOSX_DEPLOYMENT_TARGET=10.5
clang++ -arch i386 -o test32 -g test.cpp -framework ApplicationServices
clang++ -o test64 -g test.cpp -framework ApplicationServices
On 10.7 and 10.6 the 32 bit version prints
v = fe00fe00
the 64 bit version prints
v = ff00ff00
Both work correctly on 10.5.
$ cat test.cpp
#include <ApplicationServices/ApplicationServices.h>
int main() {
int stride = 100*4;
void *data = calloc(100 * stride, 1);
int bitsPerComponent = 8;
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGBitmapInfo bitinfo;
bitinfo = kCGBitmapByteOrder32Host | kCGImageAlphaPremultipliedFirst;
CGContextRef cg = CGBitmapContextCreate (data,
100,
100,
bitsPerComponent,
stride,
colorSpace,
bitinfo);
CGContextTranslateCTM(cg, 0, 100);
CGContextScaleCTM(cg, 1, -1);
CGContextScaleCTM(cg, 1, -1);
CGContextSaveGState(cg);
CGDataProviderRef data2 = CGDataProviderCreateWithFilename("bar.png");
CGImageRef image = CGImageCreateWithPNGDataProvider(data2, NULL, false, kCGRenderingIntentDefault);
CGRect flippedRect = CGRectMake(0, -100, 100, 100);
CGContextDrawImage(cg, flippedRect, image);
uint32_t *p = (uint32_t*) data;
fprintf(stderr, "v = %x\n", p[0]);
return 0;
}
$ base64 bar.png
iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAi0lEQVRoBe3SQQ6AIBTEUOT+dwbjFd7C/KS47gRan3Xeb/DZg+/+Xb0H/F2wAhVAA/1CKJDxCrBCHKgACmS8AqwQByqAAhmvACvEgQqgQMYrwApxoAIokPEKsEIcqAAKZLwCrBAHKoACGa8AK8SBCqBAxivACnGgAiiQ8QqwQhyoAApkvAKsEAfGF7gDdwJeqUuI2gAAAABJRU5ErkJggg==
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!