473,569 Members | 2,400 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

rotating image

I'm trying, for a week or two, to create a procedure in order to rotate the
image in any picturebox control in a cephalometry software. I've found a web
site that shows how that can be done:
http://vb-helper.com/index_vbnet.html
but the problem is that the image doesn't stay at the top, instead, the
image is created upon another bitmap, even larger, and at its right corner.
I've already tryed to cut the right corner, with the right dimensions, create
a new bitmap with the right dimensions and paste the part of the image
belonging to the rotated image in the x=0, y=0 coordenates. That almost
works, but the image is not big enough because, once the image is rotated the
size (width/height) of the image is increased (Pythagoras Theorem). I've
tryed several things, and i'm really, really, really desperate. Can you help
ps: if you set the picturebox sizemode as "stretchIma ge", which is what i
need to use in the software i'm developing, the image seems to get smaller,
although what's happening is what i've explained previously.

My thanks in advance

Sep 22 '06 #1
5 2532
Do you have to rotate the image by a certain number or degrees? If not
check out the RotateFlip() method of the system.drawing. image object.
It only rotates in increments of 90 degrees though.

Thanks,

Seth Rowe

Ricardo Furtado wrote:
I'm trying, for a week or two, to create a procedure in order to rotate the
image in any picturebox control in a cephalometry software. I've found a web
site that shows how that can be done:
http://vb-helper.com/index_vbnet.html
but the problem is that the image doesn't stay at the top, instead, the
image is created upon another bitmap, even larger, and at its right corner.
I've already tryed to cut the right corner, with the right dimensions, create
a new bitmap with the right dimensions and paste the part of the image
belonging to the rotated image in the x=0, y=0 coordenates. That almost
works, but the image is not big enough because, once the image is rotated the
size (width/height) of the image is increased (Pythagoras Theorem). I've
tryed several things, and i'm really, really, really desperate. Can you help
ps: if you set the picturebox sizemode as "stretchIma ge", which is what i
need to use in the software i'm developing, the image seems to get smaller,
although what's happening is what i've explained previously.

My thanks in advance
Sep 22 '06 #2
yes i do. The user will rotate the image by pressing the mouse button on the
corners of the picturebox

"rowe_newsgroup s" wrote:
Do you have to rotate the image by a certain number or degrees? If not
check out the RotateFlip() method of the system.drawing. image object.
It only rotates in increments of 90 degrees though.

Thanks,

Seth Rowe

Ricardo Furtado wrote:
I'm trying, for a week or two, to create a procedure in order to rotate the
image in any picturebox control in a cephalometry software. I've found a web
site that shows how that can be done:
http://vb-helper.com/index_vbnet.html
but the problem is that the image doesn't stay at the top, instead, the
image is created upon another bitmap, even larger, and at its right corner.
I've already tryed to cut the right corner, with the right dimensions, create
a new bitmap with the right dimensions and paste the part of the image
belonging to the rotated image in the x=0, y=0 coordenates. That almost
works, but the image is not big enough because, once the image is rotated the
size (width/height) of the image is increased (Pythagoras Theorem). I've
tryed several things, and i'm really, really, really desperate. Can you help
ps: if you set the picturebox sizemode as "stretchIma ge", which is what i
need to use in the software i'm developing, the image seems to get smaller,
although what's happening is what i've explained previously.

My thanks in advance

Sep 23 '06 #3
On Fri, 22 Sep 2006 08:31:02 -0700, Ricardo Furtado
<Ri************ @discussions.mi crosoft.comwrot e:
>I'm trying, for a week or two, to create a procedure in order to rotate the
image in any picturebox control in a cephalometry software. I've found a web
site that shows how that can be done:
http://vb-helper.com/index_vbnet.html
but the problem is that the image doesn't stay at the top, instead, the
image is created upon another bitmap, even larger, and at its right corner.
I've already tryed to cut the right corner, with the right dimensions, create
a new bitmap with the right dimensions and paste the part of the image
belonging to the rotated image in the x=0, y=0 coordenates. That almost
works, but the image is not big enough because, once the image is rotated the
size (width/height) of the image is increased (Pythagoras Theorem). I've
tryed several things, and i'm really, really, really desperate. Can you help
ps: if you set the picturebox sizemode as "stretchIma ge", which is what i
need to use in the software i'm developing, the image seems to get smaller,
although what's happening is what i've explained previously.

My thanks in advance
The example at the posted link works as expected. It's not clear to me, or
apparently anyone else, as to what you are trying to describe.

Gene

Gene
Sep 23 '06 #4
i'm trying to rotate an image with an angle set by the user.
I know this is very dificult to show you, the only way was if you could see
the image. but imagine this:
- i have an image of a patient.
- an image of a tooth is drawn on the patient face
- the user can rotate (resize it, and drag it) the image of the tooth in
order put the image of the tooth on top of the other image where the tooth
is.
I've found some code for the rotation of the image, but the problem has to
do with the size of the image after the rotation function. The imagem is
always getting bigger and the tooth is always looking smaller
the code is the following:

