Examples of ImageData


Examples of org.eclipse.swt.graphics.ImageData

  private Image getImage(String lExtension) {
    Program lProgram = ContentAssociation.getOSAssociation(lExtension);
    if (lProgram != null) {
      try {
        ImageData lData = lProgram.getImageData();
        if (lData != null) {
          return new Image(null, lData);
        }
      } catch (ArrayIndexOutOfBoundsException aio) {
        // CB TODO This is a SWT bug, have to report with SWT.
View Full Code Here

Examples of org.eclipse.swt.graphics.ImageData

  public static void storeImage(long id, byte[] bytes, ImageDescriptor defaultImage, int wHint, int hHint) {
    Assert.isNotNull(defaultImage);
    Assert.isLegal(wHint > 0);
    Assert.isLegal(hHint > 0);

    ImageData imgData = null;

    /* 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) {
        /* Ignore any Image-Format exceptions */
      } finally {
        if (inS != null) {
          try {
            inS.close();
          } catch (IOException e) {
            if (!(e instanceof MonitorCanceledException))
              Activator.getDefault().logError(e.getMessage(), e);
          }
        }
      }
    }

    /* Use default Image if img-data is null */
    if (imgData == null)
      imgData = defaultImage.getImageData();

    /* Save Image into Cache-Area on File-System */
    if (imgData != null) {
      File imageFile = getImageFile(id);
      if (imageFile == null)
        return;

      /* Scale if required */
      if (imgData.width != 16 || imgData.height != 16)
        imgData = imgData.scaledTo(16, 16);

      /* Try using native Image Format */
      try {
        if (storeImage(imgData, imageFile, imgData.type))
          return;
View Full Code Here

Examples of org.eclipse.swt.graphics.ImageData

    }
  }

  /* Returns the ImageData with best Depth or Size */
  private static ImageData getBestQuality(ImageData datas[], int wHint, int hHint) {
    ImageData bestSize = null;
    ImageData bestDepth = null;
    int maxDepth = -1;
    int maxSize = -1;

    /* Foreach Image: Check best Depth */
    for (ImageData data : datas) {
View Full Code Here

Examples of org.eclipse.swt.graphics.ImageData

          event.gc.setFont(font);
          int newX = 0, newY = 0;
          int fps = 0;

          int[] Frame = ((DataBufferInt) currentImage.getRaster().getDataBuffer()).getData();
          ImageData imgdata
            = new ImageData(currentImage.getWidth(), currentImage.getHeight(), 24,
                    new PaletteData(0xFF0000, 0x00FF00, 0x0000FF));
          imgdata.setPixels(0, 0, currentImage.getWidth() * currentImage.getHeight(), Frame, 0);

          if ((currentImage.getWidth() != cSize.x) || (currentImage.getHeight() != cSize.y)) {
            int sizeX = cSize.x, sizeY = cSize.y;
            event.gc.setInterpolation(SWT.HIGH);
            if (keepAspect) {
              if (((float) currentImage.getWidth() / (float) cSize.x)
                > ((float) currentImage.getHeight() / (float) cSize.y)) {
                sizeY = cSize.x * currentImage.getHeight() / currentImage.getWidth();
                newY = (cSize.y - sizeY) / 2;
              } else {
                sizeX = cSize.y * currentImage.getWidth() / currentImage.getHeight();
                newX = (cSize.x - sizeX) / 2;
              }
            }
            imgdata = imgdata.scaledTo(sizeX, sizeY);
          }

          if (alpha != event.gc.getAlpha()) {
            event.gc.setAlpha(alpha);
          }
View Full Code Here

Examples of org.eclipse.swt.graphics.ImageData

  public static void storeImage(long id, byte[] bytes, ImageDescriptor defaultImage, int wHint, int hHint) {
    Assert.isNotNull(defaultImage);
    Assert.isLegal(wHint > 0);
    Assert.isLegal(hHint > 0);

    ImageData imgData = null;

    /* 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) {
        /* Ignore any Image-Format exceptions */
      } finally {
        if (inS != null) {
          try {
            inS.close();
          } catch (IOException e) {
            Activator.getDefault().logError(e.getMessage(), e);
          }
        }
      }
    }

    /* Use default Image if img-data is null */
    if (imgData == null)
      imgData = defaultImage.getImageData();

    /* Save Image into Cache-Area on File-System */
    if (imgData != null) {
      File imageFile = getImageFile(id);

      /* Scale if required */
      if (imgData.width != 16 || imgData.height != 16)
        imgData = imgData.scaledTo(16, 16);

      /* Try using native Image Format */
      try {
        if (storeImage(imgData, imageFile, imgData.type))
          return;
View Full Code Here

Examples of org.eclipse.swt.graphics.ImageData

    }
  }

  /* Returns the ImageData with best Depth or Size */
  private static ImageData getBestQuality(ImageData datas[], int wHint, int hHint) {
    ImageData bestSize = null;
    ImageData bestDepth = null;
    int maxDepth = -1;
    int maxSize = -1;

    /* Foreach Image: Check best Depth */
    for (ImageData data : datas) {
View Full Code Here

Examples of org.eclipse.swt.graphics.ImageData

   * @param bytes
   * @param defaultImage
   */
  public static void storeImage(long id, byte[] bytes, ImageDescriptor defaultImage) {
    Assert.isNotNull(defaultImage);
    ImageData imgData = null;

    /* 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);
      } catch (SWTException e) {
        /* Ignore any Image-Format exceptions */
      } finally {
        if (inS != null) {
          try {
            inS.close();
          } catch (IOException e) {
            Activator.getDefault().logError(e.getMessage(), e);
          }
        }
      }
    }

    /* Use default Image if img-data is null */
    if (imgData == null)
      imgData = defaultImage.getImageData();

    /* Save Image into Cache-Area on File-System */
    if (imgData != null) {
      File imageFile = getImageFile(id);

      /* Scale if required */
      if (imgData.width != 16 || imgData.height != 16)
        imgData = imgData.scaledTo(16, 16);

      /* Try using native Image Format */
      try {
        if (storeImage(imgData, imageFile, imgData.type))
          return;
View Full Code Here

Examples of org.eclipse.swt.graphics.ImageData

    }
  }

  /* Returns the ImageData with best Depth or Size */
  private static ImageData getBestQuality(ImageData datas[]) {
    ImageData bestSize = null;
    ImageData bestDepth = null;
    int maxDepth = -1;
    int maxSize = -1;

    /* Foreach Image */
    for (ImageData data : datas) {
View Full Code Here

Examples of org.eclipse.swt.graphics.ImageData

    if (resourceBundle != null) {
      try {
        if (images == null) {
          images = new Image[imageLocations.length];
          for (int i = 0; i < imageLocations.length; ++i) {
            ImageData source = new ImageData(clazz
                .getResourceAsStream(imageLocations[i]));
            ImageData mask = source.getTransparencyMask();
            images[i] = new Image(null, source, mask);
          }
        }
        return;
      } catch (Throwable t) {
View Full Code Here

Examples of org.eclipse.swt.graphics.ImageData

  /**
   * @see CompositeImageDescriptor#getSize()
   */
  protected Point getSize() {
    if (fSize == null) {
      ImageData data= getBaseImage().getImageData();
      setSize(new Point(data.width, data.height));
    }
    return fSize;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.