Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.ImageData


        // if(
        // image.getData().getDataBuffer().getDataType()==DataBuffer.TYPE_BYTE
        // && !image.getColorModel().hasAlpha() )
        // return createImageDataFromBytes(image);
        ImageData swtdata = null;
        int width = image.getWidth();
        int height = image.getHeight();
        PaletteData palette;
        int depth;

        depth = 24;
        palette = new PaletteData(0xFF0000, 0xFF00, 0xFF);
        swtdata = new ImageData(width, height, depth, palette);
        byte blueT = (byte) 255;
        byte greenT = (byte) 255;
        byte redT = (byte) 255;
        if (transparent) {
            swtdata.transparentPixel = TRANSPARENT;
View Full Code Here


     * Convert an SWT Image to a BufferedImage - this one rips the ImageData
     * out of the live Image; and then copies it into a BufferedImage.
     *
     */
    public static BufferedImage convertToAWT( Image image ){
        ImageData data = image.getImageData();
        return convertToAWT( data );
    }
View Full Code Here

     * @param height the height of the final image
     * @return an image with a depth of 24 and has a transparency channel.
     */
    public static Image createDefaultImage( Device device, int width, int height ) {
        AWTSWTImageUtils.checkAccess();
        ImageData swtdata = null;
        PaletteData palette;
        int depth;

        depth = 24;
        palette = new PaletteData(0xFF0000, 0xFF00, 0xFF);
        swtdata = new ImageData(width, height, depth, palette);
        swtdata.transparentPixel = -1;
        swtdata.alpha = -1;
        swtdata.alphaData = new byte[swtdata.data.length];
        for( int i = 0; i < swtdata.alphaData.length; i++ ) {
            swtdata.alphaData[i] = 0;
View Full Code Here

        return new Image(device, swtdata);

    }
    public static Image createDefaultImage( Display display, int width, int height ) {
        AWTSWTImageUtils.checkAccess();
        ImageData swtdata = null;
        PaletteData palette;
        int depth;
   
        depth = 24;
        palette = new PaletteData(0xFF0000, 0xFF00, 0xFF);
        swtdata = new ImageData(width, height, depth, palette);
        swtdata.transparentPixel = 0;
        //swtdata.transparentPixel = -1;
        swtdata.alpha = -1;
        swtdata.alphaData = new byte[swtdata.data.length];
        int j=2;
View Full Code Here

    }

    public static Image createSWTImage( RenderedImage image, boolean transparent ) {
        AWTSWTImageUtils.checkAccess();
       
        ImageData data;
        if( image instanceof BufferedImage ){
            data=AWTSWTImageUtils.createImageData((BufferedImage)image);
        }else
            data = AWTSWTImageUtils.createImageData(image, transparent);
   
View Full Code Here

    }

    public static ImageData createImageData( RenderedImage image, boolean transparent ) {
        AWTSWTImageUtils.checkAccess();
   
        ImageData swtdata = null;
        int width = image.getWidth();
        int height = image.getHeight();
        PaletteData palette;
        int depth;
   
        depth = 24;
        palette = new PaletteData(0xFF, 0xFF00, 0xFF0000);
        swtdata = new ImageData(width, height, depth, palette);
        Raster raster = image.getData();
        int numbands = raster.getNumBands();
        int[] awtdata = raster.getPixels(0, 0, width, height, new int[width * height * numbands]);
        int step = swtdata.depth / 8;
   
        byte[] data = swtdata.data;
        swtdata.transparentPixel = -1;
        int baseindex = 0;
        for( int y = 0; y < height; y++ ) {
            int idx = ((0 + y) * swtdata.bytesPerLine) + (0 * step);
   
            for( int x = 0; x < width; x++ ) {
                int pixel = (x + (y * width));
                baseindex = pixel * numbands;
   
                data[idx++] = (byte) awtdata[baseindex + 2];
                data[idx++] = (byte) awtdata[baseindex + 1];
                data[idx++] = (byte) awtdata[baseindex];
                if (numbands == 4 && transparent) {
                    swtdata.setAlpha(x, y, awtdata[baseindex + 3]);
                }
            }
        }
        return swtdata;
    }
View Full Code Here

     * @param image source image.
     * @return a swtimage showing the source image.
     */
    public static Image convertToSWTImage( BufferedImage image ) {
        AWTSWTImageUtils.checkAccess();
        ImageData data;
        data = AWTSWTImageUtils.createImageData(image);
       
        return new org.eclipse.swt.graphics.Image(Display.getDefault(), data);
    }
View Full Code Here

            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++) {
                for (int x = 0; x < width; x++) {
                    int pixel = image.getRGB(x, y);
                    int alpha_value = (pixel >> 24) & 0x000000FF;
                    data.setAlpha(x, y,  alpha_value );
                }
            }
            return data;
        }
        // else pixel by pixel
View Full Code Here

     * @param height the height of the final image
     * @return a swtimage showing the 0,0,width,height rectangle of the source image.
     */
    public static Image createSWTImage( RenderedImage image  ) {
        AWTSWTImageUtils.checkAccess();
        ImageData data = AWTSWTImageUtils.createImageData(image);
   
        return new org.eclipse.swt.graphics.Image(Display.getDefault(), data);
    }
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

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.