本文整理匯總了Java中org.eclipse.swt.graphics.PaletteData.getPixel方法的典型用法代碼示例。如果您正苦於以下問題:Java PaletteData.getPixel方法的具體用法?Java PaletteData.getPixel怎麽用?Java PaletteData.getPixel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.swt.graphics.PaletteData
的用法示例。
在下文中一共展示了PaletteData.getPixel方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getImageData
import org.eclipse.swt.graphics.PaletteData; //導入方法依賴的package包/類
public ImageData getImageData(BufferedImage bufferedImage) {
DirectColorModel colorModel = (DirectColorModel) bufferedImage.getColorModel();
PaletteData palette = new PaletteData(colorModel.getRedMask(), colorModel.getGreenMask(),
colorModel.getBlueMask());
ImageData data = new ImageData(bufferedImage.getWidth(), bufferedImage.getHeight(),
colorModel.getPixelSize(), palette);
WritableRaster raster = bufferedImage.getRaster();
int[] pixelArray = new int[3];
for (int y = 0; y < data.height; y++) {
for (int x = 0; x < data.width; x++) {
raster.getPixel(x, y, pixelArray);
int pixel = palette.getPixel(new RGB(pixelArray[0], pixelArray[1], pixelArray[2]));
data.setPixel(x, y, pixel);
}
}
return data;
}
示例2: getImageData2
import org.eclipse.swt.graphics.PaletteData; //導入方法依賴的package包/類
private static ImageData getImageData2(BufferedImage bufferedImage){
DirectColorModel colorModel = (DirectColorModel) bufferedImage.getColorModel();
//System.out.println("robot:" +colorModel.getRedMask() + " "+colorModel.getGreenMask() + " "+colorModel.getBlueMask());
PaletteData palette = new PaletteData(colorModel.getRedMask(), colorModel.getGreenMask(), colorModel
.getBlueMask());
ImageData data = new ImageData(bufferedImage.getWidth(), bufferedImage.getHeight(), colorModel
.getPixelSize(), palette);
WritableRaster raster = bufferedImage.getRaster();
int[] pixelArray = new int[3];
for (int y = 0; y < data.height; y++) {
for (int x = 0; x < data.width; x++) {
raster.getPixel(x, y, pixelArray);
int pixel = palette.getPixel(new RGB(pixelArray[0], pixelArray[1], pixelArray[2]));
data.setPixel(x, y, pixel);
}
}
return data;
}
示例3: convertToImageData
import org.eclipse.swt.graphics.PaletteData; //導入方法依賴的package包/類
/**
* Converts the image to <code>ImageData</code>. Expects the
* <code>DirectColorModel</code>.
*
* @param bufferedImage
* the image to convert
* @return the extracted image data
*/
public static ImageData convertToImageData(BufferedImage bufferedImage) {
if (!(bufferedImage.getColorModel() instanceof DirectColorModel)) {
throw new SWTException(SWT.ERROR_UNSUPPORTED_FORMAT);
}
DirectColorModel colorModel = (DirectColorModel) bufferedImage.getColorModel();
PaletteData palette = new PaletteData(colorModel.getRedMask(), colorModel.getGreenMask(),
colorModel.getBlueMask());
ImageData data = new ImageData(bufferedImage.getWidth(), bufferedImage.getHeight(), colorModel.getPixelSize(),
palette);
WritableRaster raster = bufferedImage.getRaster();
int components = colorModel.getComponentSize().length;
int[] pixels = new int[components];
for (int x = 0; x < data.width; x++) {
for (int y = 0; y < data.height; y++) {
raster.getPixel(x, y, pixels);
int pixel = palette.getPixel(new RGB(pixels[0], pixels[1], pixels[2]));
data.setPixel(x, y, pixel);
}
}
return data;
}
示例4: paintFigure
import org.eclipse.swt.graphics.PaletteData; //導入方法依賴的package包/類
/**
* @see org.eclipse.draw2d.Figure#paintFigure(org.eclipse.draw2d.Graphics)
*/
protected void paintFigure(Graphics graphics) {
if (opacity != FRAMES) {
if (image != null) {
image.dispose();
count--;
image = null;
}
if (opacity != FRAMES - 1) {
Display display = Display.getCurrent();
PaletteData pData = new PaletteData(0xFF, 0xFF00, 0xFF0000);
Color localBackgroundColor = createMixedColor();
int fillColor = pData.getPixel(localBackgroundColor
.getRGB());
localBackgroundColor.dispose();
ImageData iData = new ImageData(1, 1, 24, pData);
iData.setPixel(0, 0, fillColor);
iData.setAlpha(0, 0, 255 * opacity / FRAMES);
image = new Image(display, iData);
count++;
}
Display.getCurrent().timerExec(100, new Runnable() {
public void run() {
opacity = Math.min(FRAMES, opacity + 1);
repaint();
}
});
}
Rectangle r = getBounds();
if (image != null)
graphics.drawImage(image, 0, 0, 1, 1, r.x, r.y, r.width,
r.height);
else
super.paintFigure(graphics);
}
示例5: paintFigure
import org.eclipse.swt.graphics.PaletteData; //導入方法依賴的package包/類
/**
* @see org.eclipse.draw2d.Figure#paintFigure(org.eclipse.draw2d.Graphics)
*/
protected void paintFigure(Graphics graphics) {
if (opacity != FRAMES) {
if (image != null) {
image.dispose();
count--;
image = null;
}
if (opacity != FRAMES - 1) {
Display display = Display.getCurrent();
PaletteData pData = new PaletteData(0xFF, 0xFF00, 0xFF0000);
Color localBackgroundColor = createMixedColor();
int fillColor = pData.getPixel(localBackgroundColor.getRGB());
localBackgroundColor.dispose();
ImageData iData = new ImageData(1, 1, 24, pData);
iData.setPixel(0, 0, fillColor);
iData.setAlpha(0, 0, 255 * opacity / FRAMES);
image = new Image(display, iData);
count++;
}
Display.getCurrent().timerExec(100, new Runnable() {
public void run() {
opacity = Math.min(FRAMES, opacity + 1);
repaint();
}
});
}
Rectangle r = getBounds();
if (image != null)
graphics.drawImage(image, 0, 0, 1, 1, r.x, r.y, r.width, r.height);
else
super.paintFigure(graphics);
}
示例6: SelectorFigure
import org.eclipse.swt.graphics.PaletteData; //導入方法依賴的package包/類
public SelectorFigure() {
PaletteData pData = new PaletteData(0xFF, 0xFF00, 0xFF0000);
RGB rgb = ColorConstants.menuBackgroundSelected.getRGB();
int fillColor = pData.getPixel(rgb);
iData = new ImageData(1, 1, 24, pData);
iData.setPixel(0, 0, fillColor);
iData.setAlpha(0, 0, 55);
iBounds = new Rectangle(0, 0, 1, 1);
}
示例7: paintFigure
import org.eclipse.swt.graphics.PaletteData; //導入方法依賴的package包/類
/**
* @see org.eclipse.draw2d.Figure#paintFigure(org.eclipse.draw2d.Graphics)
*/
protected void paintFigure(Graphics graphics) {
if (opacity != FRAMES) {
if (image != null) {
image.dispose();
count--;
image = null;
}
if (opacity != FRAMES - 1) {
Display display = Display.getCurrent();
PaletteData pData = new PaletteData(0xFF, 0xFF00, 0xFF0000);
Color localBackgroundColor = createMixedColor();
int fillColor = pData.getPixel(localBackgroundColor
.getRGB());
localBackgroundColor.dispose();
ImageData iData = new ImageData(1, 1, 24, pData);
iData.setPixel(0, 0, fillColor);
iData.setAlpha(0, 0, 255 * opacity / FRAMES);
graphics.setAlpha(255 * opacity / FRAMES);
image = new Image(display, iData);
count++;
}
Display.getCurrent().timerExec(100, new Runnable() {
public void run() {
opacity = Math.min(FRAMES, opacity + 1);
repaint();
}
});
}
Rectangle r = getBounds();
// SzI: I removed this part since drawImage isn't working and thus
// fading didn't work.
// if (image != null)
// graphics.drawImage(image, 0, 0, 1, 1, r.x, r.y, r.width,
// r.height);
// else
super.paintFigure(graphics);
}
示例8: swing2swt
import org.eclipse.swt.graphics.PaletteData; //導入方法依賴的package包/類
/**
* Converts BufferedImage to SWT/Image with alpha channel.
*/
protected Image swing2swt( Device device, BufferedImage img ) {
PaletteData palette = new PaletteData( 0xFF0000, 0xFF00, 0xFF );
ImageData data = new ImageData( img.getWidth(), img.getHeight(), 32, palette );
for ( int y = 0; y < data.height; y++ ) {
for ( int x = 0; x < data.width; x++ ) {
int rgba = img.getRGB( x, y );
int rgb = palette.getPixel( new RGB( ( rgba >> 16 ) & 0xFF, ( rgba >> 8 ) & 0xFF, rgba & 0xFF ) );
int a = ( rgba >> 24 ) & 0xFF;
data.setPixel( x, y, rgb );
data.setAlpha( x, y, a );
}
}
return new Image( device, data );
}
示例9: getLowResolutionPixel
import org.eclipse.swt.graphics.PaletteData; //導入方法依賴的package包/類
public int getLowResolutionPixel(final int originalPixel, final PaletteData paletteData) {
final int result = paletteData.getPixel(new RGB((int) red, (int) green, (int) blue));
final int mask = 0xFFFFFFFF & ~paletteData.redMask & ~paletteData.greenMask & ~paletteData.blueMask;
final int clearedOriginal = originalPixel & mask;
final int modifiedOriginal = clearedOriginal | result;
return modifiedOriginal;
}