TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Bharani K
NA
4
1.5k
Image rotation in WPF Image control
Mar 26 2018 4:57 AM
Hello Team,
I have a problem related to image rotation
I have 2 images :
1.FabricHeaderExample.jpg
2.H12532D_ANTIBEE.jpg
For Example 1: FabricHeaderExample.jpg image looks Potraint image, when i upload this image and displaying in Image control.
while displaying it is rotating as landscape. It is having exif data. for this i write a code as below:
Dim
img
As
Image = Image.FromFile(selectedFileName)
Dim
propid = (From p
In
img.PropertyItems Where p.Id = 274
Select
p).ToList
If
propid IsNot
Nothing
Then
For
Each
pid
In
propid
Dim
orientationValue
As
Integer
= pid.Value(0)
Dim
rotateFlipType
As
RotateFlipType = OrientationToFlipType(orientationValue)
img.RotateFlip(rotateFlipType)
img.RemovePropertyItem(274)
Exit
For
Next
End
If
Private
Shared
Function
OrientationToFlipType(
ByVal
orientation
As
String
)
As
RotateFlipType
Select
Case
Integer
.Parse(orientation)
Case
1
Return
RotateFlipType.RotateNoneFlipNone
Case
2
Return
RotateFlipType.RotateNoneFlipX
Case
3
Return
RotateFlipType.Rotate180FlipNone
Case
4
Return
RotateFlipType.Rotate180FlipX
Case
5
Return
RotateFlipType.Rotate90FlipX
Case
6
Return
RotateFlipType.Rotate90FlipNone
Case
7
Return
RotateFlipType.Rotate270FlipX
Case
8
Return
RotateFlipType.Rotate270FlipNone
Case
Else
Return
RotateFlipType.RotateNoneFlipNone
End
Select
End
Function
After that, it displaying properly.
For example 2: H12532D_ANTIBEE.jpg image looks normally image, but it is having exif data am using above code to display image in image control.
but the image is not rotating properly. but both images are getting same orientation value as 6.
I need to fix the code for both images are displaying properly.
Here am uploading sample application, in that application under images folder having above mentioned 2 images.
Attachment:
WpfApp_ImageRotation.zip
Reply
Answers (
1
)
how to set watermark to combobox
How to select listbox item into textbox in wpf