java.awt.image.RescaleOp Java Examples

The following examples show how to use java.awt.image.RescaleOp. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ImageLibrary.java    From freecol with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a faded version of an image.
 *
 * @param img The {@code Image} to fade.
 * @param fade The amount of fading.
 * @param target The offset.
 * @return The faded image.
 */
public static BufferedImage fadeImage(Image img, float fade, float target) {
    int w = img.getWidth(null);
    int h = img.getHeight(null);
    BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g = bi.createGraphics();
    g.drawImage(img, 0, 0, null);

    float offset = target * (1.0f - fade);
    float[] scales = { fade, fade, fade, 1.0f };
    float[] offsets = { offset, offset, offset, 0.0f };
    RescaleOp rop = new RescaleOp(scales, offsets, null);
    g.drawImage(bi, rop, 0, 0);
    g.dispose();
    return bi;
}
 
Example #2
Source File: OffsetViewer.java    From WorldPainter with GNU General Public License v3.0 6 votes vote down vote up
private void paintBlock(Graphics2D g2, int baseLine, int middle, int x, int y, int depth, Material material) {
    if (material.blockType == Constants.BLK_AIR) {
        return;
    }
    if (texturePack != null) {
        if (depth > 0) {
            RescaleOp rescaleOp = new RescaleOp(new float[] {1.0f, 1.0f, 1.0f, (float) Math.pow(2.0, -depth)}, new float[] {0.0f, 0.0f, 0.0f, 0.0f}, null);
            g2.drawImage(getImage(material, texturePack), rescaleOp, middle + x * 16 - 8, baseLine - y * 16 - 8);
        } else {
            g2.drawImage(getImage(material, texturePack), middle + x * 16 - 8, baseLine - y * 16 - 8, null);
        }
    } else {
        int colour = colourScheme.getColour(material);
        if (depth > 0) {
            colour = ColourUtils.mix(colour, WHITE, (int) (Math.pow(0.5, depth) * 256 + 0.5));
        }
        g2.setColor(new Color(colour));
        g2.fillRect(middle + x * 16 - 8, baseLine - y * 16 - 8, 16, 16);
    }
}
 
Example #3
Source File: ItemPanel.java    From stendhal with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Prepare a version of the place holder Sprite, that is suitable for the
 * transparency mode of the client.
 *
 * @param original original placeholder Sprite
 * @return an adjusted Sprite, or the original if no adjusting is needed
 */
private Sprite preparePlaceholder(Sprite original) {
	if ((original == null) || (TransparencyMode.TRANSPARENCY == Transparency.BITMASK)) {
		return original;
	}
	/*
	 * Using full alpha in the client.
	 *
	 * Create a black and white, but translucent version of the same image.
	 * The filtering has been chosen so that the slot images we use become
	 * suitably B&W, not for any general rule.
	 *
	 * What we'd really want is drawing an opaque B&W image in soft light
	 * mode, but swing back buffer does not actually support Composites
	 * despite being accessed via Graphics2D.
	 */
	BufferedImage img = new BufferedImage(original.getWidth(), original.getHeight(), BufferedImage.TYPE_INT_ARGB);
	Graphics g = img.createGraphics();
	original.draw(g, 0, 0);
	RescaleOp rescaleOp = new RescaleOp(new float[] {3.0f, 3.0f, 3.0f, 0.5f }, new float[] {-450f, -450f, -450f, 0f}, null);
	rescaleOp.filter(img, img);
	g.dispose();

	return new ImageSprite(img);
}
 
