Re: usage of gdk_pixbuf_scale_simple ?



From a parallel universe, Havoc Pennington <hp redhat com> scrawled.....

at this point, workbuf is completely black.
I know that the results aren't really going to be correct unless rowstride
is 0, in which case it is here. but I'd at least expect to see *something*
no matter what.
That's just it, rowstride shouldn't be 0. Rowstride is the distance
between the start of each row in the image. So it will always be
greater than or equal to the width. It's separate from width because
you may have padding at the ends of rows.

oh! I thought it was a small buffer at the end of the row, not including
the row data..

okay; so gdk_pixbuf_new_from_data doesn't compute an optimal rowstride;
I guess this could be construed as a bug.

so I'll use gdk_pixbuf_new, which the documentation says does compute
a proper rowstride. I'll copy the data in manually instead of
relying on new_from_data. I tried it; the rowstrides are fine now. 
here's what I'm doing now:

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
        srcpix=gdk_pixbuf_new(GDK_COLORSPACE_RGB,FALSE,BITSPERSAMPLE/3,
            inh->width, inh->height);
        pixels=gdk_pixbuf_get_pixels(srcpix);
        memcpy(pixels,workbuf,(inh->width*BITSPERSAMPLE/8)*inh->height);
        destpix=gdk_pixbuf_scale_simple(srcpix, 352,240,GDK_INTERP_NEAREST);
        pixels=gdk_pixbuf_get_pixels(destpix);
        memcpy(workbuf,pixels,(352*BITSPERSAMPLE/8)*240);
        gdk_pixbuf_unref(destpix);
        gdk_pixbuf_unref(srcpix);
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


I still get the same thing; black image. I do note that the rowstride
for both images is fine; something like 2160 for src and 1000 for dest.
Is there anything else I might be missing?

thanks!

-paulb

===========================================================================
paulb oasis-software com         "I'm fuzzy on this whole good/bad thing" 
paulb foobox com                                          -Dr. Peter Venkman




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