summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop
diff options
context:
space:
mode:
authorSilenio Quarti <Silenio_Quarti@ca.ibm.com>2011-10-19 12:35:02 -0400
committerSilenio Quarti <Silenio_Quarti@ca.ibm.com>2011-10-19 12:35:02 -0400
commit9f3e004f4f231562877a62ca1bbca78c904abee3 (patch)
tree949d80522e1bd14bdd95de2f4362164eb069b9cf /bundles/org.eclipse.swt/Eclipse SWT Drag and Drop
parent5bfbfd6550d25db2695eb695eae08fb135ba96b1 (diff)
downloadeclipse.platform.swt-9f3e004f4f231562877a62ca1bbca78c904abee3.tar.gz
eclipse.platform.swt-9f3e004f4f231562877a62ca1bbca78c904abee3.tar.xz
eclipse.platform.swt-9f3e004f4f231562877a62ca1bbca78c904abee3.zip
share code to create image from pixbuf. fixed pasting of images with alpha
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT Drag and Drop')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/ImageTransfer.java26
1 files changed, 12 insertions, 14 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/ImageTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/ImageTransfer.java
index 78cb173aa3..fb8d700780 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/ImageTransfer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/ImageTransfer.java
@@ -129,22 +129,20 @@ public void javaToNative(Object object, TransferData transferData) {
*/
public Object nativeToJava(TransferData transferData) {
ImageData imgData = null;
- if (transferData.length > 0)
- {
+ if (transferData.length > 0) {
int /*long*/ loader = OS.gdk_pixbuf_loader_new();
- OS.gdk_pixbuf_loader_write(loader, transferData.pValue, transferData.length, null);
- OS.gdk_pixbuf_loader_close(loader, null);
- int /*long*/ pixbuf = OS.gdk_pixbuf_loader_get_pixbuf(loader);
- if (pixbuf != 0) {
- int /*long*/ [] pixmap_return = new int /*long*/ [1];
- OS.gdk_pixbuf_render_pixmap_and_mask(pixbuf, pixmap_return, null, 0);
- int /*long*/ handle = pixmap_return[0];
- if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ try {
+ OS.gdk_pixbuf_loader_write(loader, transferData.pValue, transferData.length, null);
+ OS.gdk_pixbuf_loader_close(loader, null);
+ int /*long*/ pixbuf = OS.gdk_pixbuf_loader_get_pixbuf(loader);
+ if (pixbuf != 0) {
+ Image img = Image.gtk_new_from_pixbuf(Display.getCurrent(), SWT.BITMAP, pixbuf);
+ imgData = img.getImageData();
+ img.dispose();
+ }
+ } finally {
OS.g_object_unref(loader);
- Image img = Image.gtk_new(Display.getCurrent(), SWT.BITMAP, handle, 0);
- imgData = img.getImageData();
- img.dispose();
- }
+ }
}
return imgData;
}