Image from PNG is not fully downloaded and part of Image is black

Hi,
I have quite slow Internet connection (sth like 3kB/s). In my application I create ImageIcon (and then Image from it) from an URL.
Sometimes when I download quite big PNG images (sth like 400 kB) the download process made by internal JVM methods breaks up. All my methods finish properly, but suddenly I get an error:
java.lang.ArrayIndexOutOfBoundsException
     at java.lang.System.arraycopy(Native Method)
     at sun.awt.image.PNGFilterInputStream.read(PNGImageDecoder.java:830)
     at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:213)
     at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:134)
     at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
     at java.io.BufferedInputStream.read(BufferedInputStream.java:201)
     at sun.awt.image.PNGImageDecoder.produceImage(PNGImageDecoder.java:355)
     at sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:254)
     at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:172)
     at sun.awt.image.ImageFetcher.run(ImageFetcher.java:136)
and part of the image downloaded is totally black.
Is there a way I can somehow catch this exception or change the code:
Image img = (new ImageIcon(url)).getImage();
so I'm sure that the whole image is downloaded?
jacek

Hiya Jacek,
Try using java.awt.MediaTracker to download the image. The javadocs give an example how to use it to ensure the app waits for the image to be fully downloaded.
Cheers,
James

Similar Messages

  • My movie did not fully download and it has stopped in the middle???? Don't want to pay for the movie again

    Movie did not download properly now I have. Don't want to delete and may again?

    If you still have problem, contact iTune Support
    https://ssl.apple.com/emea/support/itunes/contact.html

  • What do i do if a song did not fully download and it only plays half the song the song

    i bought a song on itunes the other day and i realized that only the beginning half of the song will play and then it will stop for the other half and no sound will be coming out but it will still be playiny. how do i get a refund or how can i redownload the song on itunes?

    1. Delete the song from your iTunes library
    2. Redownload it via the Purchased link under Quick Links
    (Quick Links is on the right-hand side of the iTunes store home page on your computer's iTunes)
    3. Check and play song- it should play in its entirety now. If not contact support.

  • TS1702 How do I delete an App on IPad that has not fully downloaded. Unable to delete it using normal procedure!

    Hi, I have a number of Apps that are not fully downloaded and I cannot delete them using normal procedure to enable me to download them again. Any tips are very welcome

    In iOS 6 you should be able to delete apps that are downloading... if you're not on iOS 6 just update to it and you should be able to do that. If not that, connect the iPad to iTunes, download the apps on your Mac or PC and then sync them with the iPad. That should work.

  • TS1424 my album did not fully download. I have half of the album. I went back to itunes and its showing me that I have to repurchase it! Help!

    my album did not fully download. Some songs are cut in half. I went back to redownload and it's showing that I must repurchase. Help!

    Did you follow the directions for redownloading?
    Downloading past purchases from the App Store, iBookstore, and iTunes Store

  • I rented a movie and it appears in the video app, but it did not fully download. It does not appear in downloads how do I repair the file?

    I rented a movie and it appears in the video app, but it did not fully download. It does not appear in downloads how do I repair the file?

    Did you download it using iTunes for Windows, or did you download it directly to an iOS device?
    If you can't find the movie you downloaded on your iPad, iPhone or iPod Touch, check inside your Videos App

  • I am Greek. I downloaded a film from ipad but for the last days it has not been downloaded and the status is "waiting".the charge has been made to my credit card. Does any body knows?

    I am Greek. I purchased a film from ipad but for the last days it has not been downloaded and the status is "waiting".the charge has been made to my credit card. Does any body knows?

    something other is dowloading somewhere on ipad

  • TS1702 Hi, I downloaded some Apps and they all appear on my iphone screen saying waiting but will not fully download.  On my account they are showing as downloaded so won't let me download them again.  Any suggestions?

    Hi, I downloaded some Apps and they all appear on my iphone screen saying waiting but will not fully download.  On my account they are showing as downloaded so won't let me download them again.  Any suggestions?

    Hello Funkylildiva,
    Thank you for contacting Apple Support Communities.
    The following article addresses downloading past purchases.
    Download past purchases
    http://support.apple.com/kb/HT2519
    If, after going through this article, you are still having problems, there are links to report a problem or contact iTunes Store suppport at the bottom.
    Regards,
    Jeff D.

  • HT204370 TV series not fully downloaded.

    I have some 4 episodes of a TV series, with some 16 (?) still not fully downloaded. iTunes used to restart the download each day but has ceased trying to download the rest of the series. How do I re-start this download please?  Thanks. Tim

    Hi Fata Morgana,
    Welcome to the Support Communities!
    The article below may be able to help you with this.
    Click on the link to see more details and screenshots. 
    iTunes Store: Download options when purchasing TV seasons, Season Passes, Multi-Passes, movie bundles, music box sets, or individual movies or TV episodes
    http://support.apple.com/kb/HT5731
    Downloading past purchases from the iTunes Store, App Store, and iBooks Store
    http://support.apple.com/kb/HT2519
    Cheers,
    - Judy

  • Itunes purchased song did not fully download

    I bought a song from itunes store and it did not fully download

    If your country's iTunes Store allows you to redownload purchased tracks, I'd delete your current copy of the track and try redownloading a fresh one.
    Otherwise, I'd report the problem to the iTunes Store.
    Log in to the Store. Click on "Account" in your Quick Links. When you're in your Account information screen, go down to Purchase History and click "See all".
    Find the item that is not playing properly. If you can't see "Report a Problem" next to the entry, click the "Report a problem" button. Now click the "Report a Problem" link next to the item.

  • What is DIVx and why all of a sudden it says it isn't fully downloaded and I can't watch trailers or certain videos?

    Why am I not able to view trailers from the Apple website or watch tutorial videos any longer.  I keep getting a message that DIVx is not fully downloaded, but I have tried uninstalling and re-installing several times.  What can I be doing wrong?

    It is a Divx extension you might have added by mistake. All you have to do is disable. This also happened to me and it took me a day to find out! To edit the extension open Safari, then click Safari on the top bar, a window will pop up in that find extensions. Click on the DivX extension and then disable it. The DivX extension I had was this.

  • I just tried updating ITunes to the new version and it will not completely download and now I get an error message of MSVCR80

    I just tried updating ITunes to the new version and it will not completely download and now I get an error message of MSVCR80. Is there a problem with the new iTunes version?
    Now ITunes won't open.Help!!!

    Go to Control Panel > Add or Remove Programs (Win XP) or Programs and Features(Later)
    Remove all of these items in the following order:
    iTunes
    Apple Software Update
    Apple Mobile Device Support
    Bonjour
    Apple Application Support
    Reboot, download iTunes, then reinstall, either using an account with administrative rights, or right-clicking the downloaded installer and selecting Run as Administrator.
    See also HT1925: Removing and Reinstalling iTunes for Windows XP or HT1923: Removing and reinstalling iTunes for Windows Vista, Windows 7, or Windows 8
    Should you get the error iTunes.exe - Entry Point Not Found after the above reinstall then copy QTMovieWin.dll from:
    C:\Program Files (x86)\Common Files\Apple\Apple Application Support
    and paste into:
    C:\Program Files (x86)\iTunes
    The above paths would be for a 64-bit machine. Hopefully the same fix with the " (x86)" omitted would work on 32-bit systems with the same error.
    tt2

  • How do i recieve the rest of the song i downloaded if it is saying it did not fully download

    A song i have just downloaded did not fully download the song

    Hi Attila528,
    Thanks for visiting Apple Support Communities.
    If you are not able to receive a rescue email to reset your security questions and password:
    You'll need to contact iTunes Store support to have your questions and answers reset.
    You can find the article with this information here:
    Rescue email address and how to reset Apple ID security questions
    http://support.apple.com/kb/HT5312
    After your password, security questions and answers are reset, I'd recommend providing a new rescue email address:
    You can edit or delete your rescue email address at My Apple ID. To edit your rescue email address:
    Navigate to My Apple ID using your web browser.
    Click "Manage your account"
    When prompted, sign in using your Apple ID and password.
    Click Password & Security
    You'll be asked to answer 2 of your 3 security questions before you can make any modifications. If you are unable to remember your answers, you can choose to send an email to your rescue email to reset your security questions.
    All the best,
    Jeremy

  • Why wsusscn2.cab will not fully download, today?

    The wsusscn2.cab file will not fully download, today 7/10/13.  Can someone please take a look? 

    I've also been unable to download wsusscn2.cab since 7/23/13. The download gets stuck at 82% in IE and 99% with Firefox & DownThemAll. I've tried to download the file on multiple computers with the same result.

  • I bought and downloaded a few song on iTunes. Now I see that some of the songs were not completely downloaded and stops a few seconds into the song. I went back to the album but it does not give me an option to re-download. What do I do so that I can down

    I bought and downloaded a few song on iTunes. Now I see that some of the songs were not completely downloaded and stops a few seconds into the song. I went back to the album but it does not give me an option to re-download. What do I do so that I can down

    Just found the answer - if you have the sam problem look here for the answer:
    https://discussions.apple.com/thread/5769424?tstart=0

Maybe you are looking for