Rotating and scaling graphics

hi i need to rotate and scale a graphic on a canvas. i know that Affine Transform can do this (i think) but i dont know how to use it. i can get it to slide with the following method: Would it be sort of the same, or completely different?
thanks
Pedge
public void Xslide(float dist)
for (int i=0; i<vertex.size(); i++)
((Point2D)vertex.elementAt(i)).Xslide(dist);
public void Xslide(float dist)
x = x + dist;
}

if you have Shape object, you can use AffineTransform as follows:AffineTransform trans = new AffineTransform();
trans.setToRotation(float) or trans.setToScale(double, double);
Shape transformedShape = trans.createTransformedShape(originalShape);if you want to transform everything in a Graphics object, you can use the same AffineTransform using Graphics2D.transform(trans);
I hope this helps!
-JBoeing

Similar Messages

  • Rotating and scaling a movieclip withing only its parent width and height

    Dear friends,
    I'd like to rotate a movieclip within specific area (its parent width and height) and it can't rotate out of it.
    How can I achieve that.
    When I say for exampe:
    mc.rotation = 10;
    it rotates also outside the parent area.
    How can I restrict it to only parent area.
    Thank you in advance.

    [OTTOMH]
    With each rotation step you could check the bounds of the rotating MC. If it's greater than the containing MC, you can calculate the scale factor and apply it to the x- and y-scale of the rotating clip.
    The clip would have to be deadcentre in the containing clip for this to work though.
    I suppose there would be some mathimatical way with most primitive shapes to calculate the width and height with a certain rotation, but I suppose this would be easiest.

  • Problem with very slow scale, rotate and translate

    Hi -
    Here is the basic problem. I want to take a bufferedImage (read from a jpeg earlier on) and then rotate it according to an angle value (radians) and then resize it to fit within a specifically sized box. My code works fine, but... I have to do this in a loop up to 200 times. The process is often taking several minutes to complete. If this is simply a consequence of what I am trying to do, then I'll accept that, but surely I am just doing something wrong? Please help!
    Thanks - here is the (working but very slow) code
        public Graphics2D get_shape_image(Graphics2D g, BufferedImage b, double shaperotation, double space_width, double space_height,
                float x_scale_factor, float y_scale_factor, float shapeTransparency){
            // Work out the boundimg box size of the rotated image
            double imageWidth = (double) b.getWidth();
            double imageHeight = (double) b.getHeight();
            double cos = Math.abs( Math.cos(shaperotation));
            double sin = Math.abs( Math.sin(shaperotation));
            int new_width = (int) Math.floor(imageWidth * cos  +  imageHeight * sin);
            int new_height = (int) Math.floor(imageHeight * cos  +  imageWidth * sin);
            // Create the new bufferedImage of the right size
            BufferedImage transformed = new BufferedImage((int) new_width, (int) new_height, BufferedImage.TYPE_INT_RGB);
            // Create the transform and associated AffineTransformOperation
            AffineTransform at = new AffineTransform();
            AffineTransformOp affine_op;
            // Make sure our image to be rotated is in the middle of the new image
            double x_movement = ((double) (new_width / 2.0d)) - ((double) imageWidth / 2.0d);
            double y_movement = ((double) (new_height / 2.0d)) - ((double) imageHeight / 2.0d);
            at.setToTranslation(x_movement, y_movement);
            affine_op = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR);
            transformed = affine_op.filter(b, null);
            // Now we need to rotate the image according to the input rotation angle
            BufferedImage rotated = new BufferedImage((int) new_width, (int) new_height, BufferedImage.TYPE_INT_RGB);
            at.setToRotation(shaperotation, (double) new_width / 2.0d, new_height / 2.0d);
            affine_op = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR);
            rotated = affine_op.filter(transformed, null);
            // Do the scaling so that we fit into the grid sizes
            BufferedImage sizedImage = new BufferedImage((int) (space_width * x_scale_factor), (int) (space_height * y_scale_factor), BufferedImage.TYPE_INT_RGB);
            double xScale = (double) (space_width * x_scale_factor) / (double) new_width;
            double yScale = (double) (space_height * y_scale_factor) / (double) new_height;
            at.setToScale(xScale, yScale);
            affine_op = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR);
            sizedImage = affine_op.filter(rotated, null);
            // Finally translate the image to the correct position after scaling
            double x_adjust = (space_width / 2.0d) - ((space_width * x_scale_factor) / 2.0d);
            double y_adjust = (space_height / 2.0d) - ((space_height * y_scale_factor) / 2.0d);
            // Set the transparency
            AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, shapeTransparency);
            g.setComposite(ac);
            // Draw the image as long as it's above 0 size
            if (sizedImage.getWidth() > 0 && sizedImage.getHeight() > 0)
                g.drawImage(sizedImage, null, (int) x_adjust, (int) y_adjust);
            return g;
        }

    Your code worked okay in my system: busy at 200fps using 1.0f for alpha and
    the x/y scale_factor values.
    Here's another approach that isn't quite as busy.
    import java.awt.*;
    import java.awt.geom.*;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    public class XTest extends JPanel
        BufferedImage image;
        int gridWidth  = 100;
        int gridHeight = 100;
        double theta   = 0;
        double thetaInc;
        public XTest(BufferedImage image)
            this.image = image;
            thetaInc = Math.toRadians(1);
        protected void paintComponent(Graphics g)
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                                RenderingHints.VALUE_INTERPOLATION_BICUBIC);
            int w = getWidth();
            int h = getHeight();
            int imageW = image.getWidth();
            int imageH = image.getHeight();
            // rather than making a new BufferedImage for each step of
            // the rotation and scaling let's try to rotate, scale and
            // fit the source image directly into the grid by using
            // transforms...
            // rotation
            AffineTransform rotateXform = new AffineTransform();
            double x = (w - imageW)/2;
            double y = (h - imageH)/2;
            rotateXform.setToTranslation(x,y);
            rotateXform.rotate(theta, imageW/2.0, imageH/2.0);
            // get rotated size for source
            double cos = Math.abs( Math.cos(theta));
            double sin = Math.abs( Math.sin(theta));
            double rw = Math.rint(imageW * cos  +  imageH * sin);
            double rh = Math.rint(imageH * cos  +  imageW * sin);
            // scale factors to fit image into grid
            double xScale = gridWidth /  rw;
            double yScale = gridHeight / rh;
            // scale from center
            x = (1.0 - xScale)*w/2;
            y = (1.0 - yScale)*h/2;
            AffineTransform scaleXform = AffineTransform.getTranslateInstance(x,y);
            scaleXform.scale(xScale, yScale);
            scaleXform.concatenate(rotateXform);
            g2.drawRenderedImage(image, scaleXform);
            // markers
            // grid
            g2.setPaint(Color.red);
            int gx = (w - gridWidth)/2;
            int gy = (h - gridHeight)/2;
            g2.drawRect(gx, gy, gridWidth, gridHeight);
            // bounds of unscaled, rotated source image
            g2.setPaint(Color.blue);
            double rx = (w - rw)/2;
            double ry = (h - rh)/2;
            g2.draw(new Rectangle2D.Double(rx, ry, rw, rh));
        public void rotate()
            theta += thetaInc;
            repaint();
        public static void main(String[] args) throws IOException
            BufferedImage bi = ImageIO.read(new File("images/bclynx.jpg"));
            XTest test = new XTest(bi);
            Activator activator = new Activator(test);
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setContentPane(test);
            f.setSize(400,400);
            f.setLocation(200,200);
            f.setVisible(true);
            activator.start();
    class Activator implements Runnable
        XTest xTest;
        Thread thread;
        boolean animate;
        public Activator(XTest xt)
            xTest = xt;
            animate = false;
        public void run()
            while(animate)
                try
                    Thread.sleep(50);
                catch(InterruptedException ie)
                    animate = false;
                    System.out.println("interrupt");
                xTest.rotate();
        public void start()
            if(!animate)
                animate = true;
                thread = new Thread(this);
                thread.setPriority(Thread.NORM_PRIORITY);
                thread.start();
        public void stop()
            animate = false;
            thread = null;
    }

  • Performance issues with Motion (position, scale, rotate) and GTX 590

    I'm experiencing performance issues with my Premiere Pro CC when I scale, position or rotate a clip in the program monitor.
    I have no performance issues with playback! It's only, when i move something with the mouse or by changing the x,y-values of Position in the Motion-Dialog in video effects.
    Premiere then lags terribly and updates the program monitor only about once per second - this makes it very difficult and cumbersome to work and position things.
    On a second Premiere installation on my laptop, performance is fine and fluid - allthough it doesn't have GPU support and is a much slower computer.
    I'm pretty sure this has somehow to do with my graphic card, which is a Nvidia GTX 590.
    I was told by the support, that it is actually a dual graphic card, which is not supported/liked by Premiere.
    The thing is, until the latest Premiere update, I did not have performance issues at all with this card.
    I also read on the forum that others with the GTX 590 did not experience any problems with it
    So where does this come from?
    There is no change in performance whether or not I activate Mercury Playback Engine GPU acceleration.
    I also tried deactivating one of the 2 gpus, but there also was no change.
    Does anyone else know this problem and has anyone a solution?
    I'm running Premiere CC on a Win 7 64bit engine, Nvidia GTX 590, latest driver (of today),

    I am suffering from the same phenomenon since I updated just before christmas, I think.
    I am hardly able to do scaling, rotating and translating in the program monitor itslef - whil motion has been highlighted in teh effect controls.
    In the effect controls I can scale, rotate etc however.
    Also I have noticed there is a yellow box with handles in teh program monitor. I remember it was white before.
    I cannot figure out what to change in my preferences. What has happened?
    best,
    Hans Wessels
    Premiere CC
    Mac Pro OSX 10.7.5
    16 GB 1066 MHz DD3
    2 X NVIDIA GeForce GT 120 512 MB

  • Paint Component using scaled Graphics with TiledImage

    Hello,
    I am in the process of adding minor image manipulation in an application I created. I have paint overridden on the component that displays the image and in that component I am scaling the graphics to a representation of the image at 300 dpi versus the screen resolution. The image is a TiledImage which gave me pretty good performance benefits when I was painting at screen resolution. Now I want to know if there is something I can do to the tiles to get the performance benefit back. I understand this
    may not be possible because the entire image displays at once with the scaled graphics instance.
    Here is a copy of my paint method:
    public void paintComponent(Graphics gc) {
              Graphics2D g = (Graphics2D) gc;
              g.scale(scale, scale);
              Rectangle rect = this.getBounds();
              rect.width *= (1/scale);
              rect.height *= (1/scale);
              if ((viewerWidth != rect.width) || (viewerHeight != rect.height)) {
                   viewerWidth = rect.width;
                   viewerHeight = rect.height;
              setDoubleBuffered(false);
              g.setColor(Color.BLACK);
              g.fillRect(0, 0, viewerWidth, viewerHeight);
              if (displayImage == null)     return;
              int ti = 0, tj = 0;
              Rectangle bounds = new Rectangle(0, 0, rect.width, rect.height);
              bounds.translate(-panX, -panY);
              int leftIndex = displayImage.XToTileX(bounds.x);
              if (leftIndex < ImageManip.getMinTileIndexX())
                   leftIndex = ImageManip.getMinTileIndexX();
              if (leftIndex > ImageManip.getMaxTileIndexX())
                   leftIndex = ImageManip.getMaxTileIndexX();
              int rightIndex = displayImage.XToTileX(bounds.x + bounds.width - 1);
              if (rightIndex < ImageManip.getMinTileIndexX())
                   rightIndex = ImageManip.getMinTileIndexX();
              if (rightIndex > ImageManip.getMaxTileIndexX())
                   rightIndex = ImageManip.getMaxTileIndexX();
              int topIndex = displayImage.YToTileY(bounds.y);
              if (topIndex < ImageManip.getMinTileIndexY())
                   topIndex = ImageManip.getMinTileIndexY();
              if (topIndex > ImageManip.getMaxTileIndexY())
                   topIndex = ImageManip.getMaxTileIndexY();
              int bottomIndex = displayImage.YToTileY(bounds.y + bounds.height - 1);
              if (bottomIndex < ImageManip.getMinTileIndexY())
                   bottomIndex = ImageManip.getMinTileIndexY();
              if (bottomIndex > ImageManip.getMaxTileIndexY())
                   bottomIndex = ImageManip.getMaxTileIndexY();
              for (tj = topIndex; tj <= bottomIndex; tj++) {
                   for (ti = leftIndex; ti <= rightIndex; ti++) {
                        Raster tile = displayImage.getTile(ti, tj);
                        DataBuffer dataBuffer = tile.getDataBuffer();
                        WritableRaster wr = Raster.createWritableRaster(sampleModel,
                                  dataBuffer, new Point(0, 0));
                        BufferedImage bi = new BufferedImage(colorModel, wr,
                                  colorModel.isAlphaPremultiplied(), null);
                        if (bi == null) continue;
                        int xInTile = displayImage.tileXToX(ti);
                        int yInTile = displayImage.tileYToY(tj);
                        atx = AffineTransform.getTranslateInstance(
                                  xInTile + panX, yInTile + panY);
                        g.drawRenderedImage(bi, atx);
              imageDrawn = true;
              if (cropOn) {
                   Rectangle cropRect = getDimensions();
                   if (cropRect == null) return;
                   g.setColor(Color.BLACK);
                   g.drawRect(cropRect.x, cropRect.y, cropRect.width, cropRect.height);
                   g.setComposite(makeComposite(0.5f));
                   g.fillRect(0, 0, cropRect.x, cropRect.y);
                   g.fillRect(cropRect.x, 0, viewerWidth - cropRect.x, cropRect.y);
                   g.fillRect(0, cropRect.y, cropRect.x, viewerHeight - cropRect.y);
                   g.fillRect(cropRect.x + cropRect.width, cropRect.y,
                             viewerWidth - cropRect.x, viewerHeight - cropRect.y);
                   g.fillRect(cropRect.x, cropRect.y + cropRect.height, cropRect.width,
                             viewerHeight - cropRect.y);
              g.dispose();
              if (((double)GarbageCollection.getFreeMem() /
                        (double)GarbageCollection.getRuntimeMem()) > 0.7d) {
                   System.out.println("Memory Usage: " +
                             (int)(((double)GarbageCollection.getFreeMem() /
                             (double)GarbageCollection.getRuntimeMem()) * 100) + "%");
                   System.out.println("Requesting garbage collection.");
                   GarbageCollection.runGc();
              setDoubleBuffered(true);
    Thank you in advance for support

    I moved the sizing out of the paint method and put in a component listener. I am still getting approx. the
    same performance. Possibly because I am trying to do too much. I have a mouse listener that allows
    the user to pan the image. I also have crop, rotate, shear, and flip methods. The main problem I think
    is when I change graphics to scale at (72d / 300d) which puts the display comparable to 300 dpi.
    My main reason for this was to allow zooming for the user. Am I overtasking the graphics object by
    doing this?

  • 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

  • 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

  • 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());

  • 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.

  • Problem with rotation and keyboard click sound

    Ok, there's still a problem with the rotation and keyboard click sound and I thought I had the problem fixed.
    It's a serious bug when you want the keyboard click sound enbabled without having the rotation locked. I noticed this bug started when I had the previous iosinstalled 7.0.6.
    Everytime I wanted to enable the keyboard click sound, I have to always go to settings and have lock rotation checked. And it would stay locked.
    If I wanted to rotate my iPad, I have to have mute enabled, but no keyboard click sound.
    I know it sounds confusing. I'm already confused... beh.

    I completely forgot about that.
    Thank you!

  • I have a mid 2007 MacBook Pro with 2GB of RAM and NVIDIA GeForce 8600M graphics. Is it possible to upgrade the RAM and the graphics card?

    I have a mid 2007 MacBook Pro with 2GB of RAM and NVIDIA GeForce 8600M graphics card. Is it possible to upgrade the RAM and the graphics card?

    The RAM can be upgraded as indicated below. The Graphics card can not be upgraded.
    Maximum Memory
    6.0 GB (Actual) 4.0 GB (Apple)
    Memory Slots
    2 - 200-pin PC2-5300 (667MHz) DDR2 SO-DIMM

  • T520 - 42435gg / Sound stutter and slow Graphic performance with Intel Rapid Storage AHCI Driver

    Hi everybody,
    I have serious Problems with my 42435gg
    Any time I install the Intel Storage AHCI Driver (I've tried plenty of different versions) which is suggested by System Update I experience a horrible Sound stutter and slow Graphic performance in Windows 7 64-Bit.
    The funny thing in this case: If the external e-sata port is connected the problems do not occur. If the port is unused again, the stutter begins immediately.
    The only thing I can do is using the Windows internal Storage Driver with which I am not able to use my DVD recorder for example.
    The device was sent to lenovo for hardware testing with no result. It was sent back without any repairing.
    Anybody experience on this?
    Kind regards,
    Daniel

    Did you try the 11.5 RST beta? Load up DPClat and see if DPC conditions are favorable.
    What are you using to check graphics performance?
    W520: i7-2720QM, Q2000M at 1080/688/1376, 21GB RAM, 500GB + 750GB HDD, FHD screen
    X61T: L7500, 3GB RAM, 500GB HDD, XGA screen, Ultrabase
    Y3P: 5Y70, 8GB RAM, 256GB SSD, QHD+ screen

  • HP Envy 15 Graphics Problem with Windows 8.1 (Intel and NVidia Graphics). Help!

    I bought an HP ENVY TouchSmart 15-j013ea about 6 months ago and I have had a major problem with the graphics that I cannot seem to solve. I think it started when I updated to Windows 8.1, even though I am not 100% certain.
    I have noticed the following three problems, and I think they are related:
    Some windows (such as Chrome, Skype, or even Device Manager or other windows) are very blurry compared to others.
    The firefox menu window has some deformed black arrows instead of the normal ones.
    When playing a game (specifically, Star Wars the Force Unleashed 2), after a while I get an error that the computer has ran out of memory. However, according to task manager, only about 50% is in use, not to mention that I have 8 GB of RAM + 2 GB graphics memory. At the same time, the computer gets rather loud (like a fan working overtime) and hot.
    The laptop has both Intel and NVidia graphics, and both are enabled in Device Manager. To be honest, I have no idea which is used when, or how to check that (let me know if there is a way)
    I have tried the following without success:
    Uninstalling the Intel graphics driver from device manager and installing a version I downloaded from the HP website for my laptop and OS. After that, Windows would NOT BOOT, and I had to do a system restore.
    Uninstalling the Intel graphics from Programs and Features, and installing 2 different versions from the Intel website. Nothing changed.
    Updating Nvidia driver through GeForce Experience. Nothing changed.
    Updating Intel drivers from Windows Update. Nothing changed.
    Quite frankly I am not sure what the problem could be, since the graphics versions are supposed to be compatible with WIndows 8.1. I also don't get why some windows are blurry and others are not. I am thinking the computer uses only the Intel graphics and not the Nvidia (at least in the blurry windows), but even if that was the case (and it shouldn't be), I don't think I should be having this problem.
    At this point, I really need help. My graphics details are:
    Intel HD Graphics 4600: Driver version: 10.18.10.3412
    NVidia GeForce GT 740M: Driver version: 335.23
    NVidia GeForce Experience version: 1.8.2
    I am attaching screenshots that show driver details and the problems.
    Thank you.
    Blurry Chrome:
    Firefox menu problem:
    Device Manager and driver windows are also blurry, both graphics are shown

    I had a similar problem with a Dell laptop.  I found the problem was the laptop wanted to switch between the Intel and NYIDIA video cards.  It would switch to the Intel when high graphics was not required then to the NIVIDIA when high graphics was required.  The laptop does this to save power when high graphics is not required but it caused problems with some applications, specifically high graphics games.
    For me the solution was to disable the Intel graphics processor.  You can do this by right clicking on your Wallpaper, select the NIVIDIA Control Panel, then select Set Physx Configuration.  You will see a dropdown box labeled Select Physx Processor.  It is set to Auto by default.  This allows the switching I described. Select this dropdown box and select your NIVIDIA processor.  This will prevent the laptop from switching and force it to use your NVIDIA processor exclusively.
    Hope this helps.
    Sacto Fred
    Owner and CEO
    H&O PC Soultions

Maybe you are looking for

  • Footer navigation using pl/sql - substitution strings

    Hi I want to make a footer navigation (a BLAF like footer with the same captions and links that appear in the Tabs and the Navigation Bar) using a PL/SQL region. The code I want to use should work for any HTML DB application. The procedure could be d

  • Table Scroll down using a button

    Hi, Can some expert Webdynpro consultant try out this weird requirement and give me the solution. ( Its for an app to be used on Mobile which is why asking for it. Its working fine on computers/Laptops) Create a table and bind it with a child node an

  • Photoshop CS5 freezing in Windows XP, re-installed twice

    Hi There: My Photoshop CS5 freezes the first time I try to open a JPEG file. As soon as I choose the Open command and try to being in a jpeg file it locks up. I had uninstalled and re-installed the program twice now with no change. My operating syste

  • TS1702 Skype for iphone 5 not working like it does on iphone 4s

    its intermittent, always hanging , unable to click the voice call, after restart device, uninstall the skype app then reinstall. Then it will work the skype. any suggestions please

  • Need Sales Order Approval Workflow upto two level

    Hi All,    I am new user of sdn and also in workflow.I want to create a workflow to approve a sales order upto two level of approval. Is there any standard workflow available for this?or any standard task to approve sales order.Please help.