Java Programming: zooming changes the color..

  • olzen / 300 / Fri, 03 Jul 2009 09:52:00 GMT / Comments (4)
  • When I use this code to scale bufferedImages of TYPE_USHORT_GRAY or TYPE_BYTE_GRAY, the image returned is brighter than the one passed to the method?
    Does anyone have any idea of what I am doing wrong here?
    Thanx in advance.

    public BufferedImage scale_ (BufferedImage img, double magFactor)
    {
    int imgWidth = (int) (img.getWidth()* magFactor);
    int imgheight = (int) (img.getHeight() * magFactor);
    displayImage = new BufferedImage ( imgWidth, imgheight, img.getType() );
    Graphics2D g = (Graphics2D) displayImage.getGraphics();
    g.drawImage( img, 0, 0, imgWidth, imgheight, null);
    return displayImage;
    }
  • Keywords:

    zooming, changes, color, java, programming

  • http://java.itags.org/java-programming/332344/«« Last Thread - Next Thread »»
    1. I would be interested to see what the result would be if you used a color gradation panel with blocks of graduated shades of grey.

      One possible answer is that as it expands the image it is dithering (or anti-aliasing) the image which is causing the effect you're noticing.

      No idea off hand how to prove that, or how to prevent it, but those were the thoughts I had when reading your question.

      puckstopper31 | Fri, 29 Jun 2007 10:41:00 GMT |

    2. Is it really, of does it just appear to be because the scaling is causing doubling of pixels, thus giving an appearance of a brighter image... Presumably, it would appear brigher when larger, darker when smaller.... Just a guess, though.

      bsampieri | Fri, 29 Jun 2007 10:41:00 GMT |

    3. >Presumably, it would appear brigher when larger, darker when smaller.Nope it is gettiging brighter for both larger and smaler images. but thanx for the suggestion.

      olzen | Fri, 29 Jun 2007 10:41:00 GMT |

    4. Problem solved. This occur in java 1.3.0, java 1.4.X solves this problem.Thanks for the suggestions both of you!Olzen

      olzen | Fri, 29 Jun 2007 10:41:00 GMT |

  • Java Programming Questions

    • BUILD SUCCESSFUL: Maven Core

      report :Build statistics: State: Previous State: Failed Started at: Sun, 3 Sep 2006 14:33:27 -0700 F...

      By continuumbuildserver

    • Add Date and Time Class

      I want to add Date and Time to my Java Program , How can i get the system time and date and pass to ...

      By janwillem_borleffs

    • Add Date and Time Class

      Hi JW ,Many thanks !!Ken :-)"Janwillem Borleffs" glsD:4285d5b0$0$6770$dbd41001@news.euronet.nl...> ...

      By nek

    • BUILD SUCCESSFUL: Maven Core

      report :Build statistics: State: Previous State: Failed Started at: Fri, 1 Sep 2006 13:11:28 -0700 F...

      By continuumbuildserver

    • Date and Time Class

      I want to add Date and Time to my Java Program , How can i get the system time and date and pass to ...

      By nek, 2 Comments

    • ResultSet is type forward only

      I am a new developer in JSP and Java. I am building a site using JSP and running an SQL statement th...

      By mariamodeste, 1 Comments

    • java lang no classdeff found

      When I try to run my applet in explorer I get the folowing error"no classdeff found error : com/borl...

      By indikaniva, 1 Comments

    • Making Java Speech

      Hello,I need make some speech by Java.I plan to choose an item (or more than one item) from a JList,...

      By danielliuhha, 11 Comments

    • how to implement Skype in my page

      Hello,I want to implement skype in our site page. in this page I show a onebutton and that click I w...

      By vish, 1 Comments