/** * Decorates the image with the given overlay * @param image * @param overlay * @return the decorated image */ public static Image getDecoratedImage(final Image image, final ImageDescriptor overlay) { Image decoratedImage; // create one CompositeImageDescriptor cd = new CompositeImageDescriptor() { @Override protected Point getSize() { Rectangle bounds = image.getBounds(); return new Point(bounds.width, bounds.height); } @Override protected void drawCompositeImage(int width, int height) { drawImage(image.getImageData(), 0, 0); drawImage(overlay.getImageData(), 0, 0); } }; decoratedImage = cd.createImage(); return decoratedImage; }
private ImageData getZoomedImageData(ImageDataProvider srcProvider) { ImageData src = srcProvider.getImageData(compositeZoom); if (src == null) { ImageData src100 = srcProvider.getImageData(100); src = src100.scaledTo(autoScaleUp(src100.width), autoScaleUp(src100.height)); } return src; }
/** * Draws the given source image data into this composite image at the given * position. * <p> * Call this internal framework method to superimpose another image atop * this composite image. * </p> * * @param src * the source image data * @param ox * the x position * @param oy * the y position * @deprecated Use {@link #drawImage(ImageDataProvider, int, int)} instead. * Replace the code that created the ImageData by calls to * {@link #createCachedImageDataProvider(Image)} or * {@link #createCachedImageDataProvider(ImageDescriptor)} and * then pass on that provider instead of ImageData objects. * Replace references to {@link ImageData#width}/height by calls * to {@link CachedImageDataProvider#getWidth()}/getHeight(). */ @Deprecated final protected void drawImage(ImageData src, int ox, int oy) { if (src == null) { // wrong hack for https://bugs.eclipse.org/372956 , kept for compatibility with broken client code return; } drawImage(getUnzoomedImageDataProvider(src), ox, oy); }
@Override public ImageData getImageData(int zoom) { if (!supportsZoomLevel(zoom)) { return null; Point size = getSize(); imageData = new ImageData(scaleUp(size.x, zoom), scaleUp(size.y, zoom), 24, new PaletteData(0xFF, 0xFF00, 0xFF0000)); imageData.alphaData = new byte[imageData.width * imageData.height]; drawCompositeImage(size.x, size.y);
public ImageData getImageData() { Point size = getSize(); imageData.alphaData = new byte[imageData.width * imageData.height]; drawCompositeImage(size.x, size.y);
/** * Returns a computed value in SWT logical points. The given function * computes a value in pixels, based on information from the given * ImageData, which is also in pixels. This method must only * be called within the dynamic scope of a call to * {@link #drawCompositeImage(int, int)}. * * @param function * a function that takes an {@link ImageData} and computes a * value in pixels * @return the computed value in points */ public int computeInPoints(ToIntFunction<ImageData> function) { ImageData overlayData = getImageData(getZoomLevel()); if (overlayData != null) { int valueInPixels = function.applyAsInt(overlayData); return autoScaleDown(valueInPixels); } overlayData = getImageData(100); return function.applyAsInt(overlayData); } }
ImageData src = getZoomedImageData(srcProvider); for (int srcY = 0, dstY = srcY + autoScaleUp(oy); srcY < src.height; srcY++, dstY++) { for (int srcX = 0, dstX = srcX + autoScaleUp(ox); srcX < src.width; srcX++, dstX++) { if (!(0 <= dstX && dstX < dst.width && 0 <= dstY && dstY < dst.height)) continue; int srcPixel = src.getPixel(srcX, srcY);
@Override public ImageData getImageData() { Point size = getSize(); imageData.alphaData = new byte[imageData.width * imageData.height]; drawCompositeImage(size.x, size.y);
private Image getDecoratedImage(final Image image) { // check if we have a decorated image yet or not Image decoratedImage = decoratedImages.get(image); if (decoratedImage == null) { // create one CompositeImageDescriptor cd = new CompositeImageDescriptor() { @Override protected Point getSize() { Rectangle bounds = image.getBounds(); return new Point(bounds.width, bounds.height); } @Override protected void drawCompositeImage(int width, int height) { drawImage(image.getImageData(), 0, 0); drawImage(UIIcons.OVR_CHECKEDOUT.getImageData(), 0, 0); } }; decoratedImage = cd.createImage(); // store it decoratedImages.put(image, decoratedImage); } return decoratedImage; }
result = compositImageDesc.createImage(); decoratedMap.put(decorator, result);
result = compositImageDesc.createImage(); decoratedMap.put(decorator, result);
result = compositImageDesc.createImage(); decoratedMap.put(decorator, result);
useDefaultLocation.setLayoutData(data); Image virtualFolderImage = virtualFolderDescriptor.createImage(); useVirtualFolder.setLayoutData(data); Image linkedFolderImage = linkedFolderDescriptor.createImage();