Re: libgnomeprintmm and printing pixbuf.
Sebastian Vorköper <[email protected]> Sat, 16 Apr 2005 03:53:06 +0200
| Newsgroups | gmane.comp.gnome.gnomemm |
|---|---|
| Message-ID | <1113616386.32340.1.camel@localhost> |
--=-C7YqJxRXuvjlnguGI8sm Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Am Samstag, den 16.04.2005, 02:17 +0200 schrieb Murray Cumming:=20 > On Sat, 2005-04-16 at 02:10 +0200, Sebastian Vork=F6per wrote: > > Hello, > >=20 > > i'm working with libgnomeprintmm-2.5.1 lately and couldn't figure out > > how to print pictures (pixbufs). > >=20 > > I know how to do it with "normal" libgnomeprint. > >=20 > > So with libgnomeprint i would do: > >=20 > > guchar *raw_image =3D gdk_pixbuf_get_pixels (pixbuf); > > gint rowstride =3D gdk_pixbuf_get_rowstride (pixbuf); > > gint height =3D gdk_pixbuf_get_height (pixbuf); > > gint width =3D gdk_pixbuf_get_width (pixbuf); > >=20 > > gnome_print_rgbimage (context, (char *) raw_image, width, height, > > rowstride); > >=20 > > 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" ? > >=20 > > context->rgb_image( ??? , pixbuf->get_width(), pixbuf->get_height(), > > pixbuf->get_rowstride()) >=20 > It's very possible that the libgnomeprintmm API is wrong. A patch would > be welcome. >=20 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=F6per [email protected] --=-C7YqJxRXuvjlnguGI8sm Content-Disposition: attachment; filename=libgnomeprintmm-2.5.1.patch Content-Type: text/x-patch; name=libgnomeprintmm-2.5.1.patch; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 7bit 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); --=-C7YqJxRXuvjlnguGI8sm Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ gnomemm-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/gnomemm-list --=-C7YqJxRXuvjlnguGI8sm--