Public Sub rotateImg(ByRef imagem As Image, ByVal sngAngle As Single)
' Copy the output bitmap from the source image.
Dim bm_in As New Bitmap(imagem)

' Make an array of points defining the
' image's corners.
Dim wid As Single = bm_in.Width
Dim hgt As Single = bm_in.Height
Dim corners As Point() = { _
New Point(0, 0), _
New Point(wid, 0), _
New Point(0, hgt), _
New Point(wid, hgt)}

' Translate to center the bounding box at the origin.
Dim cx As Single = wid / 2
Dim cy As Single = hgt / 2
Dim i As Long
For i = 0 To 3
corners(i).X -= cx
corners(i).Y -= cy
Next i

' Rotate.
Dim theta As Single = Single.Parse(sn gAngle) * PI _
/ 180.0
Dim sin_theta As Single = Sin(theta)
Dim cos_theta As Single = Cos(theta)
Dim X As Single
Dim Y As Single
For i = 0 To 3
X = corners(i).X
Y = corners(i).Y
corners(i).X = X * cos_theta + Y * sin_theta
corners(i).Y = -X * sin_theta + Y * cos_theta
Next i

' Translate so X >= 0 and Y >=0 for all corners.
Dim xmin As Single = corners(0).X
Dim ymin As Single = corners(0).Y
For i = 1 To 3
If xmin corners(i).X Then xmin = corners(i).X
If ymin corners(i).Y Then ymin = corners(i).Y
Next i
For i = 0 To 3
corners(i).X -= xmin
corners(i).Y -= ymin
Next i

' Create an output Bitmap and Graphics object.
Dim bm_out As New Bitmap(CInt(-2 * xmin), CInt(-2 * _
ymin))
Dim gr_out As Graphics = Graphics.FromIm age(bm_out)

' Drop the last corner lest we confuse DrawImage,
' which expects an array of three corners.
ReDim Preserve corners(2)

' Draw the result onto the output Bitmap.
gr_out.DrawImag e(bm_in, corners)

' Display the result.

imagem = bm_out

End Sub
"gene kelley" wrote:
On Fri, 22 Sep 2006 08:31:02 -0700, Ricardo Furtado
<Ri************ @discussions.mi crosoft.comwrot e:
I'm trying, for a week or two, to create a procedure in order to rotate the
image in any picturebox control in a cephalometry software. I've found a web
site that shows how that can be done:
http://vb-helper.com/index_vbnet.html
but the problem is that the image doesn't stay at the top, instead, the
image is created upon another bitmap, even larger, and at its right corner.
I've already tryed to cut the right corner, with the right dimensions, create
a new bitmap with the right dimensions and paste the part of the image
belonging to the rotated image in the x=0, y=0 coordenates. That almost
works, but the image is not big enough because, once the image is rotated the
size (width/height) of the image is increased (Pythagoras Theorem). I've
tryed several things, and i'm really, really, really desperate. Can you help
ps: if you set the picturebox sizemode as "stretchIma ge", which is what i
need to use in the software i'm developing, the image seems to get smaller,
although what's happening is what i've explained previously.

My thanks in advance

The example at the posted link works as expected. It's not clear to me, or
apparently anyone else, as to what you are trying to describe.

Gene

Gene
Sep 25 '06 #5
Thanks to all of you. I've managed to solve the problem:
like i said, every time i rotated the image, the image was getting bigger,
because it was being resized. The way i fix the problem was very simple: Now
i'm always rotating the original image, instead of the rotated image, i just
have to know the angle the user rotated the image in the last time in order
to add the next rotation angle to the previous one.

Thanks, once again.

Ricardo Furtado

"Ricardo Furtado" wrote:
i'm trying to rotate an image with an angle set by the user.
I know this is very dificult to show you, the only way was if you could see
the image. but imagine this:
- i have an image of a patient.
- an image of a tooth is drawn on the patient face
- the user can rotate (resize it, and drag it) the image of the tooth in
order put the image of the tooth on top of the other image where the tooth
is.
I've found some code for the rotation of the image, but the problem has to
do with the size of the image after the rotation function. The imagem is
always getting bigger and the tooth is always looking smaller
the code is the following:

Public Sub rotateImg(ByRef imagem As Image, ByVal sngAngle As Single)
' Copy the output bitmap from the source image.
Dim bm_in As New Bitmap(imagem)

' Make an array of points defining the
' image's corners.
Dim wid As Single = bm_in.Width
Dim hgt As Single = bm_in.Height
Dim corners As Point() = { _
New Point(0, 0), _
New Point(wid, 0), _
New Point(0, hgt), _
New Point(wid, hgt)}

' Translate to center the bounding box at the origin.
Dim cx As Single = wid / 2
Dim cy As Single = hgt / 2
Dim i As Long
For i = 0 To 3
corners(i).X -= cx
corners(i).Y -= cy
Next i

