Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

DrawRotateImage - rotating an image by a specified angle

Total Hit ( 3659)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


Click here to copy the following block
' Rotate an image by a specified angle (in degrees)
' The x and y parameters are the coordinates of the upper-left point
' Note: requires Imports System.Drawing.Imaging
'
' Example:
'  Dim gr As Graphics = Me.CreateGraphics
'  gr.Clear(Color.White)
'  Dim bmp As New Bitmap("logo.bmp")
'  DrawRotateImage(gr, bmp, 100, 220, 45)
'  DrawRotateImage(gr, bmp, 300, 220, 90)
'  DrawRotateImage(gr, bmp, 500, 220, 135)
'  bmp.Dispose()
'  gr.Dispose()

Sub DrawRotateImage(ByVal gr As Graphics, ByVal bmp As Bitmap, _
  ByVal x As Single, ByVal y As Single, ByVal angle As Single)
  ' Convert the angle in degrees.
  angle = angle / (180 / Math.PI)
  ' Find the position of (x1,y1) and (x2,y2).
  Dim x1 As Single = x + bmp.Width * Math.Cos(angle)
  Dim y1 As Single = y + bmp.Width * Math.Sin(angle)
  Dim x2 As Single = x - bmp.Height * Math.Sin(angle)
  Dim y2 As Single = y + bmp.Height * Math.Cos(angle)

  ' Create the points array.
  Dim points() As Point = {New Point(x, y), New Point(x1, y1), New Point(x2, _
    y2)}
  ' Draw the rotated image
  gr.DrawImage(bmp, points)
End Sub


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.