I was playing around with the image browser code sent from JDCTechTips this
morning. I pdated the sample to properly scale the image, instead of
cropping, and discovered an interesting quirk. Using JLabel.setImage, an
animated GIF will be properly animated, but if you scale it with
getScaledInstance the animation stops. Does anyone know if this is a bug in
Image.getScaledInstance or a misfeature of JLabel.setImage?  Is there an
easy way to make this work that I have overlooked?

Code fragment follows, where f is a string containg a filename return from a
FileChooser:

/*****/

ImageIcon icon = new ImageIcon(f.getPath());

int sh = icon.getIconHeight();    // scaled height
int sw = icon.getIconWidth();    // scaled width
Rectangle r = new Rectangle(); // canvas bounding rectangle
label.getBounds(r);

if ( (sw > r.width) || (sh > r.height) )
{

        // do scaling ....

        // this foils animated gifs
        icon.setImage(icon.getImage().getScaledInstance(sw, sh,
Image.SCALE_DEFAULT));
}

label.setIcon(icon);

 /*****************/


"When reality contradicts you, it's best to listen"

David A. Finney
Principal Software Engineer
CACI Products Company
3333 North Torrey Pines Road
La Jolla, CA 92037
(619)824-5229
[EMAIL PROTECTED]
[EMAIL PROTECTED]

-----Original Message-----
From: Discussion list for Java 2D API
[mailto:[EMAIL PROTECTED]]On Behalf Of Raymond ASCHHEIM
Sent: Wednesday, June 16, 1999 2:44 AM
To: [EMAIL PROTECTED]
Subject: Re: [java2d] Graphic layer on top of the Java2D API


Date:    Wed, 16 Jun 1999 08:17:21 +0200
>>
>> I suggest you to see the JLOOX product.
>
>Is it free for academic use ..
>otherwise it is out of interesst
>for us ..
>
JLOOX is a commercial product and is not totally free.
It is not a beta version and comes with support, but not with sources.
It is runtime free : you just buy a development license, and have no
fees to pay
to deploy and distribute your products, even if you sell them.
You only pay for a little part of the time you will win, because your
time doesn't cost nothing.

For academic use, an 'academic partnership program' is currently setup,
to offer to all academic users a great rebate, and many other
advantages.
...To get both the benefits of a fully supported product (exhibited this
week at the JavaOne), and an academic price.

>> It does what you want
>> It is really designed for JDK 1.2, and comes with a powerful graphics
>> editor which give you a very easy access to all new features of Java 2D,
>> like gradients, transparency, textured text...
>> You can download from the web an evaluation version:
>> http://www.xanth.com/jloox/jloox.htm
>
>Sorry .. but
>can you also provide
>a english link ..
>I didn't
>learned french in
>school .. my second
>language was russian .. :-)
Naturally, the european site is english fluent at:
http://www.xanth.com/jloox/e_jloox.htm

And for americans and asians, the U.S. headquarter has its own site:
http://www.loox.com


Thanks for your interest, hoping that you will evaluate JLOOX, even if
it's not freeware!
        Raymond

Reply via email to