Re: Graphics transforms



On Mar 19, 11:45 am, "visionset" <s...@xxxxxxxxxxxx> wrote:
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

You reverse the translations you've done.
g2d.translate(orig.x, orig.y);
g2d.rotate(rect.getTheta(), centre.x, centre.y);

.



Relevant Pages

  • complaints/crashes in XNews 5.4.25.0
    ... Last couple of days it's been acting oddly, to wit: If I try to grab a ... scroll bar elevator (the little rectangle that slides text up and ...
    (news.software.readers)
  • Graphics transforms
    ... I'm drawing a Rectangle somewhere on a Graphics object over an image and ... I now want to use that rectangle to describe the part of the image I want to ... To grab it I'm stuffing it in a BufferedImage by drawing on its Graphics ...
    (comp.lang.java.gui)
  • 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: ULONG to Visual Basic 6
    ... I wrote a whole bunch of bit-twiddling routines, long ago, and maybe some of those ... Grab Twiddle.zip from http://www.mvps.org/vb/samples.htm if you're ... > unsigned data types. ... > translation but it never worked. ...
    (microsoft.public.vb.general.discussion)
  • Re: access violation when try Hardware Detection Demo
    ... > How do i fix this error? ... I've found that translation has problems for me as well. ... Grab SetupAPI.zip from: ... Ignacio ...
    (borland.public.delphi.nativeapi)