1022 |
cairo_format_t format; |
cairo_format_t format; |
1023 |
NSAffineTransformStruct tstruct; |
NSAffineTransformStruct tstruct; |
1024 |
cairo_surface_t *surface; |
cairo_surface_t *surface; |
1025 |
|
unsigned char *tmp; |
1026 |
|
int i = 0; |
1027 |
|
unsigned int pixels = pixelsHigh * pixelsWide; |
1028 |
|
const unsigned char *bits = data[0]; |
1029 |
|
|
1030 |
/* |
/* |
1031 |
NSLog(@"%@ DPSimage %dx%d (%p)", self, pixelsWide, pixelsHigh, |
NSLog(@"%@ DPSimage %dx%d (%p)", self, pixelsWide, pixelsHigh, |
1032 |
cairo_current_target_surface (_ct)); |
cairo_current_target_surface (_ct)); |
1041 |
switch (bitsPerSample * samplesPerPixel) |
switch (bitsPerSample * samplesPerPixel) |
1042 |
{ |
{ |
1043 |
case 32: |
case 32: |
1044 |
|
tmp = objc_malloc(pixels * 4); |
1045 |
|
while (i < pixels*4) |
1046 |
|
{ |
1047 |
|
tmp[i+0] = bits[i+2]; |
1048 |
|
tmp[i+1] = bits[i+1]; |
1049 |
|
tmp[i+2] = bits[i+0]; |
1050 |
|
tmp[i+3] = bits[i+3]; |
1051 |
|
i += 4; |
1052 |
|
} |
1053 |
|
bits = tmp; |
1054 |
format = CAIRO_FORMAT_ARGB32; |
format = CAIRO_FORMAT_ARGB32; |
1055 |
break; |
break; |
1056 |
case 24: |
case 24: |
1077 |
tstruct.tX, tstruct.tY); |
tstruct.tX, tstruct.tY); |
1078 |
cairo_transform(_ct, &local_matrix); |
cairo_transform(_ct, &local_matrix); |
1079 |
|
|
1080 |
surface = cairo_image_surface_create_for_data((void*)data, |
surface = cairo_image_surface_create_for_data((void*)bits, |
1081 |
format, |
format, |
1082 |
pixelsWide, |
pixelsWide, |
1083 |
pixelsHigh, |
pixelsHigh, |
1084 |
bytesPerRow); |
bytesPerRow); |
1085 |
|
|
1086 |
|
if (bits != data[0]) |
1087 |
|
{ |
1088 |
|
objc_free(bits); |
1089 |
|
} |
1090 |
|
|
1091 |
if (surface == NULL) |
if (surface == NULL) |
1092 |
{ |
{ |
1093 |
NSLog(@"Image surface could not be created"); |
NSLog(@"Image surface could not be created"); |