Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Rotating A Picture In VB6

How i can load a picture in an imange control and if the orientation is not correct rotate it? Thanks for the help.

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Rotating A Picture
Ok I want to make a program that allows me to have a picture (eg JPG,BMP,GIF) rotate, like in the paint programs that you can put them on angles.
(eg 45 degrees, 12 degrees)

Maybe someone could make an example program like have a text box that you type in how much you want the image rotated
and a image box with some image in it, which would be rotated


Rotating A Picture
does anyone know how i could easily rotate a picture without it being in a picture box?
thnx for any suggestions

Rotating A Picture?
Is it possible to rotate a PictureBox or Image Control in VB???

Rotating A Picture
Yes I searched the forum, and got only partly answers!
Yes I searched the msdn and there is no messiah from there…

Now for my question:

I am looking for a fast way to rotate a picture in 90 degrees to both sides, now I know that the “PaintPicture” method in the “picturebox” object can turn the picture!
the msdn says in one line in the remarks area, that you can rotate the image, in the PictureBox with the piantpicture method !

I Quote:
“You can flip a bitmap horizontally or vertically by using negative values for the destination height (height1) and/or the destination width (width1).”

Can anyone explain to me how to do it.

Thank you.

Rotating A Picture 28 Degrees(!)
hi everyone,

does anyone know a way to rotate a picture? but not 90 degrees or 180 degrees. my program scans a picture (which is also scanned by a scanner), however the paper generally does not fit perfectly, so i may have to rotate it, like the one in paint shop pro or photoshop.

thanks in advance.

Rotating A Picture + DirectX
Me again

I've just rewrote my engine using DirectX and I thought "Wow, what if I could rotate thoses ship sprites in real time?". So I was thinking (did a bit of research but did not found anything), is there's a way to rotate my ship in real time, using some magic method? If so, can anyone give me a hint?


Edit:Id like to use DirectDraw or something but avoid D3D

Rotating A Picture For A Game....
I am in the process of making a Casino game, and i was wanting to do Roulette and slot machines. How on earth would i go about rotating the roulette table? I've found a couple of VB6 programs that let you rotate a picture, but nothing that i could figure out how to use. Any help would be appreciated. Of course after i can get the picture to rotate....i'll have to figure out how to move the ball around it too...but that's a whole other problem, lol.

Rotating A Picture And Saving It.
My problem is that I have to load a picture in a picture box or image control and then rotate it and then save the rotated picture with a different name. Is this possible ? I am able to rotate a picture but when I am saving the picture it is saved without the rotation. I am saving the picture with save picture method.

Rotating And Image/picture?

If I have an image, for example a small car, and I want to move move it along a form by changing its position properties. Fine. However, the front of the car is always pointing in one direction, up. How would I rotate the image/picturebox? (Whats the difference between these? :s)

Im sure there's some whizzy control that does it for me, or some obscure API call, but alas, I do not know it


Rotating Picture Object
Morning all (and Night),

I have an airplane .jpg image loaded into a Picture Object, that is
'tracked' over a Map Image (long story, GPS interface etc).

My question is, can the airplane image (Picture Object) be rotated
to correctly align to the track the 'airplane ' is taking. In other
words, when the airplane shold be tracking south, it points
south. If track is tending east, the airplane rotates toward East....

I know an option would be to have say 8 airplane .jpg's (orientated
at different points of the compas), and load the appropriate one
as required, Is that the only way...


Rotating An Empty Picture Box Control

I am trying to rotate a picturebox control with no pictures in it using a mouse at runtime. Can anyone help me or point to the right idea regarding this matter. My other question is how would it be possible to get access to three other edges of the picturebox control other than (top,left).
I was thinking that since the position of the picturebox control is only controlled by the (top, left) edge of the picturebox control, thus it not possible to rotate the picturebox without accessing (top + height, left), (top, height + width) or (top + height, left + width).
Does anyone knows any "trick" that would enable me to access the other three edges of the picturebox and allow me to rotate it. (Please note that the picturebox does not have any picture in it in which case it might be easier to rotate).

Rotating And Saving An Image In One Picture Box
Im currently working on a program, and I have everything done with the exception of the image rotations. Here is what Im wanting to do:

<Form is loaded and has box.jpg in a picture box>
:Click 'Rotate/Flip' button:
box.jpg is rotated 90 degrees CW and flipped horizontally in the same picture box
<Save image> (I already have this working)

As I've seen its not a very short code, what would be the simplest/most efficient way of doing this.

Im still a little new to all of the functions in vb6, and Ive seen various codes for this, but Im not sure how to adapt them to my needs.

