Changeset 3136 for libpipi


Ignore:
Timestamp:
Oct 29, 2008, 2:29:28 PM (11 years ago)
Author:
Jean-Yves Lamoureux
Message:
  • Images were saved with R and B inverted
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpipi/trunk/pipi/codec/coreimage.m

    r3038 r3136  
    110110{
    111111    NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
    112     printf("%d\n", img->last_modified);
    113112    pipi_pixels_t *p = pipi_getpixels(img, PIPI_PIXELS_RGBA_C);
    114113
     114    int i;
     115    char *data = p->pixels;
     116    for(i = 0; i < img->w*img->h; i++)
     117    {
     118        unsigned char r = data[i*4 + 0];
     119        unsigned char g = data[i*4 + 1];
     120        unsigned char b = data[i*4 + 2];
     121        unsigned char a = data[i*4 + 3];
     122       
     123        /* R */    data[i*4 + 0] = b;
     124        /* G */    data[i*4 + 1] = g;
     125        /* B */    data[i*4 + 2] = r;
     126        /* A */    data[i*4 + 3] = a;   
     127    }
     128   
     129   
    115130    NSString *n = [NSString stringWithCString: name];
    116131    NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc]
     
    128143                                ];
    129144    if(bitmap == nil) return -1;
    130     memcpy([bitmap bitmapData], p->pixels, p->w*p->h*4);
     145    memcpy([bitmap bitmapData], data, p->w*p->h*4);
    131146
    132147    NSBitmapImageFileType type = NSPNGFileType;
Note: See TracChangeset for help on using the changeset viewer.