Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.ImageLoader


* @param image
*/
public static void saveImage(File outputFile, Image image) {
  // Save image
  ImageData data = downSample(image);
  ImageLoader imageLoader = new ImageLoader();
  imageLoader.data = new ImageData[] { data };

  OutputStream out = null;
  try {
    out = new BufferedOutputStream(new FileOutputStream(outputFile));
    imageLoader.save(out, SWT.IMAGE_GIF);
  } catch (FileNotFoundException e) {
    e.printStackTrace();
  } finally {
    image.dispose();
    if (out != null) {
View Full Code Here


* @param image
*/
private void saveImage(File outputFile, Image image) {
  // Save image
  ImageData data = Utils.downSample(image);
  ImageLoader imageLoader = new ImageLoader();
  imageLoader.data = new ImageData[] { data };

  OutputStream out = null;
  try {
    out = new BufferedOutputStream(new FileOutputStream(outputFile));
    imageLoader.save(out, SWT.IMAGE_GIF);
  } catch (FileNotFoundException e) {
    e.printStackTrace();
  } finally {
    image.dispose();
    if (out != null) {
View Full Code Here

    ImageData imageData = descriptor.getImageData();
    if (imageData == null) {
      return null;
    }

    ImageLoader loader = new ImageLoader();
    loader.data = new ImageData[] { imageData };
    loader.save(imageFile.getAbsolutePath(), SWT.IMAGE_PNG);

    try {
      url = imageFile.toURI().toURL();
      fURLMap.put(descriptor, url);
      return url;
View Full Code Here

    /* Bytes Provided */
    if (bytes != null && bytes.length > 0) {
      ByteArrayInputStream inS = null;
      try {
        inS = new ByteArrayInputStream(bytes);
        ImageLoader loader = new ImageLoader();
        ImageData[] imageDatas = loader.load(inS);

        /* Look for the Icon with the best quality */
        if (imageDatas != null)
          imgData = getBestQuality(imageDatas, wHint, hHint);
      } catch (SWTException e) {
View Full Code Here

    return (bestDepth != null) ? bestDepth : bestSize;
  }

  /* Saves the Image to the given File with the given Image-Format */
  private static boolean storeImage(ImageData imgData, File file, int format) {
    ImageLoader loader = new ImageLoader();
    loader.data = new ImageData[] { imgData };
    FileOutputStream fOs = null;
    try {
      fOs = new FileOutputStream(file);
      loader.save(fOs, format);
    } catch (FileNotFoundException e) {
      Activator.getDefault().logError(e.getMessage(), e);
    } finally {
      if (fOs != null)
        try {
View Full Code Here

    private Image internalCreateImage(boolean returnMissingImageOnError, Device device) {
      try {
        if (Application.IS_LINUX) //Use native loading on Linux to support alpha in ICO
          return new Image(device, fFaviconFile.toString());

        ImageLoader loader = new ImageLoader();
        ImageData[] datas = loader.load(fFaviconFile.toString());
        if (datas != null && datas.length > 0)
          return new Image(device, datas[0]);
      } catch (SWTException e) {
        //Fallback to alternative method to load Image
      } catch (SWTError error) {
View Full Code Here

        }
        final ImageData contents = (ImageData) clipboard.getContents((Transfer) ImageTransferWrapper
            .getInstance());
        if (contents != null) {

          final ImageLoader imageLoader = new ImageLoader();

          imageLoader.data = new ImageData[] { contents };
          imageLoader.logicalScreenHeight = contents.height;
          imageLoader.logicalScreenWidth = contents.width;
          final NameEndExtensionDialog dialog = new NameEndExtensionDialog(Display.getCurrent()
View Full Code Here

    try {
      log.debug(MessageFormat.format("Capturing screenshot ''{0}''", fileName)); //$NON-NLS-1$

      image = new Image(display, bounds.width, bounds.height);
      gc.copyArea(image, bounds.x, bounds.y);
      ImageLoader imageLoader = new ImageLoader();
      imageLoader.data = new ImageData[] { image.getImageData() };
      imageLoader.save(fileName, new ImageFormatConverter().imageTypeOf(fileName.substring(fileName.lastIndexOf('.') + 1)));
      return true;
    } catch (Exception e) {
      log.warn("Could not capture screenshot: " + fileName + "'", e); //$NON-NLS-1$ //$NON-NLS-2$
      File brokenImage = file.getAbsoluteFile();
      if (brokenImage.exists()) {
View Full Code Here

    paintEvent.width = canvas.getSize().x;
    paintEvent.height = canvas.getSize().y;
    paintEvent.widget = canvas;
    paintEvent.display = canvas.getDisplay();
    canvas.notifyListeners(SWT.Paint, paintEvent);
    ImageLoader loader = new ImageLoader();
    loader.data = new ImageData[] { image.getImageData() };
    int imageType = SWT.IMAGE_PNG;
    switch (selected.getFileType()) {
      case PNG: imageType = SWT.IMAGE_PNG; break;
      case JPG: imageType = SWT.IMAGE_JPEG; break;
    }
    loader.save(selected.getFilePath(), imageType);
    gc.dispose();
    image.dispose();
  }
View Full Code Here

          graphicalViewer.deselectAll();
          rootFigure.paint(grap);
        }
      });

      ImageLoader imgLoader = new ImageLoader();
      imgLoader.data = new ImageData[] { img.getImageData() };

      ByteArrayOutputStream baos = new ByteArrayOutputStream(imgLoader.data.length);

      imgLoader.save(baos, SWT.IMAGE_PNG);

      imageGC.dispose();
      img.dispose();

      // Access UI thread from runnable
View Full Code Here

TOP

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

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.