本文整理匯總了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;
}