GNOME Bugzilla – Bug 319163
Pixbuf saveToBuffer always return 0 bytes
Last modified: 2009-08-15 18:40:50 UTC
Please describe the problem: I try to capture a drawable - a Gdk window - into a pixbuf. So far is ok. When i want to save it into a byte array it alwasy report success, but the result is a 0 length byte array. Saving into a file works correctly. Steps to reproduce: 1. create a Pixbuf from a drawable 2. try to save it with saveToBuffer 3. Actual results: the returned buffer is 0 length. Expected results: the resulted byte array should contain the image of the drawable. Does this happen every time? yes Other information:
Here is a short testcase: import org.gnu.gdk.Drawable; import org.gnu.gdk.Pixbuf; import org.gnu.glib.JGException; import org.gnu.gtk.Button; import org.gnu.gtk.Gtk; import org.gnu.gtk.GtkStockItem; import org.gnu.gtk.Requisition; import org.gnu.gtk.Window; public class PixbuffTest { public Window window; public void OnClicked() { String[] optionKeys = { "quality" }; String[] optionValues = { "100" }; Pixbuf pixbuf; Requisition req = window.getSize(); pixbuf = new Pixbuf( (Drawable)window.getWindow(), window.getWindow().getColormap(), 0, 0, 0, 0, req.getWidth(), req.getHeight() ); try { byte[] buf = pixbuf.saveToBuffer( "jpeg", optionKeys, optionValues); System.out.println("Buf len:" + buf.length ); } catch (JGException e) { e.printStackTrace(); } } public PixbuffTest() { Window window = new Window(); Button b = new Button( GtkStockItem.CDROM ); window.add( b ); b.addEventHandler("clicked", "OnClicked", this ); window.showAll(); } public static void main(String[] args) { Gtk.init( args ); PixbuffTest t = new PixbuffTest(); Gtk.main(); } }
Thanks for the report and test case. Fixed in CVS HEAD.