Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.PaletteData


        if (image.getType() == BufferedImage.TYPE_3BYTE_BGR) {
            int bands = image.getColorModel().getColorSpace().getNumComponents();
            int depth = 24;
            byte[] pixels = ((DataBufferByte) image.getRaster().getDataBuffer()).getData();

            PaletteData paletteData = new PaletteData(0x0000ff, 0x00ff00, 0xff0000);
           
            ImageData data = new ImageData(width, height, depth, paletteData, width * bands, pixels);
            return data;
        }
        else if (image.getType() == BufferedImage.TYPE_4BYTE_ABGR) {
            int bands = image.getColorModel().getColorSpace().getNumComponents() + 1;
            int depth = 32;
            byte[] pixels = ((DataBufferByte) image.getRaster().getDataBuffer()).getData();

            PaletteData paletteData = new PaletteData(0x0000ff, 0x00ff00, 0xff0000);
           
            ImageData data = new ImageData(width, height, depth, paletteData, width * bands, pixels);
           
            // scanning darkly
            for (int y = 0; y < height; y++) {
View Full Code Here


        int depth=24;
        int width=image.getWidth();
        int height=image.getHeight();
        byte[] pixels = ((DataBufferByte) image.getTile(0, 0)
                .getDataBuffer()).getData();
        ImageData data = new ImageData(width, height, depth, new PaletteData(
                0xff0000, 0x00ff00, 0x0000ff), width, pixels);
        return data;
    }
View Full Code Here

    RGB rgbs[]= new RGB[] {
      new RGB(c1.getRed(), c1.getGreen(), c1.getBlue()),
      new RGB(c2.getRed(), c2.getGreen(), c2.getBlue())};

    return new PaletteData(rgbs);
  }
View Full Code Here

    return caret;
  }

  private Image createRawInsertModeCaretImage(StyledText styledText) {

    PaletteData caretPalette= new PaletteData(new RGB[] {new RGB (0,0,0), new RGB (255,255,255)});
    int width= getCaretWidthPreference();
    int widthOffset= width - 1;
   
    // XXX: Filed request to get a caret with auto-height: https://bugs.eclipse.org/bugs/show_bug.cgi?id=118612   
    ImageData imageData= new ImageData(4 + widthOffset, styledText.getLineHeight(), 1, caretPalette);
View Full Code Here

     */   
    private ImageData readPlanarImage( PlanarImage image ) {
        ColorModel cm = image.getColorModel();
        int width = image.getWidth();
        int height = image.getHeight();
        PaletteData palette = null;
        ImageData imageData = null;
       
        // Image is indexed and has a palette.
        if ( cm instanceof IndexColorModel) {
           
            // Create SWT flavour palette from the colour model
            IndexColorModel icm = (IndexColorModel)cm;
            int colourCount = icm.getMapSize();
            byte[][] data = new byte[3][colourCount];
            icm.getReds(data[0]);
            icm.getGreens(data[1]);
            icm.getBlues(data[2]);
            RGB[] colours = new RGB[ colourCount ];
            for( int i = 0; i < colourCount; i++ ) {
                int red = data[0][i] & 0xFF;
                int green = data[1][i] & 0xFF;
                int blue = data[2][i] & 0xFF;
                colours[i] = new RGB( red, green, blue );               
            }
            palette = new PaletteData( colours );
           
            // Create indexed image           
            imageData = new ImageData( width, height,
                                       icm.getPixelSize(),
                                       palette );
                                      
            // Copy the pixel data
            copyIndexed( imageData, image.getData() );
           
        // Greyscale if 8 bits per pixel but not indexed           
        } else if( cm.getPixelSize() == 8 ) {             
            // Create greyscale palette
            RGB[] colours = new RGB[ 256 ];
            for( int i = 0; i < 256; i++ ) {
                colours[i] = new RGB( i, i, i );
            }
            palette = new PaletteData( colours );
           
            // Create greyscale image
            imageData = new ImageData( width, height, 8, palette );
           
            // Copy pixel data
            copyIndexed( imageData, image.getData() );
                                                 
        // Monochrome if 1 bit per pixel
        } else if( cm.getPixelSize() == 1 ) {
            // Create monochrome palette
            RGB[] colours = new RGB[ 2 ];
            colours[0] = new RGB( 255, 255, 255);
            colours[1] = new RGB( 0, 0, 0 );
            palette = new PaletteData( colours );

            // Create monochrome image
            imageData = new ImageData( width, height, 1, palette );
           
            // Copy pixel data
            copyIndexed( imageData, image.getData() );
           
        // True colour if 24 bits per pixel
        } else if( cm.getPixelSize() == 24 ) {
            palette = new PaletteData(0xFF0000, 0xFF00, 0xFF);
            imageData = new ImageData( width,height,24,palette );
            copyTrueColour( imageData, image.getData() );
        }
       
        // this will be null if we could not determine the type of
View Full Code Here

    AnnotationStyle style = editor.getAnnotationStyle(type);
    Color fg = new Color(Display.getCurrent(), 0, 0, 0);
    Color bg = new Color(Display.getCurrent(), style.getColor().getRed(), style.getColor()
            .getGreen(), style.getColor().getBlue());

    PaletteData paletteData = new PaletteData(new RGB[] { bg.getRGB(), fg.getRGB() });
    ImageData imageData = new ImageData(40, 40, 1, paletteData);

    Image image = new Image(Display.getCurrent(), imageData);
    GC gc = new GC(image);
View Full Code Here

        for (int i = 0; i < n; ++i)
            rgbs[i] = counters[i].rgb;
        if (mask != null) {
            rgbs[rgbs.length - 1] = data.transparentPixel != -1 ? data.palette.getRGB(data.transparentPixel) : new RGB(255, 255, 255);
        }
        PaletteData palette = new PaletteData(rgbs);

        // create a new image using the new palette:
        // for each pixel in the old image, look up the best matching
        // index in the new palette
        ImageData newData = new ImageData(width, data.height, 8, palette);
View Full Code Here

    }
    return ret;
  }

  private ImageDescriptor createImage(int color) {
    PaletteData pd = getPaletteData(color);
    return ImageDescriptor.createFromImageData(new ImageData(16, 16, 1, pd));
  }