Print A Rotating Text From A Picture Box
I used the rotating text to have an inclined text in a picture box but i tried to print it with my printer (Really, with a printer!!!) but nothing appears on the paper...
what should I do?

Rotating An Image Controls Picture And Keep The Pictures Original Dimensions???
Ok, building a program that will allow for one to have collections of images. The images are displayed when they open up the collections. Each collection will have a different amount of images/pictures depending on the users preference. So, in order not to use up to many system resources, I've choose to work with the IMAGE Control, as opposed to the PictureBox Control!

This program is mainly for those users wishing to collect a bunch of WALLPAPER Pics. Some of the pictures/images dimensions will most likely be greater than that of the desktop resolution/dimensions. Thus applying effects on the image control will be most DIFFICULT and still keep the images original dimensions. Thus StretchBlt could NOT be used!!!

So far I've managed to grayscale the picture in the image control by copying the picture in the image control to a PictureBox control on another form and working with 2 PictureBox's on that form when they wish to grayscale it. Was having the most difficult time getting the RGB from the pixels when the images/pictures dimensions were greater than their Desktop dimensions/resolution. However, I managed to pull this code off without using the StretchBLT API Call!

And after searching this form for Rotating a Picture, every example I've found proved USELESS for what I need to do. I need to transfer the Image.Picture to Form2.Picture1.Picture and then Rotate all of the pixels (including those that are off of the screen) and convert that rotated picture to Form2.Picture2.Picture and then put Form2.Picture2.Picture into Image.Picture with the stretch property on true. I can't seem to get this to work.

The only rotation angles that I will be needing are 90° CW, 90° CCW, and 180°. There will be no other angle rotations but these 3.

Can anyone out there please help??


Rotating A Picture Using One Picture Box, Not 2
I know that you can rotate images using two picture boxes, but I was wondering how to rotate an image using only picture box.


Capture Entire Picture Of Picture Box Though Picture Exceeds Screen Height
please give me details how to capture entire portion of picture in a picture box control though the picture height is greater than the screen height.

I have an image in a memory DC, and i want to rotate it within memory before i bitblt it onto a picture. Does anyone know the fastest way to do this? Thanks in advance.

Rotating XYs
I need a function like this :

Public Type XY
X As Long
Y As Long
End Type

Function RotateXY(Center as XY, Angle as long, PointToRotate as XY) as XY
End fuction

'Dim Cen,Point as XY
'Cen.X = 2
'Cen.Y = 2
'Point.X = 2
'Point.Y = 1
'RotateXY(Cen, 90, Point).X will return 3
'RotateXY(Cen, 90, Point).Y will return 2

Help me make the "RotateXY" function, thanks

Gun Rotating
Hi folks,

i have made i gun in 3dsmax and converted into an .x model. I want it to rotate with the camera rotation but i don't know how exactly.
Like in all fps i want it to stick next to me:

i Have point A and the weapon must rotate about .5 away from point A
The weapon is at 90degrees on the right of Point A.
how can i do this?

*** EDIT ***

Gun.position = test2
Gun.rotate (pi / 2) + ViewingAngle, 0, 0
Gun.move Sin(ViewingAngle + (pi / 2)) * 0.5 + test2.x, Gun.position.y, Cos(ViewingAngle + (pi / 2)) * 0.5 + test2.z
it works but i doesn't go with it up

How do you rotate a picture in a picture box or on a form by ? degrees(Maybe API)?

Rotating TXT
Can sum 1 which a brain help me? i know how to make txt flash on VB but is it possible 2 make the TXT spin around or rotate?

Hello , i wanted to find out if there is someone
who knows how to take an image box (or picture box or whatever) and rotate it around it self

i can do it in pascal at real mode
but only with SINCOS formulas and to take the center as X,Y(0,0) , if anyone knows a better way in visual basic
to rotate in degree/Radians please reply me

Thank You

Rotating Pictures
hey can I rotate a simple 2d image somehow in vb without having a seperate picture file for each rotation angle?

Rotating An Image Using GDI+
I am looking for a way to rotate an image by X degrees. (ie not the rotateflip function)

I found the GdipRotateWorldTransform function that seemed to fit the bill but havent yet got it working properly.
If anyone can shed any light on what Im doing wrong I would appreciate it.

My first try :

Public Function RotateImage(ByRef hImage As Long, ByVal angle As Single)
Dim uOrder As MatrixOrder
Dim retval As Long
Dim hGraphics As Long

If IsAGoodImage(hImage) Then
uOrder = MatrixOrderPrepend
retval = GdipGetImageGraphicsContext(hImage, hGraphics)
retval = GdipRotateWorldTransform(hGraphics, angle, uOrder)
retval = GdipDeleteGraphics(hGraphics)
End If
End Function

