Re: imprecise Graphics.RotateTransform



Thanks... I've incidentally solved my problem setting the
Graphics.PixelOffsetMode to HighQuality....
I think .NET needs more documentation... (although it's already much better
than java, tho..)

"Bob Powell [MVP]" wrote:

All in the order...

e.Graphics.ResetTransform();
e.Graphics.TranslateTransform(-3, -40);
e.Graphics.RotateTransform(i * 30);
e.Graphics.TranslateTransform(100, 100);
e.Graphics.DrawImage(c.CetBitmap, 0, 0);


--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.


"thenext1" <thenext1@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:EC30BFDC-519B-4DA9-AC3D-6272623BF1DF@xxxxxxxxxxxxxxxx
I have an image representing a clock's minute hand and which I need to draw
in the 12 positions.
After fiddling a bit, i noticed that there's a strange offset from the
hand
in one position (i.e. 3 PM) and the opposite (9 PM).
It seems that the RotateTransform function i'm using doesn't work
correctly,
or alternatively that I can't manage to horizontally center the point of
rotation so that it rotates around an odd position.

To understand what I mean look here:
http://gemini.dynalias.net/web3/clock-net.png
The code I use for this drawing is the following:
float t = 0;
for (int i = 0; i < 12; i++)
{
e.Graphics.ResetTransform();
e.Graphics.TranslateTransform(100, 100);
e.Graphics.RotateTransform(i * 30);
e.Graphics.TranslateTransform(-3, -40);
e.Graphics.DrawImage(c.CetBitmap, 0, 0);
}
The png's width is 6 (hence, translated back 3 pixels)



Furthermore I tried doing the same thing with java's Graphics2d class, and
it works correctly: http://gemini.dynalias.net/web3/clock-java.png
The hand is perfectly aligned and coincident when in opposite positions.
The java code is:
AffineTransform base = g2d.getTransform();
for (int i = 0; i < 12; i++) {
g2d.setTransform(base);
g2d.translate(100,100);
g2d.rotate(i*Math.PI/6);
g2d.translate(-3, -40.0);
g2d.drawImage(NewJFrame.m, 0, 0, this);
}


many thanks in advance

.



Relevant Pages

  • Re: imprecise Graphics.RotateTransform
    ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... It seems that the RotateTransform function i'm using doesn't work correctly, ... The hand is perfectly aligned and coincident when in opposite positions. ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: In the Shallow End
    ... Yes, with Apple finally getting in there, technology is finally moving along nicely again. ... What they like to do is use the Windows desktop as data gathering frontends to these operations. ... They had other plans for Java, ... They make computers for the elite. ...
    (comp.sys.mac.advocacy)
  • Re: IE6 javascript & active x not working
    ... > I'm trying to fix a problem on a Windows XP SP1 Compaq computer. ... Where to get the JAVA VM ... Sun also offers an automatic download and install of the 1.4 Java plug-in ... ActiveX problems in IE ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: Zero Width Pen Draws through clipped region...
    ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... Exclude the rectangle from the graphics clip region. ... IF you use a pen that is more than one pixel the clipping works ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: IE6 cannot access secured sites after SP2 install
    ... I installed Windows script 5.6 ... >To download Java VM for XP: ... >Windows Update/Enable the Windows Update Catalog. ... >Sun also offers an automatic download and install of the ...
    (microsoft.public.windows.inetexplorer.ie6.browser)