Example #4
Source File: JSliderOrbit.java    From orbit-image-analysis with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected Icon getIcon ()
{
    // TODO Use that to get the state (-> highlight or not)
    TransitionAwareUI transitionAwareUI = (TransitionAwareUI) slider.getUI();
    StateTransitionTracker stateTransitionTracker = transitionAwareUI.getTransitionTracker();
    // stateTransitionTracker.getModelStateInfo().getCurrModelState();

    final Icon icon = super.getIcon();
    final BufferedImage image = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
    final Graphics iconGraphics = image.createGraphics();
    icon.paintIcon(slider, iconGraphics, 0, 0);
    // Make it brighter (very simple approach)
    final RescaleOp rescaleOp = new RescaleOp(2.0f, 50, null);
    rescaleOp.filter(image, image);

    ColorConvertOp op = new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY), null);
    op.filter(image, image);

    return new ImageIcon(image);
}
 
Example #5
Source File: ImageRescaleOpTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private void runTest(int sType, int dType, int expect) {

        BufferedImage src  = new BufferedImage(w, h, sType);
        BufferedImage dst  = new BufferedImage(w, h, dType);
        String msg = getMsgText(sType, dType);

        Graphics2D g2d = src.createGraphics();
        g2d.setColor(Color.WHITE);
        g2d.fillRect(0, 0, w, h);
        RescaleOp res = new RescaleOp(scaleFactor, offset, null);
        res.filter(src, dst);
        if (saveImage) {
            try {
               String fname = getFileName(sType, dType);
               ImageIO.write(dst, "png", new File(fname));
            } catch (IOException e) {
            }
        }
        check(dst, expect, msg);
   }
 
Example #6
Source File: StreamOutlierPanel.java    From moa with GNU General Public License v3.0 6 votes vote down vote up
public void applyDrawDecay(float factor, boolean bRedrawPointImg){
    //System.out.println("applyDrawDecay: factor="+factor);
            
    // 1)
    int v = Color.GRAY.getRed();
    //System.out.println("applyDrawDecay: v="+v);
    RescaleOp brightenOp = new RescaleOp(1f, (255-v)*factor, null);
    
    // 2)
    //RescaleOp brightenOp = new RescaleOp(1f + factor, 0, null);
    
    // 3)
    //RescaleOp brightenOp = new RescaleOp(1f, (255)*factor, null);
    
    pointImg = brightenOp.filter(pointImg, null);
    
    if (bRedrawPointImg) {
        ApplyToCanvas(pointImg);
        RedrawPointLayer();
    }
}
 
Example #7
Source File: BrightnessIncreaseDemo.java    From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void increaseImageBrightness(JLabel c, BufferedImage image) {
    float[] factors = new float[] {
        1.4f, 1.4f, 1.4f, 1.4f
    };
    float[] offsets = new float[] {
        0.0f, 0.0f, 0.0f, 0.0f
    };
    RescaleOp op = new RescaleOp(factors, offsets, null);
    BufferedImage brighter = op.filter(image, null);
    c.setIcon(new ImageIcon(brighter));
}
 
Example #8
Source File: BufferedBufImgOps.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void disableBufImgOp(RenderQueue rq, BufferedImageOp biop) {
    if (biop instanceof ConvolveOp) {
        disableConvolveOp(rq);
    } else if (biop instanceof RescaleOp) {
        disableRescaleOp(rq);
    } else if (biop instanceof LookupOp) {
        disableLookupOp(rq);
    } else {
        throw new InternalError("Unknown BufferedImageOp");
    }
}
 
Example #9
Source File: ApplicationFrame.java    From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void buildRescaleOpTab(JTabbedPane tabbedPane) {
    BufferedImage dstImage = null;
    float[] factors = new float[] {
        1.4f, 1.4f, 1.4f
    };
    float[] offsets = new float[] {
        0.0f, 0.0f, 30.0f
    };
    RescaleOp op = new RescaleOp(factors, offsets, null);
    dstImage = op.filter(sourceImage, null);
    
    tabbedPane.add("Rescale", new JLabel(new ImageIcon(dstImage)));
}
 