When this didnt work I thought it might be because the graphics was being destroyed and not being applied. So I thought, the way to apply the change is to draw it.
So then I tried this:

Public Function RotateImage(ByRef hImage As Long, ByVal angle As Single)
Dim uOrder As MatrixOrder
Dim retval As Long
Dim hGraphics1 As Long
Dim hGraphics2 As Long
Dim hClone As Long

If IsAGoodImage(hImage) Then
uOrder = MatrixOrderPrepend

'because any changes to Graphics arent written to the image until it is drawn
'we need to make a copy of our original image
'then rotate this
'then draw those changes back onto our original image
'at least... thats the plan
retval = GdipCloneImage(hImage, hClone)
'get graphics of the images
retval = GdipGetImageGraphicsContext(hClone, hGraphics1)
retval = GdipGetImageGraphicsContext(hImage, hGraphics2)
'rotate the cloned image
retval = GdipRotateWorldTransform(hGraphics1, angle, uOrder)
'and then draw that change back onto the original image
retval = GdipDrawImageI(hGraphics2, hClone, 0, 0)
'clean up
retval = GdipDeleteGraphics(hGraphics1)
retval = GdipDeleteGraphics(hGraphics2)
retval = GdipDisposeImage(hClone)
End If
End Function

But, it still doesnt work.

Anyone got any ideas?

Rotating A Bitmap
I would like to be able to rotate a bitmap image (in a PictureBox) 360 degrees.

I have little graphic experience, and don't know where to start.

Could someone point me to a tutorial or something else, to get me started in the right direction.

Rotating Controls???
Is it possible to rotate controls of any sort but especially label, image and user controls. I want to be able to rotate my image controls with the mouse. I'd also like them to rotate by any degree the user specifies (not just 90, 180 etc).


Rotating A Image
I'm developing a photo album ind need a method that rotates a image fast. The image is in picturebox.

Can somebady help me? Please be detailed i'm noobie.

Rotating Picturebox
is there any way to rotate a picturebox together with its border. i don't want to rotate just the picture but i want to rotate the picturebox on the whole.


Rotating Objects In VB
Hi guys,

At my highschool, we've learned how to move objects (i.e. shapes) in horizontal and vertical directions. We were then able to apply this idea to move objects diagonally.

However, we've never actually learned how to rotate objects, i.e. objects that rotate on a fixed axis, like the hands on a clock.

How can I rotate a line so that one end of the line remains in a fixed location, while the other end traces the path of an arc?

A 90 degree rotation, or a distance of pi/2 will suffice.


Rotating Shapes
hi i need to make a fan rotate, for the "wings" of the fan i used 4 shapes in a control array, but how do i make it turn...

Rotating An Image
Hi all,

I'm trying to rotate an image:

Option Explicit
Private Const PI As Long = 22 / 7
Private Declare Function SetPixel Lib "gdi32" _
(ByVal hdc As Long, _
ByVal x As Long, _
ByVal y As Long, _
ByVal crColor As Long) As Long

Private Declare Function GetPixel Lib "gdi32" _
(ByVal hdc As Long, _
ByVal x As Long, _
ByVal y As Long) As Long

Private Sub cmdDraw_Click()
Dim lngColour As Long
Dim intOriginX As Integer
Dim intOriginY As Integer
Dim sngAngle As Single
Dim sngRads As Single
Dim lngY As Long
Dim lngY1 As Long
Dim lngX As Long
Dim lngPointY As Long
Dim lngPointX As Long
Dim lngLength As Long
Dim lngLen As Long
Dim lngReturn As Long
sngRads = PI * 180
lngColour = vbBlack
Picture1.ForeColor = lngColour
Picture1.ScaleMode = 3
' Origin values define the centre of the Image
intOriginX = Picture1.ScaleWidth / 2
intOriginY = Picture1.ScaleHeight / 2
' Draw the cross hairs through the Origins
lngY = intOriginX
lngLen = 20
For lngX = intOriginX - lngLen To intOriginX + lngLen
lngReturn = SetPixel(Picture1.hdc, lngX, lngY, vbBlack)
Next lngX
lngX = intOriginX
For lngY = intOriginY - lngLen To intOriginY + lngLen
lngReturn = SetPixel(Picture1.hdc, lngX, lngY, vbBlack)
Next lngY
' Draw the Arrow Head
lngLength = 10
Picture1.ForeColor = vbRed
For lngY = intOriginY To (intOriginY + 30) Step 2
For lngX = 0 To lngLength
For lngY1 = lngY To lngY + 2
lngReturn = SetPixel(Picture1.hdc, intOriginX + lngX, lngY1, vbRed)
lngReturn = SetPixel(Picture1.hdc, intOriginX - lngX, lngY1, vbRed)
Next lngY1
Next lngX
lngLength = lngLength - 1
Next lngY
End Sub

