473,322 Members | 1,719 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,322 software developers and data experts.

Rotating Graphics

I can draw on a PictureBox like this ...

private void pic_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Graphics g = e.Graphics;
using (SolidBrush brush = new SolidBrush(Color.Red))
{
g.FillRectangle(brush, 0, 0, 100, 100);
}
}

.... but how can I rotate the resulting graphical output?

pic.Image.RotateFlip is no good, because my drawing doesn't count as an
Image property. I've also tried g.RotateTransform, but that doesn't seem to
do anything.

P.

--
www.CL4.org
Nov 15 '05 #1
2 3881
Paul,

1. Ensure you apply RotateTransform before drawing the rectangle.
2. Ensure the FillRectangle method supports the transformations. You might
need an alternative method of drawing your image.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Paul E Collins" <fi******************@CL4.org> wrote in message
news:bj**********@hercules.btinternet.com...
I can draw on a PictureBox like this ...

private void pic_Paint(object sender, System.Windows.Forms.PaintEventArgs e) {
Graphics g = e.Graphics;
using (SolidBrush brush = new SolidBrush(Color.Red))
{
g.FillRectangle(brush, 0, 0, 100, 100);
}
}

... but how can I rotate the resulting graphical output?

pic.Image.RotateFlip is no good, because my drawing doesn't count as an
Image property. I've also tried g.RotateTransform, but that doesn't seem to do anything.

P.

--
www.CL4.org


Nov 15 '05 #2
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote:
1. Ensure you apply RotateTransform before drawing the rectangle.


That was the problem. Thanks!

P.

--
www.CL4.org
Nov 15 '05 #3

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

Similar topics

3
by: asognoth | last post by:
Hi... Does anybody have a clue how to solve this problem? the task is to change the following method in that manner that it draws the (calculated) image form left to right instead of from top...
2
by: MichaelH | last post by:
Hi all, I am writing a program that has to draw musical notes on a staff. To do this I need to draw Ellispses (representing the notes) on a horizontal line and rotate them slightly (by 15...
4
by: Andre Nogueira | last post by:
Hi there. I have one question... How can I create a bitmap (programmatically), paint it to a picture box and have a transparent background? I don't know what will be below the picturebox because...
6
by: jcrouse | last post by:
I want to rotate it 180 degree so it is upside down. What is the easiest way to accomplish this? Thank you John
5
by: Ricardo Furtado | last post by:
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:...
4
by: Jonathan Wood | last post by:
I'd like to print some text at an angle. I was able to get Graphics.RotateTransform() to work but rotating the entire mapping area makes positioning the text a nightmare. I'd like to instead...
1
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...
7
by: J-Burns | last post by:
Hello. Need some help here. I have a 4*4 cube. So the equation of the cube becoming: x + 4*y + 16*z Now i want to rotate this cube 90 degrees anticlockwise( a right rotation). How can i do...
1
by: Nathan Sokalski | last post by:
I have a Graphics object that I have drawn several things on using transform methods (such as RotateTransform and TranslateTransform) and drawing methods (such as FillRectangle and DrawString) of...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.