View Full Code Here

      _rgb[14] = new RGB(0,128,128);//Teal
      _rgb[15] = new RGB(0,255,255);//Aqua
    }
    RGB[] rgbColor = new RGB[1];
    System.arraycopy(_rgb, color, rgbColor, 0, 1);
    return new PaletteData(rgbColor);
  }
View Full Code Here

                && (theme.isShowMenuImageShadow() && GraphicsUtil.checkGdip())
                && ((dc.getMenuItem().getStyle() & SWT.CHECK) == 0 && (dc
                    .getMenuItem().getStyle() & SWT.RADIO) == 0))
            {
              ImageData shadowImage = image.getImageData();
              PaletteData palette = new PaletteData(new RGB[] {
                  new RGB(0, 0, 0), new RGB(154, 156, 146) });
              ImageData data = new ImageData(shadowImage.width,
                  shadowImage.height, 1, palette);
              data.transparentPixel = shadowImage.transparentPixel;
              if (shadowImage.getTransparencyType() == SWT.TRANSPARENCY_PIXEL)
              {
                for (int pixelX = 0; pixelX < shadowImage.width; pixelX++)
                {
                  for (int pixelY = 0; pixelY < shadowImage.width; pixelY++)
                  {
                    int dstPixel = shadowImage.getPixel(pixelX, pixelY);
                    if (dstPixel != shadowImage.transparentPixel)
                    {
                      data.setPixel(pixelX, pixelY, 1);
                    }
                    else
                      data.setPixel(pixelX, pixelY, 0);

                  }
                }
                boolean advanced = g.getAdvanced();
                if (!advanced)
                {
                  g.setAdvanced(true);
                }
                Image tempImage = new Image(g.getDevice(), data);
                g.drawImage(tempImage, x + 1, y + 1);
                tempImage.dispose();
                g.setAdvanced(advanced);
                g.drawImage(image, x - 1, y - 1);
              }
              else
              {
                g.drawImage(image, x, y);
              }
            }
            else
            {
              if (theme.isShowMenuImageShadow() && GraphicsUtil.checkGdip())
              {
                RGB[] rgbs = image.getImageData().palette.getRGBs();
                if (rgbs != null)
                {
                  for (int i = 0; i < rgbs.length; i++)
                  {
                    RGB rgb = rgbs[i];
                    rgb.red = (rgb.red + 76)
                        - (((rgb.red + 32) / 64) * 19);
                    rgb.green = (rgb.green + 76)
                        - (((rgb.green + 32) / 64) * 19);
                    rgb.blue = (rgb.blue + 76)
                        - (((rgb.blue + 32) / 64) * 19);
                  }
                  ImageData shadowImage = image.getImageData();
                  ImageData data = new ImageData(shadowImage.width,
                      shadowImage.height, shadowImage.depth,
                      new PaletteData(rgbs));
                  data.transparentPixel = shadowImage.transparentPixel;
                  for (int pixelX = 0; pixelX < shadowImage.width; pixelX++)
                  {
                    for (int pixelY = 0; pixelY < shadowImage.width; pixelY++)
                    {
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.