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



Hello list,

I am trying to create a thumbnail from a digital image, which should not exceed 128 px width or height. After loading the image, I apply the EXIF orientation information, if available. In order to prettify the resulting display, I would like to place the pixbuf horizontally centered onto another transparent pixbuf with dimensions 128x128 px. Here is (part of) the code I use (removed the error checking for simplification):

gchar *imgSrcName;
GdkPixbuf *src, *interm, *result;
guint width, height, xOffset;
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;
gdk_pixbuf_composite( interm, result, xOffset, 0, width, height, 0, 0, 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 );

As you can see in the attached images, the result is OK only if the xOffset on translation is 0. The centered version shows artifacts on the right border of the image. And it does not make a speck of difference, if the interpolation type is _BILINEAR or _HYPER ...

Could anyone please help in solving this ?

Regards

Todor


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