Flipping/inverting a Canvas Image

C#_Mamba 1 Reputation point
2021-07-10T20:19:04.82+00:00

How would I go by flipping an image horizontally so that it is in theory inverted before a draw it ?
Im presuming it will be done with a Transform matrix, but how would I do it ?

before calling:

session.DrawImage(myCanvasBitmap, myXLocation, myYLocation);

Universal Windows Platform (UWP)
{count} votes

1 answer

Sort by: Most helpful
  1. AryaDing-MSFT 2,916 Reputation points
    2021-07-12T08:11:31.68+00:00

    Hi,

    Welcome to Microsoft Q&A!

    You mean to flip image horizontally, right? If yes, you could use Matrix3x2.CreateScale(ScaleX,ScaleY,centerpoint) method, which is used to zoom image. ScaleX between 0 and -1 flip the scale object and decrease its width. ScaleX less than -1 flip the object and increase its width. A value of -1 flips the scaled object but does not change its horizontal size. As follows:

    ds.Transform = Matrix3x2.CreateScale(-1,1, centerpoint);  
    

    Please note the value of centerpoint.


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.