Example #10
Source File: BEUtils.java    From beautyeye with Apache License 2.0 5 votes vote down vote up
/**
 * 使用RescaleOp对图片进行滤镜处理.
 * 
 * @param iconBottom 原图
 * @param redFilter 红色通道滤镜值,1.0f表示保持不变
 * @param greenFilter 绿色通道滤镜值,1.0f表示保持不变
 * @param blueFilter 蓝色通道滤镜值,1.0f表示保持不变
 * @param alphaFilter alpha通道滤镜值,1.0f表示保持不变
 * @return 处理后的图片新对象
 * @author Jack Jiang, 2013-04-05
 * @since 3.5
 */
public static ImageIcon filterWithRescaleOp(ImageIcon iconBottom
		, float redFilter, float greenFilter, float blueFilter, float alphaFilter)
{
	try
	{
		int w = iconBottom.getIconWidth(), h = iconBottom.getIconHeight();

		//原图
		BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
		Graphics2D gg = (Graphics2D)bi.getGraphics();
		gg.drawImage(iconBottom.getImage(), 0, 0,w, h,null);

		//设置滤镜效果
		float[] scales = { redFilter, greenFilter, blueFilter,alphaFilter };
		float[] offsets = new float[4];
		RescaleOp rop = new RescaleOp(scales, offsets, null);

		//执行
		//		gg.drawImage(bi, rop, 0, 0);//用这一行代码没效果,用下一行代码即可!
		rop.filter(bi, bi);
		return new ImageIcon(bi);

	}
	catch (Exception e)
	{
		LogHelper.error("filterWithRescaleOp出错了,"+e.getMessage()+",iconBottom="+iconBottom);
		return new ImageIcon();
	}
}
 
Example #11
Source File: BufferedBufImgOps.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**************************** RescaleOp support *****************************/

    public static boolean isRescaleOpValid(RescaleOp rop,
                                           BufferedImage srcImg)
    {
        int numFactors = rop.getNumFactors();
        ColorModel srcCM = srcImg.getColorModel();

        if (srcCM instanceof IndexColorModel) {
            throw new
                IllegalArgumentException("Rescaling cannot be "+
                                         "performed on an indexed image");
        }
        if (numFactors != 1 &&
            numFactors != srcCM.getNumColorComponents() &&
            numFactors != srcCM.getNumComponents())
        {
            throw new IllegalArgumentException("Number of scaling constants "+
                                               "does not equal the number of"+
                                               " of color or color/alpha "+
                                               " components");
        }

        int csType = srcCM.getColorSpace().getType();
        if (csType != ColorSpace.TYPE_RGB &&
            csType != ColorSpace.TYPE_GRAY)
        {
            // Not prepared to deal with other color spaces
            return false;
        }

        if (numFactors == 2 || numFactors > 4) {
            // Not really prepared to handle this at the native level, so...
            return false;
        }

        return true;
    }
 
Example #12
Source File: BufferedBufImgOps.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void disableBufImgOp(RenderQueue rq, BufferedImageOp biop) {
    if (biop instanceof ConvolveOp) {
        disableConvolveOp(rq);
    } else if (biop instanceof RescaleOp) {
        disableRescaleOp(rq);
    } else if (biop instanceof LookupOp) {
        disableLookupOp(rq);
    } else {
        throw new InternalError("Unknown BufferedImageOp");
    }
}
 
Example #13
Source File: BufferedBufImgOps.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**************************** RescaleOp support *****************************/

    public static boolean isRescaleOpValid(RescaleOp rop,
                                           BufferedImage srcImg)
    {
        int numFactors = rop.getNumFactors();
        ColorModel srcCM = srcImg.getColorModel();

        if (srcCM instanceof IndexColorModel) {
            throw new
                IllegalArgumentException("Rescaling cannot be "+
                                         "performed on an indexed image");
        }
        if (numFactors != 1 &&
            numFactors != srcCM.getNumColorComponents() &&
            numFactors != srcCM.getNumComponents())
        {
            throw new IllegalArgumentException("Number of scaling constants "+
                                               "does not equal the number of"+
                                               " of color or color/alpha "+
                                               " components");
        }

        int csType = srcCM.getColorSpace().getType();
        if (csType != ColorSpace.TYPE_RGB &&
            csType != ColorSpace.TYPE_GRAY)
        {
            // Not prepared to deal with other color spaces
            return false;
        }

        if (numFactors == 2 || numFactors > 4) {
            // Not really prepared to handle this at the native level, so...
            return false;
        }

        return true;
    }
 
