473,698 Members | 2,432 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 2545
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
1879
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 stretch the image diagonal, up, and down and for a border to appear when the picturebox is entered. ...
5
2097
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 adjusted to its own dimension. I would like to load a new image with its own dimension at the same time....
1
2104
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 caching problem the scripting seems to work Any help welcomed:
14
6555
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
6828
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 think. Memory read access violation or something. Im using Visual C++ 2005 express edition and...
3
5953
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 usefull applet for everybody. All suggestion welcome! Thanks Arnaud
1
1814
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 ne1 help?!?
1
2565
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
3446
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
8678
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8609
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9166
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4621
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
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
3
2007
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.