Search in sources :

Example 86 with ImageData

use of org.eclipse.swt.graphics.ImageData in project tdi-studio-se by Talend.

the class StatusConfirmSettingDialog method getItemsImage.

private Image getItemsImage(IImage iImage) {
    if (iImage == null) {
        iImage = EImage.DEFAULT_IMAGE;
    }
    Image image = cacheItemImages.get(iImage);
    if (image == null) {
        Image oImage = ImageProvider.getImage(iImage);
        ImageData imageData = oImage.getImageData();
        // enlarge image
        final int larger = 4;
        ImageData newData = imageData.scaledTo(imageData.width + larger, imageData.height + larger);
        image = new Image(oImage.getDevice(), newData);
        cacheItemImages.put(iImage, image);
    }
    return image;
}
Also used : ImageData(org.eclipse.swt.graphics.ImageData) IImage(org.talend.commons.ui.runtime.image.IImage) Image(org.eclipse.swt.graphics.Image) EImage(org.talend.commons.ui.runtime.image.EImage)

Example 87 with ImageData

use of org.eclipse.swt.graphics.ImageData in project tdi-studio-se by Talend.

the class AbstractVersionManagementProjectSettingPage method getItemsImage.

protected Image getItemsImage(IImage iImage) {
    if (iImage == null) {
        iImage = EImage.DEFAULT_IMAGE;
    }
    Image image = cacheItemImages.get(iImage);
    if (image == null) {
        Image oImage = ImageProvider.getImage(iImage);
        ImageData imageData = oImage.getImageData();
        // enlarge image
        final int larger = 4;
        ImageData newData = imageData.scaledTo(imageData.width + larger, imageData.height + larger);
        image = new Image(oImage.getDevice(), newData);
        cacheItemImages.put(iImage, image);
    }
    return image;
}
Also used : ImageData(org.eclipse.swt.graphics.ImageData) IImage(org.talend.commons.ui.runtime.image.IImage) Image(org.eclipse.swt.graphics.Image) EImage(org.talend.commons.ui.runtime.image.EImage)

Example 88 with ImageData

use of org.eclipse.swt.graphics.ImageData in project tdi-studio-se by Talend.

the class AttributeLabelProvider method getWriteOverlayImage.

/**
     * Gets the write overlay image.
     * 
     * @return The write overlay image
     */
private Image getWriteOverlayImage() {
    if (writeOverlayImage == null || writeOverlayImage.isDisposed()) {
        ImageDescriptor[] descriptors = new ImageDescriptor[] { null, null, null, null };
        descriptors[IDecoration.TOP_RIGHT] = Activator.getImageDescriptor(ISharedImages.WRITE_OVR_IMG_PATH);
        ImageData imageData = Activator.getImageDescriptor(ISharedImages.ATTRIBUTE_IMG_PATH).getImageData();
        writeOverlayImage = new OverlayImageDescriptor(imageData, descriptors, new Point(IMAGE_WIDTH, 16)).createImage();
    }
    return writeOverlayImage;
}
Also used : ImageData(org.eclipse.swt.graphics.ImageData) CompositeImageDescriptor(org.eclipse.jface.resource.CompositeImageDescriptor) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) Point(org.eclipse.swt.graphics.Point)

Example 89 with ImageData

use of org.eclipse.swt.graphics.ImageData in project tdi-studio-se by Talend.

the class HTMLDocGenerator method saveLogoImage.

protected void saveLogoImage(int type, File file) throws IOException {
    boolean documentationPluginLoaded = PluginChecker.isDocumentationPluginLoaded();
    // get image from cache
    ByteArrayOutputStream result = logoImageCache.get(type);
    if (documentationPluginLoaded) {
        String userLogoPath = CorePlugin.getDefault().getPreferenceStore().getString(ITalendCorePrefConstants.DOC_USER_LOGO);
        if (userLogoPath != null && !"".equals(userLogoPath)) {
            //$NON-NLS-1$
            if (result == null || !userLogoPath.equals(userDocImageOldPath)) {
                userDocImageOldPath = userLogoPath;
                result = new ByteArrayOutputStream(3072);
                File userLogo = new File(userLogoPath);
                if (userLogo.exists()) {
                    Image image = new Image(Display.getCurrent(), userLogoPath);
                    ImageLoader imageLoader = new ImageLoader();
                    imageLoader.data = new ImageData[] { image.getImageData() };
                    imageLoader.save(result, type);
                    logoImageCache.put(type, result);
                    image.dispose();
                }
            }
            FileOutputStream fos = new FileOutputStream(file);
            fos.write(result.toByteArray());
            fos.close();
            return;
        }
    }
    // if (result == null) {
    result = new ByteArrayOutputStream(3072);
    IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    ImageData imageData = brandingService.getLoginHImage().getImageData();
    new ByteArrayOutputStream();
    ImageLoader imageLoader = new ImageLoader();
    imageLoader.data = new ImageData[] { imageData };
    imageLoader.save(result, type);
    // put image to cache, no need to generate next time
    logoImageCache.put(type, result);
    // }
    FileOutputStream fos = new FileOutputStream(file);
    fos.write(result.toByteArray());
    fos.close();
}
Also used : ImageData(org.eclipse.swt.graphics.ImageData) FileOutputStream(java.io.FileOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IBrandingService(org.talend.core.ui.branding.IBrandingService) Image(org.eclipse.swt.graphics.Image) ImageLoader(org.eclipse.swt.graphics.ImageLoader) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Example 90 with ImageData

use of org.eclipse.swt.graphics.ImageData in project tdi-studio-se by Talend.

the class SWTResourceManager method getImage.

/**
     * Returns an image encoded by the specified input stream
     * 
     * @param is InputStream The input stream encoding the image data
     * @return Image The image encoded by the specified input stream
     */
protected static Image getImage(InputStream is) {
    Display display = Display.getCurrent();
    ImageData data = new ImageData(is);
    if (data.transparentPixel > 0) {
        return new Image(display, data, data.getTransparencyMask());
    }
    return new Image(display, data);
}
Also used : ImageData(org.eclipse.swt.graphics.ImageData) Image(org.eclipse.swt.graphics.Image) Display(org.eclipse.swt.widgets.Display)

Aggregations

ImageData (org.eclipse.swt.graphics.ImageData)132 Image (org.eclipse.swt.graphics.Image)78 PaletteData (org.eclipse.swt.graphics.PaletteData)38 RGB (org.eclipse.swt.graphics.RGB)33 Point (org.eclipse.swt.graphics.Point)32 Test (org.junit.Test)26 InputStream (java.io.InputStream)24 GC (org.eclipse.swt.graphics.GC)19 IOException (java.io.IOException)18 SWTException (org.eclipse.swt.SWTException)14 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)13 Rectangle (org.eclipse.swt.graphics.Rectangle)12 Color (org.eclipse.swt.graphics.Color)11 ImageLoader (org.eclipse.swt.graphics.ImageLoader)11 Display (org.eclipse.swt.widgets.Display)11 ByteArrayInputStream (java.io.ByteArrayInputStream)7 Cursor (org.eclipse.swt.graphics.Cursor)7 Composite (org.eclipse.swt.widgets.Composite)7 GradientPaint (java.awt.GradientPaint)5 URL (java.net.URL)5