[Top][All Lists]

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

Re: Image transformations

From: Alan Third
Subject: Re: Image transformations
Date: Thu, 13 Jun 2019 20:27:24 +0100
User-agent: Mutt/1.12.0 (2019-05-25)

On Thu, Jun 13, 2019 at 08:11:21PM +0300, Eli Zaretskii wrote:
> > Date: Thu, 13 Jun 2019 17:58:04 +0100
> > From: Alan Third <address@hidden>
> > Cc: address@hidden
> > 
> > Can you point me to the Windows API documentation and perhaps I can
> > work out how exactly we need to approach this?
> I want to use PlgBlt, see
>   https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/nf-wingdi-plgblt
> For that, I need to compute, for each of the original image's
> vertices, the coordinates of the corresponding vertex of the
> transformed image.  That's why I was asking how to interpret the
> matrix elements for transforming pixel coordinates.

I think this should be what you need:

   x’ = tm[0][0] * x + tm[0][1] * y + tm[0][2] * 1
   y’ = tm[1][0] * x + tm[1][1] * y + tm[1][2] * 1

where tm is the completed transformation matrix.

BTW, are you aware that you can use the XFORM struct:


That maps exactly to the matrices, which is one of the reasons I went
down this route originally. Almost everything supports them.

> I also want to know when no rotation is involved, so that I could use
> the existing code (which only supports scaling and will be modified to
> support cropping) on older Windows versions that cannot support
> rotations (PlgBlt is not available on those platforms).

I’d be inclined to just skip image_set_rotation when on a platform
that doesn’t support it. Or storing the basic crop and scaling
information separately so you don’t have to worry about the matrices
at all.

Now I see why you want to be able to distinguish between the
availability of the different types of transform too.
Alan Third

reply via email to

[Prev in Thread] Current Thread [Next in Thread]