Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.ImageData


   */
  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;
    if (src != null) {
      maskDepth = Math.max(maskDepth, getTransparencyDepth(src));
      Image img = new Image(device, src);
      gc.drawImage(img, 0, 0);
      img.dispose();
    }
    src = base;
    if (base != null) {
      maskDepth = Math.max(maskDepth,
          baseMaskDepth = getTransparencyDepth(src));
      Image img = new Image(device, src);
      gc.drawImage(img, 0, 0);
      img.dispose();
    }
    ImageData topLeft = src = overlay[TOP_LEFT];
    if (src != null) {
      maskDepth = Math.max(maskDepth, getTransparencyDepth(src));
      Image img = new Image(device, src);
      gc.drawImage(img, 0, 0);
      img.dispose();
    }
    ImageData topRight = src = overlay[TOP_RIGHT];
    if (src != null) {
      maskDepth = Math.max(maskDepth, getTransparencyDepth(src));
      Image img = new Image(device, src);
      gc.drawImage(img, base.width - src.width, 0);
      img.dispose();
    }
    ImageData bottomLeft = src = overlay[BOTTOM_LEFT];
    if (src != null) {
      maskDepth = Math.max(maskDepth, getTransparencyDepth(src));
      Image img = new Image(device, src);
      gc.drawImage(img, 0, base.height - src.height);
      img.dispose();
    }
    ImageData bottomRight = src = overlay[BOTTOM_RIGHT];
    if (src != null) {
      maskDepth = Math.max(maskDepth, getTransparencyDepth(src));
      Image img = new Image(device, src);
      gc.drawImage(img, base.width - src.width, base.height - src.height);
      img.dispose();
    }
    gc.dispose();
    if (baseMaskDepth > 0) {
      ImageData newData = image.getImageData();
      image.dispose();
      ImageData mask = null;
      switch (maskDepth) {
      case 1:
        mask = new ImageData(base.width, base.height, maskDepth,
            BW_PALETTE);
        break;
      case 8:
        mask = new ImageData(base.width, base.height, maskDepth,
            ALPHA_PALETTE, base.width, new byte[base.width
                * base.height]);
        break;
      }
      src = getTransparency(underlay, maskDepth);
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++]);
            }
          }
          bni.image = new Image(null, imageData);
          currentPixel += pos;
        } catch(Throwable t) {
View Full Code Here

        GC maskgc = new GC(viewMenuMask);
        drawViewMenu(gc, maskgc);
        gc.dispose();
        maskgc.dispose();
       
        ImageData data = viewMenu.getImageData();
        data.transparentPixel = data.getPixel(0,0);
       
        Image vm2 = new Image(d, viewMenu.getImageData(), viewMenuMask.getImageData());
        viewMenu.dispose();
        viewMenuMask.dispose();
               
View Full Code Here

    /* (non-Javadoc)
     * @see org.eclipse.jface.resource.CompositeImageDescriptor#drawCompositeImage(int, int)
     */
    protected void drawCompositeImage(int width, int height) {
        ImageData bg;
        if (fBase == null || (bg = fBase.getImageData()) == null) {
      bg = DEFAULT_IMAGE_DATA;
    }
        drawImage(bg, 0, 0);

View Full Code Here

    protected void drawTopRight(ImageDescriptor overlay) {
        if (overlay == null) {
      return;
    }
        int x = getSize().x;
        ImageData id = overlay.getImageData();
        x -= id.width;
        drawImage(id, x, 0);
    }
View Full Code Here

                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

      new RGB [] {
        new RGB (0, 0, 0),
        new RGB (red, green, blue),
        new RGB (0xFF, 0xFF, 0xFF),
      });
    ImageData maskData = new ImageData (1, height, 2, palette);
    for (int y=0; y < height; y++)
      maskData.setPixel(0, y, 1);
    Image image = new Image (display, maskData);
    caret.setImage(image);
    control.setCaret(caret);
  }
View Full Code Here

    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

        return new Image(display, imageData);
    }

    private static ImageDescriptor descriptor( ImageData imageData, Image image, GC gc ) {
        final ImageData finalImageData = (ImageData) image.getImageData().clone();

        image.dispose();
        gc.dispose();

        return new ImageDescriptor(){
View Full Code Here

        Color back = display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);

        Image image = image(display, new RGB[]{fill.getRGB(), back.getRGB()});
        GC gc = new GC(image);

        ImageData imageData = image.getImageData();
        int w = imageData.width;
        int h = imageData.height;

        gc.setBackground(back);
        gc.fillRectangle(0, 0, w, h);
View Full Code Here

TOP

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

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.