|Access to pixel data of SWT Image from native libary [message #901030]
||Thu, 09 August 2012 13:20
| Stephan Aßmus
Registered: August 2012
I am trying to access the pixel data that backs up an SWT Image from within a native libary. Specifically, I need to use my own graphics rendering methods to dynamically fill the contents of an SWT image.
I am fully aware that the way by which to access the pixel data depends on the SWT platform.
I need to use my own rendering implementation for performance and other reasons. Since performance is one of the main concerns, I can't be copying image data forth and back between the platform backend of SWT Image and my own image buffer. I would like access to the image data in a shared memory fashion.
My current test end experiment environment is SWT-GTK 3.7.2. I am successfully merging a Java and C/C++ project to build a Java project using a native library written in C++ into which I can embed my rendering code.
So far I managed to pass the SWT Image's "pixmap" handle into the native library and use the underlying GdkPixmap platform object. From the GdkPixmap, I can extract a GdkImage, and the documentation mentions a) that all this stuff is deprecated (Cairo surfaces should be used instead), and b) that for running a local X-Server, the GdkImage *may* use shared memory. Apparently, it is not using shared memory for my environment (Ubuntu 12.04), since I only see what I render when I draw the GdkImage back onto the GdkPixmap using gdk_draw_image().
I would like some feedback whether I am on the right path and perhaps whether there is any documentation or tutorials on what I am trying to do, or how to get to the original memory of the GdkPixmap. I somehow cannot believe I am the only one trying to get to the raw pixels and trying to avoid copying large chunks for memory for no reason. But all my googling has turned up nothing.
I stumbled over references that SWT-GTK is switching to GTK-3.0 and Cairo surfaces in the future. I have downloaded SWT 4.2 and am going to peek into the code. Maybe it already makes this easier. After I've got it working, I will need to replicate the process for all my intended target platforms, I know.
Thanks for any help!
Powered by FUDForum
. Page generated in 0.01821 seconds