Java 类org.eclipse.swt.graphics.ImageData 实例源码

项目:n4js    文件:N4JSDecoratorRow.java   
@Override
protected void drawCompositeImage(int ignoredWidth, int ignoredHeight) {
    // base image, possibly shifted to accommodate decorators
    drawImage(getMainData(), shiftFromLeft(), shiftFromTop());
    // row of decorators
    int x = marginFromLeft();
    final int y = marginFromTop();
    for (ImageData decoData : getDecosData()) {
        drawImage(decoData, x, y);
        x += decoData.width;
    }
}
项目:neoscada    文件:URLImageLabel.java   
private void processLoad ( final String stringUrl ) throws Exception
{
    final ImageLoader loader = new ImageLoader ();

    final URL url = new URL ( stringUrl );

    final ImageData[] data;
    try ( InputStream is = url.openStream () )
    {
        data = loader.load ( is );
    }

    logger.debug ( "Image loaded" );

    Display.getDefault ().asyncExec ( new Runnable () {
        @Override
        public void run ()
        {
            showImage ( stringUrl, data );
        }
    } );
}
项目:convertigo-eclipse    文件:ViewLabelDecorator.java   
protected void drawCompositeImage(int width, int height) {

            drawImage(mBase.getImageData(), 0, 0);

            ImageData imageData = mOverlay.getImageData();
            switch (mCorner) {
                case TOP_LEFT :
                    drawImage(imageData, 0, 0);
                    break;
                case TOP_RIGHT :
                    drawImage(imageData, mBase.getBounds().width - imageData.width, 0);
                    break;
                case BOTTOM_LEFT :
                    drawImage(imageData, 0, mBase.getBounds().height - imageData.height);
                    break;
                case BOTTOM_RIGHT :
                    drawImage(imageData, mBase.getBounds().width - imageData.width, mBase.getBounds().height - imageData.height);
                    break;
            }
        }
项目:convertigo-eclipse    文件:SchemaViewLabelDecorator.java   
protected void drawCompositeImage(int width, int height) {

            drawImage(mBase.getImageData(), 0, 0);

            ImageData imageData = mOverlay.getImageData();
            switch (mCorner) {
                case TOP_LEFT :
                    drawImage(imageData, 0, 0);
                    break;
                case TOP_RIGHT :
                    drawImage(imageData, mBase.getBounds().width - imageData.width, 0);
                    break;
                case BOTTOM_LEFT :
                    drawImage(imageData, 0, mBase.getBounds().height - imageData.height);
                    break;
                case BOTTOM_RIGHT :
                    drawImage(imageData, mBase.getBounds().width - imageData.width, mBase.getBounds().height - imageData.height);
                    break;
            }
        }
项目:convertigo-eclipse    文件:SWTX.java   
public static void drawShadowImage(GC gc, Image image, int x, int y,
    int alpha) {
  Display display = Display.getCurrent();
  Point imageSize = new Point(image.getBounds().width,
      image.getBounds().height);
  //
  ImageData imgData = new ImageData(imageSize.x, imageSize.y, 24,
      new PaletteData(255, 255, 255));
  imgData.alpha = alpha;
  Image img = new Image(display, imgData);
  GC imgGC = new GC(img);
  imgGC.drawImage(image, 0, 0);
  gc.drawImage(img, x, y);
  imgGC.dispose();
  img.dispose();
}
项目:AppleCommander    文件:SwtImage.java   
/**
 * Save the image.
 */
