|
|
@@ -109,9 +109,24 @@ pipi_image_t *pipi_load_coreimage(const char *name) |
|
|
|
int pipi_save_coreimage(pipi_image_t *img, const char *name) |
|
|
|
{ |
|
|
|
NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init]; |
|
|
|
printf("%d\n", img->last_modified); |
|
|
|
pipi_pixels_t *p = pipi_getpixels(img, PIPI_PIXELS_RGBA_C); |
|
|
|
|
|
|
|
int i; |
|
|
|
char *data = p->pixels; |
|
|
|
for(i = 0; i < img->w*img->h; i++) |
|
|
|
{ |
|
|
|
unsigned char r = data[i*4 + 0]; |
|
|
|
unsigned char g = data[i*4 + 1]; |
|
|
|
unsigned char b = data[i*4 + 2]; |
|
|
|
unsigned char a = data[i*4 + 3]; |
|
|
|
|
|
|
|
/* R */ data[i*4 + 0] = b; |
|
|
|
/* G */ data[i*4 + 1] = g; |
|
|
|
/* B */ data[i*4 + 2] = r; |
|
|
|
/* A */ data[i*4 + 3] = a; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
NSString *n = [NSString stringWithCString: name]; |
|
|
|
NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] |
|
|
|
initWithBitmapDataPlanes:NULL |
|
|
@@ -127,7 +142,7 @@ int pipi_save_coreimage(pipi_image_t *img, const char *name) |
|
|
|
bitsPerPixel:32 |
|
|
|
]; |
|
|
|
if(bitmap == nil) return -1; |
|
|
|
memcpy([bitmap bitmapData], p->pixels, p->w*p->h*4); |
|
|
|
memcpy([bitmap bitmapData], data, p->w*p->h*4); |
|
|
|
|
|
|
|
NSBitmapImageFileType type = NSPNGFileType; |
|
|
|
|
|
|
|