ソースを参照

* 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年前
コミット
e2d6916c06
1個のファイルの変更17行の追加2行の削除
  1. +17
    -2
      pipi/codec/coreimage.m

+ 17
- 2
pipi/codec/coreimage.m ファイルの表示

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


読み込み中…
キャンセル
保存