public void save(OutputStream outputStream) throws IOException {
    ImageLoader imageLoader = new ImageLoader();
    imageLoader.data = new ImageData[] { imageData };
    int format = SWT.IMAGE_PNG;
    if ("BMP".equals(getFileExtension())) { //$NON-NLS-1$
        format = SWT.IMAGE_BMP;
    } else if ("RLE".equals(getFileExtension())) { //$NON-NLS-1$
        format = SWT.IMAGE_BMP_RLE;
    } else if ("GIF".equals(getFileExtension())) { //$NON-NLS-1$
        format = SWT.IMAGE_GIF;
    } else if ("ICO".equals(getFileExtension())) { //$NON-NLS-1$
        format = SWT.IMAGE_ICO;
    } else if ("JPEG".equals(getFileExtension())) { //$NON-NLS-1$
        format = SWT.IMAGE_JPEG;
    } else if ("PNG".equals(getFileExtension())) { //$NON-NLS-1$
        format = SWT.IMAGE_PNG;
    }
    imageLoader.save(outputStream, format);
}
项目:applecommander    文件:SwtImage.java   
/**
 * Save the image.
 */
public void save(OutputStream outputStream) throws IOException {
    ImageLoader imageLoader = new ImageLoader();
    imageLoader.data = new ImageData[] { imageData };
    int format = SWT.IMAGE_PNG;
    if ("BMP".equals(getFileExtension())) { //$NON-NLS-1$
        format = SWT.IMAGE_BMP;
    } else if ("RLE".equals(getFileExtension())) { //$NON-NLS-1$
        format = SWT.IMAGE_BMP_RLE;
    } else if ("GIF".equals(getFileExtension())) { //$NON-NLS-1$
        format = SWT.IMAGE_GIF;
    } else if ("ICO".equals(getFileExtension())) { //$NON-NLS-1$
        format = SWT.IMAGE_ICO;
    } else if ("JPEG".equals(getFileExtension())) { //$NON-NLS-1$
        format = SWT.IMAGE_JPEG;
    } else if ("PNG".equals(getFileExtension())) { //$NON-NLS-1$
        format = SWT.IMAGE_PNG;
    }
    imageLoader.save(outputStream, format);
}
项目:pdi    文件:Interface.java   
private RGB encontraPixel(int x, int y, int indice) {

        labelPosicaoCor.setText(x + "," + y);

        ImageData imageData = null;
        PaletteData paletteData = null;

        if (indice == 1 && imagem1 != null) {
            imageData = imagem1.getImageData();
            paletteData = imageData.palette;
        } else if (indice == 2 && imagem2 != null) {
            imageData = imagem2.getImageData();
            paletteData = imageData.palette;
        } else if (indice == 3 && imagem3 != null) {
            imageData = imagem3.getImageData();
            paletteData = imageData.palette;
        }

        if (paletteData != null && x > -1 && y > -1) {
            int pixel = imageData.getPixel(x, y);
            RGB rgb = paletteData.getRGB(pixel);
            return rgb;
        }

        return null;
    }
