Procházet zdrojové kódy

* Images were saved with R and B inverted

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@3136 92316355-f0b4-4df1-b90c-862c8a59935f
master
jylam před 16 roky
rodič
revize
e2d6916c06
1 změnil soubory, kde provedl 17 přidání a 2 odebrání
  1. +17
    -2
      pipi/codec/coreimage.m

+ 17
- 2
pipi/codec/coreimage.m Zobrazit soubor

@@ -109,9 +109,24 @@ pipi_image_t *pipi_load_coreimage(const char *name)
int pipi_save_coreimage(pipi_image_t *img, const char *name) int pipi_save_coreimage(pipi_image_t *img, const char *name)
{ {
NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
printf("%d\n", img->last_modified);
pipi_pixels_t *p = pipi_getpixels(img, PIPI_PIXELS_RGBA_C); 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]; NSString *n = [NSString stringWithCString: name];
NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc]
initWithBitmapDataPlanes:NULL initWithBitmapDataPlanes:NULL
@@ -127,7 +142,7 @@ int pipi_save_coreimage(pipi_image_t *img, const char *name)
bitsPerPixel:32 bitsPerPixel:32
]; ];
if(bitmap == nil) return -1; 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; NSBitmapImageFileType type = NSPNGFileType;


Načítá se…
Zrušit
Uložit