VB.NET School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

 

Code Snippets

  

VB.NET Source Code


Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 340,163 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 4,034 people online right now. Registration is fast and FREE... Join Now!




Rotate and/or Flip an Image from a File

Uses the System.Drawing namespace to Rotate/Flip an Image.

Submitted By: RodgerB
Actions:
Rating:
Views: 5,581

Language: VB.NET

Last Modified: December 6, 2007
Instructions:
1) Copy and paste this subroutine into a class.
2) Read on how to call the subroutine.

Snippet


  1. ''' <summary>
  2. ''' Rotates and/or flips an image from a file.
  3. ''' </summary>
  4. ''' <param name="imgPath">The path of the image you'd like to flip.</param>
  5. ''' <param name="savePath">The path of the flipped image you'd like to save to.</param>
  6. ''' <param name="rotFlipType">The RotateFlipType enum to flip or rotate the image.</param>
  7. ''' <param name="imgFormat">The format to save the file to.</param>
  8. ''' <remarks></remarks>
  9.  
  10. Public Sub rotFlipImageFromFile(ByRef imgPath As String, ByRef savePath As String, _
  11. ByRef rotFlipType As RotateFlipType, ByRef imgFormat As System.Drawing.Imaging.ImageFormat)
  12.     Dim img As System.Drawing.Image
  13.     img = System.Drawing.Bitmap.FromFile(imgPath)
  14.     img.RotateFlip(rotFlipType)
  15.     ' We delete the file if it exists so it doesn't fail.
  16.     If System.IO.File.Exists(savePath) Then System.IO.File.Delete(savePath)
  17.     img.Save(savePath, imgFormat)
  18. End Sub
  19.  
  20. ' Example usage of the snippet:
  21. rotFlipImageFromFile("c:\lol.gif", "c:\lol.gif", RotateFlipType.RotateNoneFlipXY, _
  22. Imaging.ImageFormat.Gif)

Copy & Paste


Comments

There are currently no comments for this snippet. Be the first to comment!

Add comment


You must be registered and logged on to </dream.in.code> to leave comments.





Live VB.NET Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month