Example #14
Source File: BufferedBufImgOps.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**************************** RescaleOp support *****************************/

    public static boolean isRescaleOpValid(RescaleOp rop,
                                           BufferedImage srcImg)
    {
        int numFactors = rop.getNumFactors();
        ColorModel srcCM = srcImg.getColorModel();

        if (srcCM instanceof IndexColorModel) {
            throw new
                IllegalArgumentException("Rescaling cannot be "+
                                         "performed on an indexed image");
        }
        if (numFactors != 1 &&
            numFactors != srcCM.getNumColorComponents() &&
            numFactors != srcCM.getNumComponents())
        {
            throw new IllegalArgumentException("Number of scaling constants "+
                                               "does not equal the number of"+
                                               " of color or color/alpha "+
                                               " components");
        }

        int csType = srcCM.getColorSpace().getType();
        if (csType != ColorSpace.TYPE_RGB &&
            csType != ColorSpace.TYPE_GRAY)
        {
            // Not prepared to deal with other color spaces
            return false;
        }

        if (numFactors == 2 || numFactors > 4) {
            // Not really prepared to handle this at the native level, so...
            return false;
        }

        return true;
    }
 
Example #15
Source File: BufferedBufImgOps.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void disableBufImgOp(RenderQueue rq, BufferedImageOp biop) {
    if (biop instanceof ConvolveOp) {
        disableConvolveOp(rq);
    } else if (biop instanceof RescaleOp) {
        disableRescaleOp(rq);
    } else if (biop instanceof LookupOp) {
        disableLookupOp(rq);
    } else {
        throw new InternalError("Unknown BufferedImageOp");
    }
}
 
Example #16
Source File: BufferedBufImgOps.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public static void disableBufImgOp(RenderQueue rq, BufferedImageOp biop) {
    if (biop instanceof ConvolveOp) {
        disableConvolveOp(rq);
    } else if (biop instanceof RescaleOp) {
        disableRescaleOp(rq);
    } else if (biop instanceof LookupOp) {
        disableLookupOp(rq);
    } else {
        throw new InternalError("Unknown BufferedImageOp");
    }
}
 
Example #17
Source File: BufferedBufImgOps.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static void disableBufImgOp(RenderQueue rq, BufferedImageOp biop) {
    if (biop instanceof ConvolveOp) {
        disableConvolveOp(rq);
    } else if (biop instanceof RescaleOp) {
        disableRescaleOp(rq);
    } else if (biop instanceof LookupOp) {
        disableLookupOp(rq);
    } else {
        throw new InternalError("Unknown BufferedImageOp");
    }
}
 
Example #18
Source File: BufferedBufImgOps.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public static void enableBufImgOp(RenderQueue rq, SurfaceData srcData,
                                  BufferedImage srcImg,
                                  BufferedImageOp biop)
{
    if (biop instanceof ConvolveOp) {
        enableConvolveOp(rq, srcData, (ConvolveOp)biop);
    } else if (biop instanceof RescaleOp) {
        enableRescaleOp(rq, srcData, srcImg, (RescaleOp)biop);
    } else if (biop instanceof LookupOp) {
        enableLookupOp(rq, srcData, srcImg, (LookupOp)biop);
    } else {
        throw new InternalError("Unknown BufferedImageOp");
    }
}
 
