Resizing a rotated BufferedImage

Hi everybody,
I am currently developing a graphical figure editor. Users can drop several 'objects' on a JPanel.
These objects are represented on screen by BufferedImages. The objects are resizable, rotatable
and movable.
Rotating is implemented using AffineTransform. This works fine.
However, imagine one of the objects that has been rotated 90 degrees. Its north face will be facing east in
the viewport. When a user resizes the object by grabbing the east-side (i.e. the north handle before rotation)
resize-handle and dragging it to the east it is essentially resizing the object in a northwise direction.
This means that the height of the object is increased and that its origin (top left point) is decreased. However,
this will be drawn on screen exactly as stated: the height is increased and the origin is decreased and afterwards
the image is rotated. All this results in an object with the correct size, but drawn at the wrong location (I draw the
BufferedImage at the origin-point which was just decreased).
Might be a long and akward story, so here I will post a small example application which illustrates the behaviour
of my program. The program shows a BufferedImage. On this image a rectangle is drawn, along with an ellipse that
indicates the north face of the rectangle. Pressing 'R' results in a rotation of 90 degrees, whereas pressing any
of the four arrow-keys results in a 5-pixel increase in size. Just pressing R once and then an arrow key will
illustrate my problem.
My question is simple: how should I go about resizing (not rescaling, I really want to increase the
number of paintable pixels for my BufferedImage!) a BufferedImage that's been rotated using AffineTransform.
Any suggestions are greatly appreciated!
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.image.BufferedImage;
import javax.swing.JFrame;
import javax.swing.JPanel;
* Creates a BufferedImage that displays a simple image.
* This Image will can be rotated 1/2 PI degrees by pressing 'R'.
* By pressing any of the arrow-keys, the image is resized as if stretching
* the top of the image. (i.e. in the original, non-rotated, image it
* simply moves the origin of the image and increases the height).
public class ImageTest extends JPanel implements KeyListener
   double theta = 0.0; // rotation angle
   Point origin = new Point(50,50); // origin of the image
   Dimension size = new Dimension(100,100); // size of the image
   public static void main(String[] args)
      JFrame mainFrame = new JFrame("Image Tester");
      ImageTest imageTest = new ImageTest();
      mainFrame.getContentPane().add(imageTest);
      mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      mainFrame.setSize(400,400);
      mainFrame.show();
      mainFrame.addKeyListener(imageTest);
   // draw the image on the JPanel
   public void paintComponent(Graphics g)
      super.paintComponent(g);
      // create a BufferedImage and draw something on it (a rectangle)
      BufferedImage image =
         new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_ARGB);
      Graphics g2 = image.createGraphics();
      g2.drawRect(0, 0, size.width - 1, size.height - 1);
      g2.fillOval(size.width / 2, 0, 3, 3); // draw a little 'north' indicator
      g2.dispose();
      // now rotate g
      Graphics2D g2d = (Graphics2D)g;
      g2d.rotate(theta,
                 origin.x + size.width / 2.0,
                 origin.y + size.height / 2.0);
      // and draw the image on the specified origin
      g2d.drawImage(image, origin.x, origin.y, null);
    * @see java.awt.event.KeyListener#keyPressed(java.awt.event.KeyEvent)
   public void keyPressed(KeyEvent arg0)
      switch(arg0.getKeyCode())
         case (KeyEvent.VK_R):
            // rotate! add 1 / 2 PI degrees of rotation
            theta += Math.PI / 2;
            repaint();
            break;
         case (KeyEvent.VK_LEFT):
         case (KeyEvent.VK_RIGHT):
         case (KeyEvent.VK_DOWN):
         case (KeyEvent.VK_UP):
            // make the image 5 pixels larger
            origin.y = origin.y - 5;
            size.height += 5;
            repaint();
            break;
    * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
   public void keyReleased(KeyEvent arg0)
    * @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent)
   public void keyTyped(KeyEvent arg0)
}

