本文整理汇总了Java中java.awt.image.RescaleOp.filter方法的典型用法代码示例。如果您正苦于以下问题:Java RescaleOp.filter方法的具体用法?Java RescaleOp.filter怎么用?Java RescaleOp.filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.image.RescaleOp
的用法示例。
在下文中一共展示了RescaleOp.filter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: 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;
}
}
示例4: 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);
}
示例5: 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;
}
示例6: 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;
}
示例7: 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());
}
}
}
}
示例8: 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());
}
}
}
}
示例9: 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());
}
}
}
}
示例10: applyDrawDecay
import java.awt.image.RescaleOp; //导入方法依赖的package包/类
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();
}
}
示例11: snapshot
import java.awt.image.RescaleOp; //导入方法依赖的package包/类
/**
* Takes a snapshot of the screen, fades it, and sets it as the background.
*/
public static void snapshot()
{
Dimension dim = getInstance().component.getPreferredSize();
java.awt.Rectangle rect = new java.awt.Rectangle(0, 0, dim.width, dim.height);
BufferedImage image = new BufferedImage(rect.width, rect.height, BufferedImage.TYPE_INT_RGB);
Graphics g = image.getGraphics();
g.setColor(java.awt.Color.WHITE);
g.fillRect(0, 0, rect.width, rect.height);
g.setColor(java.awt.Color.BLACK);
getInstance().component.paintComponent(g);
float factor = 0.8f;
float base = 255f * (1f - factor);
RescaleOp op = new RescaleOp(factor, base, null);
BufferedImage filteredImage
= new BufferedImage(image.getWidth(), image.getHeight(), image.getType());
op.filter(image, filteredImage);
getInstance().background = filteredImage;
getInstance().component.repaint();
}
示例12: enhanceRGB
import java.awt.image.RescaleOp; //导入方法依赖的package包/类
public void enhanceRGB(float[] rgbm, float[] rgba) throws ImageOpException {
logger.debug("enhanceRGB: rgbm=" + rgbm + " rgba=" + rgba);
/*
* The number of constants must match the number of bands in the image.
* We do only 3 (RGB) bands.
*/
int ncol = img.getColorModel().getNumColorComponents();
if ((ncol != 3) || (rgbm.length != 3) || (rgba.length != 3)) {
logger.error("enhanceRGB: unknown number of color bands or coefficients (" + ncol + ")");
return;
}
if (img.getColorModel().hasAlpha()) {
// add constant for alpha
rgbm = new float[] { rgbm[0], rgbm[1], rgbm[2], 1 };
rgba = new float[] { rgba[0], rgba[1], rgba[2], 0 };
}
RescaleOp scaleOp = new RescaleOp(rgbm, rgba, renderHint);
scaleOp.filter(img, img);
}
示例13: getExSubscriberIcon
import java.awt.image.RescaleOp; //导入方法依赖的package包/类
public static URL getExSubscriberIcon(String channel) {
try {
if (exSubscriberIcon == null) {
URL subIconNormal = FaceManager.getSubIcon(channel);
if (subIconNormal != null) {
BufferedImage img = ImageIO.read(subIconNormal);
//rescaleop does not work with sub icons as is, we need to recreate them as ARGB images
BufferedImage bimage = new BufferedImage(img.getWidth(), img.getHeight(), BufferedImage.TYPE_INT_ARGB);
Graphics2D g = bimage.createGraphics();
g.drawImage(img, 0, 0, null);
g.dispose();
RescaleOp op = new RescaleOp(.35f, 0f, null);
img = op.filter(bimage, bimage);//then re-assign them
exSubscriberIcon = new File(Settings.subIconsDir + File.separator + channel + "_ex.png");
ImageIO.write(img, "PNG", exSubscriberIcon);
exSubscriberIcon.deleteOnExit();
}
}
return exSubscriberIcon.toURI().toURL();
} catch (Exception e) {
GUIMain.log(e);
}
return null;
}
示例14: createOverview
import java.awt.image.RescaleOp; //导入方法依赖的package包/类
private static URL createOverview(GeoImageReader gir, boolean toFlip) throws IOException {
File f = File.createTempFile("kmloverview", ".png");
// generate a suitable size image
double ratio = Math.max(((double) gir.getWidth()) / 1024., ((double) gir.getHeight()) / 1024.);
// generate overview image
BufferedImage temp = new BufferedImage((int) (gir.getWidth() * (1.0 / ratio)), (int) (gir.getHeight() * (1.0 / ratio)), gir.getType(true));
// get a handle on the raster data
WritableRaster raster = temp.getRaster();
int[] data = gir.readAndDecimateTile(0, 0, gir.getWidth(), gir.getHeight(), 1.0 / ratio, true,0);
raster.setSamples(0, 0, temp.getWidth(), temp.getHeight(), 0, data);
float average = 0;
for (int i = 0; i < data.length; i++) {
average = average + data[i];
}
average = average / data.length;
RescaleOp rescale = new RescaleOp(((1 << (8 * gir.getNumberOfBytes())) / 5f / average), 0, null);
rescale.filter(temp, temp);
ColorConvertOp bop = new ColorConvertOp(null);
BufferedImage out = bop.createCompatibleDestImage(temp, new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_GRAY), false, false, ComponentColorModel.OPAQUE, DataBuffer.TYPE_BYTE));
out = bop.filter(temp, out);
//flip the image if necessary
if (toFlip) {
int w = out.getWidth();
int h = out.getHeight();
BufferedImage dimg = new BufferedImage(w, h, out.getType());
Graphics2D g = dimg.createGraphics();
g.drawImage(out, 0, 0, w, h, w, 0, 0, h, null);
g.dispose();
ImageIO.write(dimg, "png", f);
} else {
ImageIO.write(out, "png", f);
}
return f.toURI().toURL();
}
示例15: paint
import java.awt.image.RescaleOp; //导入方法依赖的package包/类
@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);
}