Re: libgnomeprintmm and printing pixbuf.



Am Samstag, den 16.04.2005, 02:17 +0200 schrieb Murray Cumming: 
> On Sat, 2005-04-16 at 02:10 +0200, Sebastian Vorköper wrote:
> > Hello,
> > 
> > i'm working with libgnomeprintmm-2.5.1 lately and couldn't figure out
> > how to print pictures (pixbufs).
> > 
> > I know how to do it with "normal" libgnomeprint.
> > 
> > So with libgnomeprint i would do:
> > 
> > guchar *raw_image = gdk_pixbuf_get_pixels (pixbuf);
> > gint rowstride = gdk_pixbuf_get_rowstride (pixbuf);
> > gint height = gdk_pixbuf_get_height (pixbuf);
> > gint width = gdk_pixbuf_get_width (pixbuf);
> > 
> > gnome_print_rgbimage (context, (char *) raw_image, width, height,
> > rowstride);
> > 
> > But how to do it with libgnomeprintmm?
> > Or better: How would i create a "const Glib::ustring& data" out of
> > "guint8* Gdk::Pixbuf::get_pixels  (  )   const" ?
> > 
> > context->rgb_image( ??? , pixbuf->get_width(), pixbuf->get_height(),
> > pixbuf->get_rowstride())
> 
> It's very possible that the libgnomeprintmm API is wrong. A patch would
> be welcome.
> 

I don't think its wrong.
But i don't see a clean/simple way to get from "guint8*" to "const
Glib::ustring& data".
I would prefer the "old" behavior like:

context->rgb_image( (char *) pixbuf->get_pixels() , pixbuf->get_width(),
pixbuf->get_height(), pixbuf->get_rowstride());

So the simple patch should do the trick.
(patch -p0 < libgnomeprintmm-2.5.1.patch)

Another question would be, when will were be a stable release of
libgnomprintmm and libgnomeprintmmui?
I'm doing a whole rewrite of gnome-photo-printer to gtkmm,
libgnomecanvasmm and libgnomeprintmm/ui.
So it would be nice to know, if there is something like a release
cycle/plan.

Thanks,
Sebastian Vorköper
sv fogman de

diff -urN libgnomeprintmm-2.5.1/libgnomeprint/libgnomeprintmm/context.cc libgnomeprintmm-2.5.1.new/libgnomeprint/libgnomeprintmm/context.cc
--- libgnomeprintmm-2.5.1/libgnomeprint/libgnomeprintmm/context.cc	2004-06-08 01:10:37.000000000 +0200
+++ libgnomeprintmm-2.5.1.new/libgnomeprint/libgnomeprintmm/context.cc	2005-04-16 02:59:17.000000000 +0200
@@ -295,19 +295,19 @@
   return gnome_print_show_sized(gobj(), (const guchar*)text.c_str(), bytes);
 }
 
-int Context::gray_image(const Glib::ustring& data, int width, int height, int rowstride)
+int Context::gray_image(const guchar *data, int width, int height, int rowstride)
 {
-  return gnome_print_grayimage(gobj(), (const guchar*)data.c_str(), width, height, rowstride);
+  return gnome_print_grayimage(gobj(), data, width, height, rowstride);
 }
 
-int Context::rgb_image(const Glib::ustring& data, int width, int height, int rowstride)
+int Context::rgb_image(const guchar *data, int width, int height, int rowstride)
 {
-  return gnome_print_rgbimage(gobj(), (const guchar*)data.c_str(), width, height, rowstride);
+  return gnome_print_rgbimage(gobj(), data, width, height, rowstride);
 }
 
-int Context::rgba_image(const Glib::ustring& data, int width, int height, int rowstride)
+int Context::rgba_image(const guchar *data, int width, int height, int rowstride)
 {
-  return gnome_print_rgbaimage(gobj(), (const guchar*)data.c_str(), width, height, rowstride);
+  return gnome_print_rgbaimage(gobj(), data, width, height, rowstride);
 }
 
 int Context::begin_page(const Glib::ustring& name)
diff -urN libgnomeprintmm-2.5.1/libgnomeprint/libgnomeprintmm/context.h libgnomeprintmm-2.5.1.new/libgnomeprint/libgnomeprintmm/context.h
--- libgnomeprintmm-2.5.1/libgnomeprint/libgnomeprintmm/context.h	2004-06-08 01:10:37.000000000 +0200
+++ libgnomeprintmm-2.5.1.new/libgnomeprint/libgnomeprintmm/context.h	2005-04-16 03:02:08.000000000 +0200
@@ -184,11 +184,11 @@
 //TODO:  _WRAP_METHOD(int glyph(GnomeGlyphList *glyphlist), gnome_print_glyphlist)
 
 
-  int gray_image(const Glib::ustring& data, int width, int height, int rowstride);
+  int gray_image(const guchar *data, int width, int height, int rowstride);
   
-  int rgb_image(const Glib::ustring& data, int width, int height, int rowstride);
+  int rgb_image(const guchar *data, int width, int height, int rowstride);
   
-  int rgba_image(const Glib::ustring& data, int width, int height, int rowstride);
+  int rgba_image(const guchar *data, int width, int height, int rowstride);
 
 
   int begin_page(const Glib::ustring& name);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]