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


Java PaletteData類代碼示例

本文整理匯總了Java中org.eclipse.swt.graphics.PaletteData的典型用法代碼示例。如果您正苦於以下問題:Java PaletteData類的具體用法?Java PaletteData怎麽用?Java PaletteData使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PaletteData類屬於org.eclipse.swt.graphics包,在下文中一共展示了PaletteData類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: drawShadowImage

import org.eclipse.swt.graphics.PaletteData; //導入依賴的package包/類
public static void drawShadowImage(GC gc, Image image, int x, int y,
    int alpha) {
  Display display = Display.getCurrent();
  Point imageSize = new Point(image.getBounds().width,
      image.getBounds().height);
  //
  ImageData imgData = new ImageData(imageSize.x, imageSize.y, 24,
      new PaletteData(255, 255, 255));
  imgData.alpha = alpha;
  Image img = new Image(display, imgData);
  GC imgGC = new GC(img);
  imgGC.drawImage(image, 0, 0);
  gc.drawImage(img, x, y);
  imgGC.dispose();
  img.dispose();
}
 
開發者ID:convertigo,項目名稱:convertigo-eclipse,代碼行數:17,代碼來源:SWTX.java

示例2: encontraPixel

import org.eclipse.swt.graphics.PaletteData; //導入依賴的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;
    }
 
開發者ID:nbfontana,項目名稱:pdi,代碼行數:27,代碼來源:Interface.java

示例3: applyTransparency

import org.eclipse.swt.graphics.PaletteData; //導入依賴的package包/類
public void applyTransparency( TGColor background ){
	RGB alpha = new RGB( background.getRed(), background.getGreen(), background.getBlue() );
	RGB none = new RGB((0xff ^ alpha.red),(0xff ^ alpha.green),(0xff ^ alpha.blue));
	
	Image srcImage = this.handle;
	ImageData srcData = srcImage.getImageData();
	ImageData maskData = new ImageData(srcData.width,srcData.height,1,new PaletteData(new RGB[]{ none,alpha }  ));
	for(int x = 0; x< maskData.width; x++) {
		for(int y = 0; y < maskData.height; y++) {
			RGB rgb = srcData.palette.getRGB(srcData.getPixel(x, y));
			if(rgb.red == alpha.red && rgb.green == alpha.green && rgb.blue == alpha.blue){
				maskData.setPixel(x, y, maskData.palette.getPixel(none));
			}else{
				maskData.setPixel(x, y, maskData.palette.getPixel(alpha));
			}
		}
	}
	this.handle = new Image(srcImage.getDevice(),srcData,maskData);
	
	srcImage.dispose();
}
 
開發者ID:theokyr,項目名稱:TuxGuitar-1.3.1-fork,代碼行數:22,代碼來源:TGImageImpl.java

示例4: convertToSWT2

import org.eclipse.swt.graphics.PaletteData; //導入依賴的package包/類
public static ImageData convertToSWT2(BufferedImage bufferedImage) throws IOException {
//		/2) awt.BufferedImage -> raw Data
		java.awt.image.WritableRaster awtRaster = bufferedImage.getRaster();
		java.awt.image.DataBufferByte awtData = (DataBufferByte) awtRaster.getDataBuffer();
		byte[] rawData = awtData.getData();

		//3) raw Data -> swt.ImageData
		org.eclipse.swt.graphics.PaletteData swtPalette = new PaletteData(0xff, 0xff00, 0xff0000);

		int depth = 0x18;
		org.eclipse.swt.graphics.ImageData swtImageData = new ImageData(bufferedImage.getWidth(), bufferedImage.getHeight(), 
				depth, swtPalette, bufferedImage.getWidth(), rawData);
		
		return swtImageData;
//		return new Image(Display.getDefault(), swtImageData);		
	}
 
開發者ID:Transkribus,項目名稱:TranskribusSwtGui,代碼行數:17,代碼來源:SWTUtil.java

示例5: getImage

