本文整理汇总了Java中java.awt.image.WritableRaster.getPixel方法的典型用法代码示例。如果您正苦于以下问题:Java WritableRaster.getPixel方法的具体用法?Java WritableRaster.getPixel怎么用?Java WritableRaster.getPixel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.image.WritableRaster
的用法示例。
在下文中一共展示了WritableRaster.getPixel方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processaAlgoritmo
import java.awt.image.WritableRaster; //导入方法依赖的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: girar
import java.awt.image.WritableRaster; //导入方法依赖的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;
}
示例3: girar
import java.awt.image.WritableRaster; //导入方法依赖的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;
}
示例4: toColorCubeMatrix
import java.awt.image.WritableRaster; //导入方法依赖的package包/类
/**
* Converts the given image into a three-dimension matrix of color cubes.
*
* The first dimension is the pixel's y-coordinate
* The second dimension is the pixel's x-coordinate
* the third dimension is the pixel's four-value color cube, where:
*
* The first item is the pixel's red channel color value represented as 0..1
* The second item is the pixel's green channel color value represented as 0..1
* The third item is the pixel's blue channel color value represented as 0..1
* The fourth item is the pixel's alpha channel represented as 0..255
*
* @param image The image to convert into a color cube matrix
* @return A three dimensional array representing the ARGB value of each pixel in the source image.
*/
private static double[][][] toColorCubeMatrix(BufferedImage image) {
// Source needs to be ARGB type; make a copy to assure constraint is met
image = Transform.argbCopy(image);
double[][][] matrix = new double[image.getHeight()][image.getWidth()][4];
WritableRaster raster = image.getRaster();
for (int y = 0; y < image.getHeight(); y++) {
for (int x = 0; x < image.getWidth(); x++) {
double[] pixel = raster.getPixel(x, y, (double[]) null);
matrix[y][x][0] = pixel[0] / 255.0;
matrix[y][x][1] = pixel[1] / 255.0;
matrix[y][x][2] = pixel[2] / 255.0;
matrix[y][x][3] = pixel[3];
}
}
return matrix;
}
示例5: getSplitPoint
import java.awt.image.WritableRaster; //导入方法依赖的package包/类
private static int getSplitPoint(WritableRaster raster, String name, int startX, int startY, boolean startPoint, boolean xAxis) {
int[] rgba = new int[4];
int next = xAxis ? startX : startY;
int end = xAxis ? raster.getWidth() : raster.getHeight();
int breakA = startPoint ? 255 : 0;
int x = startX;
int y = startY;
while (next != end) {
if (xAxis) {
x = next;
} else {
y = next;
}
raster.getPixel(x, y, rgba);
if (rgba[3] == breakA) return next;
if (!startPoint && (rgba[0] != 0 || rgba[1] != 0 || rgba[2] != 0 || rgba[3] != 255))
splitError(x, y, rgba, name);
next++;
}
return 0;
}
示例6: getSplitPoint
import java.awt.image.WritableRaster; //导入方法依赖的package包/类
/** Hunts for the start or end of a sequence of split pixels. Begins searching at (startX, startY) then follows along the x or y
* axis (depending on value of xAxis) for the first non-transparent pixel if startPoint is true, or the first transparent pixel
* if startPoint is false. Returns 0 if none found, as 0 is considered an invalid split point being in the outer border which
* will be stripped. */
static private int getSplitPoint (WritableRaster raster, String name, int startX, int startY, boolean startPoint, boolean xAxis) {
int[] rgba = new int[4];
int next = xAxis ? startX : startY;
int end = xAxis ? raster.getWidth() : raster.getHeight();
int breakA = startPoint ? 255 : 0;
int x = startX;
int y = startY;
while (next != end) {
if (xAxis)
x = next;
else
y = next;
raster.getPixel(x, y, rgba);
if (rgba[3] == breakA) return next;
if (!startPoint && (rgba[0] != 0 || rgba[1] != 0 || rgba[2] != 0 || rgba[3] != 255)) {
// error
}
next++;
}
return 0;
}
示例7: getPixelValue
import java.awt.image.WritableRaster; //导入方法依赖的package包/类
private static int[] getPixelValue(WritableRaster raster, int xx, int yy) {
return raster.getPixel(xx, yy, (int[]) null);
}
示例8: getPixel
import java.awt.image.WritableRaster; //导入方法依赖的package包/类
public static Integer getPixel(BufferedImage img, int i, int j, int tipoPixel) {
WritableRaster raster = img.getRaster();
int pixels[] = new int[4];
return raster.getPixel(i, j, pixels)[tipoPixel];
}