-/*
-=item IIM_base_8bit_direct (static)
-
-A static i_img object used to initialize direct 8-bit per sample images.
-
-=cut
-*/
-static i_img IIM_base_8bit_direct =
-{
- 0, /* channels set */
- 0, 0, 0, /* xsize, ysize, bytes */
- ~0U, /* ch_mask */
- i_8_bits, /* bits */
- i_direct_type, /* type */
- 0, /* virtual */
- NULL, /* idata */
- { 0, 0, NULL }, /* tags */
- NULL, /* ext_data */
-
- i_ppix_d, /* i_f_ppix */
- i_ppixf_d, /* i_f_ppixf */
- i_plin_d, /* i_f_plin */
- i_plinf_d, /* i_f_plinf */
- i_gpix_d, /* i_f_gpix */
- i_gpixf_d, /* i_f_gpixf */
- i_glin_d, /* i_f_glin */
- i_glinf_d, /* i_f_glinf */
- i_gsamp_d, /* i_f_gsamp */
- i_gsampf_d, /* i_f_gsampf */
-
- NULL, /* i_f_gpal */
- NULL, /* i_f_ppal */
- NULL, /* i_f_addcolors */
- NULL, /* i_f_getcolors */
- NULL, /* i_f_colorcount */
- NULL, /* i_f_maxcolors */
- NULL, /* i_f_findcolor */
- NULL, /* i_f_setcolors */
-
- NULL, /* i_f_destroy */
-};
-
-/*static void set_8bit_direct(i_img *im) {
- im->i_f_ppix = i_ppix_d;
- im->i_f_ppixf = i_ppixf_d;
- im->i_f_plin = i_plin_d;
- im->i_f_plinf = i_plinf_d;
- im->i_f_gpix = i_gpix_d;
- im->i_f_gpixf = i_gpixf_d;
- im->i_f_glin = i_glin_d;
- im->i_f_glinf = i_glinf_d;
- im->i_f_gpal = NULL;
- im->i_f_ppal = NULL;
- im->i_f_addcolor = NULL;
- im->i_f_getcolor = NULL;
- im->i_f_colorcount = NULL;
- im->i_f_findcolor = NULL;
- }*/
-
-/*
-=item IIM_new(x, y, ch)
-
-=item i_img_8_new(x, y, ch)
-
-=category Image creation
-
-Creates a new image object I<x> pixels wide, and I<y> pixels high with
-I<ch> channels.
-
-=cut
-*/
-
-
-i_img *
-IIM_new(int x,int y,int ch) {
- i_img *im;
- mm_log((1,"IIM_new(x %d,y %d,ch %d)\n",x,y,ch));
-
- im=i_img_empty_ch(NULL,x,y,ch);
-
- mm_log((1,"(%p) <- IIM_new\n",im));
- return im;
-}
-
-
-void
-IIM_DESTROY(i_img *im) {
- mm_log((1,"IIM_DESTROY(im* %p)\n",im));
- i_img_destroy(im);
- /* myfree(cl); */
-}
-
-/*
-=item i_img_new()
-
-Create new image reference - notice that this isn't an object yet and
-this should be fixed asap.
-
-=cut
-*/
-
-
-i_img *
-i_img_new() {
- i_img *im;
-
- mm_log((1,"i_img_struct()\n"));
- if ( (im=mymalloc(sizeof(i_img))) == NULL)
- i_fatal(2,"malloc() error\n");
-
- *im = IIM_base_8bit_direct;
- im->xsize=0;
- im->ysize=0;
- im->channels=3;
- im->ch_mask=MAXINT;
- im->bytes=0;
- im->idata=NULL;
-
- mm_log((1,"(%p) <- i_img_struct\n",im));
- return im;
-}
-
-/*
-=item i_img_empty(im, x, y)
-
-Re-new image reference (assumes 3 channels)
-
- im - Image pointer
- x - xsize of destination image
- y - ysize of destination image
-
-**FIXME** what happens if a live image is passed in here?
-
-Should this just call i_img_empty_ch()?
-
-=cut
-*/
-
-i_img *
-i_img_empty(i_img *im,int x,int y) {
- mm_log((1,"i_img_empty(*im %p, x %d, y %d)\n",im, x, y));
- return i_img_empty_ch(im, x, y, 3);
-}
-
-/*
-=item i_img_empty_ch(im, x, y, ch)
-
-Re-new image reference
-
- im - Image pointer
- x - xsize of destination image
- y - ysize of destination image
- ch - number of channels
-
-=cut
-*/
-
-i_img *
-i_img_empty_ch(i_img *im,int x,int y,int ch) {
- int bytes;
-
- mm_log((1,"i_img_empty_ch(*im %p, x %d, y %d, ch %d)\n", im, x, y, ch));
-
- if (x < 1 || y < 1) {
- i_push_error(0, "Image sizes must be positive");
- return NULL;
- }
- if (ch < 1 || ch > MAXCHANNELS) {
- i_push_errorf(0, "channels must be between 1 and %d", MAXCHANNELS);
- return NULL;
- }
- /* check this multiplication doesn't overflow */
- bytes = x*y*ch;
- if (bytes / y / ch != x) {
- i_push_errorf(0, "integer overflow calculating image allocation");
- return NULL;
- }
-
- if (im == NULL)
- if ( (im=mymalloc(sizeof(i_img))) == NULL)
- i_fatal(2,"malloc() error\n");
-
- memcpy(im, &IIM_base_8bit_direct, sizeof(i_img));
- i_tags_new(&im->tags);
- im->xsize = x;
- im->ysize = y;
- im->channels = ch;
- im->ch_mask = MAXINT;
- im->bytes=bytes;
- if ( (im->idata=mymalloc(im->bytes)) == NULL)
- i_fatal(2,"malloc() error\n");
- memset(im->idata,0,(size_t)im->bytes);
-
- im->ext_data = NULL;
-
- mm_log((1,"(%p) <- i_img_empty_ch\n",im));
- return im;
-}
-