473,382 Members | 1,180 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

rotate gdi object

hi, im trying to rotate a gdi drawn object on my form with a
keypress....forinstance when i push the down arrow, for it to rotate the
object drawn until the top is down, or if i push the right arrow key, to
rotate the object until its pointed to the right. i tried using a drawing
matrix to accomplish this, but all it did was rotate my entire form (im
drawing my object on the back of the form) and thats not what i need. I need
it to rotate on the spot, so i tried RotateAt but that also didnt work...how
can i accomplish what im looking for?

thanks

--
-iwdu15
Jan 8 '06 #1
1 3041
Hi,

Maybe this will help. I added a picturebox to a form and have it
draw an image in the paint event. The point that the image is rotated about
is the center of the image. I added a timer so every 100 miliseconds it
redraws the image rotated 30 degrees.

Imports System.Drawing.Drawing2D

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Timer1.Enabled = True
End Sub
Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
Static bm As Bitmap
Static intAngle As Integer = 0

If bm Is Nothing Then
bm = New Bitmap(16, 16)
Dim g As Graphics = Graphics.FromImage(bm)
g.Clear(Color.White)
g.DrawLine(Pens.Red, 0, 0, 16, 16)
g.DrawLine(Pens.Blue, 0, 16, 16, 0)
End If

e.Graphics.TranslateTransform(50, 50)
e.Graphics.RotateTransform(intAngle)

e.Graphics.DrawImage(bm, -8, -8)
intAngle += 30
If intAngle > 360 Then intAngle -= 360
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
PictureBox1.Invalidate()
End Sub
End Class
Ken
------------------------
"iwdu15" <jmmgoalsteratyahoodotcom> wrote in message
news:20**********************************@microsof t.com...
hi, im trying to rotate a gdi drawn object on my form with a
keypress....forinstance when i push the down arrow, for it to rotate the
object drawn until the top is down, or if i push the right arrow key, to
rotate the object until its pointed to the right. i tried using a drawing
matrix to accomplish this, but all it did was rotate my entire form (im
drawing my object on the back of the form) and thats not what i need. I
need
it to rotate on the spot, so i tried RotateAt but that also didnt
work...how
can i accomplish what im looking for?

thanks

--
-iwdu15

Jan 8 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mullin Yu | last post by:
I can create an image object with a string printed on it. But, how I can rotate the whole image 270 degree clockwise static public Bitmap createSerial() { Graphics objGraphics; string...
3
by: steve | last post by:
I have a tablet PC and I write a application on this tablet PC, I would like to rotate the screen from portrait<->landscape mode(or 90/180/270 degree), what should I do? I only find the code for...
3
by: byrd48 | last post by:
Hi, I am developing a web site which allows users to upload and share photos. I have a datalist which lists the photos and has the usual edit, update commands. Within the edititemtemplate, I...
2
by: Peter Proost | last post by:
Hi group, I got the following piece of code which draws a square with stars round it, now I want the stars to rotate round the square, I can do this with the mx.rotate and a timer and an...
17
by: santel_helvis | last post by:
Hi All, Could anyone tell me how to rotate the image in javascript. Which concepts I should concentrate to rotate the image
8
by: lovecreatesbeauty | last post by:
I write a function to rotate a matrix by 90 degrees clockwise, this function works on a matrix of specific size, for example, it rotates a 4*4 matrix of integers in the following code. The function...
8
by: Samuel Shulman | last post by:
Is it possible and how to rotate pictures in HTML document Thank you, Samuel
10
by: Joey_Stacks | last post by:
Does anyone know of a scipt that will rotate random div layers on page refresh? I have a primary content area front and center on my site homepage, and I'd like to rotate various chunks of html...
13
by: =?Utf-8?B?dmlubw==?= | last post by:
Hello, I have created my proper control and i would to rotate it. In the paint event of my object, i have written : Dim graph As Graphics = myObject.CreateGraphics myMatrix = New...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.