🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #8916

Re: Rotate Image

#8916
From: Steve Horsley
Date: Tue, 27 Jun 2000 00:00
36 lines
1473 bytes
I have not done this with an image, but have done similar with text.
Give it a try:

public void paint(Graphics g) {

    // we need the extended graphics features, I think...
    Graphics2D g2 = (Graphics2D) g;

    // Assume I have an image that is 100 x 100
    // Move the origin to the middle of the picture
    // in reality, you will have to move to one corner, but I forget
which
    g2.translate(50, 50);

    // rotate the drawing mechanism about the origin
    g2.rotate(Math.PI / 2);

    // draw the image
    g2.drawImage(myImage);

    // de-rotate  and de-translate the paper
    g2.rotate(-Math.PI / 2);
    g2.translate(-50, -50);
}

Steve.

JPBallet wrote:
> 
> Hello,
> who can help me?
> i wish rotate (PI/2)  an image (gif) into a JPanel application.
> but all don't work  very well.
> Could you  describe me  step by step  how can to do this?
> Thank
> JP Ballet.
Technical Details
Message-ID: <39586810.D1A762EE@cwcom.co.uk>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <8j9gmh$d9q13@bornews.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,ef6b50d79cf9fa21
X-Google-Attributes: gid111d45,public
From: Steve Horsley <steve.horsley@cwcom.co.uk>
Subject: Re: Rotate Image
Date: 2000/06/27
Message-ID: <39586810.D1A762EE@cwcom.co.uk>
X-Deja-AN: 639472503
Content-Transfer-Encoding: 7bit
References: <8j9gmh$d9q13@bornews.borland.com>
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
X-Trace: 27 Jun 2000 01:28:55 -0800, 194.200.13.1
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing