Re: gdk_pixbuf_composite leaves artifacts in the dest pixbuf, if, dest_x is > 0. Help please?



Hello.

Composing function is a bit hard to use at first. Your code should
probably look something like this (I haven't tested it).

---- CODE ----
gchar *imgSrcName;
GdkPixbuf *src, *interm, *result;
guint width, height, xOffset, yOffset;
int i = 0;
...
src = gdk_pixbuf_load_from_file_at_scale( imgSrcName, 128, 128, TRUE, NULL );
result = gdk_pixbuf_new( GDK_COLORSPACE_RGB, TRUE,
gdk_pixbuf_get_bits_per_sample( src ), 128, 128 );

interm = gdk_pixbuf_apply_embedded_orientation( src );
gdk_pixbuf_unref( src );
width = gdk_pixbuf_get_width( interm );
height = gdk_pixbuf_get_height( interm );
...
while ( i < 2 )
{
       gchar *save;

       gdk_pixbuf_fill( result, 0xffffff00 );
       xOffset = i++ * ( 128 - width ) / 2;
       yOffset = i++ * ( 128 - height ) / 2;
       gdk_pixbuf_composite( interm, result, xOffset, yOffset, width,
height, xOffset, yOffset, 1.0, 1.0, GDK_INTERP_NEAREST, 255 );

       save = g_strdup_printf( "test%d.jpg", i );
       gdk_pixbuf_save( result, save, "jpeg", NULL, "quality", "100", NULL );
       g_free( save );
}
gdk_pixbuf_unref( interm );
gdk_pixbuf_unref( result );
---- CODE ----

BTW, gdk_pixbuf_unref is deprecated in favor of g_object_unref, since
GdkPixbuf is derived from GObject now.

Tadej

-- 
Tadej BorovÅak
tadeboro.blogspot.com
tadeboro gmail com
tadej borovsak gmail com



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