Re: gdk_pixbuf_composite leaves artifacts in the dest pixbuf, if, dest_x is > 0. Help please?
- From: Todor Todorov <ttodorov gmx net>
- To: Tadej BorovÅak <tadeboro gmail com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: gdk_pixbuf_composite leaves artifacts in the dest pixbuf, if, dest_x is > 0. Help please?
- Date: Thu, 12 Nov 2009 00:56:15 -0500
Thank you so much for the answer!
The correct use (yours) is
gdk_pixbuf_composite( interm, result, xOffset, 0, width, height, xOffset, 0, 1.0, 1.0, GDK_INTERP_NEAREST,
255 );
as opposed to (mine)
gdk_pixbuf_composite( interm, result, xOffset, 0, width, height, /* !!! */ 0, 0, 1.0, 1.0,
GDK_INTERP_NEAREST, 255 );
I didn't quite realize that I need to apply the destination displacement
as scaling offset as well - the documentation, or rather the nice
picture showing the use of the function in the GdkPixbuf reference, did
not explain the relationship between step 1 and step 3 in the transition
... It is a nice picture though :-)
Thanks again for the help.
Best regards,
Todor
On 11/11/2009 03:20 AM, Tadej BorovÅak wrote:
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]