Taufiq Abdur Rahman
Taufiq Abdur Rahman

Reputation: 1388

How to Vertically Flip an BitmapImage

I want to Flip an BitmapImage vertically as an a mirror image of the original. This what I have but it Rotates not flips an image.

var tb = new TransformedBitmap();
BitmapImage bi = Type.Image.Clone();
tb.BeginInit();
tb.Source = bi;
var transform = new RotateTransform(180);
tb.Transform = transform;
tb.EndInit();

Upvotes: 7

Views: 6434

Answers (1)

Alex
Alex

Reputation: 8937

You should use scaleTransform, not Rotate. And set its y scale to -1 to set it as mirror:

var transform = new ScaleTransform(1, -1, 0, 0);

See http://msdn.microsoft.com/en-us/library/aa348048.aspx

Upvotes: 12

Related Questions