Example #19
Source File: BufferedBufImgOps.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void enableBufImgOp(RenderQueue rq, SurfaceData srcData,
                                  BufferedImage srcImg,
                                  BufferedImageOp biop)
{
    if (biop instanceof ConvolveOp) {
        enableConvolveOp(rq, srcData, (ConvolveOp)biop);
    } else if (biop instanceof RescaleOp) {
        enableRescaleOp(rq, srcData, srcImg, (RescaleOp)biop);
    } else if (biop instanceof LookupOp) {
        enableLookupOp(rq, srcData, srcImg, (LookupOp)biop);
    } else {
        throw new InternalError("Unknown BufferedImageOp");
    }
}
 
Example #20
Source File: BufferedBufImgOps.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void enableBufImgOp(RenderQueue rq, SurfaceData srcData,
                                  BufferedImage srcImg,
                                  BufferedImageOp biop)
{
    if (biop instanceof ConvolveOp) {
        enableConvolveOp(rq, srcData, (ConvolveOp)biop);
    } else if (biop instanceof RescaleOp) {
        enableRescaleOp(rq, srcData, srcImg, (RescaleOp)biop);
    } else if (biop instanceof LookupOp) {
        enableLookupOp(rq, srcData, srcImg, (LookupOp)biop);
    } else {
        throw new InternalError("Unknown BufferedImageOp");
    }
}
 
Example #21
Source File: BufferedBufImgOps.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static void enableBufImgOp(RenderQueue rq, SurfaceData srcData,
                                  BufferedImage srcImg,
                                  BufferedImageOp biop)
{
    if (biop instanceof ConvolveOp) {
        enableConvolveOp(rq, srcData, (ConvolveOp)biop);
    } else if (biop instanceof RescaleOp) {
        enableRescaleOp(rq, srcData, srcImg, (RescaleOp)biop);
    } else if (biop instanceof LookupOp) {
        enableLookupOp(rq, srcData, srcImg, (LookupOp)biop);
    } else {
        throw new InternalError("Unknown BufferedImageOp");
    }
}
 
Example #22
Source File: BufferedBufImgOps.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**************************** RescaleOp support *****************************/

    public static boolean isRescaleOpValid(RescaleOp rop,
                                           BufferedImage srcImg)
    {
        int numFactors = rop.getNumFactors();
        ColorModel srcCM = srcImg.getColorModel();

        if (srcCM instanceof IndexColorModel) {
            throw new
                IllegalArgumentException("Rescaling cannot be "+
                                         "performed on an indexed image");
        }
        if (numFactors != 1 &&
            numFactors != srcCM.getNumColorComponents() &&
            numFactors != srcCM.getNumComponents())
        {
            throw new IllegalArgumentException("Number of scaling constants "+
                                               "does not equal the number of"+
                                               " of color or color/alpha "+
                                               " components");
        }

        int csType = srcCM.getColorSpace().getType();
        if (csType != ColorSpace.TYPE_RGB &&
            csType != ColorSpace.TYPE_GRAY)
        {
            // Not prepared to deal with other color spaces
            return false;
        }

        if (numFactors == 2 || numFactors > 4) {
            // Not really prepared to handle this at the native level, so...
            return false;
        }

        return true;
    }
 
Example #23
Source File: BufferedBufImgOps.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void disableBufImgOp(RenderQueue rq, BufferedImageOp biop) {
    if (biop instanceof ConvolveOp) {
        disableConvolveOp(rq);
    } else if (biop instanceof RescaleOp) {
        disableRescaleOp(rq);
    } else if (biop instanceof LookupOp) {
        disableLookupOp(rq);
    } else {
        throw new InternalError("Unknown BufferedImageOp");
    }
}
 
Example #24
Source File: BufferedBufImgOps.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void enableBufImgOp(RenderQueue rq, SurfaceData srcData,
                                  BufferedImage srcImg,
                                  BufferedImageOp biop)
{
    if (biop instanceof ConvolveOp) {
        enableConvolveOp(rq, srcData, (ConvolveOp)biop);
    } else if (biop instanceof RescaleOp) {
        enableRescaleOp(rq, srcData, srcImg, (RescaleOp)biop);
    } else if (biop instanceof LookupOp) {
        enableLookupOp(rq, srcData, srcImg, (LookupOp)biop);
    } else {
        throw new InternalError("Unknown BufferedImageOp");
    }
}
 