项目:pandionj    文件:ColorImageWidget.java   
protected ImageData getImageData() {
    int[][] a = (int[][]) array;
    ImageData data = new ImageData(width, height, 24, palette);
    for(int y = 0; y < height; y++) {
        for(int x = 0; x < width; x++) {
            int v = a[y][x];
            int r = (v >> 16) & 0xFF;
            int g = (v >> 8) & 0xFF;
            int b = v & 0xFF;

            int pixel = 0;
            if(valid(r, g, b)) {
                pixel |= (redShift < 0 ? r << -redShift : r >>> redShift) & redMask;
                pixel |= (greenShift < 0 ? g << -greenShift : g >>> greenShift) & greenMask;
                pixel |= (blueShift < 0 ? b << -blueShift : b >>> blueShift) & blueMask;
            }
            //                  int pixel = valid(r,g,b) ? palette.getPixel(new RGB(r,g,b)) : palette.getPixel(new RGB(255, 0, 0));
            data.setPixel(x, y, pixel);
        }
    }
    return data;
}
项目:code    文件:AbstractOverlayIcon.java   
protected void drawCompositeImage(int width, int height) {
    ImageData base = getBaseImageData();
    drawImage(base, 0, 0);
    if (fOverlays != null) {
        if (fOverlays.length > 0) {
            drawTopRight(fOverlays[0]);
        }

        if (fOverlays.length > 1) {
            drawBottomRight(fOverlays[1]);
        }

        if (fOverlays.length > 2) {
            drawBottomLeft(fOverlays[2]);
        }

        if (fOverlays.length > 3) {
            drawTopLeft(fOverlays[3]);
        }
    }
}
项目:PhET    文件:SWTBenchTest.java   
private static Image loadImage(final Display display, final String name) {
    InputStream stream = null;
    try {
        stream = SWTBenchTest.class.getResourceAsStream(name);
        if (stream != null) {
            final ImageData imageData = new ImageData(stream);
            return new Image(display, imageData);
            // if (imageData != null) {
            // ImageData mask = imageData.getTransparencyMask();
            // return new Image(display, imageData, mask);
            // }

        }
    }
    catch (final Exception e) {
        throw new RuntimeException(e);
    }
    return null;
}
项目:workspacemechanic    文件:MechanicPopupTest.java   
public File copyWidgetToFile(Control control) throws IOException {
  File file = File.createTempFile("MechanicalPopupTest", "jpg");
  file.deleteOnExit();
  Point size = control.getSize();
  GC gc = new GC(control);
  Image image = null;
  try {
    image = new Image(control.getDisplay(), size.x, size.y);
    gc.copyArea(image, 0, 0);
    ImageLoader loader = new ImageLoader();
    loader.data = new ImageData[] {image.getImageData()};
    loader.save(file.getPath(), SWT.IMAGE_JPEG);
  } finally {
    gc.dispose();
    if (image != null) {
      image.dispose();
    }
  }
  return file;
}
项目:TuxGuitar-1.3.1-fork    文件:ImageWriter.java   
public static void write(ImageFormat format, String path, List<ImageData> pages) throws TGFileFormatException {
    try {
        for(int i = 0; i < pages.size() ; i ++ ) {
            OutputStream stream = new FileOutputStream(new File(path + File.separator + "page-" + i + format.getExtension() ));

            ImageLoader loader = new ImageLoader();
            loader.data = new ImageData[] { (ImageData)pages.get(i) };
            loader.save(stream, format.getFormat() );

            stream.flush();
            stream.close();
        }
    } catch (Throwable throwable) {
        throw new TGFileFormatException("Could not write song!.",throwable);
    }
}
项目:TuxGuitar-1.3.1-fork    文件:TGImageImpl.java   
public void applyTransparency( TGColor background ){
    RGB alpha = new RGB( background.getRed(), background.getGreen(), background.getBlue() );
    RGB none = new RGB((0xff ^ alpha.red),(0xff ^ alpha.green),(0xff ^ alpha.blue));

    Image srcImage = this.handle;
    ImageData srcData = srcImage.getImageData();
    ImageData maskData = new ImageData(srcData.width,srcData.height,1,new PaletteData(new RGB[]{ none,alpha }  ));
    for(int x = 0; x< maskData.width; x++) {
        for(int y = 0; y < maskData.height; y++) {
            RGB rgb = srcData.palette.getRGB(srcData.getPixel(x, y));
            if(rgb.red == alpha.red && rgb.green == alpha.green && rgb.blue == alpha.blue){
                maskData.setPixel(x, y, maskData.palette.getPixel(none));
            }else{
                maskData.setPixel(x, y, maskData.palette.getPixel(alpha));
            }
        }
    }
    this.handle = new Image(srcImage.getDevice(),srcData,maskData);

    srcImage.dispose();
}
项目:ermasterr    文件:InsertedImageEditPart.java   
/**
 * {@inheritDoc}
 */