Thanks Olek for your suggestion.
I took your advice (kind-of) and tried something.
Now I create a BufferedImage on which I draw a rectangle. The resulting Image is transformed to a rotated version of
this image. To do so, a new BufferedImage is created based on an AffineTransformOp.
This resulting (rotated) image is then shown on screen.
However, it still does not work correctly.
I have to state that this is a very simplified version of my problem. The original program features 8 resize handles, along with one rotation handle above
the object. When no rotation has been applied everything works fine (i.e. the object can be resized using the handles). However, if someone uses
the rotation handle to rotate the object 90 degrees (for example), resizing does no longer work correctly.
This sample program that I provided intends to mimic the case in which a user is stretching a rectangle to the north (without rotation) and to the
east (with 90 degrees of rotation). As you can see, if you press the UP-arrow if the object is not rotated, it does exactly what it needs to do:
stretch to the north (i.e. update the origin and increase the height). If you press R once and then try the UP-arrow again, you see that it still does what it needs to do. However, since I update the origin, the BufferedImage is moving up.
This all is very logical and the program does exactly what I ask it to do. However, it is not what I want it to do and I do not know how to implement what I really want.
Maybe someone can sketch some solution to this problem:
1 - Display a buffered image of size 30 x 30 (with some north-indicator)
2 - Stretch this image to the north a few pixels
3 - Rotate the buffered image 90 degrees clockwise around its center (north indicator is pointing east)
4 - Stretch this image to the east a few pixels (which, I think, corresponds to the operation in 2, but it clearly does not!)
This might be the little kick I need to set me off in the right direction again. I think I might have been thinking about this too long to see the solution
myself.
Listed here is my own updated version of the sample I provided in my first post. Clockwise rotation is still key R, counter clockwise rotation is E,
stretching the image to the north is UP-arrow and decreasing the image from the north is down (i.e. up and down mimic the case in which a user uses
the northern resize-handle to resize the image; in case of rotation this northern resize-handle is obviously displayed east or whatever).
Any help is appreciated as always!
package test;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
import javax.swing.JFrame;
import javax.swing.JPanel;
* Creates a BufferedImage that displays a simple image.
* This Image will can be rotated 1/2 PI degrees by pressing 'R'.
* By pressing any of the arrow-keys, the image is resized as if stretching
* the top of the image. (i.e. in the original, non-rotated, image it
* simply moves the origin of the image and increases the height).
public class ImageTest extends JPanel implements KeyListener
   double theta = 0.0; // rotation angle
   Point origin = new Point(50,50); // origin of the image drawing
   Dimension size = new Dimension(100,100); // size of the image
   public static void main(String[] args)
      JFrame mainFrame = new JFrame("Image Tester");
      ImageTest imageTest = new ImageTest();
      mainFrame.getContentPane().add(imageTest);
      mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      mainFrame.setSize(400,400);
      mainFrame.show();
      mainFrame.addKeyListener(imageTest);
   public void paintComponent(Graphics g)
      super.paintComponent(g);
      // get the BufferedImage in its rotated version;
      BufferedImage image = getImage();
      // display the image
      g.drawImage(image, origin.x, origin.y, null);
   private BufferedImage getImage()
      BufferedImage result =
         new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_ARGB);
      // draw a nice rectangle
      Graphics g = result.createGraphics();
      g.fillRect(0, 0, size.width, size.height);
      // and a north indicator
      g.setColor(Color.BLACK);
      g.fillOval(size.width / 2 - 3, 0, 6, 6);
      return applyRotation(result);
   private BufferedImage applyRotation(BufferedImage source)
      // create the rotation
      AffineTransform transform =
         AffineTransform.getRotateInstance(
                  theta,
                  source.getWidth() / 2,
                  source.getHeight() / 2);
      // make an Operation to create the new buffered image
      AffineTransformOp transformOp =
         new AffineTransformOp(transform, AffineTransformOp.TYPE_BILINEAR);
      // create dest image
      BufferedImage dest =
         transformOp.createCompatibleDestImage(source, source.getColorModel());
      // apply the filter
      transformOp.filter(source, dest);
      return dest;     
    * @see java.awt.event.KeyListener#keyPressed(java.awt.event.KeyEvent)
   public void keyPressed(KeyEvent arg0)
      int key = arg0.getKeyCode();
      switch(key)
         case KeyEvent.VK_R:
            // rotate clockwise
            theta += Math.PI / 2;
            break;
         case KeyEvent.VK_E:
            // rotate counter-clockwise
            theta -= Math.PI / 2;
            break;
         case KeyEvent.VK_UP:
            // scale up
            origin.y -= 5;
            size.height += 5;
            break;
         case KeyEvent.VK_DOWN:
            // scale down
            origin.y += 5;
            size.height -= 5;
            break;
      repaint();
    * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
   public void keyReleased(KeyEvent arg0)
    * @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent)
   public void keyTyped(KeyEvent arg0)
}

