当前位置: 首页>>代码示例>>Java>>正文


Java RescaleOp类代码示例

本文整理汇总了Java中java.awt.image.RescaleOp的典型用法代码示例。如果您正苦于以下问题:Java RescaleOp类的具体用法?Java RescaleOp怎么用?Java RescaleOp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RescaleOp类属于java.awt.image包,在下文中一共展示了RescaleOp类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fadeImage

import java.awt.image.RescaleOp; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:26,代码来源:ImageLibrary.java

示例2: runTest

import java.awt.image.RescaleOp; //导入依赖的package包/类
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);
   }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:ImageRescaleOpTest.java

示例3: getIcon

import java.awt.image.RescaleOp; //导入依赖的package包/类
@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);
}
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:22,代码来源:JSliderOrbit.java

示例4: toSVG

import java.awt.image.RescaleOp; //导入依赖的package包/类
/**
 * @param op BufferedImageOp to be converted to SVG
 * @param filterRect Rectangle, in device space, that defines the area
 *        to which filtering applies. May be null, meaning that the
 *        area is undefined.
 * @return an SVGFilterDescriptor representing the SVG filter
 *         equivalent of the input BufferedImageOp
 */
public SVGFilterDescriptor toSVG(BufferedImageOp op,
                                 Rectangle filterRect){
    SVGFilterDescriptor filterDesc =
        svgCustomBufferedImageOp.toSVG(op, filterRect);

    if(filterDesc == null){
        if(op instanceof LookupOp)
            filterDesc = svgLookupOp.toSVG(op, filterRect);
        else if(op instanceof RescaleOp)
            filterDesc = svgRescaleOp.toSVG(op, filterRect);
        else if(op instanceof ConvolveOp)
            filterDesc = svgConvolveOp.toSVG(op, filterRect);
    }

    return filterDesc;
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:25,代码来源:SVGBufferedImageOp.java

示例5: paintImage

import java.awt.image.RescaleOp; //导入依赖的package包/类
protected void paintImage(Graphics2D graphics, Image image, Rectangle bounds, Color tint) {
	if (tint == null || tint.equals(Color.white)) {
		paintImage(graphics, image, bounds);
	}
	else {
		BufferedImage graphicsBuffer = new BufferedImage(Math.abs(bounds.width), Math.abs(bounds.height), BufferedImage.TYPE_INT_ARGB);
		
		paintImage(graphicsBuffer.createGraphics(), image, new Rectangle(0, 0, bounds.width, bounds.height));
		
		float[] scaleFactors = new float[4];
		float[] offsets = new float[4];
		
		scaleFactors[0] = tint.getRed() / 255f;
		scaleFactors[1] = tint.getGreen() / 255f;
		scaleFactors[2] = tint.getBlue() / 255f;
		scaleFactors[3] = tint.getAlpha() / 255f;
		
		// we must use another image, otherwise the tint isn't applied correctly (check the Sporepedia button transparency in the editor)
		BufferedImage img = new BufferedImage(Math.abs(bounds.width), Math.abs(bounds.height), BufferedImage.TYPE_INT_ARGB);
		img.createGraphics().drawImage(graphicsBuffer, new RescaleOp(scaleFactors, offsets, null), 0, 0);
		
		graphics.drawImage(img, bounds.x, bounds.y, null);
	}
}
 
开发者ID:Emd4600,项目名称:SporeModder,代码行数:25,代码来源:StdDrawable.java

示例6: drawTintedImage

import java.awt.image.RescaleOp; //导入依赖的package包/类
public static BufferedImage drawTintedImage(BufferedImage image, Dimension dim, int[] uvCoordinates, Color tint) {
	BufferedImage temp = new BufferedImage(dim.width, dim.height, BufferedImage.TYPE_INT_ARGB);
	
	Graphics2D g = temp.createGraphics();
	
	Image.drawImage(g, image, 
			0, 0, dim.width, dim.height, 
			uvCoordinates[0], uvCoordinates[1], uvCoordinates[2], uvCoordinates[3]);
	
	float[] scaleFactors = new float[4];
	float[] offsets = new float[4];
	
	scaleFactors[0] = tint.getRed() / 255f;
	scaleFactors[1] = tint.getGreen() / 255f;
	scaleFactors[2] = tint.getBlue() / 255f;
	scaleFactors[3] = tint.getAlpha() / 255f;
	
	BufferedImage img = new BufferedImage(dim.width, dim.height, BufferedImage.TYPE_INT_ARGB);
	
	img.createGraphics().drawImage(temp, new RescaleOp(scaleFactors, offsets, null), 0, 0);
	
	return img;
}
 
开发者ID:Emd4600,项目名称:SporeModder,代码行数:24,代码来源:Image.java

示例7: sBrillo_stateChanged

import java.awt.image.RescaleOp; //导入依赖的package包/类
/**
 *
 * @param e Evento
 */
public void sBrillo_stateChanged(ChangeEvent e) {
    //Comprobamos que se ha cargado una imagen
    if (this.imagenAbierta) {
        RescaleOp rop = new RescaleOp(1.0f,
                (float) this.sBrillo.getValue(), null);
        BufferedImage aux = new BufferedImage(this.imagenSinModificar.getWidth(),
                this.imagenSinModificar.getHeight(),
                this.imagenSinModificar.getType());

        //Aplicamos el filtro de brillo a la imagen transformada por los filtros
        rop.filter(this.imagenTransformada, aux);

        //Establecemos la nueva imagen a mostrar
        this.PanelTapiz.setImagen(aux);

        //Ponemos que se ha modificado la imagen
        this.modificado = true;
    }
}
 
开发者ID:sephierot,项目名称:paintmultimedia,代码行数:24,代码来源:EditorImagen.java

示例8: preparePlaceholder

import java.awt.image.RescaleOp; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:arianne,项目名称:stendhal,代码行数:32,代码来源:ItemPanel.java

示例9: drawMovingPlayer

import java.awt.image.RescaleOp; //导入依赖的package包/类
public void drawMovingPlayer(Graphics2D g) {
    if(getGameCanvas().getMovingPlayer() != null) {
        AffineTransform transform = new AffineTransform();
        double  tx = getGameCanvas().getStoredMousePosition()[0] / getT(),
                ty = getGameCanvas().getStoredMousePosition()[1] / getT();

        BufferedImage sprite;
        if(isLeft()) sprite = getGameCanvas().getMovingPlayer().getSpriteR();
        else sprite = getGameCanvas().getMovingPlayer().getSpriteL();
        if(sprite == null) sprite = new BufferedImage(100, 200, BufferedImage.TYPE_INT_ARGB);

        transform.scale(getT(), getT());
        transform.translate(tx, ty);
        double rotation = -(getGameCanvas().getGameFrame().getOldMousePositions().get(0)[0]-getGameCanvas().getGameFrame().getOldMousePositions().get(1)[0]) / getPW();
        if(rotation > GameFrame.MAX_DRAG_ROTATION) rotation = GameFrame.MAX_DRAG_ROTATION;
        else if(rotation < -GameFrame.MAX_DRAG_ROTATION) rotation = -GameFrame.MAX_DRAG_ROTATION;
        transform.rotate(rotation);
        g.transform(transform);

        g.drawImage(sprite, new RescaleOp(new float[]{0.8f, 0.8f, 0.8f, 0.6f}, new float[4], null), -ResourceManager.IMAGE_WIDTH / 2, 0);

        try { g.transform(transform.createInverse()); }
        catch (NoninvertibleTransformException ignored) {}
    }
}
 
开发者ID:milanvanzanten,项目名称:SafariBowl,代码行数:26,代码来源:GameRenderer.java

示例10: filterImage

import java.awt.image.RescaleOp; //导入依赖的package包/类
private BufferedImage filterImage(BufferedImage original, int hash, RescaleOp op) {
    HashMap<Integer, BufferedImage> imageMap = imageFilterBuffer.get(hash);
    float[] scaleFactors = op.getScaleFactors(null);
    int opHash = (int) (10*scaleFactors[0]+100*scaleFactors[1]+1000*scaleFactors[2]+10000*scaleFactors[3]);
    if(imageMap != null) {
        if(imageMap.size() > MAX_IMAGE_BUFFER_SIZE) emptyImageBuffer(); // empty image buffer of this image if it is too full.
        else if(imageMap.containsKey(opHash)) return imageMap.get(opHash); // return the buffered resized image if it was resized before.
    }

    BufferedImage filtered = gameCanvas.getGraphicsConfiguration().createCompatibleImage(original.getWidth(), original.getHeight(), Transparency.BITMASK);

    Graphics2D filteredG = filtered.createGraphics();
    filteredG.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
    filteredG.drawImage(original, op, 0, 0);
    filteredG.dispose();

    if(imageMap != null) imageMap.put(opHash, filtered);
    else {
        imageMap = new HashMap<Integer, BufferedImage>();
        imageMap.put(opHash, filtered);
        imageFilterBuffer.put(hash, imageMap);
    }

    return filtered;
}
 
开发者ID:milanvanzanten,项目名称:SafariBowl,代码行数:26,代码来源:GameRenderer.java

示例11: getStyledImage

import java.awt.image.RescaleOp; //导入依赖的package包/类
public static BufferedImage getStyledImage(File img, float brightness, float transparency, int size) {
    BufferedImage outputImage = null;
    try {
        BufferedImage readBufferedImage = ImageIO.read(img);
        BufferedImage inputBufferedImage = convertToArgb(readBufferedImage);
        outputImage = inputBufferedImage;
        if (size > 0) {
            outputImage = Scalr.resize(inputBufferedImage
                    , Method.BALANCED
                    , size
                    , size);
        }

        float brightnessFactor = 1.0f + brightness/100.0f;
        float transparencyFactor = Math.abs(transparency/100.0f - 1.0f);
        RescaleOp rescale = new RescaleOp(
                new float[]{brightnessFactor, brightnessFactor, brightnessFactor, transparencyFactor},
                new float[]{0f, 0f, 0f, 0f}, null);
        rescale.filter(outputImage, outputImage);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return outputImage;
}
 
开发者ID:shaolinwu,项目名称:uimaster,代码行数:25,代码来源:ImageUtil.java

示例12: getStyledImage

import java.awt.image.RescaleOp; //导入依赖的package包/类
private BufferedImage getStyledImage(float brightness, float transparency, int size) {
    BufferedImage outputImage = null;
    try {
        BufferedImage readBufferedImage = ImageIO.read(new File(imageFilePath));
        BufferedImage inputBufferedImage = convertToArgb(readBufferedImage);
        outputImage = inputBufferedImage;
        if (size > 0) {
            outputImage = Scalr.resize(inputBufferedImage
                    , Method.BALANCED
                    , size
                    , size);
        }

        float brightnessFactor = 1.0f + brightness/100.0f;
        float transparencyFactor = Math.abs(transparency/100.0f - 1.0f);
        RescaleOp rescale = new RescaleOp(
                new float[]{brightnessFactor, brightnessFactor, brightnessFactor, transparencyFactor},
                new float[]{0f, 0f, 0f, 0f}, null);
        rescale.filter(outputImage, outputImage);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return outputImage;
}
 
开发者ID:atominvention,项目名称:AndroidDevToolbox,代码行数:25,代码来源:StatefulButtonController.java

示例13: menuRescaleOpActionPerformed

import java.awt.image.RescaleOp; //导入依赖的package包/类
private void menuRescaleOpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuRescaleOpActionPerformed
    VentanaInterna vi = (VentanaInterna) (escritorio.getSelectedFrame());
    if (vi != null) {
        BufferedImage imgSource = vi.getLienzo().getImageOriginal();
        if (imgSource != null) {
            try {
                RescaleOp rop = new RescaleOp(1.0F, 100.0F, null);
                BufferedImage imgdest = rop.filter(convertImageType(imgSource, BufferedImage.TYPE_INT_RGB), null);
                vi.getLienzo().setImageOriginal(imgdest);
                vi.getLienzo().repaint();
            } catch (IllegalArgumentException e) {
                System.err.println(e.getLocalizedMessage());
            }
        }
    }
}
 
开发者ID:oskyar,项目名称:Sistemas-Multimedia,代码行数:17,代码来源:VentanaPrincipal.java

示例14: menuRescaleOpActionPerformed

import java.awt.image.RescaleOp; //导入依赖的package包/类
private void menuRescaleOpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuRescaleOpActionPerformed
    VentanaInternaImagen vi = (VentanaInternaImagen) selectInternalWindows();
    if (vi != null) {
        BufferedImage imgSource = vi.getLienzo().getImageOriginal();
        if (imgSource != null) {
            try {
                RescaleOp rop = new RescaleOp(1.0F, 100.0F, null);
                BufferedImage imgdest = rop.filter(convertImageType(imgSource, BufferedImage.TYPE_INT_RGB), null);
                vi.getLienzo().setImageOriginal(imgdest);
                vi.getLienzo().repaint();
            } catch (IllegalArgumentException e) {
                System.err.println(e.getLocalizedMessage());
            }
        }
    }
}
 
开发者ID:oskyar,项目名称:Sistemas-Multimedia,代码行数:17,代码来源:VentanaPrincipal.java

示例15: menuRescaleOpActionPerformed

import java.awt.image.RescaleOp; //导入依赖的package包/类
private void menuRescaleOpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuRescaleOpActionPerformed
    VentanaInterna vi = (VentanaInterna) (escritorio.getSelectedFrame());
    if (vi != null) {
        BufferedImage imgSource = vi.getLienzo().getImageOriginal();
        if (imgSource != null) {
            try {
                RescaleOp rop = new RescaleOp(1.0F, 100.0F, null);
                BufferedImage imgdest = rop.filter(imgSource, null);
                vi.getLienzo().setImageOriginal(imgdest);
                vi.getLienzo().repaint();
            } catch (IllegalArgumentException e) {
                System.err.println(e.getLocalizedMessage());
            }
        }
    }
}
 
开发者ID:oskyar,项目名称:Sistemas-Multimedia,代码行数:17,代码来源:VentanaPrincipal.java


注:本文中的java.awt.image.RescaleOp类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。