@Override
protected IFigure createFigure() {
    final InsertedImage model = (InsertedImage) getModel();

    final byte[] data = Base64.decodeBase64((model.getBase64EncodedData().getBytes()));
    final ByteArrayInputStream in = new ByteArrayInputStream(data);

    imageData = new ImageData(in);
    changeImage();

    final InsertedImageFigure figure = new InsertedImageFigure(image, model.isFixAspectRatio(), model.getAlpha());
    figure.setMinimumSize(new Dimension(1, 1));

    return figure;
}
项目:xstreamer    文件:ImageViewSaveAsHandler.java   
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
    ImageView imageView = (ImageView) activePart;
    SWTImageCanvas imageCanvas = imageView.imageCanvas;
    if (imageCanvas == null) {
        return null;
    }

    Shell shell = HandlerUtil.getActiveShell(event);

    FileDialog dialog = new FileDialog(shell, SWT.SAVE);
    dialog.setFilterExtensions(new String[] { "*.png", "*.*" });
    dialog.setFilterNames(new String[] { "PNG Files", "All Files" });
    String fileSelected = dialog.open();

    if (fileSelected != null) {
        ImageLoader imageLoader = new ImageLoader();
        imageLoader.data = new ImageData[] { imageCanvas.getImageData() };

        System.out.println("Selected file: " + fileSelected);
        imageLoader.save(fileSelected, SWT.IMAGE_PNG);
    }

    return null;
}
项目:xstreamer    文件:AbstractImageSelectionListener.java   
protected void saveImage(String filename, ImageView imageView, int imageType) {
    IPreferenceStore store = us.nineworlds.xstreamer.Activator.getDefault().getPreferenceStore();
    String outputDirectory = store.getString(PreferenceConstants.TEMPLATE_XSTREAMER_XWING_OUTPUT_DIRECTORY);
    if (outputDirectory == null || imageView == null) {
        return;
    }

    ImageLoader imageLoader = new ImageLoader();
    imageLoader.data = new ImageData[] { imageView.imageCanvas.getImageData() };
    FileOutputStream outputStream = null;
    try {
        outputStream = new FileOutputStream(new File(outputDirectory, filename));
        imageLoader.save(outputStream, imageType);
    } catch (FileNotFoundException e) {
        Logger.error("Unable to save image to file: " + filename, e);
    } finally {
        IOUtils.closeQuietly(outputStream);
    }
}
项目:xstreamer    文件:SquadSelectionChangeListener.java   
private void saveImage(String filename, ImageView imageView) {
    IPreferenceStore store = us.nineworlds.xstreamer.Activator.getDefault().getPreferenceStore();
    String outputDirectory = store.getString(us.nineworlds.xstreamer.preferences.PreferenceConstants.TEMPLATE_XSTREAMER_XWING_OUTPUT_DIRECTORY);
    if (outputDirectory == null || imageView == null) {
        return;
    }
    ImageLoader imageLoader = new ImageLoader();
    imageLoader.data = new ImageData[] { imageView.imageCanvas.getImageData() };        
    FileOutputStream outputStream = null;
    try {
        outputStream = new FileOutputStream(new File(outputDirectory, filename));
        imageLoader.save(outputStream, SWT.IMAGE_PNG);
    } catch (IOException e) {
        Logger.error("Unable to save image to file: " + filename, e);
    } finally {
        IOUtils.closeQuietly(outputStream);
    }
}
项目:xstreamer    文件:AbstractImageSelectionListener.java   
protected void saveImage(String filename, ImageView imageView, int imageType) {
    IPreferenceStore store = us.nineworlds.xstreamer.ia.Activator.getDefault().getPreferenceStore();
    String outputDirectory = store.getString(PreferenceConstants.TEMPLATE_XSTREAMER_IA_OUTPUT_DIRECTORY);
    if (outputDirectory == null || imageView == null) {
        return;
    }

    ImageLoader imageLoader = new ImageLoader();
    imageLoader.data = new ImageData[] { imageView.imageCanvas.getImageData() };
    FileOutputStream outputStream = null;
    try {
        outputStream = new FileOutputStream(new File(outputDirectory, filename));
        imageLoader.save(outputStream, imageType);
    } catch (FileNotFoundException e) {
        Logger.error("Unable to save image to file: " + filename, e);
    } finally {
        IOUtils.closeQuietly(outputStream);
    }
}
项目:TranskribusSwtGui    文件:CanvasImage.java   
public void applyGamma(double gamma) {
        if (SWTUtil.isDisposed(img) /*|| SWTUtil.isDisposed(imgBackup)*/) {
            return;
        }

        if (true) { 
            logger.debug("this.gamma = "+this.gamma);   
            double scaledGamma = gamma / this.gamma;
            logger.debug("scaledGamma = "+scaledGamma);
            ImageData d = SWTUtil.multScalar(img.getImageData(), scaledGamma, true);

            logger.debug("disposing old image and creating new one with scaled image data...");
            img.dispose();
            img = new Image(Display.getDefault(), d);
        }
//      else {
//          logger.debug("gamma = "+gamma);
//          ImageData d = SWTUtil.multScalar(imgBackup.getImageData(), gamma, false);
//          SWTUtil.dispose(img);
//          img = new Image(Display.getDefault(), d);
//      }

        this.gamma = gamma;
    }
