public JGImage toDisplayCompatible(int thresh,JGColor bg_col,
	boolean fast, boolean bitmask) {
		Color bgcol = new Color(bg_col.r,bg_col.g,bg_col.b);
		int bgcol_rgb = (bgcol.getRed()<<16) | (bgcol.getGreen()<<8)
						| bgcol.getBlue();
		JGPoint size = getSize();
		int [] buffer = getPixels();
		// render image to bg depending on bgcol
		BufferedImage img_bg;
		if (bitmask) {
			img_bg=createCompatibleImage(size.x,size.y,Transparency.BITMASK);
		} else {
		   img_bg=createCompatibleImage(size.x,size.y,Transparency.TRANSLUCENT);
		}
		int [] bg_buf;
		if (!fast) {
			Graphics g=img_bg.getGraphics();
			g.setColor(bgcol);
			// the docs say I could use bgcol in the drawImage as an
			// equivalent to the following two lines, but this
			// doesn't handle translucency properly and is _slower_
			g.fillRect(0,0,size.x,size.y);
			g.drawImage(img,0,0,null);
			bg_buf = new JREImage(img_bg).getPixels();
		} else {
			bg_buf=buffer;
		}
		//g.dispose();
		//ColorModel rgb_bitmask = ColorModel.getRGBdefault();
		//rgb_bitmask = new PackedColorModel(
		//		rgb_bitmask.getColorSpace(),25,0xff0000,0x00ff00,0x0000ff,
		//		0x1000000, false, Transparency.BITMASK, DataBuffer.TYPE_INT);
//		ColorSpace space, int bits, int rmask, int gmask, int bmask, int amask, boolean isAlphaPremultiplied, int trans, int transferType) 
		int [] thrsbuf = new int [size.x * size.y];
		for(int y = 0; y < size.y; y++) {
			for(int x = 0; x < size.x; x++) {
				if ( ( (buffer[y*size.x+x] >> 24) & 0xff ) >= thresh) {
					thrsbuf[y*size.x+x]=bg_buf[y*size.x+x]|(0xff<<24);
				} else {
					// explicitly set the colour of the transparent pixel.
					// This makes a difference when scaling!
					//thrsbuf[y*size.x+x]=bg_buf[y*size.x+x]&~(0xff<<24);
					thrsbuf[y*size.x+x]=bgcol_rgb;
				}
			}
		}
		return new JREImage( output_comp.createImage(
			new MemoryImageSource(size.x,size.y,
				//rgb_bitmask,
				img_bg.getColorModel(), // display compatible bitmask
				bitmask ? thrsbuf : bg_buf, 0, size.x) ) );
	}