Author: manolo
Date: 2010-09-07 01:38:08 -0700 (Tue, 07 Sep 2010)
New Revision: 7699
Log:
Some code reformatting


Modified:
   branches/branch-1.3/src/ps_image.cxx

Modified: branches/branch-1.3/src/ps_image.cxx
===================================================================
--- branches/branch-1.3/src/ps_image.cxx        2010-09-06 08:32:24 UTC (rev 
7698)
+++ branches/branch-1.3/src/ps_image.cxx        2010-09-07 08:38:08 UTC (rev 
7699)
@@ -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 V255=0;
   int V0 =0;
   int V_=0;
-//  uchar d;
-  for(j=0;j<h;j++){
-    for(i=0;i<w;i++)
+  for (j=0;j<h;j++){
+    for (i=0;i<w;i++)
       switch(data[j*LD+D*i+D-1]){
         case 255: V255 = 1; break;
         case 0: V0 = 1; break;
         default: V_= 1;
       }
-    if(V_) break;
+    if (V_) break;
   };
-  if(!V_){
-    if(V0)
-      if(V255){// not true alpha, only masking
+  if (!V_){
+    if (V0)
+      if (V255){// not true alpha, only masking
         xx = (w+7)/8;
         mask = new uchar[h * xx];
-        for(i=0;i<h * xx;i++) mask[i]=0;
-        for(j=0;j<h;j++)
-          for(i=0;i<w;i++)
-            if(data[j*LD+D*i+D-1])
+        for (i=0;i<h * xx;i++) mask[i]=0;
+        for (j=0;j<h;j++)
+          for (i=0;i<w;i++)
+            if (data[j*LD+D*i+D-1])
               mask[j*xx+i/8] |= 1 << (i % 8);
         mx = w;
         my = h; //mask imensions
         return 0;
-      }else{
+      } else {
         mask=0;
         return 1; //everything masked
       }
@@ -86,7 +85,7 @@
 
   mask = new uchar[((w+1)/2) * h * 4];
 
-  for(i=0;i<((w+1)/2) * h * 4; i++) mask[i] = 0; //cleaning
+  for (i = 0; i<((w+1)/2) * h * 4; i++) mask[i] = 0; //cleaning
 
 
 
@@ -98,15 +97,15 @@
   short * errors1 = new short [w*4+2]; //  two rows of dither errors
   short * errors2 = new short [w*4+2]; //  two rows of dither errors
 
-  for(i=0;i<w*4+2;i++) errors2[i] = 0; // cleaning,after first swap will 
become current
-  for(i=0;i<w*4+2;i++) errors1[i] = 0; // cleaning,after first swap will 
become current
+  for (i=0; i<w*4+2; i++) errors2[i] = 0; // cleaning,after first swap will 
become current
+  for (i=0; i<w*4+2; i++) errors1[i] = 0; // cleaning,after first swap will 
become current
 
   short * current = errors1;
   short * next = errors2;
   short * swap;
 
-  for(j=0;j<h;j++){
-    for(l=0;l<4;){           // generating 4 rows of mask lines for 1 RGB line
+  for (j=0; j<h; j++){
+    for (l=0; l<4; ){           // generating 4 rows of mask lines for 1 RGB 
line
       int jj = j*4+l;
 
       /// mask row index
@@ -114,8 +113,8 @@
       next = current;
       current = swap;
       *(next+1) = 0;          // must clean the first cell, next are overriden 
by *1
-      for(i=0;i<w;i++){
-        for(k=0;k<4;k++){   // generating 4 x-pixels for 1 RGB
+      for (i=0; i<w; i++){
+        for (k=0; k<4; k++){   // generating 4 x-pixels for 1 RGB
           short error, o1, o2, o3;
           int ii = i*4+k;   // mask cell index
           short val = data[j*LD+D*i+D-1] + current[1+ii];
@@ -126,11 +125,11 @@
             error = val;
 
           ////// error spreading /////
-          if(error >0){
+          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 @@
       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 @@
 
             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 @@
 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 @@
   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; j<ih;j++){
-    if(mask){
+    if (mask){
 
-      for(k=0;k<my/ih;k++){
+      for (k=0;k<my/ih;k++){
         for (i=0; i<((mx+7)/8);i++){
           if (!(i%80)) fprintf(output, "\n");
           fprintf(output, "%.2x",swap_byte(*curmask));
@@ -239,11 +238,11 @@
       }
     }
     const uchar *curdata=data+j*LD;
-    for(i=0 ; i<iw ; i++) {
+    for (i=0 ; i<iw ; i++) {
       uchar r = curdata[0];
       uchar g =  curdata[1];
       uchar b =  curdata[2];
-      if(lang_level_<3 && D>3) { //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 @@
   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 @@
   }
   else {
     for (j=0; j<ih;j++) {
-      if(mask && lang_level_ > 2) {  // InterleaveType 2 mask data
+      if (mask && lang_level_ > 2) {  // InterleaveType 2 mask data
        for (k=0; k<my/ih;k++) { //for alpha pseudo-masking
          for (i=0; i<((mx+7)/8);i++) {
            if (!(i%40)) fputs("\n", output);
@@ -356,12 +355,12 @@
   int i,j, k;
 
   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 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 @@
     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; j<ih;j++){
-    if(mask){
-      for(k=0;k<my/ih;k++){
+    if (mask){
+      for (k=0;k<my/ih;k++){
         for (i=0; i<((mx+7)/8);i++){
           if (!(i%80)) fprintf(output, "\n");
           fprintf(output, "%.2x",swap_byte(*curmask));
@@ -387,10 +386,10 @@
       }
     }
     const uchar *curdata=data+j*LD;
-    for(i=0 ; i<iw ; i++) {
+    for (i=0 ; i<iw ; i++) {
       if (!(i%80)) fprintf(output, "\n");
       uchar r = curdata[0];
-      if(lang_level_<3 && D>1) { //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 @@
   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 @@
   uchar *curmask=mask;
   for (j=0; j<ih;j++){
 
-    if(mask && lang_level_>2){  // InterleaveType 2 mask data
-      for(k=0; k<my/ih;k++){ //for alpha pseudo-masking
+    if (mask && lang_level_>2){  // InterleaveType 2 mask data
+      for (k=0; k<my/ih;k++){ //for alpha pseudo-masking
         for (i=0; i<((mx+7)/8);i++){
           if (!(i%40)) fprintf(output, "\n");
           fprintf(output, "%.2x",swap_byte(*curmask));
@@ -442,7 +441,7 @@
     }
     call(data,0,j,iw,rgbdata);
     uchar *curdata=rgbdata;
-    for(i=0 ; i<iw ; i++) {
+    for (i=0 ; i<iw ; i++) {
       uchar r = curdata[0];
       if (!(i%120)) fprintf(output, "\n");
       fprintf(output, "%.2x", r);
@@ -480,7 +479,7 @@
   int w = rgb->w();
   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 @@
     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;

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to