Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.PaletteData


          int fps = 0;

          int[] Frame = ((DataBufferInt) currentImage.getRaster().getDataBuffer()).getData();
          ImageData imgdata
            = new ImageData(currentImage.getWidth(), currentImage.getHeight(), 24,
                    new PaletteData(0xFF0000, 0x00FF00, 0x0000FF));
          imgdata.setPixels(0, 0, currentImage.getWidth() * currentImage.getHeight(), Frame, 0);

          if ((currentImage.getWidth() != cSize.x) || (currentImage.getHeight() != cSize.y)) {
            int sizeX = cSize.x, sizeY = cSize.y;
            event.gc.setInterpolation(SWT.HIGH);
View Full Code Here


    }

    public ImageData image (BufferedImage image) {
        if (image.getColorModel() instanceof DirectColorModel) {
            DirectColorModel cmodel = (DirectColorModel)image.getColorModel();
            PaletteData palette = new PaletteData(
                cmodel.getRedMask(), cmodel.getGreenMask(), cmodel.getBlueMask());
            ImageData data = new ImageData(image.getWidth(), image.getHeight(),
                cmodel.getPixelSize(), palette);
            for (int y = 0; y < data.height; y++) {
                for (int x = 0; x < data.width; x++) {
                    int rgb = image.getRGB(x, y);
                    int pixel = palette.getPixel(
                        new RGB((rgb >> 16) & 0xFF, (rgb >> 8) & 0xFF, rgb & 0xFF));
                    data.setPixel(x, y, pixel);
                    if (cmodel.hasAlpha()) data.setAlpha(x, y, (rgb >> 24) & 0xFF);
                }
            }
            return data;

        } else if (image.getColorModel() instanceof IndexColorModel) {
            IndexColorModel cmodel = (IndexColorModel)image.getColorModel();
            int size = cmodel.getMapSize();
            byte[] reds = new byte[size];
            byte[] greens = new byte[size];
            byte[] blues = new byte[size];
            cmodel.getReds(reds);
            cmodel.getGreens(greens);
            cmodel.getBlues(blues);
            RGB[] rgbs = new RGB[size];
            for (int ii = 0; ii < rgbs.length; ii++) {
                rgbs[ii] = new RGB(reds[ii] & 0xFF, greens[ii] & 0xFF, blues[ii] & 0xFF);
            }
            PaletteData palette = new PaletteData(rgbs);
            ImageData data = new ImageData(
                image.getWidth(), image.getHeight(), cmodel.getPixelSize(), palette);
            data.transparentPixel = cmodel.getTransparentPixel();
            WritableRaster raster = image.getRaster();
            int[] pixelArray = new int[1];
            for (int y = 0; y < data.height; y++) {
                for (int x = 0; x < data.width; x++) {
                    raster.getPixel(x, y, pixelArray);
                    data.setPixel(x, y, pixelArray[0]);
                }
            }
            return data;
        } else if (image.getColorModel() instanceof ComponentColorModel) {
            ComponentColorModel cmodel = (ComponentColorModel)image.getColorModel();
            PaletteData palette = new PaletteData(0x0000FF, 0x00FF00, 0xFF0000); // BGR
            ImageData data = new ImageData(image.getWidth(), image.getHeight(), 24, palette);
            if (cmodel.hasAlpha()) data.alphaData = new byte[image.getWidth() * image.getHeight()];
            WritableRaster raster = image.getRaster();
            int[] pixelArray = new int[4];
            for (int y = 0; y < data.height; y++) {
View Full Code Here

            /* rotate image anti-clockwise */
            final ImageData src = imageCanvas.getImageData();
            if (src == null) {
                return;
            }
            final PaletteData srcPal = src.palette;
            PaletteData destPal;
            ImageData dest;
            /* construct a new ImageData */
            if (srcPal.isDirect) {
                destPal = new PaletteData(srcPal.redMask, srcPal.greenMask,
                        srcPal.blueMask);
            } else {
                destPal = new PaletteData(srcPal.getRGBs());
            }
            dest = new ImageData(src.height, src.width, src.depth, destPal);
            /* rotate by rearranging the pixels */
            for (int i = 0; i < src.width; i++) {
                for (int j = 0; j < src.height; j++) {
View Full Code Here

        int xoffset = indent;
        int yoffset = (height - size) / 2;

        RGB black = new RGB(0, 0, 0);
        PaletteData dataPalette = new PaletteData(new RGB[] { black, black,
                color });
        ImageData data = new ImageData(width, height, 4, dataPalette);
        data.transparentPixel = 0;

        int end = size - 1;
View Full Code Here

    int xoffset = indent;
    int yoffset = (height - size) / 2;

    RGB black = new RGB(0, 0, 0);
    PaletteData dataPalette = new PaletteData(new RGB[] { black, BORDER_RGB, color });
    ImageData data = new ImageData(width, height, 4, dataPalette);
    data.transparentPixel = 0;

    int end = size - 1;
    for (int y = 0; y < size; y++) {
View Full Code Here

  static Image compositeImage(Device device, ImageData base,
      ImageData[] overlay) {
    if (base == null)
      return null;
    Image image = new Image(device, new ImageData(base.width, base.height,
        24, new PaletteData(0xff, 0xff00, 0xff00000)));
    GC gc = new GC(image);
    ImageData src;
    int maskDepth = 0, baseMaskDepth = 0;
    ImageData underlay = src = overlay.length > UNDERLAY ? overlay[UNDERLAY]
        : null;
View Full Code Here

        bni.icon = new ImageIcon(bni.awt_image);

        // SWT
        try {
          int pos = 0;
          ImageData imageData = new ImageData(bni.xSize, bni.ySize, 32, new PaletteData(0xFF0000, 0x00FF00, 0x0000FF));
          for(int y = 0; y < bni.ySize; y++) {
            for(int x = 0; x < bni.xSize; x++) {
              imageData.setPixel(x, y, pixelData[currentPixel + pos++]);
            }
          }
View Full Code Here

                int alpha = (int) Math.max(0.0, 255*f);
                alphaBytes[i] = (byte) alpha;
            }
            nnStopWatch.print();
            // define a direct palette with masks for RGB
            PaletteData palette = new PaletteData(0xFF0000 , 0xFF00 , 0xFF);  
            ImageData imageData = new ImageData(mapSize, mapSize, 24, palette, mapSize*3, imageBytes);
            // enable alpha by setting alphabytes ... strange that i can't do that per pixel using 32bit values
            imageData.alphaData = alphaBytes;
            return new Image(device, imageData);           
        }
View Full Code Here

          Integer.parseInt(caretColourString.substring(1, 3), 16);
    int green = Integer.parseInt(backgroundColourString.substring(3, 5), 16) ^
            Integer.parseInt(caretColourString.substring(3, 5), 16);
    int blue = Integer.parseInt(backgroundColourString.substring(5, 7), 16) ^
            Integer.parseInt(caretColourString.substring(5, 7), 16);
    PaletteData palette = new PaletteData (
      new RGB [] {
        new RGB (0, 0, 0),
        new RGB (red, green, blue),
        new RGB (0xFF, 0xFF, 0xFF),
      });
View Full Code Here

    static final int DEFAULT_WIDTH = 16;
    static final int DEFAULT_HEIGHT = 16;
    static final int DEFAULT_DEPTH = 24;

    private static Image image( Display display, RGB[] rgb ) {
        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

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.