' Rotate.
Dim theta As Single = Single.Parse(sn gAngle) * PI _
/ 180.0
Dim sin_theta As Single = Sin(theta)
Dim cos_theta As Single = Cos(theta)
Dim X As Single
Dim Y As Single
For i = 0 To 3
X = corners(i).X
Y = corners(i).Y
corners(i).X = X * cos_theta + Y * sin_theta
corners(i).Y = -X * sin_theta + Y * cos_theta
Next i

' Translate so X >= 0 and Y >=0 for all corners.
Dim xmin As Single = corners(0).X
Dim ymin As Single = corners(0).Y
For i = 1 To 3
If xmin corners(i).X Then xmin = corners(i).X
If ymin corners(i).Y Then ymin = corners(i).Y
Next i
For i = 0 To 3
corners(i).X -= xmin
corners(i).Y -= ymin
Next i

' Create an output Bitmap and Graphics object.
Dim bm_out As New Bitmap(CInt(-2 * xmin), CInt(-2 * _
ymin))
Dim gr_out As Graphics = Graphics.FromIm age(bm_out)

' Drop the last corner lest we confuse DrawImage,
' which expects an array of three corners.
ReDim Preserve corners(2)

' Draw the result onto the output Bitmap.
gr_out.DrawImag e(bm_in, corners)

' Display the result.

imagem = bm_out

End Sub
"gene kelley" wrote:
On Fri, 22 Sep 2006 08:31:02 -0700, Ricardo Furtado
<Ri************ @discussions.mi crosoft.comwrot e:
>I'm trying, for a week or two, to create a procedure in order to rotate the
>image in any picturebox control in a cephalometry software. I've found a web
>site that shows how that can be done:
>http://vb-helper.com/index_vbnet.html
>but the problem is that the image doesn't stay at the top, instead, the
>image is created upon another bitmap, even larger, and at its right corner.
>I've already tryed to cut the right corner, with the right dimensions, create
>a new bitmap with the right dimensions and paste the part of the image
>belonging to the rotated image in the x=0, y=0 coordenates. That almost
>works, but the image is not big enough because, once the image is rotated the
>size (width/height) of the image is increased (Pythagoras Theorem). I've
>tryed several things, and i'm really, really, really desperate. Can you help
>ps: if you set the picturebox sizemode as "stretchIma ge", which is what i
>need to use in the software i'm developing, the image seems to get smaller,
>although what's happening is what i've explained previously.
>
>My thanks in advance
The example at the posted link works as expected. It's not clear to me, or
apparently anyone else, as to what you are trying to describe.

Gene

Gene
Sep 26 '06 #6

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

Similar topics

1
1874
by: Charles A. Lackman | last post by:
Hello, I am trying to rotate a picturebox control. I have done some experimenting with rotating the image inside the picturebox, but I am trying to get the affect of grabbing the corner of the picturebox and moving the mouse to change the angle. I am sure I can implement the code to grab the corners as I have already implemented code to...
5
2088
by: John | last post by:
I am rotating images at one location of my web site. My problem is if I set the width and height of the new image before I show the new image, the old image is stretched first to the new image dimensions, and if I show the new image before setting its dimensions, the new image is stretched first to the old image dimension before it is...
1
2096
by: Grunt | last post by:
Hi, I have been trying to put together a rotating banner. the code works but I am having a problem with the caching of the banner images. no matter what I try the page is constantly reloading the images, even worse they are not loading completely. This version includes a (vain) attempt at forcing the banner images to cache. Apart form the...
14
6536
by: mikeoley | last post by:
Why would this script below work on an html page: http://www.eg-designdev.com/aircylinders/test.htm But not a java page such as this: "http://www.eg-designdev.com/aircylinders/index3.jsp" Or does anybody have a simple slide show rotation script they could refer me to...thanks. <HTML><HEAD>
9
6818
by: Kraken | last post by:
Hi, i have an assignment to open PPM images and prompt the user for either brightening, flipping or rotating the image. Ive done the brightening and flipping, but i cant get the rotating to work. When i try to rotate i get an error, although i think the concept is right. With some testing i figured out thet I get the error when x = 4 and y = 1 i...
3
5946
by: avalence | last post by:
Hello, I am trying to create a nice rotating earth globe (on mouse) on my web site, in order to display my professional relationships all over the world. The best way seems to be a javascript. In fact I still hesitate between java and javascript. My question is how can I create a interacting globe using a satellite photo. This is a very...
1
1807
by: kennykenn | last post by:
Im having trouble startin to develop a rotating image banner, I have coded part of it (only pulling image from a db). My aim is to print an image to part of my web page, allow it to screen for x amout of time and then i need a function to show the image dissolving, flipping or an effect similar to then appear with the next image and so on. Could...
1
2558
by: AR123 | last post by:
Hi I want to set up a rotating banner. Not sure how to incorporate my rotating banner code into the code below. I want the rotating banner to be the main feature image? This is set up in mediasurface My code is: <!-- start page container --> <div id="pageContainer"> <!-- start middle content area --> <div id="genericMiddle">
5
3440
by: Michael | last post by:
Hello all, how could I rotate a server side image in asp.net and show it in web page? Thanks.
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7618
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7926
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6287
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3657
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2117
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1228
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
946
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.