-
Dec 4th, 2017, 08:55 AM
#1
Thread Starter
New Member
How to Image.Save 90 degrees rotated.
Hello guys,
I have a video source streaming to a picture box. Once I click a button a i duplicate that image to a second picture box. I currently save the second picture box image to a file.
My camera is rotated 90degrees so my picturebox preview is 90' rotated too. Is there a way to rotate this picture box by 90?
Here is my code below.
Thanks.
PHP Code:
PictureBox2.Image = PictureBox1.Image
PictureBox1.Image.Save("C:\" & TextBox7.Text & "-side1.jpg", Imaging.ImageFormat.Jpeg)
-
Dec 4th, 2017, 09:11 AM
#2
Re: How to Image.Save 90 degrees rotated.
You call the RotateFlip method on the Image object to rotate or flip it. It's still an Image object like any other after that, so you can do anything with it that you can with any other Image.
-
Dec 4th, 2017, 10:48 AM
#3
Re: How to Image.Save 90 degrees rotated.
Hi.
I'm not sure that copying a file to a second picturebox and then save as jpg will maintain the quality of the image.
Again this is not 100% sure about a picturebox but when I was manipulating an Image by itself, the default saving was lowering - defaulting the resolution.
So you may also need to create a graphic object and set the image to it, in order to mess with the InterpolationMode,SmoothingMode and TextRenderingHint
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Dec 4th, 2017, 05:53 PM
#4
Re: How to Image.Save 90 degrees rotated.
vbnet Code:
' Dim picRotated As Bitmap = PictureBox1.Image.Clone 'Rotate image clockwise 90 degrees picRotated.RotateFlip(RotateFlipType.Rotate90FlipNone) PictureBox2.Image = picRotated
-
Dec 4th, 2017, 05:53 PM
#5
Re: How to Image.Save 90 degrees rotated.
Originally Posted by sapator
I'm not sure that copying a file to a second picturebox and then save as jpg will maintain the quality of the image.
It's worth noting that the code provided doesn't actually copy the Image object. The OP might be under the impression that it does but it's simply displaying the same Image in two PictureBoxes. Because there's only one Image, any changes made to it will be reflected in both PictureBoxes.
-
Dec 5th, 2017, 04:11 AM
#6
Re: How to Image.Save 90 degrees rotated.
So,Not sure what the OP wants but here is another option,similar to Niya, but avoid a copy paste of the bitmap:
Code:
PictureBox2.Image = PictureBox1.Image.Clone
PictureBox2.Image.RotateFlip(RotateFlipType.Rotate90FlipNone)
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Dec 5th, 2017, 06:29 AM
#7
Re: How to Image.Save 90 degrees rotated.
Originally Posted by sapator
So,Not sure what the OP wants but here is another option,similar to Niya, but avoid a copy paste of the bitmap:
Code:
PictureBox2.Image = PictureBox1.Image.Clone
PictureBox2.Image.RotateFlip(RotateFlipType.Rotate90FlipNone)
The only thing that that code avoids compared to Niya's is the declaration of a local variable but the cost of that is displaying the ne Image in the PictureBox before and after rotation rather than just after. I'm not sure whether that might potentially lead to some flicker but it is always good practice to process something before displaying it rather than after.
-
Dec 5th, 2017, 10:58 AM
#8
Re: How to Image.Save 90 degrees rotated.
In general I wouldn't use the picturebox so I would use Niya code or better yet manipulating the Image alone and then do whatever with it.
I just posted a quick alternative so you wouldn't have to to declare a bitmap.
Picturebox has a clone function but if you want to create a new image, rotate, or even worse, resize , you will get the defaults that may greatly reduce the image quality.
Especially on the resize, I was struggling quite a lot in order for the image to have the appropriate quality.
So for example if you have a picturebox and then resize the image, I haven't tried, but I think the quality will get the defaults.I think by default you have a 75% quality on JPEG so the image is already starting to smudge.
This is the time that you need to take the image out of the picture box, apply the InterpolationMode,Smoothing,Quality etc and get it back to the picturebox or save it to a file.
OP should explain exactly what he wants and then we can take it from there.
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|