use of org.eclipse.swt.graphics.ImageData in project cogtool by cogtool.
the class WindowsImageTransfer method main.
public static void main(String[] args) throws Exception {
Display display = new Display();
Shell shell = new Shell(display);
Clipboard c = new Clipboard(display);
System.out.println("types on the clipboard: " + Arrays.asList(c.getAvailableTypeNames()));
Object o = c.getContents(WindowsImageTransfer.getInstance());
ImageData d = (ImageData) o;
if (d == null) {
System.out.println("no image found on clipboard. try hitting the printscreen key, or using MS Paint to put an image on the clipboard.");
return;
}
//Change what's on the clipboard to show we can also put images on the
// clipboard.
c.setContents(new Object[] { "howdy" }, new Transfer[] { TextTransfer.getInstance() });
System.out.println("types on the clipboard: " + Arrays.asList(c.getAvailableTypeNames()));
//now put the ImageData back onto the clipboard.
c.setContents(new Object[] { d }, new Transfer[] { WindowsImageTransfer.getInstance() });
System.out.println("types on the clipboard: " + Arrays.asList(c.getAvailableTypeNames()));
//now read the CF_DIB (ImageData) back off the clipboard.
// and display it by using it as the image for the button.
ImageData imgData = (ImageData) c.getContents(WindowsImageTransfer.getInstance());
Image img = new Image(display, imgData);
Button button = new Button(shell, SWT.NONE);
button.setImage(img);
shell.pack();
button.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
button.dispose();
}
use of org.eclipse.swt.graphics.ImageData in project translationstudio8 by heartsome.
the class Activator method getIconDescriptor.
/**
* 提供一个图片文件对插件的相对路径,返回该图片被伸缩变换为16*16像素的描述信息。
* @param path
* the path
* @return the icon descriptor
*/
public static ImageDescriptor getIconDescriptor(String path) {
ImageDescriptor image = getImageDescriptor(path);
ImageData data = image.getImageData();
data = data.scaledTo(16, 16);
image = ImageDescriptor.createFromImageData(data);
return image;
}
use of org.eclipse.swt.graphics.ImageData in project translationstudio8 by heartsome.
the class SpellPage method addLangAndDicToTable.
/**
* 将语言与词典对进行加载到列表中,
* @param aspellDicList 第一个数据为 语言, 第二个数据为 词典
*/
private void addLangAndDicToTable(List<String[]> aspellDicList) {
for (String[] dicArray : aspellDicList) {
String lang = dicArray[0];
String dic = dicArray[1];
TableItem item = null;
for (int i = 0; i < table.getItemCount(); i++) {
TableItem currItem = table.getItem(i);
if (TextUtil.getLanguageCode(currItem.getText(0)).equals(lang)) {
item = currItem;
}
}
if (item == null) {
item = new TableItem(table, 0);
}
//$NON-NLS-1$
String[] data = { TextUtil.getLanguageName(lang), "->", dic };
String imgPath = langMap.get(lang).getImagePath();
if (imgPath != null && !imgPath.equals("")) {
imgPath = bundlePath + imgPath;
Image image = new Image(getShell().getDisplay(), imgPath);
if (image != null) {
ImageData imgData = image.getImageData().scaledTo(16, 12);
image = new Image(getShell().getDisplay(), imgData);
item.setImage(0, image);
}
}
item.setText(data);
}
}
use of org.eclipse.swt.graphics.ImageData in project translationstudio8 by heartsome.
the class Activator method getIconDescriptor.
/**
* 提供一个图片文件对插件的相对路径,返回该图片被伸缩变换为16*16像素的描述信息。
* @param path
* the path
* @return the icon descriptor
*/
public static ImageDescriptor getIconDescriptor(String path) {
ImageDescriptor image = getImageDescriptor(path);
ImageData data = image.getImageData();
data = data.scaledTo(16, 16);
image = ImageDescriptor.createFromImageData(data);
return image;
}
use of org.eclipse.swt.graphics.ImageData in project dbeaver by serge-rider.
the class ImageViewCanvas method loadImage.
/**
* Reload image from a file
* @return swt image created from image file
*/
public Image loadImage(InputStream inputStream) {
if (sourceImage != null && !sourceImage.isDisposed()) {
sourceImage.dispose();
sourceImage = null;
imageData = null;
}
this.error = null;
if (inputStream != null) {
try {
imageData = new ImageData(inputStream);
sourceImage = new Image(getDisplay(), imageData);
} catch (SWTException e) {
this.error = e;
}
}
showOriginal();
return sourceImage;
}
Aggregations