项目:TranskribusSwtGui    文件:SWTUtil.java   
public static ImageData convertToSWT2(BufferedImage bufferedImage) throws IOException {
//      /2) awt.BufferedImage -> raw Data
        java.awt.image.WritableRaster awtRaster = bufferedImage.getRaster();
        java.awt.image.DataBufferByte awtData = (DataBufferByte) awtRaster.getDataBuffer();
        byte[] rawData = awtData.getData();

        //3) raw Data -> swt.ImageData
        org.eclipse.swt.graphics.PaletteData swtPalette = new PaletteData(0xff, 0xff00, 0xff0000);

        int depth = 0x18;
        org.eclipse.swt.graphics.ImageData swtImageData = new ImageData(bufferedImage.getWidth(), bufferedImage.getHeight(), 
                depth, swtPalette, bufferedImage.getWidth(), rawData);

        return swtImageData;
//      return new Image(Display.getDefault(), swtImageData);       
    }
项目:mesfavoris    文件:IconImageDescriptor.java   
private ImageData loadImageData() {
    ImageData[] imageDatas;
    try {
        imageDatas = new ImageLoader().load(new ByteArrayInputStream(favIconBytes));
    } catch (SWTException e) {
        return null;
    }
    Optional<ImageData> optionalImageData = Arrays.stream(imageDatas).sorted((imageData1,
            imageData2) -> distanceFrom16x16ImageData(imageData1) - distanceFrom16x16ImageData(imageData2))
            .findFirst();
    if (!optionalImageData.isPresent()) {
        return null;
    }
    ImageData imageData = optionalImageData.get();
    if (imageData.width <= 16 && imageData.height <= 16) {
        return imageData;
    }
    return imageData.scaledTo(16, 16);
}
项目:mesfavoris    文件:ImageAssert.java   
public static void assertImageDataIs(ImageData expectedImageData,
        ImageData actualImageData) {
    if (expectedImageData.width != actualImageData.width
            || expectedImageData.height != actualImageData.height) {
        fail(MessageFormat
                .format(
                        "Image data do not have the same dimensions ({0}x{1} expected, got {2}x{3})",
                        expectedImageData.width, expectedImageData.height,
                        actualImageData.width, actualImageData.height));
    }

    for (int y = 0; y < expectedImageData.height; y++) {
        for (int x = 0; x < expectedImageData.width; x++) {
            int actualPixel = actualImageData.getPixel(x, y);
            int expectedPixel = expectedImageData.getPixel(x, y);
            RGB actualRGB = actualImageData.palette.getRGB(actualPixel);
            RGB expectedRGB = expectedImageData.palette
                    .getRGB(expectedPixel);
            if (!actualRGB.equals(expectedRGB)) {
                fail(MessageFormat.format(
                        "Image data do not match at ({0},{1})", x, y));
            }
        }
    }
}
项目:ermaster-k    文件:ImageUtils.java   
public static void drawAtBufferedImage(BufferedImage bimg, Image image,
        int x, int y) throws InterruptedException {

    ImageData data = image.getImageData();

    for (int i = 0; i < image.getBounds().width; i++) {

        for (int j = 0; j < image.getBounds().height; j++) {
            int tmp = 4 * (j * image.getBounds().width + i);

            if (data.data.length > tmp + 2) {
                int r = 0xff & data.data[tmp + 2];
                int g = 0xff & data.data[tmp + 1];
                int b = 0xff & data.data[tmp];

                bimg.setRGB(i + x, j + y, 0xFF << 24 | r << 16 | g << 8
                        | b << 0);
            }
        }
    }
}
项目:ermaster-k    文件:ChangeBackgroundColorAction.java   
private void setColorToImage() {
    ImageData imageData = ERDiagramActivator.getImageDescriptor(
            ImageKey.CHANGE_BACKGROUND_COLOR).getImageData();
    int blackPixel = imageData.palette.getPixel(new RGB(0, 0, 0));
    imageData.transparentPixel = imageData.palette.getPixel(new RGB(255,
            255, 255));
    imageData.palette.colors[blackPixel] = this.rgb;

    // if (this.image != null) {
    // this.image.dispose();
    // }
    this.image = new Image(Display.getCurrent(), imageData);

    ImageDescriptor descriptor = ImageDescriptor.createFromImage(image);
    this.setImageDescriptor(descriptor);
}
项目:code    文件:AbstractOverlayIcon.java   
protected void drawCompositeImage(int width, int height) {
    ImageData base = getBaseImageData();
    drawImage(base, 0, 0);
    if (fOverlays != null) {
        if (fOverlays.length > 0) {
            drawTopRight(fOverlays[0]);
        }

        if (fOverlays.length > 1) {
            drawBottomRight(fOverlays[1]);
        }

        if (fOverlays.length > 2) {
            drawBottomLeft(fOverlays[2]);
        }

        if (fOverlays.length > 3) {
            drawTopLeft(fOverlays[3]);
        }
    }
}
项目:code    文件:AbstractOverlayIcon.java   
protected void drawCompositeImage(int width, int height) {
    ImageData base = getBaseImageData();
    drawImage(base, 0, 0);
    if (fOverlays != null) {
        if (fOverlays.length > 0) {
            drawTopRight(fOverlays[0]);
        }

        if (fOverlays.length > 1) {
            drawBottomRight(fOverlays[1]);
        }

        if (fOverlays.length > 2) {
            drawBottomLeft(fOverlays[2]);
        }

        if (fOverlays.length > 3) {
            drawTopLeft(fOverlays[3]);
        }
    }
}
项目:ether    文件:GIFAccess.java   
public GIFAccess(URLVideoSource src, int numPlays) throws IOException, URISyntaxException {
    super(src, numPlays);
    ImageLoader loader = new ImageLoader();
    ImageData[] images = loader.load(src.getURL().openStream());
    for(int i = 0; i < images.length; i++) {
        width  = Math.max(width,  images[i].x + images[i].width); 
        height = Math.max(height, images[i].y + images[i].height); 
    }
    nClips = images[0].delayTime - 10;
    if (nClips > 0 && images.length > (nClips * 2 + 1))
        shotStarts = new int[nClips];
    else
        nClips = 1;
    for(int i = 0; i < images.length; i++)
        frames.add(convert(i, i == 0 ? null : frames.get(i-1), images[i]));
    if(shotStarts != null) {
        duration /= nClips * 1000.0;
        duration *= images.length;
    }
    if(shotStarts != null)
        for(int i = 1; i < shotStarts.length; i++)
            shotStarts[i] += shotStarts[i-1];
}
项目:ether    文件:GIFAccess.java   
private IHostImage convert(int idx, IHostImage previous, ImageData imageData) {
    if(shotStarts != null) {
        int clip = (idx - 1) / 2;
        if(clip >= 0 && clip < nClips) {
            if(((idx - 1) & 1) == 0) 
                shotStarts[clip] = imageData.delayTime;
            else
                duration += imageData.delayTime;
        }
    } else
        duration += imageData.delayTime / 1000.0;
    IHostImage result = previous == null ? IHostImage.create(width, height, ComponentType.BYTE, ComponentFormat.RGB) : previous.copy();
    for(int y = imageData.height; --y >= 0;)
        for(int x = imageData.width; --x >= 0;) {
            int pixel = imageData.getPixel(x, y);
            if(pixel == imageData.transparentPixel) continue;
            RGB srcrgb = imageData.palette.getRGB(pixel);
            rgb[0] = (byte) srcrgb.red;
            rgb[1] = (byte) srcrgb.green;
            rgb[2] = (byte) srcrgb.blue;
            result.setPixel(x+imageData.x, height-(y+imageData.y+1), rgb);
        }
    return result;
}
项目:ether    文件:Bouncelet.java   
public Image getControllerImage(Display display) {
    if(ctrlImage == null) {
        ImageData img = new ImageData(48, 48, 32, RGB_PALETTE);
        for(int y = 0; y < 40; y++)
            for(int x = 0; x < 48; x++) {
                int col = x / 6;
                int row = y / 5;
                int id  = (row * 8) + col; 
                if(x % 6 < 5 && y % 5 < 4) {
                    img.setAlpha(x, y+4, 255);
                    if(id == this.id)   img.setPixel(x, y+4, color.toARGB32());
                    else                img.setPixel(x, y+4, 0x444444);
                } else img.setAlpha(x, y+4, 0);
            }
        ctrlImage = new Image(display, img);
    }
    return ctrlImage;
}
项目:Sensors    文件:SWTResourceManager.java   
/**
 * Returns an {@link Image} encoded by the specified {@link InputStream}.
 * 
 * @param stream
 *            the {@link InputStream} encoding the image data
 * @return the {@link Image} encoded by the specified input stream
 */
