Rotating and Clickable Images

Hello Everyone,
Please point me to the right tutorial or provide steps to
create the following effects. I want to create a Flash page, with:
-3 category of speakers(in-wall, ceiling, and floor)
-each time i click on anyone of thess categories, a 'window'
will pop out and the different types of speaker images(for the
category selected) will rotate/scroll in this 'window.' Then if a
user see a speaker that he/she likes, he can simply point and click
-when he clicks on the specific speaker, another
window(within the same page) will show the specifications for this
specific speaker.
Please advise.
Thank you.
Leon

Well, cycle is running in all but IE. I suggest that you double check your init code for cycle.
See http://jquery.malsup.com/cycle/ for details on cycle.
Also, try the jquery Plugins forum. The author of cycle is very pro-active there.
Hope this helps.
BTW: Mixing Spry and jQuery adds a lot of code to be downloaded. I recommend you considered sticking with just either Spry or jQuery.

Similar Messages

  • Problem in rotating and moving image at the same time

    the problem is that im making a car game(2D) in which u have upper view of car.
    i have make the car rotate bt problem is that i canot move it forward or backward correctly
    .wen i move it forward or backward i goes wrong...
    nd another problem is that i cannot both rotate and move the car at same time
    example if i press both up nd right arrow keys i doesnt move nd rotate..
    nd also plz tell me the accelerate nd reverse method so i can speedup my car like other car games
    here is the code
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.geom.*;
    import java.applet.*;
    import java.net.URL;
    public class RaceGame extends JComponent
    static int x=560;
    static int y=410;
    static int currentAngle=0;
    static double hspeed,vspeed;
    static int carspeed=1;
    Image car;
    //int angle=car.getAngle();
    Image getImage(String filename)
    URL url = getClass().getResource(filename);
    ImageIcon icon = new ImageIcon(url);
    return icon.getImage();
    //Rectangle2D.Float rect=new Rectangle2D.Float(x,y,30,30);
    //Rectangle rect=new Rectangle(x,y,30,30);
    public RaceGame()
    car=getImage("car1.jpeg");
    public void CreateBase()
    JFrame frame=new JFrame("Dare2Race");
    frame.setBounds(70,30,650,500);
    frame.setVisible(true);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container c=frame.getContentPane();
    c.add(new RaceGame());
    frame.addKeyListener(new adapter());
    c.setBackground(Color.BLACK);
    //JLabel finish=new JLabel("FINISH");
    //c.add(finish);
    public void rotate()
    currentAngle+=1;
    if(currentAngle>=360)
    currentAngle=0;
    repaint();
    public void paint(Graphics g)
    super.paint(g);
    Graphics2D g2d=(Graphics2D)g;
    AffineTransform origXform=g2d.getTransform();
    AffineTransform newXform=(AffineTransform)(origXform.clone());
    newXform.rotate(Math.toRadians(currentAngle),x,y);
    g2d.setTransform(newXform);
    g2d.drawImage(car,x,y,this);
    g2d.setTransform(origXform);
    g.setColor(Color.WHITE);
    g.drawLine(640,380,420,380);
    g.drawLine(640,460,320,460);
    g.drawLine(420,380,420,300);
    g.drawLine(320,460,320,380);
    g.drawLine(420,300,125,300);
    g.drawLine(320,380,230,380);
    g.drawLine(230,380,230,460);
    g.drawLine(230,460,2,460);
    g.drawLine(125,300,125,370);
    g.drawLine(125,370,105,370);
    g.drawLine(2,460,2,180);
    g.drawLine(105,370,105,300);
    g.drawLine(2,180,450,180);
    g.drawLine(105,300,105,250);
    g.drawLine(105,250,550,250);
    g.drawLine(550,250,550,20);
    g.drawLine(550,20,275,20);
    g.drawLine(450,180,450,100);
    g.drawLine(450,100,360,100);
    g.drawLine(360,100,360,160);
    g.drawLine(360,160,10,160);
    g.drawLine(10,160,10,30);
    g.drawLine(275,20,275,90);
    g.drawLine(275,90,110,90);
    g.drawLine(110,90,110,30);
    repaint();
    class adapter extends KeyAdapter
    public void keyPressed(KeyEvent e)
    switch(e.getKeyCode())
    case KeyEvent.VK_LEFT:
    currentAngle--;
    repaint();
    break;
    case KeyEvent.VK_RIGHT:
    currentAngle++;
    repaint();
    break;
    case KeyEvent.VK_UP:
    carspeed++;
    hspeed=((double)carspeed)*Math.cos(currentAngle);
    vspeed=((double)carspeed)*Math.sin(currentAngle);
    x = x - (int) hspeed;
    y = y - (int) vspeed;
    repaint();
    break;
    case KeyEvent.VK_DOWN:
    carspeed--;
    hspeed=((double)carspeed)*Math.cos(currentAngle);
    vspeed=((double)carspeed)*Math.sin(currentAngle);
    x = x + (int)hspeed;
    y = y + (int)vspeed;
    repaint();
    break;
    public static void main(String[]args)
    RaceGame race=new RaceGame();
    race.CreateBase();
    //race.setDoubleBuffered(true);
    }

    the problem is that im making a car game(2D) in which u have upper view of car.
    i have make the car rotate bt problem is that i canot move it forward or backward correctly
    .wen i move it forward or backward i goes wrong...
    nd another problem is that i cannot both rotate and move the car at same time
    example if i press both up nd right arrow keys i doesnt move nd rotate..
    nd also plz tell me the accelerate nd reverse method so i can speedup my car like other car games
    plz help me
    here is the code
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.geom.*;
    import java.applet.*;
    import java.net.URL;
    public class RaceGame extends JComponent
    static int x=560;
    static int  y=410;
    static int currentAngle=0;
    static double hspeed,vspeed;
    static  int carspeed=1;
    Image car;
    //int angle=car.getAngle();
    Image getImage(String filename)
    URL url = getClass().getResource(filename);
    ImageIcon  icon = new ImageIcon(url);   
    return icon.getImage();
    //Rectangle2D.Float rect=new Rectangle2D.Float(x,y,30,30);
    //Rectangle rect=new Rectangle(x,y,30,30);
    public RaceGame()
    car=getImage("car1.jpeg");
    public void CreateBase()
    JFrame frame=new JFrame("Dare2Race");
    frame.setBounds(70,30,650,500);
    frame.setVisible(true);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container c=frame.getContentPane();
    c.add(new RaceGame());
    frame.addKeyListener(new adapter());
    c.setBackground(Color.BLACK);
    //JLabel finish=new JLabel("FINISH");
    //c.add(finish);
    public void rotate()
    currentAngle+=1;
    if(currentAngle>=360)
    currentAngle=0;
    repaint();
    public void paint(Graphics g)
    super.paint(g);
    Graphics2D g2d=(Graphics2D)g;
    AffineTransform origXform=g2d.getTransform();
    AffineTransform newXform=(AffineTransform)(origXform.clone());
    newXform.rotate(Math.toRadians(currentAngle),x,y);
    g2d.setTransform(newXform);
    g2d.drawImage(car,x,y,this);
    g2d.setTransform(origXform);
    g.setColor(Color.WHITE);
    g.drawLine(640,380,420,380);
    g.drawLine(640,460,320,460);
    g.drawLine(420,380,420,300);
    g.drawLine(320,460,320,380);
    g.drawLine(420,300,125,300);
    g.drawLine(320,380,230,380);
    g.drawLine(230,380,230,460);
    g.drawLine(230,460,2,460);
    g.drawLine(125,300,125,370);
    g.drawLine(125,370,105,370);
    g.drawLine(2,460,2,180);
    g.drawLine(105,370,105,300);
    g.drawLine(2,180,450,180);
    g.drawLine(105,300,105,250);
    g.drawLine(105,250,550,250);
    g.drawLine(550,250,550,20);
    g.drawLine(550,20,275,20);
    g.drawLine(450,180,450,100);
    g.drawLine(450,100,360,100);
    g.drawLine(360,100,360,160);
    g.drawLine(360,160,10,160);
    g.drawLine(10,160,10,30);
    g.drawLine(275,20,275,90);
    g.drawLine(275,90,110,90);
    g.drawLine(110,90,110,30);
    repaint();
    class adapter extends KeyAdapter
    public void keyPressed(KeyEvent e)
      switch(e.getKeyCode())
        case KeyEvent.VK_LEFT:
        currentAngle--;
        repaint();
        break;
        case KeyEvent.VK_RIGHT:
        currentAngle++;
        repaint();
        break;
        case KeyEvent.VK_UP:
        carspeed++;
        hspeed=((double)carspeed)*Math.cos(currentAngle);
        vspeed=((double)carspeed)*Math.sin(currentAngle);
        x = x - (int) hspeed;
        y = y - (int) vspeed;
        repaint();
        break;
        case KeyEvent.VK_DOWN:
        carspeed--;
        hspeed=((double)carspeed)*Math.cos(currentAngle);
        vspeed=((double)carspeed)*Math.sin(currentAngle);
        x = x + (int)hspeed;
        y = y + (int)vspeed;
        repaint();
        break;
    public static void main(String[]args)
    RaceGame race=new RaceGame();
    race.CreateBase();
    //race.setDoubleBuffered(true);
    }and there is no compile time error in this code
    the only error that occurs when u write java RaceGame is because of the car image which compiler doesnt found and throughs exception if u place any image in ur bin folder adn name it car.jpg it wont generate error

  • Ease of rotating and cropping images in CS6

    There is much I like about the new crop: Rotating the image instead of the box is SO much easier and the straighten option is a great time saver.
    But in one instance, I'm finding cropping in CS6 to be harder: Cropping images that are not correctly oriented in the first place.  Rotating an image 90-degrees was a snap in CS2: Alt-I/E/0.  The shortcut keys are gone in CS6, so using the rotation command is no longer quick.
    But I can do it in the crop box, right?  True -- but not easily.  The image is landscape, the crop box is portrait.  With the crop tool selected, holding the shift key down to get fixed-increment rotations doesn't work: Pressing the SHIFT key changes the cursor from rotation to the crop cursor.  To get the rotation, I have to start rotating the image and then press SHIFT to get 15-degree increments.  A few moments later, I have rotated the image into portrait orientation -- and the crop box is now centered on the image, but it is set to crop the middle.  I have to drag the handles out to get approximately what I want: The full image in the crop box.  (What I want is what I would get if I rotate the image with the Rotate command, then control-zero to fill the screen, and then select the crop tool.)
    We rotate a lot of images.  It's easy to do in CS2 and the two approaches I've found for CS6 are both awkward.  The new crop tool has replaced the dual arrows in older versions (to swap the horizontal and vertical sizes) with a rotation arrow.  I think you should restore the arrows (and their function) -- then use the rotate button to rotate the image, not the crop box.  (Isn't that the design center for the new crop box?  We're moving the image, not the crop box.)

    Howard, thanks for the tip about the X key; didn't realize it worked that way when the crop tool is active.  But in this case I had set the crop box dimenions, so the crop box starts out with the correct orientation.  Having played with this for a day, I conclude that the best approach for this task is to restore the old keyboard conventions for image rotation and rotate the image before launching the crop tool.
    I stand by my observation that the rotate key should affect the image, not the crop box because that is consistent with the new cropping paradigm: We rotate the image, not the crop box.  I realize making a change this late in the development cycle is awkward -- but if CS6 ships with this behavior, it will become even harder to change later -- and the user interface should be as consistent as possible.
    Noel, you are correct: The images are coming from scanned film.  All frames get scanned with the same orientation.  I want to avoid the "Patient: Doctor, it hurts when I do this.  Doctor: Then don't do that!" scenario.  Granted: If images are "correctly" oriented, this issue doesn't arise.  But not all images are oriented correctly and CS6 should be at least as graceful in handling the task as previous versions.

  • Rotate and move image

    Hi,I'm trying to make a game kinda like gta or asteroids whereyou have top view. I am using an image to be the player and, I want to rotate that image using left and righ keys and with the up key move the player to the direction whereit is rotated.
    The problem is that i cannot display the rotation and movement at the same time.
    I'm using a code like this.
    AffineTransform transform = new AffineTransform
    public void checkGameInput(){
         float velocityX=0;
         float velocityY=0;
         if(rotateLeft.isPressed()){
               angle1+=angle2;    
              transform.rotate(-angle2, player.getWidth()/2, player.getHeight()/2);
    // similar for rightkey
       if (moveFront.isPressed()){
               velocityX=_Player.SPEED*Math.cos(angle1),
               //same for velocityY
    }the problem is when i try to print on the sceen.
    I can update position
    public void draw(Graphics 2D g){
    g.drawImage(player. getImage(), Math.round(player.getX()), Math.round(player.getY()),null)  // player.getX(9 returns position of playeror update rtation
    public void draw(Graphics 2D g){
    g.drawImage(player.getImage(),transform, null);is there a way to join this to drawImageso I can rotate ane move the rotatyed image?
    thank you very much for any kind of help.
    Edited by: Muninn on Nov 29, 2008 3:13 AM

    Use the transform to do both rotation and translation (multiple transform operations can be concatenated)
    transform.rotate(-angle2, player.getWidth()/2, player.getHeight()/2);
    transform.translate(player.getX(), player.getY());

  • Online banking site now shows login page as text-only; on different computer it still shows page with images and clickables -- is there a fix?

    Previously when I logged in to my INGdirect online bank account, the login window came up showing images and clickable hotspots. Recently, the login window changed to a text-only version. On two different computers running Firefox, the login comes up in the previous version, with images and clickable hotspots. I'm unaware of having done anything to change my settings either in Firefox or on the banking website. Because it seems to be localized on this computer, I've tried downloading latest version of Firefox, but got no change, login still comes up in text-only format.

    Try clearing your browser cache.
    Tools > Clear Recent History... - hit Details and make sure only Cache is selected, then select Everything and hit the Clear Now button.

  • Fast image rotation and contrast adaptation

    First: I'm new in vision processing.
    I'm using LabView 8.0 with the IMAQ Vision development module. The aim is to control the angle and the contrast of a precalculated image (a greyscale wedge) in a fast loop with a framerate of 60 or 100Hz. Currently I use the time-consuming IMAQ rotate and IMAQ BCG functions. All these function works very fine but a litle bit to slow for my application. I have measure: IMAQ rotate with 40ms and IMAQ BCG with 15ms for an image with 1024 x 768 pixels (8-bit greyscale) on a new PC. I know that an arbitrary rotation is a processor intensive task.
    Please correct me, but i assume that with IMAQ rotate the image rotation will be carried out in the PC RAM. Afterwards the recalculated image will be written in the grafic memory. In a final step the image will be displayed on the monitor by mean of the grafic processor.
    I can imagine there exist a solution or some ideas in the LabView community to use the high end 3D very fast grafic card processor for the rotation and contrast tasks. I hope the approach will accelerate the time of calculation.
    Thanks for your help.
    Best regards
    Ivo Buske

    And of course, the rambling about IMAQ image pointers isn't relevant. (Skip all IMAQ.)
    You might as well send the image once (each time it changes), and rotate it with opengl.
    "Wiebe@CARYA" <[email protected]> wrote in message news:[email protected]...
    Hi,
    If I understand correctly, you just want a gradient screen to rotate, and to be able to adjust it's contrast.
    This can be done a lot easier without an image. If you use OpenGL, you can just draw two triangles with there color set correctly. (You'd be able to make nice rainbow pictures as a bonus.)
    An C/C++ application, or dll, could be made in a few hours by someone experienced with opengl and c++. You could even create an opengl window, and control it with LabVIEW. In other opengl applications there are some practical problems, but some might not matter to your application. Biggest problem is getting feedback (mouse clicks, close, move, resize window etc.) from the OpenGL window to LabVIEW.
    Opening a opengl window, rotating a few polygons, adjusting color, closing window certainly doable.
    Regards,
    Wiebe.
    "ibstein74" <[email protected]> wrote in message news:[email protected]...
    Hi Wiebe, I have a fixed image, created before with array functions, that contain a pure linear greyscale gradient (left side: white / right side: black). I used this image to control a "spatial light modulator". This device is connected to the second DVI graphic card output. The main task of the "spatial light modulator" is to shift the local phase of the reflective light. It works as an spatial resolved "adaptive mirror".&nbsp; The local phase shift correspondes directly to the applied grey level of the image. To change the direction in both dimensions of the reflective light I need to rotate this image (= rotate the phase wedge) Thereby the contrast can adjust the absolute angle of reflection.After I had calculated my greyscale gradient image and applied it to the second DVI output, I want only control the contrast and rotation. I think the graphic card function are very fast. But I have to control the graphic card directly per DLL or C-function node. It must be possible because I can tune the contrast and adjust the rotation manually with the nvidea driver in the windows system manager. I'm&nbsp; waiting for a couple of weeks of an answer from nvidea but it seems that contrast and rotation of an 2D-image is not a real problem for these 3-D guys. :-(I hope of an answer or new ideas.Ivo Buske

  • Lightroom 3 Beta-Image Rotate and Crop Tool

    Good Morning Adobe,
    First of all let me say Lightroom 3 is fantastic! I do have a couple of suggestions that might make the image editing more efficient. I find that I use the image rotate and crop tools frequently and think that possibly locating these 2 features below the image in the tool bar with the loupe view/zoom fit/before and after will allow the user to edit the images more efficiantly.
    I believe that this is an incredible program and can't wait to see the finished product!
    I will offer more suggestions as they evolve.
    Thank you Adobe! You are the BEST!
    D.A.    

    Thank you...I discovered this answer online from another post last night and tried it.  (Since I didn't re-size the thumbnails, I wasn't aware that you could do this.)  After re-starting Lightroom and my computer, the crop issue corrected itself.  Thank you very much for your response.  It worked!

  • Size and rotate a background image

    I would like to have a background image that rotates different images when the page is refreshed and sizes with my page. I believe I have a handle on the sizing part but I can't figure out how to make the images rotate. I would like the images to go in a particular order instead of random if that's possible.
    This is what I have so far:
    <head>
    <title>Stretched Background Image</title>
    <style type="text/css">
    /* Remove margins from the 'html' and 'body' tags, and ensure the page takes up full screen height */
    html, body {height:100%; margin:0; padding:0;}
    /* Set the position and dimensions of the background image. */
    #page-background {position:fixed; top:0; left:0; width:100%;;}
    /* Specify the position and layering for the content that needs to appear in front of the background image. Must have a higher z-index value than the background image. Also add some padding to compensate for removing the margin from the 'html' and 'body' tags. */
    #navbar {position:relative; z-index:1; padding:10px;}
    #content {position:relative; z-index:2; padding:10px;}
    </style>
    <!-- The above code doesn't work in Internet Explorer 6. To address this, we use a conditional comment to specify an alternative style sheet for IE 6 -->
    <!--[if IE 6]>
    <style type="text/css">
    html {overflow-y:hidden;}
    body {overflow-y:auto;}
    #page-background {position:absolute; z-index:-1;}
    #content {position:static;padding:10px;}
    </style>
    <![endif]-->
    </head>
    <body>
    <div id="page-background"><img src="stretchPix2.jpg" width="100%" alt="Smile"></div>
    <div id="navbar">
    <h2><img src="TestNavArt.gif" width="900" height="30"></h2>
    </div>
    <div id="content"><font color="#FFFFFF"> more test here?</font></div>
    </body>
    </html>
    If anyone can give me some insight into making the background image rotate I would greatly appreciate it.
    Thanks,
    Dave

    Hi
    The only reliable way to rotate a background image is using css3 but as this feature is only implemented in 1 browser, (and that is in beta)? There are a few javascript frameworks that claim to do this, but in testing I have not found one that is even 50% reliable.
    PZ

  • Scale and rotate a tiff image

    How do you scale and rotate a tiff image without running out of memory?
    I have been trying to scale the image and rotate it before i pass it to the DisplayJAI but i keep running out of memory.
    code i use to rotate the image.
    private Image rotateImage(boolean rotateRight)
    Image img = imageHolder.getInUseImageIcon().getImage();
    Image rot = null;
    int imageWidth = imageHolder.getInUseImageIcon().getIconWidth();
    int imageHeight = imageHolder.getInUseImageIcon().getIconHeight();
    int buffer[] = new int[imageWidth * imageHeight];
    int rotate[] = new int[imageWidth * imageHeight];
    try
    MediaTracker tracker = new MediaTracker (this);
    tracker.addImage (img, 0);
    tracker.waitForAll();
    PixelGrabber grabber = new PixelGrabber(img, 0, 0, imageWidth, imageHeight, buffer, 0, imageWidth);
    try {
    grabber.grabPixels();
    catch(InterruptedException e) {
    e.printStackTrace();
    if(rotateRight)
    for(int x = 0; x < imageWidth; x++)
    for(int y = 0; y < imageHeight; y++)
    rotate[(x*imageHeight)+y] = buffer[((imageHeight-y-1)*imageWidth)+x];
    else
    for(int y = 0; y < imageHeight; y++)
    for(int x = 0; x < imageWidth; x++)
    buffer[(y*imageWidth)+x] = rotate[((imageWidth-x-1)*imageHeight)+y];
    for(int y = 0; y < imageHeight; y++)
    for(int x = 0; x < imageWidth; x++)
    rotate[((imageWidth-x-1)*imageHeight)+y] = buffer[(y*imageWidth)+x];
    rot = createImage(new MemoryImageSource(imageHeight, imageWidth, rotate, 0, imageHeight));
    catch (Exception e)
    e.printStackTrace();
    return rot;
    this is the code i use to scaled the image.
    Image scaled = originalImage.getImage().getScaledInstance(
    (int)(currentWidth * 1.5),
    (int)(currentHeight * 1.5),
    Image.SCALE_FAST);
    I tried this method, it works and does what i want but the scrolling and loading is too slow.
    public void paintComponent(Graphics g)
    Graphics2D g2D = (Graphics2D)g;
    g2D.rotate(Math.PI/2, (int)dimension.getWidth()/2, (int)dimension.getHeight()/2);
    g2D.drawImage(image, 0,0,(int)dimension.getWidth(), (int)dimension.getHeight(), this);
    Help plss.

    Nvm got the answer :)

  • Rotate and Shift 16-bit Image

    I would like to rotate and shift a 16-bit RGB image (U64 in LabVIEW).  The IMAQ rotate and shift functions don't accept this image type, but they do accept a 16-bit grayscale image (I16 in LabVIEW).  Unfortunately, this clips all values in my original image since it runs from -32,767 to + 32,767.  The ExtractColorPlanes function requires a 16-bit image to be wired as the desination image but the IMAQ create VI does not allow U16 image to be created.
    Any ideas?
    Solved!
    Go to Solution.

    SJT a écrit:
    I would like to rotate and shift a 16-bit RGB image (U64 in LabVIEW).  The IMAQ rotate and shift functions don't accept this image type, but they do accept a 16-bit grayscale image (I16 in LabVIEW).  Unfortunately, this clips all values in my original image since it runs from -32,767 to + 32,767.  The ExtractColorPlanes function requires a 16-bit image to be wired as the desination image but the IMAQ create VI does not allow U16 image to be created.
    IMAQ Create can create U16 images, but the standard Image Type input lack the appropriate value. This is bug n°1 . As workaround, you can either wire directly a con,stant with value 7 or dig into the Vision palettes and get a better typed constant from the IMAQ Cast Image VI.
    However, this is not the solution to your problem, since there is the n°2 bug in the IMAQ ExtractSingleColorPlane VI : it doesn't accept U16 or U64 as destination images, and coerce the output to a I16 default image type.
    A workaround is to create your own color plane extraction function. First convert the U64 image into an array, then extract the desired plane, as shown on the diagram below.
    Message Edité par chilly charly le 12-30-2008 08:31 AM
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        
    Attachments:
    Extract Color Plane U64.vi.zip ‏15 KB
    U16 ExtractSingleColorPlane.vi.zip ‏13 KB
    U16 ExtractSingleColorPlane_BD.png ‏10 KB

  • Rotating and Translating an Image

    I am making a game with a tank that can rotate and move forwards and backwards.
    I am able to get the tank Image to rotate, but when I call a translation, it resets the image back to its original image. How can I fix this?

    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    import javax.swing.event.*;
    public class TankGame extends JPanel {
        Walker walker = new Walker(this);
        BufferedImage image;
        AffineTransform at = new AffineTransform();
        Point2D.Double loc = new Point2D.Double(200,150);
        double theta = 0;
        double t = 3.0;
        boolean goAhead = true;
        public TankGame(BufferedImage image) {
            this.image = image;
            setTransform();
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.drawRenderedImage(image, at);
            //g2.setPaint(Color.red);
            //g2.fill(new Ellipse2D.Double(loc.x-2, loc.y-2, 4, 4));
        public synchronized void step() {
            int sign = goAhead ? 1 : -1;
            double x = loc.x + sign*t*Math.cos(theta);
            double y = loc.y + sign*t*Math.sin(theta);
            loc.setLocation(x, y);
            setTransform();
            repaint();
        private void setTransform() {
            double x = loc.x - image.getWidth()/2;
            double y = loc.y - image.getHeight()/2;
            at.setToTranslation(x, y);
            at.rotate(theta, image.getWidth()/2, image.getHeight()/2);
        private JPanel getUIPanel() {
            JPanel panel = new JPanel(new GridBagLayout());
            GridBagConstraints gbc = new GridBagConstraints();
            gbc.insets = new Insets(1,0,1,0);
            gbc.weightx = 1.0;
            String[] ids = { "ahead", "stop", "back" };
            ActionListener al = new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    String ac = e.getActionCommand();
                    if(ac.equals("stop")) {
                        walker.stop();
                    } else {
                        if(ac.equals("ahead")) {
                            goAhead = true;
                        } else if(ac.equals("back")) {
                            goAhead = false;
                        walker.start();
            for(int j = 0; j < ids.length; j++) {
                JButton button = new JButton(ids[j]);
                button.addActionListener(al);
                if(j == ids.length-1)
                    gbc.gridwidth = GridBagConstraints.REMAINDER;
                panel.add(button, gbc);
            JSlider slider = new JSlider(-180, 180, 0);
            slider.addChangeListener(new ChangeListener() {
                public void stateChanged(ChangeEvent e) {
                    int angle = ((JSlider)e.getSource()).getValue();
                    theta = Math.toRadians(angle);
                    setTransform();
                    repaint();
            gbc.gridwidth = 3;
            gbc.fill = GridBagConstraints.HORIZONTAL;
            panel.add(slider, gbc);
            return panel;
        public static void main(String[] args) throws IOException {
            String path = "images/geek/geek----t.gif";
            BufferedImage image = ImageIO.read(new File(path));
            TankGame test = new TankGame(image);
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.add(test);
            f.add(test.getUIPanel(), "Last");
            f.setSize(400,400);
            f.setLocation(200,200);
            f.setVisible(true);
    class Walker implements Runnable {
        TankGame game;
        Thread thread;
        boolean moving = false;
        long delay = 100;
        public Walker(TankGame tg) {
            game = tg;
        public void run() {
            while(moving) {
                try {
                    Thread.sleep(delay);
                } catch(InterruptedException e) {
                    moving = false;
                game.step();
        public void start() {
            if(!moving) {
                moving = true;
                thread = new Thread(this);
                thread.setPriority(Thread.NORM_PRIORITY);
                thread.start();
        public void stop() {
            moving = false;
            if(thread != null)
                thread.interrupt();
            thread = null;
    }

  • Rotate and scale an image witohout deforming it

    Hello you all!
    I have to rotate and scale an image, but i don't wont to deform it.
    I'm thinking to something like 16/9 images on 4/3 screens (with two horizontal or vertical black lines around the scaled image)...
    I thinked to transform the image in bitmap format, then create a bigger image and fill the empty spaces with zero-pixels...
    Is there a simplest and more efficient way to do it with 2D java classes?
    Thank you!

    See reply 8 in Help to rotate image for an idea.

  • Is it possible to rotate and scale an image?

    Is it possible to rotate and scale an image with Grapchis2D at the same time?
    One method call to do it all?
    lets say the original image size is 200x200
    I can scale the image with
    Graphics.drawImage(image, 0,0, 500,500,this);
    But now i need to rotate it as well and keep the new size which is 500x500
    how do i do that ?

    Have you already tried the scale(double sx, double
    sy) and rotate(double theta) methods of Graphics2D?no.

  • Flip and rotation on an Image

    Hello,
    I would like to perform flip and +/-90� rotation on an image but after a rotation, the flip is performed in the wrong direction my code looks like this :
    /*axis at the center of image*/
    g2D.translate(width/2,height/2);
    g2D.scale(-1,1);
    g2D.rotate(Math.PI);
    /*image orientation correction*/   
    g2D.scale(1,-1);
    /*rotation and flip*/     
    g2D.rotate(flipHorizontal*flipVectical*Math.toRadians(angle));
    g2D.scale(flipHorizontal,flipVectical); //1 or -1
    /* drawing the image */   
    g2D.drawImage(imageToDraw, centreToX,centreToY, null);
    // than positioning the axis back to origine I've tried to say that if the image as already been rotated then invert the flips, but in that case, after one flip the rotation is performed in the wrong direction...
    Does anybody know how to solve this problem???
    Thank you in advance.

    i have to rotate, flip & scale an image , but it get misplaced when rotated on 90 and -90 please help me public void putImage_buffer(String s,int x,int y,int width,int height,double rotation,int xScale,int yScale,boolean hFlip,boolean vFlip) {
              int Rwidth=width;
              int Rheight=height;
                    try{
    ImageInputStream imageInput = ImageIO.createImageInputStream(new FileInputStream(filename));
                it = ImageIO.getImageReaders(imageInput);
                reader = (ImageReader) it.next();
                reader.setInput(imageInput);
                objBufimage=reader.read(0);
    }catch(Exception e){System.out.println(e);}
              System.out.println("width : height! ratation"+width+" : "+height+"  : "+rotation);
            if(width==0&&height==0){
                offscreen.drawImage(objBufimage,0,0, null);      
             else{
                   if(!(vFlip||hFlip)){
                        if(rotation==90)
                             Rwidth=height;
                             Rheight=width;
                             System.out.println("!(vFlip||hFlip) 90");
                        if(rotation==-90 )
                             rotation=270;
                             System.out.println(" -90 !(vFlip||hFlip");
                             Rwidth=height;
                             Rheight=width;
                   if(vFlip )
                        if(rotation==90)
                             hFlip=!hFlip;
                             vFlip=!vFlip;
                             //Rwidth=height;
                             //Rheight=width;
                             System.out.println("width : height 90 vFlip");
                        if(rotation==-90)
                             hFlip=!hFlip;
                             vFlip=!vFlip;
                             //Rwidth=height;
                             //Rheight=width;
                             rotation = 270;
                             System.out.println("width : height -90 vFlip");
                        if(rotation==180)
                             System.out.println("width : height 180 vFlip");
                   else if(hFlip )
                        if(rotation==90)
                             hFlip=!hFlip;
                             vFlip=!vFlip;
                             System.out.println("width : height 90 hFlip");
                             //Rwidth=height;
                             //Rheight=width;
                        if(rotation==-90)
                        {     rotation=270;
                             hFlip=!hFlip;
                             vFlip=!vFlip;
                             Rwidth=height;
                             Rheight=width;
                        if(rotation==180)
                             System.out.println("width : height 180 hFlip");
                   if(vFlip && hFlip)
                        if(rotation==90)
                             System.out.println("width : height 180 hFlip&&vFlip 90");
                        if(rotation==-90)
                             rotation=270;
                             System.out.println("width : height 180 hFlip&&vFlip -90");
                AffineTransform tx = new AffineTransform();
                AffineTransform origTransform = offscreen.getTransform();
                   System.out.println("hFlip:vFlip Math.PI "+hFlip+" : "+vFlip);
                   rotation=rotation*(hFlip?-1:1)*(vFlip?-1:1);
                   rotation = Math.toRadians( rotation );
                   AffineTransform rotate=AffineTransform.getRotateInstance(rotation, Rwidth/2d, Rheight/2d);
                   AffineTransform moveToImageCenter=AffineTransform.getTranslateInstance(Rwidth/2d, Rheight/2d);
                   moveToImageCenter.concatenate(AffineTransform.getScaleInstance(hFlip?-1:1,vFlip?-1:1));
                   moveToImageCenter.concatenate(AffineTransform.getTranslateInstance(Rwidth/-2d, Rheight/-2d));
                   AffineTransform flip=moveToImageCenter;
                   AffineTransform transformer = AffineTransform.getTranslateInstance(x,y);
                   offscreen.setTransform(transformer);
                                  offscreen.transform(rotate);
                   offscreen.transform(flip);
                   offscreen.drawImage(objBufimage,0,0,Rheight,Rwidth,null);
                   //offscreen.drawImage(objBufimage.getScaledInstance(width,height,objBufimage.SCALE_DEFAULT),0,0,width,height, null);
                   offscreen.setTransform( origTransform );
         }i get vFlip if hFlip+90or-90 and i get hFlip if vflip +90-90 means if actual flipping is vflip+90/-90 my method parameter gets hFlip +/-90 thats by i'm changing values

  • How can I rotate a screen image on a peripheral monitor?

    I have a MacBook that runs OS 10.5.8.  I bought a Samsung monitor for it that rotates 90 degrees so that I could use certain very large files.
    The last time I used the MacBook, I used it with  the image rotated 90 degrees (so that the screen is about 3 times as tall as it is wide), as I planned to. 
    Since then, because of my job, I have been using a Windows OS laptop  exclusively when I've used the Samsung monitor.  It worked fine, and in fact although I wanted to try to use the Samsung with the Dell Windows OS with the rotation, I found that I could not do so, because the Windows OS would not support the rotation.
    I have now returned the Dell laptop after transferring all my files to my MacBook.  Today I connected the MacBook to the Samsung for the first time, and was stunned to see the Mac screen appearing at the 90-degree rotation.  No matter what I do, I can't figure out how to restore it.  So I have this huge monitor and basically it's showing me the same screen size as I have on my laptop.  When I change the resolution, it just gets distorted.  And nowhere can I find out how to rotate the image back to landscape.
    Online, the only instructions I have found refer to a Preferences Panel in the Displays section of the System Preferences which allows you to choose a rotation.  However, I can't locate that panel.  I tried to find it through Spotlight, using the word "rotate," and here's what came up:
    It lists "Displays" as one of the first two hits
    But when I click on that, I get the "Displays" window labeled "Color LCD"
    And that window is obscured by a smaller window that says the following: 
    The Geometry tab of Displays preferences is hidden because this display does not have
    geometry controls.
    Which is insane, since the reason that my display is now set at 90-degrees is that I did the rotation while using this MacBook.
    If anyone can help me get this resolved, I would be very grateful.
    Thanks.

    Click the gear button on the clip and select Cropping & Rotation.
    There are rotation buttons at the top of the viewer.

Maybe you are looking for