Example #25
Source File: BufferedBufImgOps.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**************************** RescaleOp support *****************************/

    public static boolean isRescaleOpValid(RescaleOp rop,
                                           BufferedImage srcImg)
    {
        int numFactors = rop.getNumFactors();
        ColorModel srcCM = srcImg.getColorModel();

        if (srcCM instanceof IndexColorModel) {
            throw new
                IllegalArgumentException("Rescaling cannot be "+
                                         "performed on an indexed image");
        }
        if (numFactors != 1 &&
            numFactors != srcCM.getNumColorComponents() &&
            numFactors != srcCM.getNumComponents())
        {
            throw new IllegalArgumentException("Number of scaling constants "+
                                               "does not equal the number of"+
                                               " of color or color/alpha "+
                                               " components");
        }

        int csType = srcCM.getColorSpace().getType();
        if (csType != ColorSpace.TYPE_RGB &&
            csType != ColorSpace.TYPE_GRAY)
        {
            // Not prepared to deal with other color spaces
            return false;
        }

        if (numFactors == 2 || numFactors > 4) {
            // Not really prepared to handle this at the native level, so...
            return false;
        }

        return true;
    }
 
Example #26
Source File: BufferedBufImgOps.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void disableBufImgOp(RenderQueue rq, BufferedImageOp biop) {
    if (biop instanceof ConvolveOp) {
        disableConvolveOp(rq);
    } else if (biop instanceof RescaleOp) {
        disableRescaleOp(rq);
    } else if (biop instanceof LookupOp) {
        disableLookupOp(rq);
    } else {
        throw new InternalError("Unknown BufferedImageOp");
    }
}
 
Example #27
Source File: StreamPanel.java    From moa with GNU General Public License v3.0 5 votes vote down vote up
public void applyDrawDecay(float factor){

        RescaleOp brightenOp = new RescaleOp(1f, 150f/factor, null);
        pointCanvas = brightenOp.filter(pointCanvas, null);

        layerPointCanvas.setImage(pointCanvas);
        layerPointCanvas.repaint();
    }
 
Example #28
Source File: BufferedBufImgOps.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public static void disableBufImgOp(RenderQueue rq, BufferedImageOp biop) {
    if (biop instanceof ConvolveOp) {
        disableConvolveOp(rq);
    } else if (biop instanceof RescaleOp) {
        disableRescaleOp(rq);
    } else if (biop instanceof LookupOp) {
        disableLookupOp(rq);
    } else {
        throw new InternalError("Unknown BufferedImageOp");
    }
}
 
Example #29
Source File: BufferedBufImgOps.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public static void enableBufImgOp(RenderQueue rq, SurfaceData srcData,
                                  BufferedImage srcImg,
                                  BufferedImageOp biop)
{
    if (biop instanceof ConvolveOp) {
        enableConvolveOp(rq, srcData, (ConvolveOp)biop);
    } else if (biop instanceof RescaleOp) {
        enableRescaleOp(rq, srcData, srcImg, (RescaleOp)biop);
    } else if (biop instanceof LookupOp) {
        enableLookupOp(rq, srcData, srcImg, (LookupOp)biop);
    } else {
        throw new InternalError("Unknown BufferedImageOp");
    }
}
 
Example #30
Source File: TileViewer.java    From freecol with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Centers the given Image on the tile.
 *
 * @param g a {@code Graphics2D}
 * @param image the BufferedImage
 * @param rop An optional RescaleOp for fog of war.
 */
public void displayCenteredImage(Graphics2D g, BufferedImage image,
        RescaleOp rop) {
    g.drawImage(
        image,
        rop,
        (tileWidth - image.getWidth())/2,
        (tileHeight - image.getHeight())/2);
}