Ways to interrupt loading of large images

Discussion in 'Java' started by William Rose, Aug 18, 2004.

  1. William Rose

    William Rose Guest

    Hi,

    I'm looking for ways to interrupt the loading of a large image from a
    remote site. The simple way to load such an image is obviously to use
    Toolkit getImage/createImage with a URL parameter. The less simple way
    is to manage the download oneself and get a byte array, and pass that to
    createImage.

    Once that's done though (createImage( byte[] )), it seems there's no way
    to prevent full decoding of the image. Does anyone know a way around
    this? Because it seems that this can take a non-trivial amount of time
    for a large image, so it would be nice to abort it if possible.

    cheers,
    Will
     
    William Rose, Aug 18, 2004
    #1
    1. Advertising

  2. William Rose

    Paul Lutus Guest

    William Rose wrote:

    > Hi,
    >
    > I'm looking for ways to interrupt the loading of a large image from a
    > remote site. The simple way to load such an image is obviously to use
    > Toolkit getImage/createImage with a URL parameter. The less simple way
    > is to manage the download oneself and get a byte array, and pass that to
    > createImage.
    >
    > Once that's done though (createImage( byte[] )), it seems there's no way
    > to prevent full decoding of the image. Does anyone know a way around
    > this? Because it seems that this can take a non-trivial amount of time
    > for a large image, so it would be nice to abort it if possible.


    You could always write your own decoding algorithm, place the decoding
    activity in a separate thread, and have the thread (and the algorithm)
    monitor an external flag that commands it to pause or abort.

    This may sound like a strange solution, but since the Java library decoders
    are not written in native code any more, there shouldn't be much speed
    difference if you write your own. The JPEG decoder in particular is
    extremely slow, and it happens I have an application with the same problem.

    --
    Paul Lutus
    http://www.arachnoid.com
     
    Paul Lutus, Aug 18, 2004
    #2
    1. Advertising

  3. William Rose wrote:
    >
    > I'm looking for ways to interrupt the loading of a large image from a
    > remote site. The simple way to load such an image is obviously to use
    > Toolkit getImage/createImage with a URL parameter. The less simple way
    > is to manage the download oneself and get a byte array, and pass that to
    > createImage.
    >
    > Once that's done though (createImage( byte[] )), it seems there's no way
    > to prevent full decoding of the image. Does anyone know a way around
    > this? Because it seems that this can take a non-trivial amount of time
    > for a large image, so it would be nice to abort it if possible.
    >


    Have you tried reading in the image using the classes from the javax.imageio
    package ? The ImageReader class (which is the super class of all actual
    implementations) has an "abort()" method that is supposed to provide this
    functionality. (Never tried it myself - so not sure how the implementations
    supplied in the library really behave).

    BK
     
    Babu Kalakrishnan, Aug 18, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tony
    Replies:
    0
    Views:
    1,047
  2. paul
    Replies:
    3
    Views:
    867
    Duende
    Jan 24, 2005
  3. Joergen Bech
    Replies:
    6
    Views:
    405
    Joergen Bech
    Sep 17, 2007
  4. QQ
    Replies:
    5
    Views:
    90
Loading...

Share This Page