Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.ImageData


    @Override
    protected void drawCompositeImage(int width, int height) {
        drawImage(_baseImage.getImageData(), 0, 0);
        Image overlayImage = Plugin.getDefault().getImageRegistry().get(Plugin.IMAGE_WORLD);
        ImageData overlayImageData = overlayImage.getImageData();
        int xValue = 5;
        int yValue = 0;
        drawImage (overlayImageData, xValue, yValue);       
    }
View Full Code Here


  {
    InputStream is = pi.getPluginClassLoader().getResourceAsStream( res);
   
    if ( is != null ){
           
      ImageData imageData = new ImageData(is);
     
      try {
        is.close();
      } catch (IOException e) {
        Debug.out(e);
View Full Code Here

      }
      stream = null;
      return img;
    }
   
    ImageData image_data = program.getImageData();
    if (image_data == null) {
      return getImage("image_not_found.png");
    }
    image_data = image_data.scaledTo(16, 16);
    Image image = new Image(SWTThread.getDisplay(),image_data);
    return image;
  }
View Full Code Here

  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

  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

    }
  }

  /* 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

          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

  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

    }
  }

  /* 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

   * @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

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.