[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.drawing

Re: imprecise Graphics.RotateTransform

Robert Brower

2/28/2011 7:53:00 PM

I have the same problem. Did you ever solve this?

> On Friday, April 20, 2007 3:12 PM thenext wrote:

> 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/clo...
> 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/cloc...
> 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


>> On Saturday, April 21, 2007 6:27 AM 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.ra...
>>
>> Find great Windows Forms articles in Windows Forms Tips and Tricks
>> http://www.bobpowell.net/tips...
>>
>> Answer those GDI+ questions with the GDI+ FAQ
>> http://www.bobpowell.net/f...
>>
>> All new articles provide code in C# and VB.NET.
>> Subscribe to the RSS feeds provided and never miss a new article.
>>
>>
>> "thenext1" <thenext1@discussions.microsoft.com> wrote in message
>> news:EC30BFDC-519B-4DA9-AC3D-6272623BF1DF@microsoft.com...


>>> On Saturday, April 21, 2007 6:40 AM thenext wrote:

>>> 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:


>>> Submitted via EggHeadCafe
>>> Statistics, Probability, Lotteries and Dumb Programmers
>>> http://www.eggheadcafe.com/tutorials/aspnet/041de19a-e704-468f-bd3c-79164fc739f5/statistics-probability-lotteries-and-dumb-progra...