Hi all,

 

Im writing a portion of my program tos acle a JPEG image down to fit within a small viewerPane.  When I use the setToScale method, and I try to scle the image down but maintain the sacled aspect ratio it takes much longer and causes other problems in my program as compared to when I do a setToScale to make the image TO_FIT the viewerPane.  Anyone know why this is…is there a bug that I don’t know about?  Maybe another way to do this so that it works properly?

 

Its very strange because the only thing that changes is the mag pararmeter to setToScale()….when the parameters are set for TO_FIT, it works perfectly, but anyother mag values make the program go extremely slow.  Any help would be much appreciated…I’m stumped.  Thanks

 

Below is the code where I do the setToScale transformation.:

 

switch(displayMode){

        case DisplayMode.ORIG_SIZE:

          bufferWid = imageWidth;

          bufferHt = imageHeight;

          break;

        case DisplayMode.SCALED:

          double mag= (magY > magX)? magX:magY;

              System.out.println("magX:"+magX);

              System.out.println("magY:"+magY);

              System.out.println("mag:"+mag);

          dispModeAtx.setToScale(mag, mag);

          //dispModeAtx.setToScale(mag/magX, mag/magY);

          bufferWid = (int)(imageWidth*mag);

          bufferHt = (int)(imageHeight*mag);

              System.out.println("bw:"+bufferWid);

              System.out.println("bh:"+bufferHt);

          break;

      case DisplayMode.TO_FIT:

          dispModeAtx.setToScale(magX, magY);

          bufferWid = width;

          bufferHt = height;

          System.out.println("bw:"+bufferWid);

          System.out.println("bh:"+bufferHt);

          default:

          break;

      }

 

      //atx.translate(-(this.getWidth()-bufferWid)/2, -(this.getHeight() - bufferHt)/2);

      BufferedImage bi = new BufferedImage(bufferWid, bufferHt,imageType);

      Graphics2D bigc = bi.createGraphics();

      if(originalImageType == TYPE_AWT_IMAGE) bigc.drawImage(awtImage, dispModeAtx, this);

      else bigc.drawImage(bufferedImage, dispModeAtx, this);

=========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to