本文整理汇总了Java中org.eclipse.swt.graphics.ImageData.getPixel方法的典型用法代码示例。如果您正苦于以下问题:Java ImageData.getPixel方法的具体用法?Java ImageData.getPixel怎么用?Java ImageData.getPixel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.swt.graphics.ImageData
的用法示例。
在下文中一共展示了ImageData.getPixel方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: encontraPixel
import org.eclipse.swt.graphics.ImageData; //导入方法依赖的package包/类
private RGB encontraPixel(int x, int y, int indice) {
labelPosicaoCor.setText(x + "," + y);
ImageData imageData = null;
PaletteData paletteData = null;
if (indice == 1 && imagem1 != null) {
imageData = imagem1.getImageData();
paletteData = imageData.palette;
} else if (indice == 2 && imagem2 != null) {
imageData = imagem2.getImageData();
paletteData = imageData.palette;
} else if (indice == 3 && imagem3 != null) {
imageData = imagem3.getImageData();
paletteData = imageData.palette;
}
if (paletteData != null && x > -1 && y > -1) {
int pixel = imageData.getPixel(x, y);
RGB rgb = paletteData.getRGB(pixel);
return rgb;
}
return null;
}
示例2: assertImageDataIs
import org.eclipse.swt.graphics.ImageData; //导入方法依赖的package包/类
public static void assertImageDataIs(ImageData expectedImageData,
ImageData actualImageData) {
if (expectedImageData.width != actualImageData.width
|| expectedImageData.height != actualImageData.height) {
fail(MessageFormat
.format(
"Image data do not have the same dimensions ({0}x{1} expected, got {2}x{3})",
expectedImageData.width, expectedImageData.height,
actualImageData.width, actualImageData.height));
}
for (int y = 0; y < expectedImageData.height; y++) {
for (int x = 0; x < expectedImageData.width; x++) {
int actualPixel = actualImageData.getPixel(x, y);
int expectedPixel = expectedImageData.getPixel(x, y);
RGB actualRGB = actualImageData.palette.getRGB(actualPixel);
RGB expectedRGB = expectedImageData.palette
.getRGB(expectedPixel);
if (!actualRGB.equals(expectedRGB)) {
fail(MessageFormat.format(
"Image data do not match at ({0},{1})", x, y));
}
}
}
}
示例3: convert
import org.eclipse.swt.graphics.ImageData; //导入方法依赖的package包/类
private IHostImage convert(int idx, IHostImage previous, ImageData imageData) {
if(shotStarts != null) {
int clip = (idx - 1) / 2;
if(clip >= 0 && clip < nClips) {
if(((idx - 1) & 1) == 0)
shotStarts[clip] = imageData.delayTime;
else
duration += imageData.delayTime;
}
} else
duration += imageData.delayTime / 1000.0;
IHostImage result = previous == null ? IHostImage.create(width, height, ComponentType.BYTE, ComponentFormat.RGB) : previous.copy();
for(int y = imageData.height; --y >= 0;)
for(int x = imageData.width; --x >= 0;) {
int pixel = imageData.getPixel(x, y);
if(pixel == imageData.transparentPixel) continue;
RGB srcrgb = imageData.palette.getRGB(pixel);
rgb[0] = (byte) srcrgb.red;
rgb[1] = (byte) srcrgb.green;
rgb[2] = (byte) srcrgb.blue;
result.setPixel(x+imageData.x, height-(y+imageData.y+1), rgb);
}
return result;
}
示例4: multScalar
import org.eclipse.swt.graphics.ImageData; //导入方法依赖的package包/类
/**
* Multiplies all pixels of the given ImageData with the given scalar factor
* and returns a new image data
*/
public static ImageData multScalar(ImageData data, double factor, boolean inPlace) {
ImageData newImageData = inPlace ? data :
new ImageData (data.width, data.height, 24, new PaletteData (0xFF, 0xFF00, 0xFF0000));
final int w = data.width;
final int h = data.height;
for (int x=0; x<w; ++x) {
for (int y=0; y<h; ++y) {
int p = data.getPixel(x, y);
RGB rgb = data.palette.getRGB(p);
// System.out.println("rgb = "+rgb);
rgb.red = CoreUtils.bound(rgb.red *= factor, 0, 255);
rgb.green = CoreUtils.bound(rgb.green *= factor, 0, 255);
rgb.blue = CoreUtils.bound(rgb.blue *= factor, 0, 255);
// rgb.red = CoreUtils.bound((int) Math.pow(rgb.red, gamma), 0, 255);
// rgb.green = CoreUtils.bound((int) Math.pow(rgb.green, gamma), 0, 255);
// rgb.blue = CoreUtils.bound((int) Math.pow(rgb.blue, gamma), 0, 255);
// System.out.println("rgb2 = "+rgb);
newImageData.setPixel(x, y, newImageData.palette.getPixel(rgb));
}
}
return newImageData;
}