User Tools

Site Tools


cs276:scaledown
// scaleDownImage(source, dest)
// This works by writing every other pixel of the source
// into the array of the destination; must be careful that 
// the sizes of the pixel arrays are compatible
// Note: a reasonable destination would be a "blank canvas",
// for example, the image file 7inX95in.jpg (see Assignments links)
 
void scaleDownImage(PImage source, PImage dest) {
  for (int row = 0, drow = 0; row < source.height; drow++, row += 2) {
    for (int col = 0, dcol = 0; col < source.width; dcol++, col += 2) {
      // copy is PImage object passed into function
      color c = source.get(col, row);
      dest.set(dcol, drow, c);
    }
  }
}
cs276/scaledown.txt · Last modified: 2007/10/05 14:07 by scarl