Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.ImageLoader


      int width = bounds.width;
      int height = bounds.height;

      Image image = new Image(display, width, height);
      gc.copyArea(image, 0, 0);
      ImageLoader imageLoader = new ImageLoader();
      imageLoader.data = new ImageData[] { image.getImageData() };
      imageLoader.save(fileName, SWT.IMAGE_PNG);
      return true;
    } catch (Exception e) {
      return false;
    }
  }
View Full Code Here


    ImageData imdata = (ImageData) object;
    try {
      // write data to a byte array and then ask super to convert to pMedium
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      DataOutputStream writeOut = new DataOutputStream(out);
      ImageLoader loader = new ImageLoader();
      loader.data = new ImageData[] { imdata };
      loader.save(writeOut, SWT.IMAGE_BMP);
      writeOut.close();
      byte[] buffer = out.toByteArray();
      super.javaToNative(buffer, transferData);
      out.close();
    } catch (IOException e) {
View Full Code Here

      // Cache the filename.
      currentName = filename;
      fileName = filename;

      // Fill in array and loader data.
      loader = new ImageLoader();
      imageDataArray = new ImageData[] { imageData };
      loader.data = imageDataArray;

      // Display the image.
      imageDataIndex = 0;
View Full Code Here

      return;

    Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
    shell.setCursor(waitCursor);
    imageCanvas.setCursor(waitCursor);
    ImageLoader oldLoader = loader;
    try {
      loader = new ImageLoader();
      if (incremental) {
        // Prepare to handle incremental events.
        loader.addImageLoaderListener(new ImageLoaderListener() {
          public void imageDataLoaded(ImageLoaderEvent event) {
            incrementalDataLoaded(event);
View Full Code Here

      return;

    Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
    shell.setCursor(waitCursor);
    imageCanvas.setCursor(waitCursor);
    ImageLoader oldLoader = loader;
    try {
      URL url = new URL(urlname);
      InputStream stream = url.openStream();
      loader = new ImageLoader();
      if (incremental) {
        // Prepare to handle incremental events.
        loader.addImageLoaderListener(new ImageLoaderListener() {
          public void imageDataLoaded(ImageLoaderEvent event) {
            incrementalDataLoaded(event);
View Full Code Here

    animate = false; // stop any animation in progress
    Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
    shell.setCursor(waitCursor);
    imageCanvas.setCursor(waitCursor);
    try {
      loader = new ImageLoader();
      ImageData[] newImageData;
      if (fileName == null) {
        URL url = new URL(currentName);
        InputStream stream = url.openStream();
        long startTime = System.currentTimeMillis();
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

    static public BufferedImage loadImageFile(File file) throws IOException {
        return ImageIO.read(file);
    }

  public static byte[] imageToPNG(org.eclipse.swt.graphics.Image image) {
    ImageLoader loader = new ImageLoader();
    loader.data = new ImageData[] {image.getImageData()};
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    loader.save(stream, SWT.IMAGE_PNG);
    return stream.toByteArray();
  }
View Full Code Here

  Image image = new Image(Display.getDefault(), GRAPH_WIDTH, GRAPH_HEIGHT);
  p.paint(image);

  /* Downscale to 8 bit depth palette to save to gif */
  ImageData data = Utils.downSample(image);
  ImageLoader il = new ImageLoader();
  il.data = new ImageData[] { data };
  OutputStream out = null;
  try {
    out = new BufferedOutputStream(new FileOutputStream(outputFile));
    il.save(out, SWT.IMAGE_GIF);

  } catch (FileNotFoundException e) {
    e.printStackTrace();
  } finally {
    image.dispose();
View Full Code Here

      } catch (IOException e) {
          is = null;
      }
    }
    if (is != null) {
      loader = new ImageLoader();
      try {
        progressData = loader.load(is);
      } catch (IllegalArgumentException e) {
      }
      try {
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.