protected static Image getImage(InputStream stream) throws IOException {
    try {
        Display display = Display.getCurrent();
        ImageData data = new ImageData(stream);
        if (data.transparentPixel > 0) {
            return new Image(display, data, data.getTransparencyMask());
        }
        return new Image(display, data);
    } finally {
        stream.close();
    }
}
项目:n4js    文件:N4JSDecoratorRow.java   
/**
 * This method initializes a field on demand, given that each invocation of the delegate allocates anew.
 */
private ImageData getMainData() {
    if (null == mainData) {
        mainData = main.getImageData();
    }
    return mainData;
}
项目:n4js    文件:N4JSDecoratorRow.java   
/**
 * This method initializes a field on demand, given that each invocation of the delegate allocates anew.
 */
private ImageData[] getDecosData() {
    if (null == decosData) {
        decosData = new ImageData[decos.length];
        for (int i = 0; i < decosData.length; i++) {
            decosData[i] = decos[i].getImageData();
        }
    }
    return decosData;
}
项目:n4js    文件:N4JSDecoratorRow.java   
/**
 * @return Summation over the width of each decorator.
 */
private int getDecosWidth() {
    int result = 0;
    for (ImageData dd : getDecosData()) {
        result += dd.width;
    }
    return result;
}
项目:n4js    文件:N4JSDecoratorRow.java   
/**
 * @return The maximum height over all decorators.
 */
