281 {
282 unsigned *
base, *lptr;
283 unsigned char *rbuf, *gbuf, *bbuf, *abuf;
286
288
289 if(!image)
290 return nullptr;
291
292 (*width)=
image->xsize;
293 (*height)=
image->ysize;
294 (*components)=
image->zsize;
295 const unsigned int imageWidth =
image->xsize;
296 const unsigned int imageHeight =
image->ysize;
297 const unsigned int uintSize(sizeof(unsigned)), ucharSize(sizeof(unsigned char));
298 const unsigned int colourBufSize=imageWidth*ucharSize;
299 base =
reinterpret_cast<unsigned *
>(
malloc(imageWidth*imageHeight*uintSize));
300 rbuf = ucharAddress(
malloc(colourBufSize));
301 gbuf = ucharAddress(
malloc(colourBufSize));
302 bbuf = ucharAddress(
malloc(colourBufSize));
303 abuf = ucharAddress(
malloc(colourBufSize));
304 if(!
base || !rbuf || !gbuf || !bbuf) {
307 if (rbuf)
free(rbuf);
308 if (gbuf)
free(gbuf);
309 if (bbuf)
free(bbuf);
310 if (abuf)
free(abuf);
311 return NULL;
312 }
315 if (
image->zsize>=4) {
316
317
323 lptr +=
image->xsize;
324 }
else if(
image->zsize==3) {
329 lptr +=
image->xsize;
330 }
else if(
image->zsize==2) {
334 lptr +=
image->xsize;
335 } else {
338 lptr +=
image->xsize;
339 }
340 }
346
347 return (
unsigned *)
base;
348 }
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)