Re: [LIBART] art_rgb_affine()



On Sun, 2004-10-17 at 21:32 +0200, Patrick Leslie Polzer wrote:

> In art_rgb_affine(), how should I know what size the final image needs?
> I know that max(size) is sqr(a^2 + b^2), but how should one get the
> real size for a given angle? In other words, how big should dst be and
> what values should x0, y0, x1, y1, dst_rowstride contain?

The purpose of art_rgb_affine() is to take an input image buffer,
transform it, and paste the result clipped to the bounds of an output
image buffer.

If you need to have the "whole result", you need to compute the size of
the output image buffer yourself.  This involves transforming the
vertices of the source's bounding rectangle, and then finding the
bounding box of the resulting points.  This is exactly what
art_drect_affine_transform() does.

So, you need something like this:

ArtDRect src, dst;
ArtIRect idst;
int dest_width, dest_height, dest_rowstride;
art_u8 *dest_buffer;

src.x0 = 0;
src.y0 = 0;
src.x1 = source_image_width;
src.y1 = source_image_height;

art_drect_affine_transform (&dst, &src, affine);
art_drect_to_irect (&idst, &dst);

dest_width = idst.x1 - idst.x0;
dest_height = idst.y1 - idst.y0;

dest_buffer = create_empty_image_buffer (dest_width, dest_height, &dest_rowstride);

art_rgb_affine (dest_buffer,
                idst.x0, idst.y0, idst.x1, idst.y1,
                dest_rowstride,
                source_buffer,
                affine,
                filter_level,
                alphagamma);

  Federico




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