288 {
289 unsigned *
base, *lptr;
290 unsigned char *rbuf, *gbuf, *bbuf, *abuf;
293
295
296 if(!image)
297 return NULL;
298
299 (*width)=
image->xsize;
300 (*height)=
image->ysize;
301 (*components)=
image->zsize;
302 const unsigned int imageWidth =
image->xsize;
303 const unsigned int imageHeight =
image->ysize;
304 const unsigned int uintSize(sizeof(unsigned)), ucharSize(sizeof(unsigned char));
305 const unsigned int colourBufSize=imageWidth*ucharSize;
306 base =
reinterpret_cast<unsigned *
>(
malloc(imageWidth*imageHeight*uintSize));
307 rbuf = ucharAddress(
malloc(colourBufSize));
308 gbuf = ucharAddress(
malloc(colourBufSize));
309 bbuf = ucharAddress(
malloc(colourBufSize));
310 abuf = ucharAddress(
malloc(colourBufSize));
311 if(!
base || !rbuf || !gbuf || !bbuf) {
314 if (rbuf) free(rbuf);
315 if (gbuf) free(gbuf);
316 if (bbuf) free(bbuf);
317 if (abuf) free(abuf);
318 return NULL;
319 }
322 if (
image->zsize>=4) {
323
324
330 lptr +=
image->xsize;
331 }
else if(
image->zsize==3) {
336 lptr +=
image->xsize;
337 }
else if(
image->zsize==2) {
341 lptr +=
image->xsize;
342 } else {
345 lptr +=
image->xsize;
346 }
347 }
349 free(rbuf);
350 free(gbuf);
351 free(bbuf);
352 free(abuf);
353
354 return (
unsigned *)
base;
355 }
static void rgbatorgba(unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *a, unsigned char *l, int n)
static void ImageGetRow(ImageRec *image, unsigned char *buf, int y, int z)
static void latorgba(unsigned char *b, unsigned char *a, unsigned char *l, int n)
static void rgbtorgba(unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *l, int n)
static void ImageClose(ImageRec *image)
static void bwtorgba(unsigned char *b, unsigned char *l, int n)
static ImageRec * ImageOpen(const char *fileName)