makeImageRequest not responding

Trying to use the new makeImageRequest function implemented as part of SDK 1.2.0, fetching a simple png image (256x256 pixels). I get no error message. However, function in responseCallback is never called. Also strange is that the quick-tip in Eclipse says makeImageRequest take three parameters, whereas the documentation online talks about four.

Comm.makeImageRequest("http://adress.png", {}, method(:onReceive));

(In a browser the picture is shown without problems)

Anyone who has made this work?
  • Hello,

    may I ask how to draw an image to the screen (in an widget) after loading it?

    In the simulator I succeed loading an image with
    Comm.makeImageRequest("http://test.png",
    {},{:maxWidth=>50,:maxHeight=>50}, method(:onReceiveImage));


    In the onReceiveImage callback i can verify
    function onReceiveImage(responseCode, data){
    if( responseCode == 200 ){
    if(data instanceof Ui.BitmapResource){
    Sys.println("IMAGE RECEIVED!");
    }
    }
    }


    So i receive something and IT IS an BitmapResource. But the data seems to be useless....
    data.getHeight();
    data.getWidth();
    data.toString();

    None of the above does work. They all fail with
    "Failed invoking <symbol>
    in onReceiveImage(C:\..."

    What do I do wrong? Has somebody ever got this going?

    Thanks a lot,
    Lukas
  • Comm.makeImageRequest("http://test.png", {}, {:maxWidth=>50,:maxHeight=>50}, method(:onReceiveImage));


    Is that the actual url that you're passing? If so, it appears to be a user error since you've failed to specify the authority (typically the host name) which owns the resource you're attempting to access. If this is the code you're using and onReceiveImage() is being called with a responseCode of 200, that would seem to be a bug in the framework as well.

    Travis
  • Sorry for the ambiguity, the actual code referes to a valid path to a .png file.

    For example

    http://a.tile.stamen.com/toner/16/33986/21690.png

    I just wonder if anybody ever had this running in the simulator.... I have not seen any example or reference to this function yet...

    Thanks,
    Lukas
  • Former Member
    Former Member over 9 years ago
    Have you tried using dc.drawBitmap(x, y, bitmap)?
  • Just tested it and it exits with a

    Failed invoking <symbol>
    Invalid Resource


    Seems as the result code (200) and the test on "instanceof Ui.BitmapResource" are misleading, or something else is wrong with the data of the response...

    Tanks again.. Maybe one of the next updates allowes me to code my desired widget. I am waiting for it since SDK 0.1.0 I think.... Some day... I won't give up.... :o
  • Sorry for the ambiguity, the actual code referes to a valid path to a .png file.

    For example

    http://a.tile.stamen.com/toner/16/33986/21690.png

    I just wonder if anybody ever had this running in the simulator.... I have not seen any example or reference to this function yet...

    Thanks,
    Lukas


    Hi,
    I've been investigating and this works. The problem is the palette! After many hours, I'm unable to find the right palette ...

    Try this:

    hidden var bitmap=null;

    hidden var paletteTEST=[0x000000,
    0x000055,
    0x0000AA,
    0x0000FF];

    function initialize() {
    View.initialize();
    }

    //! Load your resources here
    function onLayout(dc) {
    }

    function onReceiveImage(responseCode, data)
    {
    if(responseCode==200)
    {
    if(data instanceof Ui.BitmapResource)
    {
    System.println("IMAGE OK");
    bitmap=data;

    Ui.requestUpdate();
    }
    }

    System.println("END ResponseCode=="+responseCode);
    }


    //! Update the view
    function onUpdate(dc) {
    // Call the parent onUpdate function to redraw the layout
    View.onUpdate(dc);

    if(bitmap==null)
    {
    Comm.makeImageRequest("a.tiles.wmflabs.org/.../12147.png", {}, {:palette=>paletteTEST, :maxWidth=>200, :maxHeight=>200}, method(:onReceiveImage));
    }
    else
    {
    dc.setColor( Gfx.COLOR_WHITE, Gfx.COLOR_WHITE );
    dc.clear();

    dc.drawBitmap(20,10,bitmap);
    }
    }
  • Good work MarkusGL. I had been pretty sure the feature worked, but I haven't had a chance to play with it since the first incarnation. Also, if you put tags around your code snippets they will appear in a pane and be rendered with a monospace font, which makes them much easier to read.
  • I've been investigating and this works. The problem is the palette! After many hours, I'm unable to find the right palette ...


    Are you able to call methods on the BitmapResource as indicated by CROWZ187? You should definitely be able to call those methods and get actual data back from them. If they don't work then a bug needs to be filed.
  • Thank you MarkusGL for this Hint!

    I just exported my program and tested it on my Fenix 3, and it WORKS! So this seems to be a problem in the simulator only!
  • Hi! Thank you! :)

    On the simulator, the image appears inverted. Running on Fenix3, do you have the same result?
    I think that is related with the palette. If you success with this please share!