Graphics transforms



I'm drawing a Rectangle somewhere on a Graphics object over an image and
rotating it some degrees about its centre.
I now want to use that rectangle to describe the part of the image I want to
grab.
To grab it I'm stuffing it in a BufferedImage by drawing on its Graphics
like so:

// rect is a Shape
// origin is the min x & min y of the rectangle
Point centre = rect.getCentre();

g2.rotate(-rect.getTheta(), centre.x, centre.y);

Point orig = rect.getOrigin();

g2.translate(-orig.x, -orig.y);

g2.setClip(rect);

renderTiles(g2);

The rotation works fine. But I can't figure out the translation to get it
back to 0,0



Any clues folks?

TIA

--

Mike W






.



Relevant Pages

  • Re: Usable ClientRectangle for Form
    ... transform on the graphics object to translate the drawing so that that is ... // Start drawing BELOW the statusbar ... What I want to get is a rectangle that represents the ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Make rectangle with managed D3D
    ... You shouldn't need to lock the rectangle. ... Just grab the Graphics and draw, ... then release the Graphics object. ...
    (microsoft.public.win32.programmer.directx.managed)
  • Re: dashed line not displaying
    ... tab> Object> Create from File> MO Visio Drawing. ... I am unable to use the pencil tool (to resize in any ... the invisible rectangle as I mentioned in my last post. ...
    (microsoft.public.visio.general)
  • Re: dashed line not displaying
    ... the dashed rectangle is the "outer most ... step of opening the pasted drawing and "re-triggering" the dashed lines. ... One other thought, using your approach, when you open the placed Visio ... and then close the Visio edit window. ...
    (microsoft.public.visio.general)
  • Re: dashed line not displaying
    ... it to Word due the following in Visio. ... Delete the dashed shape and replace it with a rectangle. ... Save your drawing. ... I am unable to use the pencil tool (to resize in any ...
    (microsoft.public.visio.general)

Loading