本文整理汇总了Java中java.awt.image.BufferedImage.setData方法的典型用法代码示例。如果您正苦于以下问题:Java BufferedImage.setData方法的具体用法?Java BufferedImage.setData怎么用?Java BufferedImage.setData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.image.BufferedImage
的用法示例。
在下文中一共展示了BufferedImage.setData方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processaAlgoritmo
import java.awt.image.BufferedImage; //导入方法依赖的package包/类
public BufferedImage processaAlgoritmo(BufferedImage img, PosicoesDTO posicoes) {
WritableRaster raster = img.getRaster();
BufferedImage newImage = new BufferedImage(img.getWidth(), img.getHeight(), BufferedImage.TYPE_INT_RGB);
int pixels[] = new int[4];
for (int i = posicoes.getX1(); i < posicoes.getY1() - 1; i++) {
for (int j = posicoes.getX2(); j < posicoes.getY2() - 1; j++) {
raster.getPixel(i, j, pixels);
int[] novosPixels = calculaPixeis(img, i, j);
pixels[0] = novosPixels[0];
pixels[1] = novosPixels[1];
pixels[2] = novosPixels[2];
raster.setPixel(i, j, pixels);
}
}
newImage.setData(raster);
return newImage;
}
示例2: toImage
import java.awt.image.BufferedImage; //导入方法依赖的package包/类
/**
* Convert {@link AbstractImage} to {@link Image}.
*
* @param in
* the input image
* @return the converted image
*/
public static Image toImage(AbstractImage in) {
if (in == null) {
return null;
}
BufferedImage res = new BufferedImage(in.width, in.height, BufferedImage.TYPE_INT_ARGB);
int[] pixels = new int[in.pixels.length];
for (int i = 0; i < pixels.length; i += 1) {
pixels[i] = in.pixels[i] & 0xFF;
}
WritableRaster raster = Raster.createWritableRaster(res.getSampleModel(), null);
raster.setPixels(0, 0, in.width, in.height, pixels);
res.setData(raster);
res.flush();
return res;
}
示例3: girar
import java.awt.image.BufferedImage; //导入方法依赖的package包/类
public BufferedImage girar(BufferedImage img, PosicoesDTO posicoes) {
WritableRaster raster = img.getRaster();
BufferedImage newImage = new BufferedImage(img.getWidth(), img.getHeight(), BufferedImage.TYPE_INT_RGB);
WritableRaster rasterNewImage = newImage.getRaster();
int pixels[] = new int[4];
for (int i = posicoes.getX1(); i < posicoes.getX2(); i++) {
for (int j = posicoes.getY1(); j < posicoes.getY2(); j++) {
raster.getPixel(i, j, pixels);
rasterNewImage.setPixel(i, img.getHeight() - j, pixels);
}
}
newImage.setData(rasterNewImage);
return newImage;
}
示例4: girar
import java.awt.image.BufferedImage; //导入方法依赖的package包/类
public BufferedImage girar(BufferedImage img, PosicoesDTO posicoes) {
WritableRaster raster = img.getRaster();
BufferedImage newImage = new BufferedImage(img.getWidth(), img.getHeight(), BufferedImage.TYPE_INT_RGB);
WritableRaster rasterNewImage = newImage.getRaster();
int pixels[] = new int[4];
for (int i = 1; i < img.getWidth() - 1; i++) {
for (int j = 1; j < img.getHeight() - 1; j++) {
raster.getPixel(i, j, pixels);
rasterNewImage.setPixel(i, j, pixels);
}
}
for (int i = posicoes.getX1(); i < posicoes.getX2(); i++) {
int pixeisInvertidos = 0;
for (int j = posicoes.getY1(); j < posicoes.getY2(); j++) {
raster.getPixel(i, j, pixels);
rasterNewImage.setPixel(i, posicoes.getY2() - pixeisInvertidos, pixels);
pixeisInvertidos++;
}
}
newImage.setData(rasterNewImage);
return newImage;
}
示例5: getNewImageInstance
import java.awt.image.BufferedImage; //导入方法依赖的package包/类
/**
* Return a new instance of the BufferedImage
* @return BufferedImage
*/
public BufferedImage getNewImageInstance(){
BufferedImage buf = new BufferedImage(image.getWidth(),image.getHeight(), image.getType());
buf.setData(image.getData());
return buf;
}