File: image.c

package info (click to toggle)
pngphoon 1.1-2
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 512 kB
  • sloc: ansic: 5,484; makefile: 58
file content (33 lines) | stat: -rw-r--r-- 658 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

#include "image.h"
#include <stdlib.h>


image_t *imagecreate( int width, int height )
{
   int i;
   image_t *image;
   
   image = (image_t*)malloc( sizeof(image_t) );
   image->width  = width;
   image->height = height;
   image->xbytes = (width + 7) / 8;
   image->bitmap = (png_bytep)calloc( image->xbytes + 1, height );
   image->rowps  = (png_bytep*)malloc( sizeof( png_bytep ) * height );
   
   for( i = 0; i < height; i ++ )
   {
      image->rowps[i] = image->bitmap + (i * image->xbytes);
   }
   
   return image;
}


void imagedestroy( image_t *image )
{
   free( image->bitmap );
   free( image->rowps );
   free( image );
   image = NULL;
}