Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.PaletteData


    return Integer.valueOf(hash);
  }

  protected Image buildTaskImage(Task t, Action a) {
    ImageData data = new ImageData((16 * 3) + 2, 16, 8, new PaletteData(255, 255, 255));
    data.transparentPixel = data.palette.getPixel(new RGB(0, 0, 0));

    Image image = new Image(null, data);
    GC g = new GC(image);
    drawSide(g, t, a, Location.Source);
View Full Code Here


        return this.coloredBackgroundImage;
    }


    private ImageData tintImageData(ImageData imageData, Color color) {       
        PaletteData palette = imageData.palette;
        imageData = (ImageData) imageData.clone();
       
        if (palette.isDirect) {
            this.tintDirectImageData(imageData, color, palette);           
        } else {
View Full Code Here

    greenMask = data.palette.greenMask;
    blueMask = data.palette.blueMask;
  }

  public ImageData createImageData(byte[] data) {
    final PaletteData palette = new PaletteData(redMask, greenMask, blueMask);
    return new ImageData(width, height, depth, palette, scanlinePad, data);
  }
View Full Code Here

    BufferedImage handle = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB);
    Graphics g = handle.getGraphics();
    g.drawImage(image, 0, 0, null);
    g.dispose();
    ColorModel colorModel = handle.getColorModel();
    PaletteData paletteData = new PaletteData(0xFF0000, 0xFF00, 0xFF);
    int width = handle.getWidth();
    ImageData imageData = new ImageData(width, handle.getHeight(), colorModel.getPixelSize(), paletteData);
    int height = handle.getHeight();
    byte[] maskData = new byte[(width + 7) / 8 * height];
    for(int x=width-1; x >= 0; x--) {
      for(int y=height-1; y >= 0; y--) {
        int rgb = handle.getRGB(x, y);
        int pixel = paletteData.getPixel(new RGB((rgb >> 16) & 0xFF, (rgb >> 8) & 0xFF, rgb & 0xFF));
        imageData.setPixel(x, y, pixel);
        int alpha = (rgb >> 24) & 0xFF;
        imageData.setAlpha(x, y, alpha);
        if(alpha != 0) {
          int index = x + y * ((width + 7) / 8) * 8;
 
View Full Code Here

    return imageData;
  }

  public static BufferedImage convertSWTImage(ImageData data) {
    ColorModel colorModel = null;
    PaletteData palette = data.palette;
    if (palette.isDirect) {
      BufferedImage bufferedImage = new BufferedImage(data.width, data.height, BufferedImage.TYPE_INT_ARGB);
      ImageData transparencyMask = data.getTransparencyMask();
      for(int x=data.width-1; x >= 0; x--) {
        for(int y=data.height-1; y >= 0; y--) {
          RGB rgb = data.palette.getRGB(data.getPixel(x, y));
          int pixel = rgb.red << 16 | rgb.green << 8 | rgb.blue;
          rgb = transparencyMask.palette.getRGB(transparencyMask.getPixel(x, y));
          int mask = rgb.red << 16 | rgb.green << 8 | rgb.blue;
          if(mask != 0) {
            int alpha = data.getAlpha(x, y);
            if(alpha > 0) {
              pixel = pixel & 0x00FFFFFF | alpha << 24;
              bufferedImage.setRGB(x, y, pixel);
            }
          }
        }
      }
//      BufferedImage bufferedImage = new BufferedImage(data.width, data.height, BufferedImage.TYPE_INT_ARGB);
//      int transparencyType = data.getTransparencyType();
//      int transparentPixel = data.transparentPixel;
//      ImageData transparencyMask = data.getTransparencyMask();
//      for(int x=data.width-1; x >= 0; x--) {
//        for(int y=data.height-1; y >= 0; y--) {
//          int pixel = data.getPixel(x, y);
//          RGB rgb = data.palette.getRGB(pixel);
//          int iRGB = rgb.red << 16 | rgb.green << 8 | rgb.blue;
//          switch(transparencyType) {
//            case SWT.TRANSPARENCY_PIXEL: {
//              if(pixel != transparentPixel) {
//                bufferedImage.setRGB(x, y, iRGB);
//              }
//              break;
//            }
//            case SWT.TRANSPARENCY_ALPHA: {
//              int alpha = data.getAlpha(x, y);
//              if(alpha > 0) {
//                iRGB = iRGB & 0x00FFFFFF | alpha << 24;
//                bufferedImage.setRGB(x, y, iRGB);
//              }
//              break;
//            }
//            case SWT.TRANSPARENCY_MASK: {
//              rgb = transparencyMask.palette.getRGB(transparencyMask.getPixel(x, y));
//              int mask = rgb.red << 16 | rgb.green << 8 | rgb.blue;
//              if(mask != 0) {
//                int alpha = data.getAlpha(x, y);
//                if(alpha > 0) {
//                  iRGB = iRGB & 0x00FFFFFF | alpha << 24;
//                }
//                bufferedImage.setRGB(x, y, iRGB);
//              }
//              break;
//            }
//            default:
//              bufferedImage.setRGB(x, y, iRGB);
//              break;
//          }
//        }
//      }

//      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;
    }
    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;
      }
      int cursor = 0;
      // Has to be a multiple of 3
      byte[] bytes = new byte[1024 * 3];
      PaletteData palette = imageData.palette;
      Socket socket = null;
      BufferedOutputStream out = null;
      int width = imageData.width;
      int height = imageData.height;
      try {
View Full Code Here

    for (int i = 0; i < websafePalette.length; i++) {
      int[] currentcolor = websafePalette[i];
      rgb = new RGB(currentcolor[0], currentcolor[1], currentcolor[2]);
      array[i] = rgb;
    }
    webSafePaletteData = new PaletteData(array);
  }
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.