public void generateImage()
	{
		if( icon instanceof ImageIcon) 
			icon.getImage().flush();
		// Set up temp image at native resolution
		BufferedImage temp;
		// needs to be in color if overlays will be displayed:
		if( p_selected || r_selected || c_selected )
		{
			temp = new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
			temp.getRaster().setPixels(0,0,width,height,image_data_overlay);
		}
		else
		{
			temp = new BufferedImage(width,height,BufferedImage.TYPE_BYTE_GRAY);
			temp.getRaster().setPixels(0,0,width,height,image_data);
		}
		
		// calculated scaled dimensions:
		int disp_width = (int) (scale*(float)width);
		int disp_height = (int) (scale*(float)height);

		// set class image variable to a BufferedImage with the scaled dimensions:
		image = new BufferedImage(disp_width, disp_height, temp.getType());  

		// Use Graphics2D to re-render temp into image:
		Graphics2D g = image.createGraphics();  
		g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
		RenderingHints.VALUE_INTERPOLATION_BILINEAR);  
		g.drawImage(temp, 0, 0, disp_width, disp_height, 0, 0, width, height, null);  

		// If a point/rectangle is selected, draw them:
			g.setStroke(new BasicStroke((float)1.0));
		if( p_selected )
		{
			Rectangle to_draw = new Rectangle((int)(p_image.x*scale), (int)(p_image.y*scale), 
				(int)(1*scale), (int)(1*scale));
			g.setColor(Color.BLUE);
			g.draw(to_draw);
			g.fill(to_draw);
		}
		if( r_selected )
		{
			// calculate scaled rectangle:
			Rectangle r_scaled = new Rectangle((int)(r_image.x*scale), (int)(r_image.y*scale), 
				(int)(r_image.width*scale), (int)(r_image.height*scale));
			// draw it on the image:
			g.setColor(Color.RED);
			g.draw(r_scaled);
			g.setColor(new Color(255,0,0,50));
			g.fill(r_scaled);
		}
		if( c_selected )
		{
			// Calculate a scaled circle:
			Ellipse2D.Float c_scaled = new Ellipse2D.Float( (float)(c_image.getX()*scale), (float)(c_image.getY()*scale), 
				(float)(c_image.getWidth()*scale), (float)(c_image.getHeight()*scale));
			// draw it on the image:
			g.setColor(Color.GREEN);
			g.draw(c_scaled);
			g.setColor(new Color(0,255,0,50));
			g.fill(c_scaled);
		}

		// done drawing
		g.dispose();  

		// generate a new ImageIcon from image:
		icon = new ImageIcon(image);
		icon_label.setIcon(icon); 
	}