private int getDecosHeight() {
    int result = 0;
    for (ImageData dd : getDecosData()) {
        result = Math.max(result, dd.height);
    }
    return result;
}
项目:AgentWorkbench    文件:SWTResourceManager.java   
/**
 * Returns an {@link Image} encoded by the specified {@link InputStream}.
 * 
 * @param stream
 *            the {@link InputStream} encoding the image data
 * @return the {@link Image} encoded by the specified input stream
 */
protected static Image getImage(InputStream stream) throws IOException {
    try {
        Display display = Display.getCurrent();
        ImageData data = new ImageData(stream);
        if (data.transparentPixel > 0) {
            return new Image(display, data, data.getTransparencyMask());
        }
        return new Image(display, data);
    } finally {
        stream.close();
    }
}
项目:neoscada    文件:URLImageLabel.java   
protected void showImage ( final String url, final ImageData[] data )
{
    if ( isDisposed () || getDisplay ().isDisposed () )
    {
        return;
    }

    if ( data == null || data.length <= 0 )
    {
        logger.info ( "No image data" );
        return;
    }

    synchronized ( this )
    {
        if ( url.equals ( this.currentUrl ) )
        {
            if ( this.currentImage != null )
            {
                this.currentImage.dispose ();
            }
            this.currentImage = new Image ( getDisplay (), data[0] );
            this.label.setImage ( this.currentImage );
        }
        else
        {
            logger.warn ( "Image url changed - current: {}, our: {}", this.currentUrl, url );
        }
    }
}
项目:avoCADo    文件:ImageUtils.java   
public static Image getIcon(String filename, int width, int height){
    int ICON_WIDTH  = width;
    int ICON_HEIGHT = height;

    File test = new File(ICON_DIR + filename);
    if(test.isFile() != true){
        filename = "no-image.png";
    }
    Image tempImage = new Image(Display.getCurrent(), ICON_DIR + filename);
    ImageData id = tempImage.getImageData().scaledTo(ICON_WIDTH,ICON_HEIGHT);
    return new Image(Display.getCurrent(),id);
}
项目:scanning    文件:Activator.java   
public static ImageDescriptor getImageDescriptor(String path) {
    if (plugin==null) {
        final ImageData data = new ImageData("../"+PLUGIN_ID+"/"+path);
        return new ImageDescriptor() {
            @Override
            public ImageData getImageData() {
                return data;
            }
        };
    }
    return imageDescriptorFromPlugin(PLUGIN_ID, path);
}
项目:Open_Source_ECOA_Toolset_AS5    文件:ImageSaveUtil.java   
private static void saveEditorContentsAsImage(IEditorPart editorPart, GraphicalViewer viewer, String saveFilePath, int format) {

        ScalableFreeformRootEditPart rootEditPart = (ScalableFreeformRootEditPart) viewer.getEditPartRegistry().get(LayerManager.ID);
        IFigure rootFigure = ((LayerManager) rootEditPart).getLayer(LayerConstants.PRINTABLE_LAYERS);// rootEditPart.getFigure();
        Rectangle rootFigureBounds = rootFigure.getBounds();

        Control figureCanvas = viewer.getControl();
        GC figureCanvasGC = new GC(figureCanvas);

        Image img = new Image(null, rootFigureBounds.width, rootFigureBounds.height);
        GC imageGC = new GC(img);
        imageGC.setBackground(figureCanvasGC.getBackground());
        imageGC.setForeground(figureCanvasGC.getForeground());
        imageGC.setFont(figureCanvasGC.getFont());
        imageGC.setLineStyle(figureCanvasGC.getLineStyle());
        imageGC.setLineWidth(figureCanvasGC.getLineWidth());
        imageGC.setXORMode(figureCanvasGC.getXORMode());
        Graphics imgGraphics = new SWTGraphics(imageGC);

        rootFigure.paint(imgGraphics);

        ImageData[] imgData = new ImageData[1];
        imgData[0] = img.getImageData();

        ImageLoader imgLoader = new ImageLoader();
        imgLoader.data = imgData;
        imgLoader.save(saveFilePath, format);

        figureCanvasGC.dispose();
        imageGC.dispose();
        img.dispose();
    }