类java.awt.image.RescaleOp源码实例Demo

下面列出了怎么用java.awt.image.RescaleOp的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: moa   文件: StreamOutlierPanel.java
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();
    }
}
 
源代码2 项目: freecol   文件: ImageLibrary.java
/**
 * 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;
}
 
源代码3 项目: WorldPainter   文件: OffsetViewer.java
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);
    }
}
 
源代码4 项目: openjdk-jdk9   文件: ImageRescaleOpTest.java
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);
   }
 
源代码5 项目: orbit-image-analysis   文件: JSliderOrbit.java
@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);
}
 
源代码6 项目: stendhal   文件: ItemPanel.java
/**
 * 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);
}
 
源代码7 项目: dragonwell8_jdk   文件: BufferedBufImgOps.java
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");
    }
}
 
源代码8 项目: dragonwell8_jdk   文件: BufferedBufImgOps.java
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");
    }
}
 
源代码9 项目: dragonwell8_jdk   文件: BufferedBufImgOps.java
/**************************** 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;
    }
 
源代码10 项目: jdk8u-jdk   文件: BufferedBufImgOps.java
/**************************** 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;
    }
 
源代码11 项目: TencentKona-8   文件: BufferedBufImgOps.java
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");
    }
}
 
源代码12 项目: TencentKona-8   文件: BufferedBufImgOps.java
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");
    }
}
 
源代码13 项目: TencentKona-8   文件: BufferedBufImgOps.java
/**************************** 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;
    }
 
源代码14 项目: java-swing-tips   文件: MainPanel.java
private static ImageIcon makeRolloverIcon(ImageIcon srcIcon) {
  int w = srcIcon.getIconWidth();
  int h = srcIcon.getIconHeight();
  BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
  Graphics2D g2 = img.createGraphics();
  srcIcon.paintIcon(null, g2, 0, 0);
  float[] scaleFactors = {.5f, .5f, .5f, 1f};
  float[] offsets = {0f, 0f, 0f, 0f};
  RescaleOp op = new RescaleOp(scaleFactors, offsets, g2.getRenderingHints());
  g2.dispose();
  return new ImageIcon(op.filter(img, null));
}
 
源代码15 项目: jdk8u60   文件: BufferedBufImgOps.java
/**************************** 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;
    }
 
源代码16 项目: openjdk-jdk8u   文件: BufferedBufImgOps.java
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");
    }
}
 
源代码17 项目: openjdk-jdk8u   文件: BufferedBufImgOps.java
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");
    }
}
 
源代码18 项目: openjdk-jdk8u   文件: BufferedBufImgOps.java
/**************************** 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;
    }
 
源代码19 项目: xyTalk-pc   文件: ScreenShot.java
@Override
public void paint(Graphics g)
{
    RescaleOp ro = new RescaleOp(0.6f, 0, null);
    tempImage = ro.filter(image, null);
    g.drawImage(tempImage, 0, 0, this);

    if (!isShown)
    {
        setOpacity(1);
        isShown = true;
    }
}
 
源代码20 项目: lams   文件: BitmapImageRenderer.java
@Override
public void setAlpha(double alpha) {
    if (img == null) return;

    Dimension dim = getDimension();
    BufferedImage newImg = new BufferedImage((int)dim.getWidth(), (int)dim.getHeight(), BufferedImage.TYPE_INT_ARGB);
    Graphics2D g = newImg.createGraphics();
    RescaleOp op = new RescaleOp(new float[]{1.0f, 1.0f, 1.0f, (float)alpha}, new float[]{0,0,0,0}, null);
    g.drawImage(img, op, 0, 0);
    g.dispose();

    img = newImg;
}
 
源代码21 项目: myqq   文件: ScreenFram.java
@Override
public void paint(Graphics g)
{
	RescaleOp ro = new RescaleOp(0.8f, 0, null);
	tempImage = ro.filter(image, null);
	g.drawImage(tempImage, 0, 0, this);
}
 
源代码22 项目: openjdk-jdk8u-backup   文件: BufferedBufImgOps.java
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");
    }
}
 
源代码23 项目: openjdk-jdk8u-backup   文件: BufferedBufImgOps.java
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");
    }
}
 
源代码24 项目: freecol   文件: TileViewer.java
/**
 * 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);
}
 
源代码25 项目: Bytecoder   文件: BufferedBufImgOps.java
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");
    }
}
 
源代码26 项目: Bytecoder   文件: BufferedBufImgOps.java
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");
    }
}
 
源代码27 项目: moa   文件: StreamPanel.java
public void applyDrawDecay(float factor){

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

        layerPointCanvas.setImage(pointCanvas);
        layerPointCanvas.repaint();
    }
 
源代码28 项目: openjdk-jdk9   文件: BufferedBufImgOps.java
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");
    }
}
 
源代码29 项目: openjdk-jdk9   文件: BufferedBufImgOps.java
/**************************** 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;
    }
 
源代码30 项目: jdk8u-jdk   文件: BufferedBufImgOps.java
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");
    }
}
 
 类所在包
 同包方法