Similar Messages

  • I am losing resolution when I resize or rotate a line I have drawn.

    Can anyone help me?  I have been using photoshop to turn my drawings into digital stamps for crafting.  I always import my image, then with the pen tool I re-draw it in photoshop.  Usually I can take say my eye I had drawn and resize it or rotate it and it's perfect.  Lately I try any of that ant the lines will get very pixelated or lose resolution making them super fuzzy and ugly.  Does anyone know why this is now happening?
    I used to be able to duplicate it and flip it to have two perfect eyes, but again when I do that now same thing happens, it gets horribly pixelated. 
    I have attached two examples...
    Any helps is very much appreciated.  I am having the worst time trying to figure out why it's doing this all of the sudden. It has never done that before.  I have always been able to duplicate, rotate, and resize without it losing resolution or had the lines so fuzzy or pixelated.
    Thank you,
    Betty

    Hi again,
    Did you mean screen shots of my settings?  Maybe that would help?
    These are all my settings, and each time I draw a line and flip it or rotate it, it starts to lose resolution.  It is also now doing it when I take the finished file and place it into a "guide" file for making a watermark catalog image. Once I shrink the photo it looses resolution really badly.

  • Flex Help - Creating Resizable, Draggable, Rotatable Shapes

    Hello,
    Hopefully some feedback from this forum can guide me into
    creating what I hope to accomplish.
    What I want to do is have the user be able to draw shapes
    onto a canvas/panel. The shaeps are standard squares, rectangles,
    circles, etc. .... This is the easy part.
    Once the shapes are drawn, I would like for the user to be
    able to click on a shape, and have 4 squares show up at each corner
    of the shape. When a user clicks on one of the squares and drags
    the mouse, the object expands in size. Furthermore, I would like to
    provide the functionality so that the user may rotate the shape.
    I have currently completed the user being able to draw
    shapes, as well as drag them anywhere on the application. I have
    used sprites for this. Can someone please guide me on how to
    incorporate the other functionality such as the user being able to
    resize the shape by selecting a tiny square at one of the corners
    of the object. Thanks

    As cxf02 mentioned in a separate thread:
    http://code.google.com/p/flex-object-handles/downloads/list
    http://www.rogue-development.com/objectHandles.html
    Your work is done :)

  • Resizing of Rotated Frames in InDesign CS4

    Hi All,
    I have one group frame which contains one rotated image frame (with 30 degree) and one empy frame at zero degree.
    Programmatically when I set a new width size to the group frame in InDesign Desktop application it sets the new width properly to the group frame, but it does not retain the angles of the image which is inside frame.
    When we ungroup the frame it shows result like below one
    Even if I try this manually I get the same results.
    Please help me into this issue. Its very urgent.
    Thanks in advance & Regards,
    Santosh Kadam.

    Hi,
    Thanks for your quick response.
    1.  I have a group frame having size  409 X 409.  When I try to set the new width which is double of old width then it sets the group size to  818 X 409.
    This is correct. But it does not retain the angles of image as mentioned earlier.
    2. Instead of resizing the whole group frame, I have resized child frames individually.  In this condition I have set new width which is double of old width i.e 818.  It retains the proper image angle but the new size of group frame is 669 X 559 which is incorrect. It should be 818 X 409.
    Thanks in Advance,
    Santosh Kadam.

  • BitmapData Resize and rotation

    Hi there,
    I'm having some problems manipulating an image with AS3 and Flash Player 10.
    I've managed to edit a Bitmap from a local image by changing it's size and rotation with the help of class Matrix.
    The problem is that now I want to save the new image to the disk as a PNG file.
    I'm using a PNG as encoder that requires a BitmaData.
    When I passed that Bitmap.bitmapData all of the matrix changes do not get reflected in the bitmapData.
    Here is the code:
    var BMP:Bitmap  = Bitmap (LOADERINFO.content);
          BMP.pixelSnapping = PixelSnapping.ALWAYS;
          BMP.smoothing     = true;
          BMP.bitmapData.lock ();
    var scale:Number = .2;
    var matrix:Matrix = BMP.transform.matrix;
          matrix.rotate(90*(Math.PI/180));
          matrix.scale (scale,scale);
         BMP.transform.matrix = matrix;
    var BMPD:BitmapData = new BitmapData ( BMP.width, BMP.height, true, 0x00000000 );
          BMPD.draw(BMP);
    var BMP2:Bitmap = new Bitmap ( BMPD, PixelSnapping.ALWAYS, true );
    // JUST TO TEST
    addChild (BMP);
    addChild (BMP2);
    Thanks,
    PM

    oops, typo:
    kglad wrote:
    try:
    var BMP:Bitmap  = Bitmap (LOADERINFO.content);
          BMP.pixelSnapping = PixelSnapping.ALWAYS;
          BMP.smoothing     = true;
          BMP.bitmapData.lock ();
    var scale:Number = .2;
    var matrix:Matrix = BMP.transform.matrix;
          matrix.rotate(90*(Math.PI/180));
          matrix.scale (scale,scale);
         BMP.transform.matrix = matrix;
    var BMPD:BitmapData = new BitmapData ( BMP.width, BMP.height, true, 0x00000000 );
          BMPD.draw(BMP,matrix);
    var BMP2:Bitmap= new Bitmap(BMPD);
    // JUST TO TEST
    addChild (BMP);
    addChild (BMP2);

  • Issues with vector resizing & rotation! (CS5)

    I need some help and cannot seem to find the solution anywhere!
    All of my questions come from this basic task: Dragging files from Illustrator into Photoshop
    PROBLEM #1
    In CS3, when I dragged vector Illustrator files over into Photoshop, it used to automatically resize the vector image to fit the canvas I was working on. It doesn't do that anymore with CS5. Now when I drag files over from Illustrator, it places it at full size, so I waste a lot of time having to zoom out, make it smaller, and zoom back into my project. I DO have "Resize Image During Place" selected in Photoshop, but it still doesn't resize it! I went back to CS3 and it automatically fit the vector image I was trying to drag over into my project so it fit!
    PROBLEM #2
    In CS3, when I rotated a vector image (usually that I dragged over from Illustrator), it would maintain the bounding box, but now in CS5 it doesn't! For instance, I would normally drag an Illustrator file into Photoshop, then want to rotate the image as desired. Then later in the day if I wanted to rotate the image a little more or less, all I had to do was select the vector image and it would keep that rotated box around it, and would tell me that the image was currently rotated 41 degrees. However, in CS5, when I rotate a vector image and then want to re-rotate it, or re-size it, later in the day it doesn't do it. When I select the vector image, the bounding box is always a box or rectangle, with all flat sides, and it tells me that the image is rotated 0 degrees (even though earlier I may have rotated it, say, 70 degrees). I'm not explaining this very well, but basically, I can't resize or rotate it more than once because it acts like it rasterizes the image, if that makes any sense.
    Bottom line, these are HUGE annoyances for what I do!
    PLEASE HELP!
    wyzz7

    Ok, here are the three screenshots. Sorry if they're hard to see. Adobe puts a cap on size...
    In the first screenshot, you can see I dragged a vector image of a sweatshirt from Illustrator into Photoshop, and it didn't resize it. In this instance, my Photoshop size was 1500x1500. Most of the time, I'm working on small images (under 300px). So when I drag an image over, it's massive compared to my canvas size. It's a huge annoyance and time waster.
    In the second screenshot, I rotated the images as I wanted. However I want it to maintain that rotated bounding box (and it would keep it in CS3), but it doesn't now.
    In the final screenshot, you can see how it displays the vector image after I rotated it, then wanted to re-rotate it or resize it. It defaults back to a square bounding box. Therefore, if I wanted to compress the image vertically (make the sweatshirt shorter), it will skew/distort the image.
    Did that make things more clear?

  • Which approach to use for resizing image

    There are two ways of resizing images as I know:
    1. image.getScaledInstance(width,height,hint);
    Using hint like Image.SCALE_AREA_AVERAGING gives somehwat satisfactory resizing.
    2. static BufferedImage resize(GraphicsConfiguration gc, BufferedImage source, int w, int h, Object hintValue) {
    BufferedImage result = gc.createCompatibleImage(w, h, source.getTransparency());
    Graphics2D g2 = result.createGraphics();
    g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, hintValue);
    double sx = (double) w / source.getWidth(), sy = (double) h / source.getHeight();
    g2.drawRenderedImage(source, AffineTransform.getScaleInstance(sx, sy));
    g2.dispose();
    return result;
    where the hint passed is RenderingHints.VALUE_INTERPOLATION_BILINEAR ;
    Now which of the two method method should I use-using image.getScaledInstance() or using AffineTranform ? opr is there any other way which is faster but provides good result?
    i am creating an image editor, so the GUI dialog will have oprtion to choose the algorithm. I want the method which provides better result yet faster.
    Tanveer

    http://forum.java.sun.com/thread.jsp?forum=20&thread=522483

  • Unable to find rotate controls in Quicktime Pro 7.6 for Windows

    I have a number of Quicktime movies that I have taken with my digital camera. A number of them have been shot in portrait orientation instead of landscape so I bought Quicktime Pro in order to rotate them. Unfortunately I cannot find the controls to do so. I have followed the instructions in the manual:
    To resize or rotate a QuickTime movie:
    1 In QuickTime Player, choose Window > Show Movie Properties.
    2 In the Properties window, select a video track and click Visual Settings.
    3 To resize the movie, type new numbers in the Current Size fields.
    To keep the same height-to-width proportions, select Preserve Aspect Ratio.
    4 To rotate the movie, click one of the rotate buttons.
    but when I open the Show Movie Properties window and select a video track there is no "Visual Settings" box to select and so I cannot access the resize or rotate controls.
    Any advice anyone?

    It's okay I've found them now.
    If anyone else has this problem, you have to select the row at the top of properties that says "video track" rather than the one with the filename in order to get the visual settings tab and make sure that you have the box to the left of the row checked otherwise you won't be able to see the results.

  • How can i rotate a PNG photo and keep the transparent background?

    current i use this method to rotate a photo, but the transparent background is lost.
    what can I do ?
    public CreateRotationPhoto(String photofile,String filetype,int rotation_value,String desfile){
                 File fileIn = new File(photofile);
               if (!fileIn.exists()) {
                   System.out.println(" file not exists!");
                   return;
               try {
                       InputStream input = new FileInputStream(fileIn);
                       JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(input);
                       BufferedImage imageSrc = decoder.decodeAsBufferedImage();
                       int width = imageSrc.getWidth();
                       int height = imageSrc.getHeight();
                       BufferedImage src = ImageIO.read(input);
                       int width = src.getWidth(); //????? 
                            int height = src.getHeight(); //????? 
                       Image img = src.getScaledInstance(width, height,
                               Image.SCALE_FAST);
                       BufferedImage bi;
                       int fill_width=0;
                       int fill_height=0;
                       if (rotation_value==1||rotation_value==3){
                            bi = new BufferedImage(height, width,BufferedImage.TYPE_INT_RGB);
                            fill_width=height;
                            fill_height=width;
                       else{
                            bi = new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
                            fill_height=height;
                            fill_width=width;
                            //BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
                       input.close();
                       System.out.println(photofile);
                       File fileOut = new File(desfile);
                       //File fileOut = new File("c:/Host1.PNG");
                       OutputStream output = new FileOutputStream(fileOut);
                       JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(output);
                       JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bi);
                       param.setQuality(0.90f, false);
                       encoder.setJPEGEncodeParam(param);
                       Graphics2D biContext =bi.createGraphics();
                      biContext.setColor(Color.white);
                       biContext.fillRect(0,0,fill_width,fill_height);
                       int frame_width,frame_height;
                     if (rotation_value==1||rotation_value==3){
                            frame_width=height;
                            frame_height=width;
                       }else{
                            frame_width=width;
                            frame_height=height;
                       int x=0,y=0;
                       if (rotation_value==2){
                            x=frame_width;
                            y=frame_height;
                       if (rotation_value==0){
                             x=frame_width;
                             y=frame_height;
                       if (rotation_value==1){
                                x=frame_height;
                                 y=frame_height;
                       if (rotation_value==3){
                                    x=frame_width;
                                 y=frame_width;
                       double rotate=0;
                       if (rotation_value==0){
                             rotate=Math.PI *2;
                       if (rotation_value==1){
                            rotate=Math.PI / 2;
                       if (rotation_value==2){
                            rotate=Math.PI;
                       if (rotation_value==3){
                            rotate=Math.PI*1.5;
                       int x=0,y=0;
                       if (rotation_value==2){
                            x=width;
                            y=height;
                       if (rotation_value==1){
                                x=height;
                                 y=height;
                       if (rotation_value==3){
                                    x=width;
                                 y=width;
                       double rotate=0;
                       if (rotation_value==1){
                            rotate=Math.PI / 2;
                       if (rotation_value==2){
                            rotate=Math.PI;
                       if (rotation_value==3){
                            rotate=Math.PI*1.5;
                       System.out.println(Integer.toString(x)+"|x|"+Integer.toString(y)+"|y|"+Double.toString(rotate));
                       biContext.rotate(rotate, x / 2, y / 2);
                       biContext.drawImage(src, 0, 0, null);
                       biContext.dispose();
                       System.out.println("123123123123");
                       try{
                               ImageIO.write(bi, filetype, output);
                               //ImageIO.write(bi, filetype, "c:/Host.PNG");
                               output.close();
                          }catch (IOException e) {
                              System.err.println(e);
                      // encoder.encode(bi);
                       //output.close();
                } catch (Exception e) {
                         e.printStackTrace();
          }

    Using this BufferedImage.TYPE_INT_RGB for the type will eliminate any transparency in
    your image. Try BufferedImage.TYPE_INT_ARGB.
    Image file: Bird.gif
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.AffineTransform;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    import javax.swing.event.*;
    public class Rotate implements ChangeListener
        BufferedImage image;
        JLabel label;
        JSlider slider;
        public Rotate(BufferedImage orig)
            // make transparent background
            Color toErase = new Color(248, 248, 248, 255);
            image = eraseColor(convertImage(orig), toErase);
        public void stateChanged(ChangeEvent e)
            int value = slider.getValue();
            double theta = Math.toRadians(value);
            BufferedImage rotated = getImage(theta);
            label.setIcon(new ImageIcon(rotated));
        private BufferedImage getImage(double theta)
            double cos = Math.cos(theta);
            double sin = Math.sin(theta);
            int w = image.getWidth();
            int h = image.getHeight();
            int width  = (int)(Math.abs(w * cos) + Math.abs(h * sin));
            int height = (int)(Math.abs(w * sin) + Math.abs(h * cos));
            BufferedImage bi = new BufferedImage(width, height, image.getType());
            Graphics2D g2 = bi.createGraphics();
            g2.setPaint(new Color(0,0,0,0));
            g2.fillRect(0,0,width,height);
            AffineTransform at = AffineTransform.getRotateInstance(theta, width/2, height/2);
            double x = (width - w)/2;
            double y = (height - h)/2;
            at.translate(x, y);
            g2.drawRenderedImage(image, at);
            g2.dispose();
            return bi;
        private BufferedImage convertImage(BufferedImage in)
            GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
            GraphicsDevice gd = ge.getDefaultScreenDevice();
            GraphicsConfiguration gc = gd.getDefaultConfiguration();
            BufferedImage out = gc.createCompatibleImage(in.getWidth(), in.getHeight(),
                                                         Transparency.TRANSLUCENT);
            Graphics2D g2 = out.createGraphics();
            g2.drawImage(in, 0, 0, null);
            g2.dispose();
            return out;
        private BufferedImage eraseColor(BufferedImage source, Color color)
            int w = source.getWidth();
            int h = source.getHeight();
            int type = BufferedImage.TYPE_INT_ARGB;
            BufferedImage out = new BufferedImage(w, h, type);
            Graphics2D g2 = out.createGraphics();
            g2.setPaint(new Color(0,0,0,0));
            g2.fillRect(0,0,w,h);
            int target = color.getRGB();
            for(int j = 0; j < w*h; j++)
                int x = j % w;
                int y = j / w;
                if(source.getRGB(x, y) == target)
                    source.setRGB(x, y, 0);
            g2.drawImage(source, 0, 0, null);
            g2.dispose();
            return out;
        private JLabel getLabel()
            label = new JLabel(new ImageIcon(image));
            return label;
        private JSlider getSlider()
            slider = new JSlider(JSlider.HORIZONTAL, 0, 360, 0);
            slider.addChangeListener(this);
            return slider;
        public static void main(String[] args) throws IOException
            String path = "images/Bird.gif";
            ClassLoader cl = Rotate.class.getClassLoader();
            InputStream is = cl.getResourceAsStream(path);
            Rotate rotate = new Rotate(ImageIO.read(is));
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().setBackground(Color.pink);
            f.getContentPane().add(rotate.getLabel());
            f.getContentPane().add(rotate.getSlider(), "South");
            f.setSize(400,400);
            f.setLocation(200,200);
            f.setVisible(true);
    }

  • How to load images in List from Xml and view the image and resize the image & save in Flex?

    Hi Friends,
    I am new to flex i am doing application for image resizing rotating and save the resize image.
    I want to load the images from xml file to listcontrol and show that images as a icon in the listview,then i want to drag that image to panel that time it should show it original size of the Image.then it allows user to resize ,crop,rotate the image.then i want to save the resize image,when i save the resize image it should replace the original image in the xmllist.
    I am looking for some useful suggession ,if you dont mind want to see some snippet code.
    It will help me to understand the concept.
    Cheers,
    B.Venkatesan

    Not in Crystal Reports Basic for Visual Studio 2008. You'll have to upgrade to CR 2008 (12.x). Then use kbase [1320507|http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_erq/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes.do] as a guide on how to do this.
    Ludek

  • Resizing within layer? Playing with image size?

    Help! I have been searching FAQs and tutorials for hours. I used to be able to click and drag an image to change it's size while in the layer without having to specify a numeric value, just simply clicking and dragging then when happy with the size double clicking. I just upgraded to CS4 and can't find that option.
    Also how can I rotate just one of many layers in an image, using the rotate tool, it rotates all layers at once!

    I cannot identify with your past experience in Photoshop, perhaps you were referring to some other application  In Photoshop consider the following approach to both resize and rotate. Press Ctrl + T and a bounding box appears around the elements in the active layer. pull on a corner to resize, or
    pull on a corner with the shift key held down to resize proportionally.  If you hover just beyond the corner point you will see small curved arrows indicating the ability to rotate. Click and drag to rotate (just that layer) when the curved arrows appear.  Finish off any of the above transformations by hitting enter. Hope this helps.
    Paulo

  • Resizing, renaming images...

    Okay, maybe Java isnt the solution for this, but I figured I'd check it out.
    I'ma photogenic person, I love my digital camera to death but I have a problem... When I take the images off my camera they're like 2200px by 1800px or something to that effect, way to large. So I immediately open them in photoshop, resize them, and save/rename them. It's rather tedious. So I'm looking to write an application, preferably in java, that I will enter in a directory (c:\dir\blah\blah) and it takes all the images in there and resizes them to say 600x400px and bumps the quality down from 10 to 7 (photoshop talk there, heh) then saves them.
    Is Java best for this situation, if so, can anyone push me into the right direction?

    It can be done with java.
    I wrote a hobby application to generate thumb-views (and extract exif data) into a separate directory. It is written in Java including the thumb-views' resizing from the original images. I used code snippets (for resizing) and an exif package found in the internet - see the comment in the code.
    If I had your address, I could mail the whole stuff to you.
    Beware however the spammers' e-mail-sniffing bots!
    As said it was a hobby project. But you do not need to reinvent the wheel.
    Image Magic(k) has ready-made tools (convert.exe) for this purpose, you only need to write some launcher script. Or some image viewers could provide a GUI interface to this batch-like activity, maybe Irfanview too.
    http://www.imagemagick.org/script/index.php
    http://www.irfanview.com/
    package hu.bij.thwutil;
    //http://blog.cyberjos.idv.tw/space/Esaily+scale+image+in+Java
    import java.awt.Graphics2D;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import javax.imageio.ImageIO;
    import javax.swing.JFrame;
    public class SImage
      public static final String    JPEG = "jpg";
      public static final String    PNG = "png";
      private int                   srcHeight = 0;
      private int                   srcWidth = 0;
      private int                   height = 0;
      private int                   width = 0;
      private double                scale = 0.0;
      private boolean               resized = false;
      private BufferedImage         bimage;
      public SImage( String filename )  throws Exception
        this( filename, 1.0 );
      public SImage( BufferedImage aimage, double scale ) throws Exception
        bimage = aimage;
        srcHeight = bimage.getHeight();
        srcWidth = bimage.getWidth();
        setScale( scale );
      public SImage( String filename, double scale ) throws Exception
        this(ImageIO.read(new File( filename)),scale);
      public void write(String filename, String format ) throws Exception
         write(new File(filename),format);
      public void write( File output, String format ) throws Exception
        BufferedImage       bimage2 = new BufferedImage( width, height, BufferedImage.TYPE_INT_RGB );
        Graphics2D          g2d = ( Graphics2D ) bimage2.getGraphics();
        if ( resized )
          g2d.scale( ( double ) width / srcWidth, ( double ) height / srcHeight );
        else
          g2d.scale( scale, scale );
        g2d.drawImage( bimage, 0, 0, new JFrame() );
        ImageIO.write( bimage2, format, output );
      public void resize( int width, int height )
        if ( width < 1 )
          width = 1;
        if ( height < 1 )
          height = 1;
        this.width = width;
        this.height = height;
        resized = true;
      public boolean isResized()
        return resized;
      public double getScale()
        if ( resized )
          return 0.0;
        return scale;
      public void setScale( double scale )
        if ( scale < 0.01 )
          scale = 0.01;
        else if ( scale > 16.0 )
          scale = 16.0;
        this.scale = scale;
        height = ( int ) ( srcHeight * scale );
        width = ( int ) ( srcWidth * scale );
        resized = false;
      public int getHeight()
        return height;
      public int getWidth()
        return width;
      public int getSrcHeight()
        return srcHeight;
      public int getSrcWidth()
        return srcWidth;
      public static void main( String args[] ) throws Exception
        if ( args.length != 3 )
          System.out.println( "Usage: java ImageScale [src] [dest] [rate]" );
          System.exit( 0 );
        SImage      image = new SImage( args[ 0 ], Double.parseDouble( args[ 2 ] ) );
        image.write( args[ 1 ], SImage.JPEG );
        image.setScale( 0.5 );
        image.write( "1" + args[ 1 ], SImage.PNG );
        image.resize( image.getWidth() + 300, image.getHeight() + 100 );
        image.write( "2" + args[ 1 ], SImage.JPEG );
    }

  • Proportional Image Resizing

    Hi,
    Description of the task:
    I need to upload two images one is a full image and the other is a thumbnail representation of the same image of type jpg. I also need to ensure that all the uploaded images are within a given maximun size. For example:
    Thumbs should be 76 x 55 pixels
    FullSized should be 247 x 183 pixels
    Task Achievements:
    I've used the apachee commons package's FileItem class to handle retrival and storage of the image from the submitting servelet form.
    Description of the Problem:
    Don't know how to apply a proportional resize on the uploaded files (images) before storing them.
    Other Questions:
    1. Will the fact that conventional Buffered approach for reading files being not used hamper file manipulation?
    2. Can a proportional Image resizing function be applied to images in java. (Similar to that of php)
    3. Can an external php file be called or accessed from within java (a servlet) to perform the same functions of uploading an image and resizing it porportionally.

    private void uploadThumbImage(FileItem thumbImage, int eventId) throws JspException
         // code for fikle uploade goes here
         try
          //write the orginalFiles
          thumbImage.write(orginalThumbNail);
          resizeThumb(eventId);
         catch(Exception e)
             ErrorPrinter(e.getMessage()+" Exception in Image Upload");
    private void resizeThumb(int eventId) throws JspException
         try
              File loc = new File ("c:/"+eventId+".jpg");
              BufferedImage storedImage = ImageIO.read(loc);
              //ASSIGN  MAXIMUM X AND Y FOR STORAGE
              //1. set the expected allowable x and y maximum
              double maxiumX = 75;
              double maxiumY = 55;
              //2. check that the image is not too long or too wide
              double imgHeight = storedImage.getHeight()*1.0;
              double imgWidth = storedImage.getWidth()*1.0;
              if (imgHeight > maxiumY*2 && imgWidth > maxiumX*2)
                maxiumX = maxiumX*1;
                maxiumY = maxiumX*1;
              else if (imgHeight > maxiumY*2)
                maxiumY = maxiumY*2;
              else if (imgWidth > maxiumY*2)
                maxiumX = maxiumX*2;
              //3. Scale for the width (x)
              if (imgWidth > maxiumX)
               imgHeight = imgHeight*(maxiumX/imgWidth);
               imgWidth = maxiumX;
              //4. Scale for the lenght (l)
              if (imgHeight > maxiumY)
                   imgHeight = maxiumY;
                   imgWidth = imgWidth*(maxiumY/imgHeight);
              Image testImage = storedImage.getScaledInstance((int)imgWidth,(int)imgHeight,Image.SCALE_AREA_AVERAGING);
              BufferedImage biRescaled = toBufferedImage(testImage, BufferedImage.TYPE_INT_RGB);
              if (loc.exists())
                   if(!loc.delete())
                        ErrorPrinter("File that already exisits with file name could not be removed - (Thumbnail)");
              ImageIO.write(biRescaled, "jpg", new File ("c:/et_"+eventId+".jpg"));
              catch (IOException e)
                   ErrorPrinter(e.getMessage()+" Exception in Image Resize");
              catch(Exception e)
                   ErrorPrinter(e.getMessage()+" Exception in Image Resize");
    private static BufferedImage toBufferedImage(Image image, int type)
            int w = image.getWidth(null);
            int h = image.getHeight(null);
            BufferedImage result = new BufferedImage(w, h, type);
            return result;
       }

  • Rotate dragged shape on button click

    Hi guys,
    I need help here. I want to do a drawing application where user can resize and rotate a shape. I have created a shape which I can drag around but how to make it rotate upon clicking on button?? Let say when I select the shape and click on 'rotate' button my shape will be rotate by 90 degree. After that the rotated shape can still be drag. Any help would be appreciated.

    Hi Darryl.Burke,
    Thanks for your reply, yes I use AffineTransform methods to rotate the shape. Is there any different with other rotation method?? Ok when I use setToRotation, the shape indeed rotate to the correct position but when I click the shape return back to its original and other weird things happen. Below is the code. Can you please point out the part that I done it wrong please. Thanks.
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import javax.swing.*;
    import java.util.Vector;
    import javax.swing.border.CompoundBorder;
    import java.io.*;
    public class RotateShape
         private static void createAndShowGUI() {
            //Create and set up the window.
           JFrame.setDefaultLookAndFeelDecorated(true);      
           Viewer frame = new Viewer();
           frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
           frame.setVisible(true);
        public static void main(String[] args)
             javax.swing.SwingUtilities.invokeLater(new Runnable() {
              public void run() {
                   createAndShowGUI();
    class Viewer extends JFrame implements ActionListener
         JMenuBar menuBar;
         drawRect buildDesign;
        public Viewer()
           Toolkit kit = Toolkit.getDefaultToolkit();
            Dimension screenSize = kit.getScreenSize();
            int screenHeight = screenSize.height;
            int screenWidth = screenSize.width;
            // center frame in screen
              setSize(700, 600);
              setLocation(screenWidth / 4, screenHeight / 4);
              setResizable(false);
            buildDesign = new drawRect();
            buildDesign.setBorder(BorderFactory.createEmptyBorder(0, 2, 3, 3));
            JTabbedPane tabbed = new JTabbedPane();
            tabbed.addTab("Design", buildDesign);
            //tabbed.addTab("Viewer", buildViewer());
            tabbed.setBorder(new CompoundBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6),
                                                tabbed.getBorder()));
            //------------------------End of Tabbed Pane----------------------------------------------------//
          JPanel pane = new JPanel();
          Button rectButton = new Button("Rect");
          rectButton.addActionListener(this);
          pane.add(rectButton);
          Button deleteButton = new Button("Delete");
          deleteButton.addActionListener(this);
          pane.add(deleteButton);
          Button rotateButton = new Button("Rotate");
          rotateButton.addActionListener(this);
          pane.add(rotateButton);
          JScrollPane scroller = new JScrollPane(pane);
          scroller.setOpaque(false);
          scroller.getViewport().setOpaque(false);
          scroller.setBorder(new CompoundBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6),
                                                  scroller.getBorder()));
               //------------------------End of Build Item list----------------------------------------------//
          JPanel content = new JPanel(new BorderLayout());
          content.setOpaque(false);
          content.add(tabbed, BorderLayout.CENTER);
          content.add(scroller, BorderLayout.WEST);
          add (content, BorderLayout.CENTER);
          //------------------------End of add content----------------------------------------------//
              public void actionPerformed(ActionEvent evt) {
               // Respond to a command from one of the window's menu.
          String command = evt.getActionCommand();
          if (command.equals("Rect"))
             buildDesign.addShape(new RectShape());
          else if (command.equals("Delete"))
             buildDesign.delete();
          else if (command.equals("Rotate"))
             buildDesign.rotate();
    class drawRect extends JPanel implements ActionListener, MouseListener, MouseMotionListener
             Image offScreenCanvas = null;   // off-screen image used for double buffering
                 Graphics offScreenGraphics;     // graphics context for drawing to offScreenCanvas
                 Vector shapes = new Vector();   // holds a list of the shapes that are displayed on the canvas
                 Color currentColor = Color.black; // current color; when a shape is created, this is its color
                 float alpha;
            drawRect() {
            // Constructor: set background color to white set up listeners to respond to mouse actions
          setBackground(Color.white);
          addMouseListener(this);
          addMouseMotionListener(this);
       synchronized public void paintComponent(Graphics g) {
            Graphics2D g2 = (Graphics2D) g;
            // In the paint method, everything is drawn to an off-screen canvas, and then
            // that canvas is copied onto the screen.
          g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
          g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
          makeOffScreenCanvas();
          g2.drawImage(offScreenCanvas,0,0,this); 
          AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OUT,alpha);
              g2.setComposite(composite);
          g2.setColor(Color.GRAY);
          drawGrid(g, 20); 
       public void update(Graphics g) {
            // Update method is called when canvas is to be redrawn.
            // Just call the paint method.
          super.paintComponent(g);
       void makeOffScreenCanvas() {
             // Erase the off-screen canvas and redraw all the shapes in the list.
             // (First, if canvas has not yet been created, then create it.)
          if (offScreenCanvas == null) {
             offScreenCanvas = createImage(getSize().width,getSize().height);
             offScreenGraphics = offScreenCanvas.getGraphics();
          offScreenGraphics.setColor(getBackground());
          offScreenGraphics.fillRect(0,0,getSize().width,getSize().height);
          int top = shapes.size();
          for (int i = 0; i < top; i++) {
             Shape s = (Shape)shapes.elementAt(i);
             s.draw(offScreenGraphics);
            private void drawGrid(Graphics g, int gridSpace) {
          Insets insets = getInsets();
          int firstX = insets.left;
          int firstY = insets.top;
          int lastX = getWidth() - insets.right;
          int lastY = getHeight() - insets.bottom;
          //Draw vertical lines.
          int x = firstX;
          while (x < lastX) {
            g.drawLine(x, firstY, x, lastY);
            x += gridSpace;
          //Draw horizontal lines.
          int y = firstY;
          while (y < lastY) {
            g.drawLine(firstX, y, lastX, y);
            y += gridSpace;
        public void actionPerformed(ActionEvent evt)
         synchronized void addShape(Shape shape) {
              // Add the shape to the canvas, and set its size/position and color.
              // The shape is added at the top-left corner, with size 50-by-30.
              // Then redraw the canvas to show the newly added shape.
          shape.setColor(Color.red);
          shape.setColor(currentColor);
           shape.reshape(3,3,70,10);
          shapes.addElement(shape);
          repaint();
         void clear() {
             // remove all shapes
           shapes.setSize(0);
           repaint();
        void delete() {
             // remove selected shapes
                  shapes.removeElement(selectedShape);
                   repaint();
       void rotate() {     
                     //shapes.addElement(selectedShape);
                  selectedShape.setToRotate(true);
                  //shapes.removeElement(selectedShape);
                   repaint();
       Shape selectedShape = null;
       Shape shapeBeingDragged = null;  // This is null unless a shape is being dragged.
                                        // A non-null value is used as a signal that dragging
                                        // is in progress, as well as indicating which shape
                                        // is being dragged.
       int prevDragX;  // During dragging, these record the x and y coordinates of the
       int prevDragY;  //    previous position of the mouse.
        Shape clickedShape(int x, int y) {
             // Find the frontmost shape at coordinates (x,y); return null if there is none.
          for ( int i = shapes.size() - 1; i >= 0; i-- ) {  // check shapes from front to back
             Shape s = (Shape)shapes.elementAt(i);
             if (s.containsPoint(x,y))
                  s.tickSelected(true);
                  selectedShape = s;
                return s;
                else
                s.tickSelected(false);
                repaint();
          return null;
       synchronized public void mousePressed(MouseEvent evt) {
             // User has pressed the mouse.  Find the shape that the user has clicked on, if
             // any.  If there is a shape at the position when the mouse was clicked, then
             // start dragging it.  If the user was holding down the shift key, then bring
             // the dragged shape to the front, in front of all the other shapes.
          int x = evt.getX();  // x-coordinate of point where mouse was clicked
          int y = evt.getY();  // y-coordinate of point                                  
             shapeBeingDragged = clickedShape(x,y);
             if (shapeBeingDragged != null) {
                prevDragX = x;
                prevDragY = y;
                if (evt.isShiftDown()) {                 // Bring the shape to the front by moving it to
                   shapes.removeElement(shapeBeingDragged);  //       the end of the list of shapes.
                   shapes.addElement(shapeBeingDragged);
                   repaint();  // repaint canvas to show shape in front of other shapes
       synchronized public void mouseDragged(MouseEvent evt) {
              // User has moved the mouse.  Move the dragged shape by the same amount.
          int x = evt.getX();
          int y = evt.getY();
          if (shapeBeingDragged != null) {
             shapeBeingDragged.moveBy(x - prevDragX, y - prevDragY);
             prevDragX = x;
             prevDragY = y;
             repaint();      // redraw canvas to show shape in new position
       synchronized public void mouseReleased(MouseEvent evt) {
              // User has released the mouse.  Move the dragged shape, then set
              // shapeBeingDragged to null to indicate that dragging is over.
              // If the shape lies completely outside the canvas, remove it
              // from the list of shapes (since there is no way to ever move
              // it back onscreen).
          int x = evt.getX();
          int y = evt.getY();
          if (shapeBeingDragged != null) {
             shapeBeingDragged.moveBy(x - prevDragX, y - prevDragY);
             if ( shapeBeingDragged.left >= getSize().width || shapeBeingDragged.top >= getSize().height ||
                     shapeBeingDragged.left + shapeBeingDragged.width < 0 ||
                     shapeBeingDragged.top + shapeBeingDragged.height < 0 ) {  // shape is off-screen
                shapes.removeElement(shapeBeingDragged);  // remove shape from list of shapes
             shapeBeingDragged = null;
             repaint();
       public void mouseEntered(MouseEvent evt) { }   // Other methods required for MouseListener and
       public void mouseExited(MouseEvent evt) { }    //              MouseMotionListener interfaces.
       public void mouseMoved(MouseEvent evt) { }
       public void mouseClicked(MouseEvent evt) { }
       abstract class Shape implements Serializable{
          // A class representing shapes that can be displayed on a ShapeCanvas.
          // The subclasses of this class represent particular types of shapes.
          // When a shape is first constucted, it has height and width zero
          // and a default color of white.
       int left, top;      // Position of top left corner of rectangle that bounds this shape.
       int width, height;  // Size of the bounding rectangle.
       Color color = Color.white;  // Color of this shape.
       boolean isSelected;
       boolean isRotate;
       AffineTransform t;
       AffineTransform origTransform;
       void reshape(int left, int top, int width, int height) {
             // Set the position and size of this shape.
          this.left = left;
          this.top = top;
          this.width = width;
          this.height = height;
       void moveTo(int x, int y) {
              // Move upper left corner to the point (x,y)
          this.left = x;
          this.top = y;
       void moveBy(int dx, int dy) {
              // Move the shape by dx pixels horizontally and dy pixels veritcally
              // (by changing the position of the top-left corner of the shape).
          left += dx;
          top += dy;
       void setColor(Color color) {
              // Set the color of this shape
          this.color = color;
       void tickSelected (boolean draw) {
                 // If true, a red outline is drawn around this shape.
             isSelected = draw;
       void setToRotate (boolean draw) {
                 // If true, the shape will rotate 90 deg
             isRotate = draw;
       boolean containsPoint(int x, int y) {
             // Check whether the shape contains the point (x,y).
             // By default, this just checks whether (x,y) is inside the
             // rectangle that bounds the shape.  This method should be
             // overridden by a subclass if the default behaviour is not
             // appropriate for the subclass.
          if (x >= left && x < left+width && y >= top && y < top+height)
             return true;
          else
                      return false;
       abstract void draw(Graphics g); 
             // Draw the shape in the graphics context g.
             // This must be overriden in any concrete subclass.
         }  // end of class Shape
    class RectShape extends Shape {
          // This class represents rectangle shapes.
       void draw(Graphics g) {
            Graphics2D g2 = (Graphics2D) g;
            Rectangle2D wall = new Rectangle2D.Double(left,top,width,height);
            Rectangle2D border = new Rectangle2D.Double(left-2,top-2,width+3,height+3);
            origTransform = g2.getTransform();
            if ((isRotate) && (isSelected))
                   t = new AffineTransform();
                      t.setToRotation ((Math.toRadians (90)),(left+width/2) , (top+height/2) );
                      g2.transform(t);
                      g2.setColor(color);
                   g2.fill(wall);
                   g2.setColor(Color.red);
                    g2.draw(border);
                    g2.setTransform( origTransform );
                    return;
            else
                 g2.setColor(color);
              g2.fill(wall);
            if ((isSelected)&& !(isRotate))
                         g2.setColor(Color.red);
                         g2.draw(border);
                              else
                                   g2.setColor(Color.black);
                                   g2.draw(wall);
    }

  • Resizing a diagonal line

    I have a line that is on an angle of 15.3 degs which i want
    to be the width of the stage - in case the stage/browser is
    resized.
    I want the thickness and angle of the line to stay the same.
    I have a stageListener to execute the onResize which works.
    I have tried 3 methods within the function command, but they
    all have problems.
    line._width = Stage.width;
    - the angle changes depending on the size of the stage
    line._width = Stage.width;
    line._yscale = preloader._xscale;
    - the line gets thicker as it gets longer
    line._x = 0;
    line._width = Stage.width * 1.05;
    line._rotation = 15.3;
    - with this method I start the line on the stage at 0degs
    which is then resized and rotated, however the thickness of the
    line still increases as the line gets longer.
    Any ideas?
    Cheers
    Barton

    kglad: oh, no I just meant the same line scaling option in
    the Movieclip.lineStyle method arguments that became available from
    flash 8. And yes I assume its the same as the authoring scale
    options for lines. I'd used that before in actionscript. I had to
    check for it to see if it was available in the property panel,
    because I'd never used it there
    I use the pixelHinting one quite often in code.

Maybe you are looking for