User Tools

Site Tools


cs276:scaleup

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
cs276:scaleup [2007/10/04 14:53]
scarl
cs276:scaleup [2007/10/05 14:08] (current)
scarl experimenting with syntax colors
Line 1: Line 1:
-  ​// copy(source,​ dest, xoffset, yoffset) +<code java> 
-  // copies the source image to the destination,​ offset in the +// copy(source,​ dest, xoffset, yoffset) 
-  // x and y directions by xoffset, yoffset, respectively+// copies the source image to the destination,​ offset in the 
 +// x and y directions by xoffset, yoffset, respectively
  
-  ​void copy (PImage src, PImage dest, int xoff, int yoff) { +void copy (PImage src, PImage dest, int xoff, int yoff) { 
-    src.loadPixels();​ +  src.loadPixels();​ 
-    dest.loadPixels();​ +  dest.loadPixels();​ 
-    for (int row = 0, drow = yoff; row < src.height; drow++, row++) { +  for (int row = 0, drow = yoff; row < src.height; drow++, row++) { 
-      for (int col = 0, dcol = xoff; col < src.width; dcol++, col++) { +    for (int col = 0, dcol = xoff; col < src.width; dcol++, col++) { 
-        color c = src.get((int) col, (int) row); +      color c = src.get((int) col, (int) row); 
-        dest.set((int) dcol, (int) drow, c); +      dest.set((int) dcol, (int) drow, c);
-      }+
     }     }
-    dest.updatePixels();​ 
   }   }
-   +  ​dest.updatePixels();​ 
-  // scaleUpImage(source,​ dest) +
-  // This works by writing every pixel of the source twice + 
-  // into the array of the destination;​ again, be careful that  +// scaleUpImage(source,​ dest) 
-  // the sizes of the pixel arrays are compatible +// This works by writing every pixel of the source twice 
-   +// into the array of the destination;​ again, be careful that  
-  void scaleUpImage(PImage source, PImage dest) { +// the sizes of the pixel arrays are compatible 
-    source.loadPixels();​ + 
-    dest.loadPixels();​ +void scaleUpImage(PImage source, PImage dest) { 
-    for (float row = 0, drow = 0; row < source.height;​ drow++, row += 0.5) { +  source.loadPixels();​ 
-      for (float col = 0, dcol = 0; col < source.width;​ dcol++, col += 0.5) { +  dest.loadPixels();​ 
-        color c = source.get((int) col, (int) row); +  for (float row = 0, drow = 0; row < source.height;​ drow++, row += 0.5) { 
-        dest.set((int) dcol, (int) drow, c); +    for (float col = 0, dcol = 0; col < source.width;​ dcol++, col += 0.5) { 
-      }+      color c = source.get((int) col, (int) row); 
 +      dest.set((int) dcol, (int) drow, c);
     }     }
-    dest.updatePixels();​ 
   }   }
 +  dest.updatePixels();​ 
 +
 +</​code>​
cs276/scaleup.1191527617.txt.gz · Last modified: 2007/10/04 14:53 by scarl