Changeset 3032 for libpipi/trunk/pipi/codec/coreimage.m
- Timestamp:
- Oct 19, 2008, 2:32:42 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libpipi/trunk/pipi/codec/coreimage.m
r3021 r3032 47 47 pipi_image_t *img; 48 48 img = pipi_new(w, h); 49 img->p[PIPI_PIXELS_RGBA_C].pixels = [myImage bitmapData]; 49 50 50 img->p[PIPI_PIXELS_RGBA_C].w = w; 51 51 img->p[PIPI_PIXELS_RGBA_C].h = h; … … 55 55 img->last_modified = PIPI_PIXELS_RGBA_C; 56 56 57 58 /* CoreImage feeds us with BGRA while we need RGBA, so convert it. 59 * We also need to get a pitch==(w*bpp) in order to pipi to opper properly. 60 */ 61 62 int pitch = (img->p[PIPI_PIXELS_RGBA_C].bpp/8); 63 unsigned char *tmp = (unsigned char*)malloc(h*w*pitch); 64 unsigned char *orig = (unsigned char*)[myImage bitmapData]; 65 int x, y, k=0, o=0, a=[myImage bytesPerRow] - (w*([myImage bitsPerPixel]/8)); 66 67 for(y=0; y<h; y++) 68 { 69 for(x=0; x<w*pitch; x+=4) 70 { 71 if(!([myImage bitmapFormat] & NSAlphaFirstBitmapFormat)) 72 { 73 tmp[k+2] = orig[o]; 74 tmp[k+1] = orig[o+1]; 75 tmp[k+0] = orig[o+2]; 76 tmp[k+3] = orig[o+3]; 77 } else 78 { 79 tmp[k+0] = orig[o]; 80 tmp[k+1] = orig[o+1]; 81 tmp[k+2] = orig[o+2]; 82 tmp[k+3] = orig[o+3]; 83 } 84 85 o+=4; 86 k+=4; 87 } 88 o+=a; 89 } 90 img->p[PIPI_PIXELS_RGBA_C].pixels = tmp; 91 img->p[PIPI_PIXELS_RGBA_C].pitch = w*([myImage bitsPerPixel]/8); 92 93 94 95 57 96 img->codec_priv = (struct pipi_codec_coreimage *) malloc(sizeof(struct pipi_codec_coreimage *)); 58 97 struct pipi_codec_coreimage *infos = (struct pipi_codec_coreimage *) img->codec_priv; … … 109 148 } 110 149 111 112 150 [[bitmap representationUsingType:type properties:nil] writeToFile:n atomically:YES]; 113 151 [autoreleasepool release];
Note: See TracChangeset
for help on using the changeset viewer.