Private Sub cmdRotate_Click()
Dim lngX As Long
Dim lngY As Long
Dim lngX1 As Long
Dim lngY1 As Long
Dim lngXMin As Long
Dim lngYMin As Long
Dim lngReturn As Long
Dim lngColour As Long
Dim sngAngle As Single
Dim sngSin As Single
Dim sngCos As Single
Dim intOffSetX As Long
Dim intOffSetY As Long
Dim lngBack As Long
Dim lngLen As Long
' Ensure both PictureBoxes are identical in dimensions
' and (important) configuration
Picture2.ScaleMode = Picture1.ScaleMode
Picture2.ScaleWidth = Picture1.ScaleWidth
Picture2.ScaleHeight = Picture1.ScaleHeight
Picture2.Width = Picture1.Width
Picture2.Height = Picture1.Height

Picture2.BackColor = vbWhite
' Get the background colour
' It's used later to stop the process from
' copying the background to PictureBox2
lngBack = GetPixel(Picture1.hdc, 0, 0)
' OffSet values define the Rotation Point
' (They just happen to be in the centre of the Image)
intOffSetX = (Picture1.ScaleWidth) / 2
intOffSetY = (Picture1.ScaleHeight) / 2

lngColour = vbBlue
' Angle of Rotation
sngAngle = 180
' The angle doesn't change so its outside of the loops
sngSin = Sin(sngAngle * PI / 180)
sngCos = Cos(sngAngle * PI / 180)
' Perform the rotation
lngXMin = 0
lngYMin = 0
For lngY = lngYMin To Picture1.ScaleHeight - 1
lngX1 = (((lngXMin - intOffSetX) * sngCos) + ((lngY - intOffSetY) * sngSin) + intOffSetX)
lngY1 = (((lngY - intOffSetY) * sngCos) - ((lngXMin - intOffSetX) * sngSin) + intOffSetY)
For lngX = lngXMin To Picture1.ScaleWidth - 1
' Ensure that the Pixel is within the PictureBox
If (lngX1 <= Picture1.ScaleWidth - 1 And lngX1 >= 0) _
And _
(lngY1 <= Picture1.ScaleHeight - 1 And lngY1 >= 0) Then

