예제 #1
0
struct image *
create_image_qt(int width, int height, struct palette* palette, float pixelwidth, float pixelheight)
{
    QImage **data = new QImage*[2];
    data[0] = new QImage(width, height, QImage::Format_RGB32);
    data[1] = new QImage(width, height, QImage::Format_RGB32);
    struct image* img = create_image_cont(width, height, data[0]->bytesPerLine(), 2, data[0]->bits(), data[1]->bits(), palette, NULL, 0, pixelwidth, pixelheight);
    if (!img) {
        delete data[0];
        delete data[1];
        delete data;
        return NULL;
    }
    img->data = data;
    img->free = freeImage;
    return img;
}
예제 #2
0
파일: image.c 프로젝트: Jheengut/gmerlin
struct image *
create_image_mem (int width, int height, int nimages, struct palette *palette,
		  float pixelwidth, float pixelheight)
{
  unsigned char *data = (unsigned char *) calloc (((width + 3) & ~3) * height,
						  bytesperpixel
						  (palette->type));
  unsigned char *data1 =
    (unsigned char *) (nimages == 2 ? calloc (((width + 3) & ~3) * height,
					      bytesperpixel (palette->type)) :
		       NULL);
  struct image *img;
  if (data == NULL)
    {
#ifdef DEBUG
      printf ("Image:out of memory\n");
#endif
      return (NULL);
    }
  if (nimages == 2 && data1 == NULL)
    {
      free (data);
#ifdef DEBUG
      printf ("Image:out of memory2\n");
#endif
      return NULL;
    }
  img =
    create_image_cont (width, height,
		       ((width + 3) & ~3) * bytesperpixel (palette->type),
		       nimages, data, data1, palette, NULL, 0, pixelwidth,
		       pixelheight);
  if (img == NULL)
    {
      free (data);
      if (data1 != NULL)
	free (data1);
      return NULL;
    }
  img->flags |= FREEDATA;
  return (img);
}