Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.PaletteData


    public static ImageData createImageData( RenderedImage image ) {
        ImageData swtdata = null;
        int width = image.getWidth();
        int height = image.getHeight();
        PaletteData palette;
        int depth;

        depth = 24;
        palette = new PaletteData(0xFF0000, 0xFF00, 0xFF);
        swtdata = new ImageData(width, height, depth, palette);
        swtdata.transparentPixel = TRANSPARENT;

        byte blueT = (byte) ((TRANSPARENT) & 0xFF);
        byte greenT = (byte) ((TRANSPARENT >> 8) & 0xFF);
View Full Code Here


        ImageData push = icon.getImageData();
        if( !push.palette.isDirect){
          RGB[] rgb=new RGB[push.palette.colors.length];
          System.arraycopy(push.palette.colors, 0, rgb, 0, push.palette.colors.length);
          rgb[push.transparentPixel]=Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW).getRGB();
          push.palette=new PaletteData(rgb);
          push.transparentPixel=-1;
                   
                    createBorder(push);
                   
          return push;
View Full Code Here

     * @param display
     * @param rgb
     * @return
     */
    public static Image image( Display display ) {
        PaletteData palette = new PaletteData(0xFF0000, 0xFF00, 0xFF);
        ImageData imageData = new ImageData(DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_DEPTH, palette);
        imageData.transparentPixel = palette.getPixel(display.getSystemColor(
                SWT.COLOR_WIDGET_BACKGROUND).getRGB());

        return new Image(display, imageData);
    }
View Full Code Here

        drawImage(rimage, 0, 0, rimage.getWidth(), rimage.getHeight(), x, y, x + rimage.getWidth(), y + rimage.getHeight());
    }

    public static Image createDefaultImage( Display display, int width, int height ) {
        ImageData swtdata = null;
        PaletteData palette;
        int depth;

        depth = 24;
        palette = new PaletteData(0xFF0000, 0xFF00, 0xFF);
        swtdata = new ImageData(width, height, depth, palette);
        swtdata.transparentPixel = -1;
        swtdata.alpha = -1;
        swtdata.alphaData = new byte[swtdata.data.length];
        for( int i = 0; i < swtdata.alphaData.length; i++ ) {
View Full Code Here

    // optimized version that works if the image is rgb with a byte data buffer
    public static ImageData createImageDataFromBytes( RenderedImage image ) {
        ImageData swtdata = null;
        int width = image.getWidth();
        int height = image.getHeight();
        PaletteData palette;
        int depth;
        depth = 24;
        palette = new PaletteData(0xFF0000, 0xFF00, 0xFF);
        swtdata = new ImageData(width, height, depth, palette);

        Raster raster = image.getData();
        raster.getDataElements(0, 0, width, height, swtdata.data);
View Full Code Here

        // && !image.getColorModel().hasAlpha() )
        // return createImageDataFromBytes(image);
        ImageData swtdata = null;
        int width = image.getWidth();
        int height = image.getHeight();
        PaletteData palette;
        int depth;

        depth = 24;
        palette = new PaletteData(0xFF0000, 0xFF00, 0xFF);
        swtdata = new ImageData(width, height, depth, palette);
        byte blueT = (byte) 255;
        byte greenT = (byte) 255;
        byte redT = (byte) 255;
        if (transparent) {
View Full Code Here

     * </p>
     * @return a Buffered Image
     */
    public static BufferedImage convertToAWT(ImageData data) {
      ColorModel colorModel = null;
      PaletteData palette = data.palette;
      if (palette.isDirect) {
          // no alpha data?
          if(data.alphaData==null) {
              colorModel = new DirectColorModel(32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);              
              BufferedImage bufferedImage = new BufferedImage(colorModel,
                      colorModel.createCompatibleWritableRaster(data.width, data.height),
                      false, null);              
              WritableRaster raster = bufferedImage.getRaster();             
              int[] pixelArray = new int[4];
              for (int y = 0; y < data.height; y++) {
                  for (int x = 0; x < data.width; x++) {
                      int pixel = data.getPixel(x, y);                       
                      RGB rgb = palette.getRGB(pixel);
                      pixelArray[0] = rgb.red;
                      pixelArray[1] = rgb.green;
                      pixelArray[2] = rgb.blue;
                      if (pixel == data.transparentPixel) {
                          pixelArray[3]=0// transparent
                      }
                      else {
                          pixelArray[3]=255; // opaque
                      }
                      raster.setPixels(x, y, 1, 1, pixelArray);                      
                  }
              }
                int w = bufferedImage.getWidth();
                int h = bufferedImage.getHeight();
                Raster ras = bufferedImage.getData();
                for( int i = 0; i < w; i++ ) {
                    for( int j = 0; j < h; j++ ) {
                        double[] pixel = ras.getPixel(i, j, new double[4]);
                    }
                }

                return bufferedImage;
          }
         
          // image has alpha data, preserve it
          else {
              colorModel = new DirectColorModel(32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);              
              BufferedImage bufferedImage = new BufferedImage(colorModel,
                      colorModel.createCompatibleWritableRaster(data.width, data.height),
                      false, null);              
              WritableRaster raster = bufferedImage.getRaster();             
              int[] pixelArray = new int[4];
              for (int y = 0; y < data.height; y++) {
                  for (int x = 0; x < data.width; x++) {
                      int pixel = data.getPixel(x, y);                       
                      RGB rgb = palette.getRGB(pixel);
                      pixelArray[0] = rgb.red;
                      pixelArray[1] = rgb.green;
                      pixelArray[2] = rgb.blue;
                      pixelArray[3]=data.getAlpha(x,y);
                      raster.setPixels(x, y, 1, 1, pixelArray);                      
                  }
              }
              return bufferedImage;
          }
         
          //la paleta swt no es directa �?�?�?
         
//        ColorSpace colorSpace = ColorSpace.getInstance(ColorSpace.CS_sRGB);
//        colorModel = new DirectColorModel(colorSpace, data.depth, palette.redMask,
//                palette.greenMask, palette.blueMask, 0, false, DataBuffer.TYPE_INT);
////        colorModel = new DirectColorModel(data.depth, palette.redMask,
////            palette.greenMask, palette.blueMask);
//        BufferedImage bufferedImage = new BufferedImage(colorModel,
//            colorModel.createCompatibleWritableRaster(data.width,
//                data.height), false, null);
//        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++) {
//            int pixel = data.getPixel(x, y);
//            RGB rgb = palette.getRGB(pixel);
//            pixelArray[0] = rgb.red;
//            pixelArray[1] = rgb.green;
//            pixelArray[2] = rgb.blue;
//            raster.setPixels(x, y, 1, 1, pixelArray);
//          }
//        }
//        return bufferedImage;
      } else {
        RGB[] rgbs = palette.getRGBs();
        byte[] red = new byte[rgbs.length];
        byte[] green = new byte[rgbs.length];
        byte[] blue = new byte[rgbs.length];
        for (int i = 0; i < rgbs.length; i++) {
          RGB rgb = rgbs[i];
View Full Code Here

     * @return an image with a depth of 24 and has a transparency channel.
     */
    public static Image createDefaultImage( Device device, int width, int height ) {
        AWTSWTImageUtils.checkAccess();
        ImageData swtdata = null;
        PaletteData palette;
        int depth;

        depth = 24;
        palette = new PaletteData(0xFF0000, 0xFF00, 0xFF);
        swtdata = new ImageData(width, height, depth, palette);
        swtdata.transparentPixel = -1;
        swtdata.alpha = -1;
        swtdata.alphaData = new byte[swtdata.data.length];
        for( int i = 0; i < swtdata.alphaData.length; i++ ) {
View Full Code Here

    }
    public static Image createDefaultImage( Display display, int width, int height ) {
        AWTSWTImageUtils.checkAccess();
        ImageData swtdata = null;
        PaletteData palette;
        int depth;
   
        depth = 24;
        palette = new PaletteData(0xFF0000, 0xFF00, 0xFF);
        swtdata = new ImageData(width, height, depth, palette);
        swtdata.transparentPixel = 0;
        //swtdata.transparentPixel = -1;
        swtdata.alpha = -1;
        swtdata.alphaData = new byte[swtdata.data.length];
View Full Code Here

        AWTSWTImageUtils.checkAccess();
   
        ImageData swtdata = null;
        int width = image.getWidth();
        int height = image.getHeight();
        PaletteData palette;
        int depth;
   
        depth = 24;
        palette = new PaletteData(0xFF, 0xFF00, 0xFF0000);
        swtdata = new ImageData(width, height, depth, palette);
        Raster raster = image.getData();
        int numbands = raster.getNumBands();
        int[] awtdata = raster.getPixels(0, 0, width, height, new int[width * height * numbands]);
        int step = swtdata.depth / 8;
View Full Code Here

TOP

Related Classes of org.eclipse.swt.graphics.PaletteData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.