0

I want to write some tests to verify that an IValueConverter rotates an image according to it's EXIF Metadata for orientation.

I've created a test image which is 400px wide and 300px high, the top half of which is white and the lower half is black.

If I can examine the colours of the pixels in the corners of the image then I can write my tests and make assertions according to the following table:

Orientation                Top Left    Top Right    Bottom Left   Bottom Right
Landscape                  White       White        Black         Black
Portrait Clockwise         Black       White        Black         White
Portrait Anti Clockwise    White       Black        White         Black

(I am not expecting images to be upside-down or reflected either horizontally or vertically)

using(var f = new FileStream(@"C:\test.jpg",FileMode.Open, FileAccess.Read))
{
     var bitmapFrame = BitmapFrame.Create(f);
}

How can I access the corner pixels and examine whether they are black or white?

Grokodile
  • 3,881
  • 5
  • 33
  • 59

1 Answers1

1

The answer from here applies to BitmapFrame as well: Finding specific pixel colors of a BitmapImage

Copy the data into a byte array and carefully parse the array

Community
  • 1
  • 1
Robert Levy
  • 28,747
  • 6
  • 62
  • 94