import org.eclipse.swt.graphics.PaletteData; //導入依賴的package包/類
@Override
public Image getImage(Object element) {
	if (element instanceof RGB) {
		RGB rgb = (RGB) element;
		if (!rgb.equals(colorRGB)){
			if (colorImage != null){
				colorImage.dispose();
			}
			colorRGB = rgb;
			PaletteData palette = new PaletteData(new RGB[]{rgb, new RGB(0,0,0)});
			ImageData data = new ImageData(1, 1, 1, palette);
			colorImage = new Image(null, data);
		}
	} else {
		if (colorImage != null){
			colorImage.dispose();
			colorImage = null;
		}
		colorRGB = null;
	}
	return colorImage;
}
 
開發者ID:ShoukriKattan,項目名稱:ForgedUI-Eclipse,代碼行數:23,代碼來源:ColorPropertyDescriptor2.java

示例6: toSWT

import org.eclipse.swt.graphics.PaletteData; //導入依賴的package包/類
/**
 * Converts an AWT based buffered image into an SWT <code>Image</code>. This will always return an <code>Image</code> that has 24 bit depth regardless of the
 * type of AWT buffered image that is passed into the method.
 *
 * @param device
 * @param awtImage
 *          the {@link java.awt.image.BufferedImage} to be converted to an <code>Image</code>
 *          
 * @return an <code>Image</code> that represents the same image data as the AWT <code>BufferedImage</code> type.
 */
public static org.eclipse.swt.graphics.Image toSWT(Device device, BufferedImage awtImage) {
  device = (device!=null) ? device : Display.getCurrent();
  // We can force bitdepth to be 24 bit because BufferedImage getRGB
  // allows us to always retrieve 24 bit data regardless of source color depth.
  PaletteData palette = new PaletteData(0xFF0000, 0xFF00, 0xFF);
  ImageData swtImageData = new ImageData(awtImage.getWidth(), awtImage.getHeight(), 24, palette);
  // Ensure scansize is aligned on 32 bit.
  int scansize = (((awtImage.getWidth() * 3) + 3) * 4) / 4;
  WritableRaster alphaRaster = awtImage.getAlphaRaster();
  byte[] alphaBytes = new byte[awtImage.getWidth()];
  for (int y = 0; y < awtImage.getHeight(); y++) {
    int[] buff = awtImage.getRGB(0, y, awtImage.getWidth(), 1, null, 0, scansize);
    swtImageData.setPixels(0, y, awtImage.getWidth(), buff, 0);
    if (alphaRaster != null) {
      int[] alpha = alphaRaster.getPixels(0, y, awtImage.getWidth(), 1, (int[]) null);
      for (int i = 0; i < awtImage.getWidth(); i++) {
        alphaBytes[i] = (byte) alpha[i];
      }
      swtImageData.setAlphas(0, y, awtImage.getWidth(), alphaBytes, 0);
    }
  }
  return new org.eclipse.swt.graphics.Image(device, swtImageData);
}
 
開發者ID:eclipse,項目名稱:triquetrum,代碼行數:34,代碼來源:ShapeUtils.java

示例7: createLinearHeapImage

import org.eclipse.swt.graphics.PaletteData; //導入依賴的package包/類
/**
 * Creates a linear image of the heap data.
 * @param pixData
 * @param h
 * @param palette
 * @return
 */
protected ImageData createLinearHeapImage(byte[] pixData, int h, PaletteData palette) {
    int w = pixData.length / h;
    if (pixData.length % h != 0) {
        w++;
    }

    // Create the heap image.
    ImageData id = new ImageData(w, h, 8, palette);

    int x = 0;
    int y = 0;
    for (byte b : pixData) {
        if (b >= 0) {
            id.setPixel(x, y, b);
        }

        y++;
        if (y >= h) {
            y = 0;
            x++;
        }
    }

    return id;
}
 
開發者ID:utds3lab,項目名稱:SMVHunter,代碼行數:33,代碼來源:BaseHeapPanel.java

