use of org.eclipse.swt.graphics.ImageData in project cubrid-manager by CUBRID.
the class ImageViewer method createImageByImageData.
/**
*
* Create the image by image data
*
*/
private void createImageByImageData() {
images = new Image[imageDatas.length];
//Get the image size
int width = imageDatas[0].width;
int height = imageDatas[0].height;
//Create every image
int disposalMethod = SWT.DM_FILL_BACKGROUND;
for (int i = 0; i < imageDatas.length; i++) {
ImageData currImageData = imageDatas[i];
images[i] = new Image(display, width, height);
GC currImageGC = new GC(images[i]);
switch(disposalMethod) {
case SWT.DM_FILL_PREVIOUS:
//Draw the second last image.
currImageGC.drawImage(images[i - 2], 0, 0);
break;
case SWT.DM_FILL_NONE:
case SWT.DM_UNSPECIFIED:
//Draw the last image.
currImageGC.drawImage(images[i - 1], 0, 0);
break;
default:
//If DM_FILL_BACKGROUND or anything else, fill with default background
currImageGC.setBackground(background);
currImageGC.fillRectangle(0, 0, width, height);
break;
}
//Draw the current image,then clean up
Image currImage = new Image(display, currImageData);
currImageGC.drawImage(currImage, 0, 0, currImageData.width, currImageData.height, currImageData.x, currImageData.y, currImageData.width, currImageData.height);
currImage.dispose();
currImageGC.dispose();
//Compute the next disposal method.
disposalMethod = currImageData.disposalMethod;
if (i == 0 && disposalMethod == SWT.DM_FILL_PREVIOUS) {
disposalMethod = SWT.DM_FILL_NONE;
}
}
}
use of org.eclipse.swt.graphics.ImageData in project MonjaDB by Kanatoko.
the class SWTResourceManager method getImage.
/**
* Returns an {@link Image} encoded by the specified {@link InputStream}.
*
* @param stream
* the {@link InputStream} encoding the image data
* @return the {@link Image} encoded by the specified input stream
*/
protected static Image getImage(InputStream stream) throws IOException {
try {
Display display = Display.getCurrent();
ImageData data = new ImageData(stream);
if (data.transparentPixel > 0) {
return new Image(display, data, data.getTransparencyMask());
}
return new Image(display, data);
} finally {
stream.close();
}
}
use of org.eclipse.swt.graphics.ImageData in project dbeaver by serge-rider.
the class DBeaverIcons method getViewMenuImage.
public static synchronized Image getViewMenuImage() {
if (viewMenuImage == null) {
Display d = Display.getCurrent();
Image viewMenu = new Image(d, 16, 16);
Image viewMenuMask = new Image(d, 16, 16);
Display display = Display.getCurrent();
GC gc = new GC(viewMenu);
GC maskgc = new GC(viewMenuMask);
gc.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));
gc.setBackground(display.getSystemColor(SWT.COLOR_LIST_BACKGROUND));
int[] shapeArray = new int[] { 6, 3, 15, 3, 11, 7, 10, 7 };
gc.fillPolygon(shapeArray);
gc.drawPolygon(shapeArray);
Color black = display.getSystemColor(SWT.COLOR_BLACK);
Color white = display.getSystemColor(SWT.COLOR_WHITE);
maskgc.setBackground(black);
maskgc.fillRectangle(0, 0, 16, 16);
maskgc.setBackground(white);
maskgc.setForeground(white);
maskgc.fillPolygon(shapeArray);
maskgc.drawPolygon(shapeArray);
gc.dispose();
maskgc.dispose();
ImageData data = viewMenu.getImageData();
data.transparentPixel = data.getPixel(0, 0);
viewMenuImage = new Image(d, viewMenu.getImageData(), viewMenuMask.getImageData());
viewMenu.dispose();
viewMenuMask.dispose();
}
return viewMenuImage;
}
use of org.eclipse.swt.graphics.ImageData in project dbeaver by serge-rider.
the class OverlayImageDescriptor method drawTopLeft.
protected void drawTopLeft(ImageDescriptor[] overlays) {
if (overlays == null)
return;
int length = overlays.length;
int x = 0;
for (int i = 0; i < 3; i++) {
if (i < length && overlays[i] != null) {
ImageData id = overlays[i].getImageData();
drawImage(id, x, 0);
x += id.width;
}
}
}
use of org.eclipse.swt.graphics.ImageData in project dbeaver by serge-rider.
the class OverlayImageDescriptor method drawBottomRight.
protected void drawBottomRight(ImageDescriptor[] overlays) {
if (overlays == null)
return;
int length = overlays.length;
int x = getSize().x;
for (int i = 2; i >= 0; i--) {
if (i < length && overlays[i] != null) {
ImageData id = overlays[i].getImageData();
x -= id.width;
drawImage(id, x, getSize().y - id.height);
}
}
}
Aggregations