lngReturn = GetPixel(Picture1.hdc, lngX1, lngY1)
If lngReturn <> -1 Then
' Check if this is the background colour
' if it is then ignore it
'(Commented out so the background can be seen)
'If lngReturn <> lngBack Then
lngReturn = SetPixel(Picture2.hdc, lngX, lngY, lngReturn)
'End If
' This shouldn't happen
' (I think) but it does
Debug.Print lngX1; " "; lngY1
End If
End If
' Increment the values
' (Put here to reduce the amount of calculations
' both values increase by a fixed amount each time
' through the loop)
lngX1 = (lngX1 + sngCos)
lngY1 = (lngY1 - sngSin)
Next lngX
Next lngY
MsgBox "End"
End Sub
Subrotine cmdDraw creates the Image in PictureBox1 and cmdRotate should rotate it by 180 degrees and draw the rotated object in PictureBox2.
Well, it has a very good go but it's not quite there. I end up with about a 160 degree rotation, the problem being, I think, that the codes is going outside of the boundaries of PictureBox1 and I can't for the life of me work out how or where. (I've posted all the code as it's easier to see the problem by actually running it - at least it's easier for me !)

Any help would be greatly appreciated.


Rotating Circle.
i'm making a wheel of fortune clone so i need somehelp with the 'wheel'.
1) how do i create a circle that is divided up into 20 or so different sections
2) how do i print the money TEXT on those pieces so it is sideways like in the tv show wheel.
3) how do i rotate the circle (some sort of trig function?)
4) when the wheel stops on a certain point (say 12'o clock) how do i determine what money value stopped on that marker.

thanks for any help.

Rotating Pictures?
is there an easy way (like an API or soemthing) to rotate pictures like any rotation I want to?

Rotating A Surface
Are there anyone who know how to rotate a surface. I know i should use DDBLTFX type. But i dont know how. I am using DirectX 7.

Rotating A Shape
Say, I have an array of vertices which represent a shape, (eg 4 verticies could represent a square). I could draw the shape quite easily using the Line function. Now how do I rotate the shape through a certain angle given a pivot point? I think this has something to do with matrix transformation but all the articles I can find on this subject talk about 3D coordinates and go into more depth than I'd like. Does anyone know of a simple solution?

Rotating, And Angles...
So i have checked out OnErrors script for rotating images...

i am making a 2d shooter game, set up like the first GTA. I was wondering if there was any (easy) way to make the sprite move at a certain angle, reletive to the angle in which the image was rotated...

currently now it rotates the image, and the movement looks more humorous than realistic.

any help, suggestions... code?


ps - i am reletively new to VB, so go real easy on me please.

Rotating Images
I just need to rotate a small image for asteroids, 40 x 40. Since I am only in 8th grade I dont know how to use Sign/Cosign/Tangent. (I think thats what theyre called) And i think i need them for this operation, BUT I DONT KNOW HOW TO USE THEM! Plz help. All i need is the code, and i dont know how to attach images otherwise i would show you it. And its not online, its made by me.

BitBlt Rotating

Does someone know if (and if how ) you can rotatate, mirrow etc.. something using BitBlt.???

Also....I know this can be done with DirectDraw but my Englisch ant very well and directx4vb is for my too hard to understand. Does someone know an other site?

Sorry 4 my stupidety

A 3D-rotating Cube
hi at all,

i'm a newbie in programming DX 3D.
In the last weeks i startet with DirectDraw and so i've coded a little 2Darcade-game to learn it and get experience in easy game programming.

now that 2D stuff is not interesting anymore.
but i've a problem to get over that wall of 3dprogramming.

i've set my self the goal to programm a 3d cube or something like that which is rotating. The sides of the cube should get bitmaps on their surfaces.

to blit an image on a 2d surface is easy..but how do i build an object with more side than one ?

and how can i get images (on the sides) in perspective ?

are their directX Features to rotate an multisided object by changing the coordinates of one specified edgepoint of this object

if i had answers for all that could i begin ? please correct me, if i am on the wrong way..

Has anyone seen an open source example in vb for that ? (a nice link for me,etc..)

thank you for any posts our helps

Rotating Image
i got keydown and keyup events

on keydown
if vbkeyleft is pressed
then mveleft = 1 ' this will move the image rotating left
end keydown

on keyup
if vbkeyleft is released
then mveleft = 0 ' this will stop moving the image rotating left
end keyup

now if the left key was pressed and then released while the image has rotated only 50 degrees. and then the up key is pressed how will i make the image moving forwards instead of moving up?

Rotating Images
i am making a race track program that has two images, they "race" eachother around a circular track (like the dot races at the ball game), but my problem is when the images get the a part of the track when the need to turn, i can make the images move in a diferent direction, but they are orientated wrond, so they finish the race upside down.

any ideas on how to rotate the imgaes

Rotating And Mirroring
how can i rotate and mirror it

Pictures Rotating
can you rotate an image
If you could send me a example code it would be greatly apreciated

Rotating Sprites On The Fly
Is there any practicle way to rotate sprites during runtime that doesnt take a minute to do? I'm working a 2d space game using DirectDraw and a ship that is drawn in the same way the asteroids ship is, just 4 lines the make a little ship, and I can rotate it easy by simply moving the points that draw the lines. But using lines to have a ship leaves a nice gaping hole in the middle which I would like to be filled with color. The easiest way I see of doing this is to just use a sprite, and it would be even easier if I could make one sprite and just rotate it instead of making alot of them to keep ship rotating smooth.

Rotating Images
How can you rotate images in Direct X? Would you use an API or a function?

Rotating Image In Dx8.1
how can this be done? I need to rotate it like you would a 2d image since my game is going to be 2d, so I have no matrixes.

Rotating Problem
Dim x As Single
x = Sin(count)
ShotGun.rotate x, 0, 0
this works but when i do this:

Dim x As Single
x = Sin(count)/100
ShotGun.rotate x, 0, 0
it doesn't work. Why is this because it doesn't make sense

Help In Rotating Circle
Hello. I am controlling servo motor with mscomm control. I can rotate the motor with visual basic. But i also want a visual effect in my form which rotates a circle at a specific angle regarding to how long i push the button. What must i do? Thanks for your help...

Rotating Text
I've searched time and time again, and I can't find what I need...

I can use Textbox, Picturebox, or label, it doesn't matter...

I need to rotate... a barcode, yes a barcode...

90 degrees...

I can do this on the form (surface of the form) but I can't get it to be on top of any items (The problem is it needs to be on the frame)

Any helpful code?

Copyright © 2005-08, All rights reserved