示例8: 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

示例9: 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

示例10: createImage

import org.eclipse.swt.graphics.PaletteData; //導入依賴的package包/類
private Image createImage(final String fontName) {

		Image stringImage = cache.getImage(fontName);
		if (stringImage == null){
			Display display = Display.getCurrent();
			Color TRANSPARENT_COLOR = display.getSystemColor(SWT.COLOR_WHITE);
			Color DRAWING_COLOR = display.getSystemColor(SWT.COLOR_BLACK);
			PaletteData paletteData = new PaletteData(new RGB[] { TRANSPARENT_COLOR.getRGB(), DRAWING_COLOR.getRGB() });
			ImageData imageData = new ImageData(55, 15, 4, paletteData);
			imageData.transparentPixel = 0; // index of the palette
	
			stringImage = new Image(display, imageData);
			GC stringGc = new GC(stringImage);
			try {
				stringGc.setForeground(DRAWING_COLOR);
				stringGc.setBackground(TRANSPARENT_COLOR);
				stringGc.setFont(cache.getFont(fontName, 10, 0));
				stringGc.drawText("Sample", 0, 0);
			} finally {
				stringGc.dispose();
				cache.storeImage(fontName, stringImage);
			}
		}
		return stringImage;
	}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:26,代碼來源:SPRWCCombo.java

示例11: createSliderImage

import org.eclipse.swt.graphics.PaletteData; //導入依賴的package包/類
/**
 * Create the image data for the rectangle data without arrow, so it can be cached
 * 
 * @param rect size of the rectangle area
 * @return ImageData that will be placed inside the rectangle area
 */
