Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.ImageData


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

        Image image = image(display, new RGB[]{line.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


        return descriptor(imageData, image, gc);
    }

    public static void disable( ImageDescriptor descriptor ) {
        ImageData imageData = descriptor.getImageData();
        //PaletteData paletteData = imageData.palette;
       
        for( int i = 2; i < DEFAULT_WIDTH - 2; i++ ) {
            imageData.setPixel(i, i, 0);
        }
    }
View Full Code Here

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

        Image image = image(display, new RGB[]{line.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

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

        Image image = image(display, new RGB[]{line.getRGB(), 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

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

        Image image = image(display, new RGB[]{line.getRGB(), 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

                image = imageDescriptor.createImage();
                Rectangle bound = image.getBounds();
                if (bound.width == 16 && bound.height == 16) {
                    // perfect! it did what was expected!
                    //
                    final ImageData data = (ImageData) image.getImageData().clone();
                    return new ImageDescriptor(){
                        public ImageData getImageData() {
                            return (ImageData) data.clone();
                        }
                    };
                }
                if (bound.height < 16 || bound.width < 16) {
                    // the image is smaller than what we asked for
                    // perhaps we should display nothing?
                    // in stead we will try scaling it up
                    if (WmsPlugin.getDefault().isDebugging()) {
                        System.out.println("Icon scaled up to requested size"); //$NON-NLS-1$                                       
                    }
                    final ImageData data = image.getImageData().scaledTo(16, 16);
                    return new ImageDescriptor(){
                        public ImageData getImageData() {
                            return (ImageData) data.clone();
                        }
                    };
                }
                // the image is larger than the size we asked for
                // (so this WMS is not being nice!)
                // we will try and decide what to do here ...
                // let us select the image we want ...

                swatch = new Image(null, 16, 16);
                GC gc = new GC(swatch);
                int sy = 0; // (bound.height / 2 ) - 8;
                int sx = 0;
                int sw = 0;
                int sh = 0;
                ImageData contents = image.getImageData();
                if (contents == null) {
                    return CatalogUIPlugin.getDefault().getImageDescriptor(
                            ISharedImages.GRID_MISSING);
                }
                if (contents.maskData != null) {
                    // ((width + 7) / 8 + (maskPad - 1)) / maskPad * maskPad
                    int maskPad = contents.maskPad;
                    int scanLine = ((contents.width + 7) / 8 + (maskPad - 1)) / maskPad * maskPad;
                    // skip leading mask ...
                    SKIPY: for( int y = 0; y < contents.height / 2; y++ ) {
                        sy = y;
                        for( int x = 0; x < contents.width / 2; x++ ) {
                            int mask = contents.maskData[y * scanLine + x];
                            if (mask != 0)
                                break SKIPY;
                        }
                    }
                    SKIPX: for( int x = 0; x < contents.width / 2; x++ ) {
                        sx = x;
                        for( int y = sy; y < contents.height / 2; y++ ) {
                            int mask = contents.maskData[y * scanLine + x];
                            if (mask != 0)
                                break SKIPX;
                        }
                    }
                    sh = Math.min(contents.height - sy, 16);
                    sw = Math.min(contents.width - sx, 16);
                    if (WmsPlugin.getDefault().isDebugging())
                        System.out.println("Mask offset to " + sx + "x" + sy); //$NON-NLS-1$ //$NON-NLS-2$                       
                } else if (contents.alphaData != null) {
                    SKIPY: for( int y = 0; y < contents.height / 2; y++ ) {
                        sy = y;
                        for( int x = 0; x < contents.width / 2; x++ ) {
                            int alpha = contents.alphaData[y * contents.width + x];
                            if (alpha != 0)
                                break SKIPY;
                        }
                    }
                    SKIPX: for( int x = 0; x < contents.width / 2; x++ ) {
                        sx = x;
                        for( int y = sy; y < contents.height / 2; y++ ) {
                            int alpha = contents.alphaData[y * contents.width + x];
                            if (alpha != 0)
                                break SKIPX;
                        }
                    }
                    sh = Math.min(contents.height - sy, 16);
                    sw = Math.min(contents.width - sx, 16);
                    if (WmsPlugin.getDefault().isDebugging())
                        System.out.println("Alpha offset to " + sx + "x" + sy); //$NON-NLS-1$ //$NON-NLS-2$                       
                } else {
                    // try ignoring "white"
                    int depth = contents.depth;
                    int scanLine = contents.bytesPerLine;
                    SKIPY: for( int y = 0; y < contents.height / 2; y++ ) {
                        sy = y;
                        for( int x = 0; x < contents.width / 2; x++ ) {
                            int datum = contents.data[y * scanLine + x * depth];
                            if (datum != 0)
                                break SKIPY;
                        }
                    }
                    SKIPX: for( int x = 0; x < contents.width / 2; x++ ) {
                        sx = x;
                        for( int y = sy; y < contents.height / 2; y++ ) {
                            int datum = contents.data[y * scanLine + x * depth];
                            if (datum != 0)
                                break SKIPX;
                        }
                    }
                    sh = Math.min(contents.height - sy, 16);
                    sw = Math.min(contents.width - sx, 16);
                    if (WmsPlugin.getDefault().isDebugging())
                        System.out.println("Alpha offset to " + sx + "x" + sy); //$NON-NLS-1$ //$NON-NLS-2$                       
                }
                // else {
                // sh = Math.min( bound.height, bound.width );
                // sw = Math.min( bound.height, bound.width );
                // }
                if (WmsPlugin.getDefault().isDebugging())
                    System.out.println("Image resized to " + sh + "x" + sw); //$NON-NLS-1$ //$NON-NLS-2$

                // gc.drawImage(image, sx, sy, sw, sh, 0, 0, 16, 16);

                // chances are this has a label or category view or something
                // grab the gply from the bottom left corner and we are good to
                // (based on mapserver example)
                //
                gc.drawImage(image, 0, bound.height - 16, 16, 16, 0, 0, 16, 16);

                final ImageData data = (ImageData) swatch.getImageData().clone();
                return new ImageDescriptor(){
                    public ImageData getImageData() {
                        return (ImageData) data.clone();
                    }
                };
            } finally {
                if (image != null) {
                    image.dispose();
View Full Code Here

            return null;
        }
    }

    private static ImageData getImageData( InputStream in ) {
        ImageData result = null;
        if (in != null) {
            try {
                result = new ImageData(in);
            } catch (SWTException e) {
                if (e.code != SWT.ERROR_INVALID_IMAGE)
                    throw e;
                // fall through otherwise
            } finally {
View Full Code Here

        if (image == null) {
          return;
        }
        GC gc = event.gc;
        ImageData imageData = imageMetrics.getImageData();

        if (zoomFeedback != null) {
          zoomFeedback(gc, imageData);
        } else {
View Full Code Here

    this.imageMetrics.updateScrollValues(0, 0);

    // calculate the xscale and yscale so the image width or height will fit
    // the canvas size.
    ImageData imageData = this.imageMetrics.getImageData();

    float canvasHeight = this.canvas.getClientArea().height;
    float canvasWidth = this.canvas.getClientArea().width;
    float imageHeight = imageData.height;
    float imageWidth = imageData.width;
View Full Code Here

   * @param y
   *            Position in the canvas.
   */
  public void focusPosition(int x, int y) {

    ImageData imageData = this.imageMetrics.getImageData();
    int w = Math.round(imageData.width * this.imageMetrics.getScale());
    int h = Math.round(imageData.height * this.imageMetrics.getScale());
    Rectangle area = this.getCanvasClientArea();

    // first, calculate if any of the sides of the image can fit inside the
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.