Selaa lähdekoodia

* 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 16 vuotta sitten
vanhempi
commit
e2d6916c06
1 muutettua tiedostoa jossa 17 lisäystä ja 2 poistoa
  1. +17
    -2
      pipi/codec/coreimage.m

+ 17
- 2
pipi/codec/coreimage.m Näytä tiedosto

@@ -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;


Ladataan…
Peruuta
Tallenna