private ImageData createSliderImage(Rectangle rect){
  int padWidth = governor.getPadMaxX() - governor.getPadMinX();
   int padHeight = governor.getPadMaxY() - governor.getPadMinY();
 	float padX = ((float)(circlePosition.x*padWidth))/(getPadWidth()-1);
 	float padY = ((float)(circlePosition.y*padHeight))/(getPadHeight()-1);
	ImageData image = new ImageData(Math.max(1, rect.width),Math.max(1, rect.height),32,new PaletteData(0xFF0000,0xFF00,0xFF));
	int sliderHeight = governor.getSliderMax() - governor.getSliderMin();
	
	int backGroundPixel = image.palette.getPixel(slider.getParent().getBackground().getRGB());
	for(int y = 0; y<image.height; y++){
		float actaulSlider = ((float)sliderHeight / getSliderHeight()) * y;
		RGB actualHueColor = governor.getSliderColor(Math.round(padX), Math.round(padY), Math.round(actaulSlider));
		for(int x = 0; x<image.width; x++){
			if (x > arrowWidth && x<image.width-arrowWidth)
				image.setPixel(x,y,image.palette.getPixel(actualHueColor));
			else 
				image.setPixel(x,y, backGroundPixel);
		}
	}
	return image;
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:28,代碼來源:ColorsSelectorWidget.java

示例12: createPadImage

import org.eclipse.swt.graphics.PaletteData; //導入依賴的package包/類
/**
 * Create the image data for the square data without the selection mark, so it can be cached
 * 
 * @param rect size of the square area
 * @return ImageData that will be placed inside the square area
 */
private ImageData createPadImage(Rectangle rect){
   ImageData imageData=new ImageData(Math.max(1, rect.width),Math.max(1, rect.height),32,new PaletteData(0xFF0000,0xFF00,0xFF));
   int padWidth = governor.getPadMaxX() - governor.getPadMinX();
   int padHeight = governor.getPadMaxY() - governor.getPadMinY();
   //Calculate the actual slider
   int slider = Math.round(((float)governor.getSliderMax() / getSliderHeight())*sliderPosition);
   for(int i=0; i<imageData.width; i++){
   	for (int j=0; j<imageData.height; j++){
     	float padX = ((float)(i*padWidth))/(imageData.width-1);
     	float padY = ((float)(j*padHeight))/(imageData.height-1);
   		imageData.setPixel(i,j,imageData.palette.getPixel(governor.getPadColor(Math.round(padX), Math.round(padY), slider)));
   	}
   }
   
   return imageData;
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:23,代碼來源:ColorsSelectorWidget.java

示例13: getImagePreview

import org.eclipse.swt.graphics.PaletteData; //導入依賴的package包/類
/**
  * Return a a preview image of an embedded color. The image will have size of 
  * 20x10. The image are cached, so it will be generated only the first time that are 
  * requested.
  * 
  * @param colorName the human name of the color
  * @return an SWT image, preview of the color. It can be null if the human name dosen't match 
  * none of the embedded colors.
  */
 public static Image getImagePreview(String colorName){
//The images are cached and disposed at the end
String key = "colorPreview_"+colorName; //$NON-NLS-1$
Image image = ResourceManager.getImage(key);
if (image == null){
	if (colorsMap == null) getColors();
	String colorCode = colorsMap.get(colorName);
	if (colorCode != null){
		Color color = decodeColor("#"+colorCode); //$NON-NLS-1$
		RGB colorRGB = new RGB(color.getRed(), color.getGreen(), color.getBlue());
		ImageData data = new ImageData(20, 10, 1, new PaletteData(new RGB[]{colorRGB}));
		image = new Image(null,data); 
		GC graphics = new GC(image);
		graphics.setForeground(ColorConstants.black);
		graphics.drawRectangle(0,0,19,9);
		graphics.dispose();
		ResourceManager.addImage(key, image);
	} else return null;
}
return image;
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:31,代碼來源:ColorSchemaGenerator.java

示例14: getNoBordersImage

import org.eclipse.swt.graphics.PaletteData; //導入依賴的package包/類
/**
 * Return a border preview for a not visible border. The image is created only the first time is requested, then it is
 * cached and disposed when the application is closed.
 * 
 * @return an image with the words "No Borders" rendereized into it
 */
private Image getNoBordersImage() {
	String key = "linePreset_noBorders";
	Image image = ResourceManager.getImage(key);
	if (image == null) {
		ImageData data = new ImageData(getWidth(), 15, 1, new PaletteData(new RGB[] { ColorConstants.white.getRGB() }));
		// data.transparentPixel = data.getPixel(0, 0);
		image = new Image(null, data);
		GC graphics = new GC(image);
		try {
			// graphics.setTextAntialias(SWT.ON);
			graphics.setFont(ResourceManager.getFont("Time New Roman", 10, SWT.NORMAL));
			graphics.drawString("No Borders", 5, 0);
		} finally {
			graphics.dispose();
		}
		ResourceManager.addImage(key, image);
	}
	return image;
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:26,代碼來源:TemplateBorder.java

示例15: getCustomImage

import org.eclipse.swt.graphics.PaletteData; //導入依賴的package包/類
/**
 * Return a border preview for a custom border (not equals to any preset). The image is created only the first time is
 * requested, then it is cached and disposed when the application is closed.
 * 
 * @return an image with the words "Custom" rendereized into it
 */
public static Image getCustomImage() {
	String key = "linePreset_custom";
	Image image = ResourceManager.getImage(key);
	if (image == null) {
		ImageData data = new ImageData(getWidth(), 15, 1, new PaletteData(new RGB[] { ColorConstants.white.getRGB() }));
		// data.transparentPixel = data.getPixel(0, 0);
		image = new Image(null, data);
		GC graphics = new GC(image);
		try {
			graphics.setFont(ResourceManager.getFont("Time New Roman", 10, SWT.NORMAL));
			// graphics.setTextAntialias(SWT.ON);
			graphics.drawString("Custom", 5, 0);
		} finally {
			graphics.dispose();
		}
		ResourceManager.addImage(key, image);
	}
	return image;
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:26,代碼來源:TemplateBorder.java


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