當前位置: 首頁>>代碼示例>>Java>>正文


Java PaletteData.getPixel方法代碼示例

本文整理匯總了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;
}
 
開發者ID:hoozheng,項目名稱:AndroidRobot,代碼行數:18,代碼來源:SetCheckPoint2.java

示例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;
}
 
開發者ID:hoozheng,項目名稱:AndroidRobot,代碼行數:19,代碼來源:DeviceSocketClient.java

示例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;
}
 
開發者ID:sopeco,項目名稱:DynamicSpotter,代碼行數:31,代碼來源:ImageUtils.java

示例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);
}
 
開發者ID:ShoukriKattan,項目名稱:ForgedUI-Eclipse,代碼行數:38,代碼來源:SnapFeedbackPolicy.java

示例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);
}
 
開發者ID:Yakindu,項目名稱:statecharts,代碼行數:36,代碼來源:SimpleSnapFeedbackPolicy.java

示例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);
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:10,代碼來源:ScrollableThumbnail.java

示例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);
}
 
開發者ID:ghillairet,項目名稱:gef-gwt,代碼行數:41,代碼來源:SnapFeedbackPolicy.java

示例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 );
}
 
開發者ID:pentaho,項目名稱:pentaho-kettle,代碼行數:18,代碼來源:SwtUniversalImage.java

示例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;
    }
 
開發者ID:jo-source,項目名稱:jo-widgets,代碼行數:12,代碼來源:AntiAliasingFilter.java


注:本文中的org.eclipse.swt.graphics.PaletteData.getPixel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。