From 6c68126238f1faf39e51fbbb90b1cf35701a4cb2 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Tue, 7 Sep 2010 08:38:08 +0000 Subject: Some code reformatting git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7699 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/ps_image.cxx | 111 +++++++++++++++++++++++++++---------------------------- 1 file changed, 55 insertions(+), 56 deletions(-) (limited to 'src') diff --git a/src/ps_image.cxx b/src/ps_image.cxx index 1bad4375b..eb1c878c5 100644 --- a/src/ps_image.cxx +++ b/src/ps_image.cxx @@ -39,7 +39,7 @@ int Fl_PostScript_Graphics_Driver::alpha_mask(const uchar * data, int w, int h, int D, int LD){ mask = 0; - if((D/2)*2 != D){ //no mask info + if ((D/2)*2 != D){ //no mask info return 0; } int xx; @@ -48,30 +48,29 @@ int Fl_PostScript_Graphics_Driver::alpha_mask(const uchar * data, int w, int h, int V255=0; int V0 =0; int V_=0; -// uchar d; - for(j=0;j0){ + if (error >0){ next[ii] += o1 = (error * 3 + 8)/16; current[ii+2] += o2 = (error * 7 + 8)/16; next[ii+2] = o3 =(error + 8)/16; // *1 - ok replacing (cleaning) - }else{ + } else { next[ii] += o1 = (error * 3 - 8)/16; current[ii+2] += o2 = (error * 7 - 8)/16; next[ii+2] = o3 = (error - 8)/16; @@ -148,9 +147,9 @@ int Fl_PostScript_Graphics_Driver::alpha_mask(const uchar * data, int w, int h, current = swap; *(next+1) = 0; // must clean the first cell, next are overriden by *1 - for(i=w-1;i>=0;i--){ + for (i = w-1; i >= 0; i--){ - for(k=3;k>=0;k--){ // generating 4 x-pixels for 1 RGB + for (k=3; k>=0; k--){ // generating 4 x-pixels for 1 RGB short error, o1, o2, o3; int ii = i*4+k; // mask cell index @@ -159,15 +158,15 @@ int Fl_PostScript_Graphics_Driver::alpha_mask(const uchar * data, int w, int h, mask[jj*xx+ii/8] |= 1 << (ii % 8); //set mask bit error = val-255; - }else + } else error = val; ////// error spreading ///// - if(error >0){ + if (error >0){ next[ii+2] += o1 = (error * 3 + 8)/16; current[ii] += o2 = (error * 7 + 8)/16; next[ii] = o3 =(error + 8)/16; // *1 - ok replacing (cleaning) - }else{ + } else { next[ii+2] += o1 = (error * 3 - 8)/16; current[ii] += o2 = (error * 7 - 8)/16; @@ -199,7 +198,7 @@ extern uchar **fl_mask_bitmap; void Fl_PostScript_Graphics_Driver::draw_scaled_image(const uchar *data, double x, double y, double w, double h, int iw, int ih, int D, int LD) { - if(D<3){ //mono + if (D<3){ //mono draw_scaled_image_mono(data, x, y, w, h, iw, ih, D, LD); return; } @@ -210,26 +209,26 @@ void Fl_PostScript_Graphics_Driver::draw_scaled_image(const uchar *data, double fprintf(output,"save\n"); const char * interpol; - if(lang_level_>1){ - if(interpolate_) + if (lang_level_>1){ + if (interpolate_) interpol="true"; else interpol="false"; - if(mask && lang_level_>2) + if (mask && lang_level_>2) fprintf(output, "%g %g %g %g %i %i %i %i %s CIM\n", x , y+h , w , -h , iw , ih, mx, my, interpol); else fprintf(output, "%g %g %g %g %i %i %s CII\n", x , y+h , w , -h , iw , ih, interpol); - }else + } else fprintf(output , "%g %g %g %g %i %i CI", x , y+h , w , -h , iw , ih); - if(!LD) LD = iw*D; + if (!LD) LD = iw*D; uchar *curmask=mask; for (j=0; j3) { //can do mixing using bg_* colors) + if (lang_level_<3 && D>3) { //can do mixing using bg_* colors) unsigned int a2 = curdata[3]; //must be int unsigned int a = 255-a2; r = (a2 * r + bg_r * a)/255; @@ -290,7 +289,7 @@ void Fl_PostScript_Graphics_Driver::draw_scaled_image(Fl_Draw_Image_Cb call, voi uchar *rgbdata=new uchar[LD]; uchar *curmask=mask; - if(level2_mask) { + if (level2_mask) { for (j = ih - 1; j >= 0; j--) { // output full image data call(data, 0, j, iw, rgbdata); uchar *curdata = rgbdata; @@ -317,7 +316,7 @@ void Fl_PostScript_Graphics_Driver::draw_scaled_image(Fl_Draw_Image_Cb call, voi } else { for (j=0; j 2) { // InterleaveType 2 mask data + if (mask && lang_level_ > 2) { // InterleaveType 2 mask data for (k=0; k1){ - if(interpolate_) + if (lang_level_>1){ + if (interpolate_) interpol="true"; else interpol="false"; - if(mask && lang_level_>2) + if (mask && lang_level_>2) fprintf(output, "%g %g %g %g %i %i %i %i %s GIM\n", x , y+h , w , -h , iw , ih, mx, my, interpol); else fprintf(output, "%g %g %g %g %i %i %s GII\n", x , y+h , w , -h , iw , ih, interpol); @@ -369,15 +368,15 @@ void Fl_PostScript_Graphics_Driver::draw_scaled_image_mono(const uchar *data, do fprintf(output , "%g %g %g %g %i %i GI", x , y+h , w , -h , iw , ih); - if(!LD) LD = iw*D; + if (!LD) LD = iw*D; int bg = (bg_r + bg_g + bg_b)/3; uchar *curmask=mask; for (j=0; j1) { //can do mixing + if (lang_level_<3 && D>1) { //can do mixing unsigned int a2 = curdata[1]; //must be int unsigned int a = 255-a2; @@ -415,14 +414,14 @@ void Fl_PostScript_Graphics_Driver::draw_scaled_image_mono(Fl_Draw_Image_Cb call fprintf(output,"save\n"); int i,j,k; const char * interpol; - if(lang_level_>1){ - if(interpolate_) interpol="true"; + if (lang_level_>1){ + if (interpolate_) interpol="true"; else interpol="false"; - if(mask && lang_level_>2) + if (mask && lang_level_>2) fprintf(output, "%g %g %g %g %i %i %i %i %s GIM\n", x , y+h , w , -h , iw , ih, mx, my, interpol); else fprintf(output, "%g %g %g %g %i %i %s GII\n", x , y+h , w , -h , iw , ih, interpol); - }else + } else fprintf(output , "%g %g %g %g %i %i GI", x , y+h , w , -h , iw , ih); int LD=iw*D; @@ -430,8 +429,8 @@ void Fl_PostScript_Graphics_Driver::draw_scaled_image_mono(Fl_Draw_Image_Cb call uchar *curmask=mask; for (j=0; j2){ // InterleaveType 2 mask data - for(k=0; k2){ // InterleaveType 2 mask data + for (k=0; kw(); int h = rgb->h(); mask=0; - if(lang_level_>2) //when not true, not making alphamask, mixing colors instead... + if (lang_level_>2) //when not true, not making alphamask, mixing colors instead... if (alpha_mask(di, w, h, rgb->d(),rgb->ld())) return; //everthing masked, no need for painting! push_clip(XP, YP, WP, HP); draw_scaled_image(di, XP + cx, YP + cy, w, h, w, h, rgb->d(), rgb->ld()); @@ -502,7 +501,7 @@ void Fl_PostScript_Graphics_Driver::draw(Fl_Bitmap * bitmap,int XP, int YP, int w =WP; xx = (w+7)/8 - cx/8; } - if( HP > bitmap->h()-cy) + if ( HP > bitmap->h()-cy) h = bitmap->h() - cy; else h = HP; -- cgit v1.2.3