i_color *
ICL_new_internal(unsigned char r,unsigned char g,unsigned char b,unsigned char a) {
- i_color *cl=NULL;
+ i_color *cl = NULL;
- mm_log((1,"ICL_new_internal(r %d,g %d,b %d,a %d)\n",cl,r,g,b,a));
+ mm_log((1,"ICL_new_internal(r %d,g %d,b %d,a %d)\n", r, g, b, a));
if ( (cl=mymalloc(sizeof(i_color))) == NULL) m_fatal(2,"malloc() error\n");
- cl->rgba.r=r;
- cl->rgba.g=g;
- cl->rgba.b=b;
- cl->rgba.a=a;
- mm_log((1,"(0x%x) <- ICL_new_internal\n",cl));
+ cl->rgba.r = r;
+ cl->rgba.g = g;
+ cl->rgba.b = b;
+ cl->rgba.a = a;
+ mm_log((1,"(%p) <- ICL_new_internal\n",cl));
return cl;
}
i_color *
ICL_set_internal(i_color *cl,unsigned char r,unsigned char g,unsigned char b,unsigned char a) {
- mm_log((1,"ICL_set_internal(cl* 0x%x,r %d,g %d,b %d,a %d)\n",cl,r,g,b,a));
+ mm_log((1,"ICL_set_internal(cl* %p,r %d,g %d,b %d,a %d)\n",cl,r,g,b,a));
if (cl == NULL)
if ( (cl=mymalloc(sizeof(i_color))) == NULL)
m_fatal(2,"malloc() error\n");
cl->rgba.g=g;
cl->rgba.b=b;
cl->rgba.a=a;
- mm_log((1,"(0x%x) <- ICL_set_internal\n",cl));
+ mm_log((1,"(%p) <- ICL_set_internal\n",cl));
return cl;
}
void
ICL_info(i_color *cl) {
- mm_log((1,"i_color_info(cl* 0x%x)\n",cl));
+ mm_log((1,"i_color_info(cl* %p)\n",cl));
mm_log((1,"i_color_info: (%d,%d,%d,%d)\n",cl->rgba.r,cl->rgba.g,cl->rgba.b,cl->rgba.a));
}
void
ICL_DESTROY(i_color *cl) {
- mm_log((1,"ICL_DESTROY(cl* 0x%x)\n",cl));
+ mm_log((1,"ICL_DESTROY(cl* %p)\n",cl));
myfree(cl);
}
im=i_img_empty_ch(NULL,x,y,ch);
- mm_log((1,"(0x%x) <- IIM_new\n",im));
+ mm_log((1,"(%p) <- IIM_new\n",im));
return im;
}
void
IIM_DESTROY(i_img *im) {
- mm_log((1,"IIM_DESTROY(im* 0x%x)\n",im));
+ mm_log((1,"IIM_DESTROY(im* %p)\n",im));
/* myfree(cl); */
}
im->i_f_gpix=i_gpix_d;
im->ext_data=NULL;
- mm_log((1,"(0x%x) <- i_img_struct\n",im));
+ mm_log((1,"(%p) <- i_img_struct\n",im));
return im;
}
i_img *
i_img_empty(i_img *im,int x,int y) {
- mm_log((1,"i_img_empty(*im 0x%x,x %d,y %d)\n",im,x,y));
+ mm_log((1,"i_img_empty(*im %p, x %d, y %d)\n",im, x, y));
if (im==NULL)
if ( (im=mymalloc(sizeof(i_img))) == NULL)
m_fatal(2,"malloc() error\n");
- im->xsize=x;
- im->ysize=y;
- im->channels=3;
- im->ch_mask=MAXINT;
+ im->xsize = x;
+ im->ysize = y;
+ im->channels = 3;
+ im->ch_mask = MAXINT;
im->bytes=x*y*im->channels;
- if ( (im->data=mymalloc(im->bytes)) == NULL) m_fatal(2,"malloc() error\n");
- memset(im->data,0,(size_t)im->bytes);
+ if ( (im->data = mymalloc(im->bytes)) == NULL) m_fatal(2,"malloc() error\n");
+ memset(im->data, 0, (size_t)im->bytes);
- im->i_f_ppix=i_ppix_d;
- im->i_f_gpix=i_gpix_d;
- im->ext_data=NULL;
+ im->i_f_ppix = i_ppix_d;
+ im->i_f_gpix = i_gpix_d;
+ im->ext_data = NULL;
- mm_log((1,"(0x%x) <- i_img_empty\n",im));
+ mm_log((1,"(%p) <- i_img_empty\n", im));
return im;
}
i_img *
i_img_empty_ch(i_img *im,int x,int y,int ch) {
- mm_log((1,"i_img_empty_ch(*im 0x%x,x %d,y %d,ch %d)\n",im,x,y,ch));
- if (im==NULL)
+ mm_log((1,"i_img_empty_ch(*im %p, x %d, y %d, ch %d)\n", im, x, y, ch));
+ if (im == NULL)
if ( (im=mymalloc(sizeof(i_img))) == NULL)
m_fatal(2,"malloc() error\n");
- im->xsize=x;
- im->ysize=y;
- im->channels=ch;
- im->ch_mask=MAXINT;
+ im->xsize = x;
+ im->ysize = y;
+ im->channels = ch;
+ im->ch_mask = MAXINT;
im->bytes=x*y*im->channels;
if ( (im->data=mymalloc(im->bytes)) == NULL) m_fatal(2,"malloc() error\n");
memset(im->data,0,(size_t)im->bytes);
- im->i_f_ppix=i_ppix_d;
- im->i_f_gpix=i_gpix_d;
- im->ext_data=NULL;
+ im->i_f_ppix = i_ppix_d;
+ im->i_f_gpix = i_gpix_d;
+ im->ext_data = NULL;
- mm_log((1,"(0x%x) <- i_img_empty_ch\n",im));
+ mm_log((1,"(%p) <- i_img_empty_ch\n",im));
return im;
}
i_img_exorcise(i_img *im) {
mm_log((1,"i_img_exorcise(im* 0x%x)\n",im));
if (im->data != NULL) { myfree(im->data); }
- im->data=NULL;
- im->xsize=0;
- im->ysize=0;
- im->channels=0;
+ im->data = NULL;
+ im->xsize = 0;
+ im->ysize = 0;
+ im->channels = 0;
im->i_f_ppix=i_ppix_d;
im->i_f_gpix=i_gpix_d;
if (im != NULL) {
mm_log((1,"i_img_info: xsize=%d ysize=%d channels=%d mask=%ud\n",im->xsize,im->ysize,im->channels,im->ch_mask));
mm_log((1,"i_img_info: data=0x%d\n",im->data));
- info[0]=im->xsize;
- info[1]=im->ysize;
- info[2]=im->channels;
- info[3]=im->ch_mask;
+ info[0] = im->xsize;
+ info[1] = im->ysize;
+ info[2] = im->channels;
+ info[3] = im->ch_mask;
} else {
- info[0]=0;
- info[1]=0;
- info[2]=0;
- info[3]=0;
+ info[0] = 0;
+ info[1] = 0;
+ info[2] = 0;
+ info[3] = 0;
}
}
=cut
*/
int
-i_ppix(i_img *im,int x,int y,i_color *val) { return im->i_f_ppix(im,x,y,val); }
+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)
=cut
*/
int
-i_gpix(i_img *im,int x,int y,i_color *val) { return im->i_f_gpix(im,x,y,val); }
+i_gpix(i_img *im, int x, int y, i_color *val) { return im->i_f_gpix(im, x, y, val); }
/*
=item i_ppix_d(im, x, y, col)
=cut
*/
int
-i_ppix_d(i_img *im,int x,int y,i_color *val) {
+i_ppix_d(i_img *im, int x, int y, i_color *val) {
int ch;
if ( x>-1 && x<im->xsize && y>-1 && y<im->ysize ) {
=cut
*/
int
-i_gpix_d(i_img *im,int x,int y,i_color *val) {
+i_gpix_d(i_img *im, int x, int y, i_color *val) {
int ch;
if (x>-1 && x<im->xsize && y>-1 && y<im->ysize) {
for(ch=0;ch<im->channels;ch++)
i_color pv;
int x,y,t,ttx,tty,tt,ch;
- mm_log((1,"i_copyto_trans(im* 0x%x,src 0x%x,x1 %d,y1 %d,x2 %d,y2 %d,tx %d,ty %d,trans* 0x%x)\n",im,src,x1,y1,x2,y2,tx,ty,trans));
-
+ mm_log((1,"i_copyto_trans(im* %p,src 0x%x, x1 %d, y1 %d, x2 %d, y2 %d, tx %d, ty %d, trans* 0x%x)\n",
+ im, src, x1, y1, x2, y2, tx, ty, trans));
+
if (x2<x1) { t=x1; x1=x2; x2=t; }
if (y2<y1) { t=y1; y1=y2; y2=t; }
*/
void
-i_copyto(i_img *im,i_img *src,int x1,int y1,int x2,int y2,int tx,int ty) {
+i_copyto(i_img *im, i_img *src, int x1, int y1, int x2, int y2, int tx, int ty) {
i_color pv;
- int x,y,t,ttx,tty;
+ int x, y, t, ttx, tty;
if (x2<x1) { t=x1; x1=x2; x2=t; }
if (y2<y1) { t=y1; y1=y2; y2=t; }
- mm_log((1,"i_copyto(im* 0x%x,src 0x%x,x1 %d,y1 %d,x2 %d,y2 %d,tx %d,ty %d)\n",im,src,x1,y1,x2,y2,tx,ty));
+ mm_log((1,"i_copyto(im* %p, src %p, x1 %d, y1 %d, x2 %d, y2 %d, tx %d, ty %d)\n",
+ im, src, x1, y1, x2, y2, tx, ty));
- tty=ty;
- for(y=y1;y<y2;y++) {
- ttx=tx;
- for(x=x1;x<x2;x++) {
- i_gpix(src,x,y,&pv);
- i_ppix(im,ttx,tty,&pv);
- ttx++;
+ tty = ty;
+ for(y=y1; y<y2; y++) {
+ ttx = tx;
+ for(x=x1; x<x2; x++) {
+ i_gpix(src, x, y, &pv);
+ i_ppix(im, ttx, tty, &pv);
+ ttx++;
}
tty++;
}
*/
void
-i_copy(i_img *im,i_img *src) {
+i_copy(i_img *im, i_img *src) {
i_color pv;
int x,y,y1,x1;
- mm_log((1,"i_copy(im* 0x%x,src 0x%x)\n",im,src));
+ mm_log((1,"i_copy(im* %p,src %p)\n", im,s rc));
- x1=src->xsize;
- y1=src->ysize;
- i_img_empty_ch(im,x1,y1,src->channels);
+ x1 = src->xsize;
+ y1 = src->ysize;
+ i_img_empty_ch(im, x1, y1, src->channels);
- for(y=0;y<y1;y++) for(x=0;x<x1;x++) {
- i_gpix(src,x,y,&pv);
- i_ppix(im,x,y,&pv);
+ for(y=0; y<y1; y++) for(x=0; x<x1; x++) {
+ i_gpix(src, x, y, &pv);
+ i_ppix(im, x, y, &pv);
}
}
void
i_rubthru(i_img *im,i_img *src,int tx,int ty) {
- i_color pv,orig,dest;
- int x,y,ttx,tty;
+ i_color pv, orig, dest;
+ int x, y, ttx, tty;
- mm_log((1,"i_rubthru(im 0x%x,src 0x%x,tx %d,ty %d)\n",im,src,tx,ty));
+ mm_log((1,"i_rubthru(im %p, src %p, tx %d, ty %d)\n", im, src, tx, ty));
- if (im->channels != 3) { fprintf(stderr,"Destination is not in rgb mode.\n"); exit(3); }
+ if (im->channels != 3) { fprintf(stderr,"Destination is not in rgb mode.\n"); exit(3); }
if (src->channels != 4) { fprintf(stderr,"Source is not in rgba mode.\n"); exit(3); }
- ttx=tx;
- for(x=0;x<src->xsize;x++)
- {
- tty=ty;
- for(y=0;y<src->ysize;y++)
- {
- /* fprintf(stderr,"reading (%d,%d) writing (%d,%d).\n",x,y,ttx,tty); */
- i_gpix(src,x,y,&pv);
- i_gpix(im,ttx,tty,&orig);
- dest.rgb.r=(pv.rgba.a*pv.rgba.r+(255-pv.rgba.a)*orig.rgb.r)/255;
- dest.rgb.g=(pv.rgba.a*pv.rgba.g+(255-pv.rgba.a)*orig.rgb.g)/255;
- dest.rgb.b=(pv.rgba.a*pv.rgba.b+(255-pv.rgba.a)*orig.rgb.b)/255;
- i_ppix(im,ttx,tty,&dest);
- tty++;
- }
- ttx++;
+ ttx = tx;
+ for(x=0; x<src->xsize; x++) {
+ tty=ty;
+ for(y=0;y<src->ysize;y++) {
+ /* fprintf(stderr,"reading (%d,%d) writing (%d,%d).\n",x,y,ttx,tty); */
+ i_gpix(src, x, y, &pv);
+ i_gpix(im, ttx, tty, &orig);
+ dest.rgb.r = (pv.rgba.a*pv.rgba.r+(255-pv.rgba.a)*orig.rgb.r)/255;
+ dest.rgb.g = (pv.rgba.a*pv.rgba.g+(255-pv.rgba.a)*orig.rgb.g)/255;
+ dest.rgb.b = (pv.rgba.a*pv.rgba.b+(255-pv.rgba.a)*orig.rgb.b)/255;
+ i_ppix(im, ttx, tty, &dest);
+ tty++;
}
+ ttx++;
+ }
}