SVP - Strategic Vectorization Project - Displaying pixel numerical values

Version of 9 April 2004. By Bob Futrelle


This page shows the image that results when zoomed into to 32x32 fat pixels. Five additional lines of code were needed. They are inserted very near the end of the paintComponent method. Note that in the current state of the system, you have to run the SVP before the zoom capability is turned on. At the moment, the maximum fat pixel size is set to 32x32, which is just enough to print a legible pixel value.

 else {

  //draw pixels     
  x = startx = first_box.y * box_size;
  y = first_box.x * box_size;

  for (int i = first_box.x; i <= last_box.x; i++) {
  for (int j = first_box.y; j <= last_box.y; j++) {
       g.setColor(new Color(image[i][j],image[i][j],image[i][j]));
       g.fillRect(x,y,scale,scale);

       // the following added by RPF 9 April 2004, 11am
       // they print the pixel numerical value in the upper corner
       if(scale >= 32) {
           g.setColor(Color.white);
           g.fillRect(x,y,28,10); 
           g.setColor(Color.black);
           g.drawString("" + image[i][j], x + 2, y + 10);
        } // end RPF addition

       x += box_size;
     }
  x = startx;
  y += box_size;
  }
 }
}//paintComponent

Here's a screen shot from my Mac G4 PB:


Return to SVP index page