i_setcolors_p, /* i_f_setcolors */
i_destroy_p, /* i_f_destroy */
+
+ i_gsamp_bits_fb,
+ NULL, /* i_f_psamp_bits */
};
/*
-=item i_img_pal_new_low(im, x, y, channels, maxpal)
+=item i_img_pal_new(x, y, channels, maxpal)
-Creates a new paletted image.
+=category Image creation/destruction
+=synopsis i_img *img = i_img_pal_new(width, height, channels, max_palette_size)
+
+Creates a new paletted image of the supplied dimensions.
-Currently 0 < maxpal <= 256
+I<maxpal> is the maximum palette size and should normally be 256.
+
+Returns a new image or NULL on failure.
=cut
*/
-i_img *i_img_pal_new_low(i_img *im, int x, int y, int channels, int maxpal) {
+i_img *
+i_img_pal_new(int x, int y, int channels, int maxpal) {
+ i_img *im;
i_img_pal_ext *palext;
int bytes, line_bytes;
return NULL;
}
+ im = i_img_alloc();
memcpy(im, &IIM_base_8bit_pal, sizeof(i_img));
palext = mymalloc(sizeof(i_img_pal_ext));
palext->pal = mymalloc(sizeof(i_color) * maxpal);
memset(im->idata, 0, im->bytes);
im->xsize = x;
im->ysize = y;
-
- return im;
-}
-
-/*
-=item i_img_pal_new(x, y, channels, maxpal)
-
-=category Image creation
-
-Creates a new paletted image of the supplied dimensions.
-
-Returns a new image or NULL on failure.
-
-=cut
-*/
-
-i_img *i_img_pal_new(int x, int y, int channels, int maxpal) {
- i_img *im;
- mm_log((1, "i_img_pal_new(x %d, y %d, channels %d, maxpal %d)\n", x, y, channels, maxpal));
- im = mymalloc(sizeof(i_img));
- if (!i_img_pal_new_low(im, x, y, channels, maxpal)) {
- myfree(im);
- im = NULL;
- }
+ i_img_init(im);
+
return im;
}
}
}
else {
+ if (chan_count <= 0 || chan_count > im->channels) {
+ i_push_errorf(0, "chan_count %d out of range, must be >0, <= channels",
+ chan_count);
+ return 0;
+ }
for (i = 0; i < w; ++i) {
i_palidx which = *data++;
if (which < palsize) {