After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 319163 - Pixbuf saveToBuffer always return 0 bytes
Pixbuf saveToBuffer always return 0 bytes
Status: VERIFIED FIXED
Product: java-gnome
Classification: Bindings
Component: GTK
mainline
Other All
: Normal normal
: ---
Assigned To: Ismael Juma
Ismael Juma
Depends on:
Blocks:
 
 
Reported: 2005-10-18 13:52 UTC by Bodo-Merle Sandor
Modified: 2009-08-15 18:40 UTC
See Also:
GNOME target: ---
GNOME version: 2.11/2.12



Description Bodo-Merle Sandor 2005-10-18 13:52:11 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:
Comment 1 Bodo-Merle Sandor 2005-10-18 21:24:18 UTC
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();
	}

}
Comment 2 Ismael Juma 2005-10-18 22:41:29 UTC
Thanks for the report and test case. Fixed in CVS HEAD.