#define minmax(a,b,i) ( ((a>=i)?a: ( (b<=i)?b:i )) )
/* Hack around an obscure linker bug on solaris - probably due to builtin gcc thingies */
-void fake(void) { ceil(1); }
+static void fake(void) { ceil(1); }
static int i_ppix_d(i_img *im, int x, int y, i_color *val);
static int i_gpix_d(i_img *im, int x, int y, i_color *val);
static int i_gpixf_d(i_img *im, int x, int y, i_fcolor *val);
static int i_glinf_d(i_img *im, int l, int r, int y, i_fcolor *vals);
static int i_plinf_d(i_img *im, int l, int r, int y, i_fcolor *vals);
-static int i_gsamp_d(i_img *im, int l, int r, int y, i_sample_t *samps, int *chans, int chan_count);
-static int i_gsampf_d(i_img *im, int l, int r, int y, i_fsample_t *samps, int *chans, int chan_count);
+static int i_gsamp_d(i_img *im, int l, int r, int y, i_sample_t *samps, const int *chans, int chan_count);
+static int i_gsampf_d(i_img *im, int l, int r, int y, i_fsample_t *samps, const int *chans, int chan_count);
+/*static int i_psamp_d(i_img *im, int l, int r, int y, i_sample_t *samps, int *chans, int chan_count);
+ static int i_psampf_d(i_img *im, int l, int r, int y, i_fsample_t *samps, int *chans, int chan_count);*/
/*
=item ICL_new_internal(r, g, b, a)
i_img_getchannels(i_img *im) { return im->channels; }
-/*
-=item i_ppix(im, x, y, col)
-
-Sets the pixel at (I<x>,I<y>) in I<im> to I<col>.
-
-Returns true if the pixel could be set, false if x or y is out of
-range.
-
-=cut
-*/
-int
-(i_ppix)(i_img *im, int x, int y, i_color *val) { return im->i_f_ppix(im, x, y, val); }
-
-/*
-=item i_gpix(im, x, y, &col)
-
-Get the pixel at (I<x>,I<y>) in I<im> into I<col>.
-
-Returns true if the pixel could be retrieved, false otherwise.
-
-=cut
-*/
-int
-(i_gpix)(i_img *im, int x, int y, i_color *val) { return im->i_f_gpix(im, x, y, val); }
-
-/*
-=item i_ppix_pch(im, x, y, ch)
-
-Get the value from the channel I<ch> for pixel (I<x>,I<y>) from I<im>
-scaled to [0,1].
-
-Returns zero if x or y is out of range.
-
-Warning: this ignores the vptr interface for images.
-
-=cut
-*/
-float
-i_gpix_pch(i_img *im,int x,int y,int ch) {
- /* FIXME */
- if (x>-1 && x<im->xsize && y>-1 && y<im->ysize) return ((float)im->idata[(x+y*im->xsize)*im->channels+ch]/255);
- else return 0;
-}
-
/*
=item i_copyto_trans(im, src, x1, y1, x2, y2, tx, ty, trans)
}
}
+/*
+=item i_sametype_chans(i_img *im, int xsize, int ysize, int channels)
+
+Returns an image of the same type (sample size).
+
+For paletted images the equivalent direct type is returned.
+
+=cut
+*/
+
+i_img *i_sametype_chans(i_img *src, int xsize, int ysize, int channels) {
+ if (src->bits == 8) {
+ return i_img_empty_ch(NULL, xsize, ysize, channels);
+ }
+ else if (src->bits == i_16_bits) {
+ return i_img_16_new(xsize, ysize, channels);
+ }
+ else if (src->bits == i_double_bits) {
+ return i_img_double_new(xsize, ysize, channels);
+ }
+ else {
+ i_push_error(0, "Unknown image bits");
+ return NULL;
+ }
+}
+
/*
=item i_transform(im, opx, opxl, opy, opyl, parm, parmlen)
parm[1]=(double)ny;
/* fprintf(stderr,"(%d,%d) ->",nx,ny); */
- rx=op_run(opx,opxl,parm,parmlen);
- ry=op_run(opy,opyl,parm,parmlen);
+ rx=i_op_run(opx,opxl,parm,parmlen);
+ ry=i_op_run(opy,opyl,parm,parmlen);
/* fprintf(stderr,"(%f,%f)\n",rx,ry); */
i_gpix(im,rx,ry,&val);
i_ppix(new_img,nx,ny,&val);
return colorcnt;
}
-
-symbol_table_t symbol_table={i_has_format,ICL_set_internal,ICL_info,
- i_img_new,i_img_empty,i_img_empty_ch,i_img_exorcise,
- i_img_info,i_img_setmask,i_img_getmask,i_ppix,i_gpix,
- i_box,i_draw,i_arc,i_copyto,i_copyto_trans,i_rubthru};
-
-
/*
=back
static
int
i_gsamp_d(i_img *im, int l, int r, int y, i_sample_t *samps,
- int *chans, int chan_count) {
+ const int *chans, int chan_count) {
int ch, count, i, w;
unsigned char *data;
static
int
i_gsampf_d(i_img *im, int l, int r, int y, i_fsample_t *samps,
- int *chans, int chan_count) {
+ const int *chans, int chan_count) {
int ch, count, i, w;
unsigned char *data;
for (ch = 0; ch < chan_count; ++ch) {
=cut
*/
int i_gsampf_fp(i_img *im, int l, int r, int y, i_fsample_t *samp,
- int *chans, int chan_count) {
+ int const *chans, int chan_count) {
i_sample_t *work;
if (y >= 0 && y < im->ysize && l < im->xsize && l >= 0) {
gci->cpos = 0;
gci->length = did_read;
- copy_size = min(length, gci->length);
+ copy_size = i_min(length, gci->length);
memcpy(buf, gci->buffer, copy_size);
gci->cpos += copy_size;
buf += copy_size;
}
/*
-=item free_gen_read_data(i_gen_read_data *)
+=item i_free_gen_read_data(i_gen_read_data *)
Cleans up.
=cut
*/
-void free_gen_read_data(i_gen_read_data *self) {
+void i_free_gen_read_data(i_gen_read_data *self) {
myfree(self);
}
Allocates and initializes the data structure used by i_gen_writer.
-This should be released with L<image.c/free_gen_write_data>
+This should be released with L<image.c/i_free_gen_write_data>
=cut
*/
i_gen_write_data *self = mymalloc(sizeof(i_gen_write_data));
self->cb = cb;
self->userdata = userdata;
- self->maxlength = min(max_length, sizeof(self->buffer));
+ self->maxlength = i_min(max_length, sizeof(self->buffer));
if (self->maxlength < 0)
self->maxlength = sizeof(self->buffer);
self->filledto = 0;
}
/*
-=item free_gen_write_data(i_gen_write_data *info, int flush)
+=item i_free_gen_write_data(i_gen_write_data *info, int flush)
Cleans up the write buffer.
=cut
*/
-int free_gen_write_data(i_gen_write_data *info, int flush)
+int i_free_gen_write_data(i_gen_write_data *info, int flush)
{
int result = !flush ||
info->filledto == 0 ||