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 10:07:17 -0400
committerSilenio Quarti <Silenio_Quarti@ca.ibm.com>2011-10-19 10:13:37 -0400
commita3b02a04a381231f9082de077a6f17f8af5d2dad (patch)
treeddec64c5d38983933ab813feb8a2d9ba1c1907a3 /bundles/org.eclipse.swt/Eclipse SWT Drag and Drop
parent641df66d77688c7d9893fc22d380993faf531414 (diff)
downloadeclipse.platform.swt-a3b02a04a381231f9082de077a6f17f8af5d2dad.tar.gz
eclipse.platform.swt-a3b02a04a381231f9082de077a6f17f8af5d2dad.tar.xz
eclipse.platform.swt-a3b02a04a381231f9082de077a6f17f8af5d2dad.zip
shared copies of Display.createPixbuf
shared copies of Display.createPixbuf
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/DragSource.java58
1 files changed, 1 insertions, 57 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java
index 3874254e25..b9d52f63f6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java
@@ -299,7 +299,7 @@ void drag(Event dragEvent) {
Image image = event.image;
int /*long*/ context = OS.gtk_drag_begin(control.handle, targetList, actions, 1, 0);
if (context != 0 && image != null) {
- int /*long*/ pixbuf = createPixbuf(image);
+ int /*long*/ pixbuf = ImageList.createPixbuf(image);
OS.gtk_drag_set_icon_pixbuf(context, pixbuf, 0, 0);
OS.g_object_unref(pixbuf);
}
@@ -574,60 +574,4 @@ public void setTransfer(Transfer[] transferAgents){
OS.g_free(targets[i].target);
}
}
-
-static int /*long*/ createPixbuf(Image image) {
- int [] w = new int [1], h = new int [1];
- OS.gdk_drawable_get_size (image.pixmap, w, h);
- int /*long*/ colormap = OS.gdk_colormap_get_system ();
- int /*long*/ pixbuf;
- boolean hasMask = image.mask != 0 && OS.gdk_drawable_get_depth (image.mask) == 1;
- if (hasMask) {
- pixbuf = OS.gdk_pixbuf_new (OS.GDK_COLORSPACE_RGB, true, 8, w [0], h [0]);
- if (pixbuf == 0) SWT.error (SWT.ERROR_NO_HANDLES);
- OS.gdk_pixbuf_get_from_drawable (pixbuf, image.pixmap, colormap, 0, 0, 0, 0, w [0], h [0]);
- int /*long*/ maskPixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, false, 8, w [0], h [0]);
- if (maskPixbuf == 0) SWT.error (SWT.ERROR_NO_HANDLES);
- OS.gdk_pixbuf_get_from_drawable(maskPixbuf, image.mask, 0, 0, 0, 0, 0, w [0], h [0]);
- int stride = OS.gdk_pixbuf_get_rowstride(pixbuf);
- int /*long*/ pixels = OS.gdk_pixbuf_get_pixels(pixbuf);
- byte[] line = new byte[stride];
- int maskStride = OS.gdk_pixbuf_get_rowstride(maskPixbuf);
- int /*long*/ maskPixels = OS.gdk_pixbuf_get_pixels(maskPixbuf);
- byte[] maskLine = new byte[maskStride];
- for (int y=0; y<h[0]; y++) {
- int /*long*/ offset = pixels + (y * stride);
- OS.memmove(line, offset, stride);
- int /*long*/ maskOffset = maskPixels + (y * maskStride);
- OS.memmove(maskLine, maskOffset, maskStride);
- for (int x=0; x<w[0]; x++) {
- if (maskLine[x * 3] == 0) {
- line[x * 4 + 3] = 0;
- }
- }
- OS.memmove(offset, line, stride);
- }
- OS.g_object_unref(maskPixbuf);
- } else {
- ImageData data = image.getImageData ();
- boolean hasAlpha = data.getTransparencyType () == SWT.TRANSPARENCY_ALPHA;
- pixbuf = OS.gdk_pixbuf_new (OS.GDK_COLORSPACE_RGB, hasAlpha, 8, w [0], h [0]);
- if (pixbuf == 0) SWT.error (SWT.ERROR_NO_HANDLES);
- OS.gdk_pixbuf_get_from_drawable (pixbuf, image.pixmap, colormap, 0, 0, 0, 0, w [0], h [0]);
- if (hasAlpha) {
- byte [] alpha = data.alphaData;
- int stride = OS.gdk_pixbuf_get_rowstride (pixbuf);
- int /*long*/ pixels = OS.gdk_pixbuf_get_pixels (pixbuf);
- byte [] line = new byte [stride];
- for (int y = 0; y < h [0]; y++) {
- int /*long*/ offset = pixels + (y * stride);
- OS.memmove (line, offset, stride);
- for (int x = 0; x < w [0]; x++) {
- line [x*4+3] = alpha [y*w [0]+x];
- }
- OS.memmove (offset, line, stride);
- }
- }
- }
- return pixbuf;
-}
}