Images loading from url

Hi All !
I am trying to load images onto a canvas using url source.
The images loaded are forming a map , so its important that
every image will be
exactly in the wright place.
The problem is that sometimes an image is not loaded , and I
get error 504 "Gateway RequestTimeout" ,
what i want to do is shorten the time of the error so if an
image isnt loaded after 5 seconds i will get the error
and reload it. How do i change the timeout of the loading ?
or maybe i should use another method to load the images to
the canvas ?
10x alot !
mr. flex ;)

hi,
looks like PaintComponent() instead of paint did the job.
thanks a million..
for those interested in loading images, I find ImageIcon very limited and at the end I found a better solution :
public class ImageComponent extends JComponent implements ImageObserver{
    private Image image;
    public void loadImage(URL imageURL){           
            image = Toolkit.getDefaultToolkit().getImage(imageURL);
            prepareImage(image,getWidth(),getHeight(), this);
    public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height){
        System.out.print("."); // loading progress...
    public void paintComponent(Graphics g){
        if(image!=null){
             g.drawImage(image,0,0,null);
}it is far nicer as it displays dots while loading... up to you to attach progress bars or favorit loading guizmo...
DrLeinster.

Similar Messages

  • How to display a dynamic image file from url?

    Hey,I want to display a dynamic image file from url in applet.For example,a jpg file which from one video camera server,store one frame pictur for ever.My java file looks like here:
    //PlayJpg.java:
    import java.awt.*;
    import java.applet.*;
    import java.net.*;
    public class PlayJpg extends Applet implements Runnable {
    public static void main(String args[]) {
    Frame F=new Frame("My Applet/Application Window");
    F.setSize(480, 240);
    PlayJpg A = new PlayJpg();
    F.add(A);
    A.start(); // Web browser calls start() automatically
    // A.init(); - we skip calling it this time
    // because it contains only Applet specific tasks.
    F.setVisible(true);
    Thread count = null;
    String urlStr = null;
    int sleepTime = 0;
    Image image = null;
    // called only for an applet - unless called explicitely by an appliaction
    public void init() {
                   sleepTime = Integer.parseInt(getParameter("refreshTime"));
              urlStr = getParameter("jpgFile");
    // called only for an applet - unless called explicitely by an appliaction
    public void start() {
    count=(new Thread(this));
    count.start();
    // called only for applet when the browser leaves the web page
    public void stop() {
    count=null;
    public void paint(Graphics g) {
    try{
    URL location=new URL(urlStr);
    image = getToolkit().getImage(location);
    }catch (MalformedURLException mue) {
                   showStatus (mue.toString());
              }catch(Exception e){
              System.out.println("Sorry. System Caught Exception in paint().");
              System.out.println("e.getMessage():" + e.getMessage());
              System.out.println("e.toString():" + e.toString());
              System.out.println("e.printStackTrace():" );
              e.printStackTrace();
    if (image!=null) g.drawImage(image,1,1,320,240,this);
    // called each time the display needs to be repainted
    public void run() {
    while (count==Thread.currentThread()) {
    try {
    Thread.currentThread().sleep(sleepTime*1000);
    } catch(Exception e) {}
    repaint(); // forces update of the screen
    // end of PlayJpg.java
    My Html file looks like here:
    <html>
    <applet code="PlayJpg.class" width=320 height=240>
    <param name=jpgFile value="http://Localhost/playjpg/snapshot0.jpg">
    <param name=refreshTime value="1">
    </applet>
    </html>
    I only get the first frame picture for ever by my html.But the jpg file is dynamic.
    Why?
    Can you help me?
    Thanks.
    Joe

    Hi,
    Add this line inside your run() method, right before your call to repaint():
    if (image != null) {image.flush();}Hope this helps,
    Kurt.

  • Jasper report on HTML when one image loaded from database and for the other

    How to generate jasper report on HTML when one image loaded from database and for the other we give a image path
    My code
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
              exporter = new JRHtmlExporter();
              exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
              exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos);
              exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, strImageInputDirectory);
         exporter.setParameter(JRHtmlExporterParameter.IMAGES_DIR_NAME, strImageOutputPath == null ? "." : strImageOutputPath);
         exporter.setParameter(JRHtmlExporterParameter.IS_OUTPUT_IMAGES_TO_DIR, Boolean.TRUE);
         exporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, Boolean.FALSE);
         exporter.setParameter(JRHtmlExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);
              exporter.exportReport();
              byte[] bdata = ((ByteArrayOutputStream) baos).toByteArray();
    Can any one help pls
    Message was edited by:
    ameet.au

    hey sorry for posting it in this forum.
    but do u have sample code for making it work.. since i am able to do it on PDF format(image from Database and another stored in the webserver) using
    byte image[] =(byte[]) outData.get("image");
                        ByteArrayInputStream img = new ByteArrayInputStream(image);
                        hmimg.put("P_PARAMV3", img);
    print = JasperFillManager.fillReport(reportFileName, hmimg, jrxmlds);
    bdata= JasperExportManager.exportReportToPdf(print);

  • ERR "Could not load "image-loading" from icon theme"

    Just finished installing OpenBox on a virtualbox
    But cannot get nitrogen to set background.
    while running nitrogen from command line
    [utkarsh@myhost ~] $ nitrogen
    ERR: Could not load "image-loading" from icon theme, this indicates a problem with your Gtk/Gtkmm install

    I too had to the same problem. Couldn't find why we get that error. But could set the wallpaper using the command line.

  • Bean to load image item from URL?

    Can someone point me to a bean that will allow the loading of an image item from a URL?
    Cheers,
    Gary

    Here is the material:
    <p>
    the screen shot is here : http://sheikyerbouti.developpez.com/forms-pjc-bean/handleimage/getimage.png</p>
    <p>Get the jar file and the form module sample (9.0.2)</p>
    Notice that you could also download the image with the File_Transfert.URL_To_Client() Webutil function then load it with the Client_Read_Image_File() built-in.
    Francois

  • Pre-loading images loaded from XML.

    Hello,
    I hoping for some guidance please.
    I have a Gallery that loads thumbnails from an XML.
    I have added a pre-loader to each one of the thumbnails as it is being loaded from the XML.
    My problem is that I can't figure out how to remove the pre-loaders after it has called the Event.COMPLETE.
    With my curent code,
    As it completes loading the thumbnails, it throws an error and only removes the very last pre-loader.
    Thanks for any help you can provide.
    Here is the code I am currently using.
    var urlRequest:URLRequest = new URLRequest("images.xml");
    var urlLoader:URLLoader = new URLLoader();
    var myXML:XML = new XML();
    var xmlList:XMLList;
    urlLoader.load(urlRequest);
    myXML.ignoreWhitespace = true;
    urlLoader.addEventListener(Event.COMPLETE,fileLoaded);
    var arrayURL:Array = new Array();
    var arrayName:Array = new Array();
    var holderArray:Array = new Array();
    var nrColumns:uint = 1;
    var wheel:MovieClip;
    var holdMe;
    var thumbsprite:Sprite = new Sprite();
    addChild(thumbsprite);
    var thumb:Thumbnail;
    var thumbsHolder:Sprite = new Sprite();
    thumbsprite.addChild(thumbsHolder);
    function fileLoaded(event:Event):void {
         myXML = XML(event.target.data);
         xmlList = myXML.children();
         for (var i=0; i<xmlList.length(); i++) {
              var picURL:String = xmlList[i].url;
              var picName:String = xmlList[i].big_url;
              arrayURL.push(picURL);
              arrayName.push(picName);
              holderArray[i] = new Thumbnail(arrayURL[i],i,arrayName[i]);
              holdMe = holderArray[i];
              var loader:Loader = new Loader();
              loader.load(new URLRequest(xmlList[i].url));
              wheel=new rootz();
              holdMe.addChild(wheel);
              loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, preload);
              loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completed);
              function preload(event:ProgressEvent):void {
                   var percent:Number = Math.round(event.bytesLoaded / event.bytesTotal * 100);
                   trace(String(percent) + "%");
              function completed(event:Event):void {
                   holdMe.removeChild(wheel);
              if (i<nrColumns) {
                   holderArray[i].y = 65;
                   holderArray[i].x = i*100;
              } else {
                   holderArray[i].y = holderArray[i-nrColumns].y+110;
                   holderArray[i].x = holderArray[i-nrColumns].x;
              thumbsHolder.addChild(holderArray[i]);

    I am not sure why but the code I posted did not post right,
    Here is my code -
    var urlRequest:URLRequest = new URLRequest("images.xml");
    var urlLoader:URLLoader = new URLLoader();
    var myXML:XML = new XML();
    var xmlList:XMLList;
    urlLoader.load(urlRequest);
    myXML.ignoreWhitespace = true;
    urlLoader.addEventListener(Event.COMPLETE,fileLoaded);
    var arrayURL:Array = new Array();
    var arrayName:Array = new Array();
    var holderArray:Array = new Array();
    var nrColumns:uint = 1;
    var wheel:MovieClip;
    var holdMe;
    var thumbsprite:Sprite = new Sprite();
    addChild(thumbsprite);
    var thumb:Thumbnail;
    var thumbsHolder:Sprite = new Sprite();
    thumbsprite.addChild(thumbsHolder);
    function fileLoaded(event:Event):void {
    myXML = XML(event.target.data);
    xmlList = myXML.children();
    for (var i=0; i<xmlList.length(); i++) {
    var picURL:String = xmlList[i].url;
    var picName:String = xmlList[i].big_url;
    arrayURL.push(picURL);
    arrayName.push(picName);
    holderArray[i] = new Thumbnail(arrayURL[i],i,arrayName[i]);
    holdMe = holderArray[i];
    var loader:Loader = new Loader();
    loader.load(new URLRequest(xmlList[i].url));
    wheel=new rootz();
    holdMe.addChild(wheel);
    loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, preload);
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completed);
    function preload(event:ProgressEvent):void {
    var percent:Number = Math.round(event.bytesLoaded / event.bytesTotal * 100);
    trace(String(percent) + "%");
    function completed(event:Event):void {
    holdMe.removeChild(wheel);
    if (i<nrColumns) {
    holderArray[i].y = 65;
    holderArray[i].x = i*100;
    } else {
    holderArray[i].y = holderArray[i-nrColumns].y+110;
    holderArray[i].x = holderArray[i-nrColumns].x;
    thumbsHolder.addChild(holderArray[i]);

  • Dynamic Image (.gif) from URL into adobe Form by SFP

    Hi all
    I post the comment of Shamila because I have the same problem
    I need to place an image in the Adobe form based on the url.
    I have written the following formcalc script in the image field form ready action
    ImageField1.value.image.href = "http://www.adobe.com/imageshome/pdfgift_home.gif"
    But when i view the form , the image field is empty, and when i click on the blank space of the image field, a popup appears to select the image............
    How can i show the image from url in the form..........
    Regards,

    Hello,
    have you checked these basics documents?
    When you need to send a picture into the offline form: another image question - using Regular ABAP not web dynpro and Display a logo dynamically in adobe form
    Where to start with scripting: http://www.adobe.com/devnet/livecycle/articles/lc_designer_scripting_basics/lc_designer_scripting_basics.pdf
    http://help.adobe.com/en_US/livecycle/es/FormCalc.pdf
    Also try: Re: Dynamic R/3 Image URL in Adoeb Form
    regards, Otto

  • Image loading via URL with resources in packages

    And another newbie-question:
    When I want to access local media-files (for example images) in a subdirectory, I can use a url to get a local path/filename. For example:
    url = getClass().getResource("/path/image-name.gif");
    image = getToolkit().getImage(url);
    Now I have packaged my classes including the subdirs containing the images in a jar file.
    package.jar
    |
    -- subdir (with images)
    |
    -- a.class
    |
    -- b.class
    |
    -- x.class
    Now the access via url doesn't seem to work any longer. When I subclass "a" outside the package (with correct import-statements, of course) and the constructor of "a" tries to access the images in "subdir" (invoking super()), it cannot find it and an exception occurs.
    Is this correct, or does the error lie maybe somewhere else?
    I had the impression that a jar-archive can be accessed like a directory? Have I to access the images in another way to get them working inside a package? When the classes and images are not packaged, all works fine.
    I work with Sun One, btw., and do mount the jar-archive as a filesystem...
    Any advise?
    Thanks in advance.
    Xanathon

    Am I on the right way when using an URLClassLoader instead of getClass()?

  • Error while Image loading from database

    I'am using generic handler for loading Image from data bases. Its work fine when when I hardcode the ImageID in QureyString when call Handler. But it's giving errors of different type when I dynamically pass value to qurey string(from datatable).
    "There is already an open DataReader associated with this Command which must be closed first." 
    OR
    "There is already an open DataReader associated with this Command which must be closed first."
    here is a code of Handler
    public void ProcessRequest(HttpContext context)
    Int64 id = Convert.ToInt64(HttpContext.Current.Request.QueryString["adid"]);
    // dt = obj_dalayer.GetRecpDetailsByID(id);
    dt=GetRecpDetailsByID(id);
    if (dt.Rows.Count > 0)
    //context.Response.ContentType = "image/jpeg";
    context.Response.BinaryWrite((byte[])dt.Rows[0][2]);
    public DataTable GetRecpDetailsByID(Int64 reid)
    try
    obj_DB.Open();
    obj_sqlcmd = new SqlCommand("GetRecpDetailsByID", obj_DB.GetDBConnection());
    obj_sqlcmd.CommandType = CommandType.StoredProcedure;
    obj_sqlcmd.Parameters.Add(new SqlParameter("@rid", reid));
    obj_sqlda = new SqlDataAdapter();
    obj_dt = new DataTable();
    obj_sqlda.SelectCommand = obj_sqlcmd;
    obj_sqlda.Fill(obj_dt);
    return obj_dt;
    finally
    obj_DB.Close();
    And here is a HTML and ServerSide code on ASPX page of call handler.
    <img id="img2" alt="Image" runat="server" src='<%#"~/ImageReqHandler.ashx?adid="+Eval("ReID")%>' width="179" height="148" /
    I'm using Eval("ReID") to get ID of Image from datatable.

    Ayez,
    This is the VB forum, try it in the C# form.
    http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral
    However, there they will probably tell you that although your problem is C#, it is ASP.Net some programmers become scared if it is Web you know.
    Success
    Cor

  • LOSING IT: "Image Loading" from a DVD is NOT!!

    I don't know what's the deal. Aren't we supposed to have our photos anywhere? That's how Aperture is being marketed right?
    How come I can't edit my referenced photos from a DVD? I import them fine and during the import it seems I can edit the photos. But say that I want to edit some of my photos a week after; Aperture simply doesn't allow that! It tells me that the "Image is Loading", but the DVD doesn't even spin.
    It's not the DVD player as I can access the photos in the Finder and even edit them using Preview....
    H....E....L.....P.....!

    Hi Eduardo,
    Thanks for the reply. I had tried that to no avail. It's weird because the photos I have in external drives have no problems. Only DVDs.
    The screen to manage referenced files (the top part) shows that all files were found (the ones I have referred to in my DVD as well). However in the "volume" column it only shows "All Volumes" and my external hard drive. I'm assuming that here also the DVD volume should also be listed. This may be the reason why it doesn't work. But how can I force it to see my DVD? Any other approach?
    Any ideas?

  • Problem with dimension of an image loaded from a database

    Hi,
    I succeed in saving image in a MSAccess database with this code:
    Image img;
    image = new ImageIcon("d:\\prova\\comore.jpg");
    img=image.getImage();
    try{
    int[] pix = new int[img.getWidth(null) * img.getHeight(null)];
    PixelGrabber pg = new PixelGrabber(img, 0, 0, img.getWidth(this), img.getHeight(this), pix, 0, img.getWidth(this));
    pg.grabPixels();
    System.out.println(pix.length);
    byte[] pixels = new byte[img.getWidth(this) * img.getHeight(this)*4];
    for(int j=0;j<pix.length;j++){
    pixels[j] = new Integer(pix[j]).byteValue();
    String sql="insert into Immagini values ('1',?)";
    PreparedStatement ps = con.prepareStatement(sql);
    ps.setBytes(1,pix);
    ps.executeUpdate();
    }catch(Exception except){
    except.printStackTrace();
    then, I've load the image with this code:
    try{
    String query = "select * from Immagini where IDprog = 1";
    Statement s = con.createStatement();
    s.executeQuery(sql);
    ResultSet rs=s.getResultSet();
    rs.next();
    Viaggio vi = new Viaggio(rs.getInt(1),rs.getBytes(2));
    byte[] b=vi.getBytesImage();
    int[] intImage = new int[b.length];
    for(int j=0;j<b.length;j++){
    intImage[j]=(int)b[j];
    Image img = createImage(new MemoryImageSource(124,100,intImage,0,124));
    ImageIcon imgic = new ImageIcon(img);
    jLabel3.setIcon(imgic);
    }catch(Exception tps){
    tps.printStackTrace();
    All works correctly;
    but I've two problems:
    How do I do to take the dimension of the image from the byte array?
    infact in the code up written I've used 124 and 100 as image dimension;
    but I can have images of different dimension.
    The other problem is:
    Why in the image that is loaded are not the same number of colors of the image saved, but only a few, so that the image seems to be out of focus?
    Thank and excuse me for my english.
    I'm Italian.

    Noone can help me?
    Thank

  • Youtube not loading from URL

    hi has anybody come across problems with Safari not opening youtube on imac running version OS X 10.9.3 all updates current , Safari not loading youtube from fav or address bar, it just does nothing blank screen , any off the other web sites works fine ?????????

    Try turning off all extensions in Safari Preferences > Extensions tab. There are a number of reports lately of one of the ad blocking extensions causing a blank screen.

  • Image Loaded From Database not Visible in JLabel

    import java.sql.*;
    import javax.swing.*;
    import java.awt.*;
    public class consqlimage
         public consqlimage()
              try
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   Connection con = DriverManager.getConnection("jdbc:odbc:dsn","sa","manshu");
                   Statement stat = con.createStatement();
                   ResultSet rs = stat.executeQuery("Select pic from t_image");
                   byte b[];
                   b = new byte[1000];
                   while(rs.next())
                        b= rs.getBytes("pic");
                   for(int a=0;a!=b.length;a++)
                        System.out.println(b[a]);
                   JFrame f = new JFrame();
                   ImageIcon i1 = new ImageIcon(b+"jpeg");
                   JLabel l1=new JLabel("january",i1,SwingConstants.LEFT);
                   f.getContentPane().add(l1);
                   f.getContentPane().setLayout(new FlowLayout(FlowLayout.LEFT));
                   f.setSize(500,500);
                   f.setVisible(true);
                   con.close();
              catch(Exception e)
                   System.out.println(e);
         public static void main(String args[])
              new consqlimage();
    }

    Any reason why you are adding the "jpeg" to the end of the byte array?
    You should only have to pass the byte array to the ImageIcon constructor.

  • How to display an movieclip loaded from asset with specified view port ?

    Hi all,
    I would like to display only a specified viewport or
    cliprect of an movie clip(image) loaded from the asset library
    using the MovieClip::attachMovie fn. I searched thro the flash
    api's & could not find anything which is applicable. Is there
    any way
    to do this.
    Thanks in advance,
    McMuthu

    Here is some code that will show you how to setup a view
    port.
    ============================================================
    map.setMask(mapMask);
    this.onMouseMove = function() {
    mapMask._x = this._xmouse;
    mapMask._y = this._ymouse;
    updateAfterEvent();
    this.onEnterFrame = function() {
    mapMask.onPress = function() {
    this.startDrag();
    mapMask.onRelease = function() {
    this.stopDrag();
    =====================================================
    You will have to import your own map image convert it to a
    MovieClip instance and name it map. The viewport shape should also
    be converted to a MovieClip instance and given the name of mapMask
    in order to correspond with the variables in this code.
    You could change the code to have the view port move from one
    position or another.
    Hope this helps.
    Take Care

  • Image loaded successfully, but fail to draw bitmap of it

    I  have a image loaded from  different domain. The checkpolicy is set to  true and crossdomain file  has no problem.  The image isn't that large,  2,304px × 1,260px
    In the application, I will draw the bitmap image with this call
    new Bitmap(Bitmap(imgLoader.content).bitmapData, "auto", true);
    The   weird part is, there is 1% chance... the application can't draw the   bitmap... it will just be empty. It never happens to me, but some of my   users are complaining they can't see any image. I think they have  pretty  decent computer, and see the application on ie8 or ff4
    Not   sure is there anything I am doing wrong... I am sure the image is   loaded to user's browser, but the application just can't draw it....
    Can anyone help?
    Thanks a lot

    I have the crossdomain file hosted on the site... and i have the code like this in my app
    ImgLoader = new Loader();
    context = new LoaderContext();
    context.checkPolicyFile = true;
    ImgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImgLoadedHandler);
    ImgLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onImgLoadedErrorHandler);
    ImgLoader.load(new URLRequest(Params.imgURL), context);
    private function onImgLoadedHandler(e:Event):void
         ImgLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, onImgLoadedHandler);
         ImgLoader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, onImgLoadedErrorHandler);
         imgBmp = new Bitmap(Bitmap(ImgLoader.content).bitmapData, "auto", true);
    The thing need to mention is my ImgLoader is a public variable in one class... because I need to create another copy of that image in a different place... so in that clasee, I will reference the ImgLoader variable and create a another bimap with code like
    imgBmp2 = new Bitmap(Bitmap(ClassName.ImgLoader.content).bitmapData, "auto", true);

Maybe you are looking for

  • Connection Problems following Upgrade at Exchange

    I have been having problems since 1st November. I had received an e-mail advising that “we’re rolling out our faster broadband and we’ll be upgrading our network in your area on 01-Nov-11…For the first ten days or so after your upgrade, your broadban

  • Po creation date and release date during print po.

    hello all, i want to add po creation date and changed on date,po releasing date in printout of po. is there any standard settings available for this or i have to go for abaper help? what is the table and field for these addition. i know CDHDR and CDP

  • Changes to RFKABL00 for bank details.

    Hi Experts, I want to display the changes of bank details from RFKABL00 repot, right now it is not showing. is it possible from this program, please suggest your suggestions. Regards, Shivshanakar.

  • HT2589 Why is apple not authorizing my payment information ?

    Why is apple not authorizing my payment information ?

  • Deliver locally and forward to alternate domain?

    Is there a simple setting that would allow Postfix on Mac OS X to deliver messages locally as well as relay a copy to an alternate domain? For example: Let's say I have my server configured to deliver mail locally for '[email protected]' and I want t