PHP Code? Shouldn't it be Helium/Widget/Script code?)
Anyways problem with your code is that by the time you call pic.getImage() the image has not been loaded yet, and only placeholder image (loading bar) is returned.
I remember that I added ITEM_CHANGED/ITEM_CANCEL event support for getPicture(). I am not sure if it has been released yet (cannot access source code right now), but if it is released it can be used like this
Code:
Picture pic = getPicture(url);
void actionPerformed(Shell shell, Component source, int action)
{
if (action == ITEM_CHANGED && source == pic) {
Image img = pic.getImage();
}
}
If it hasn't been released, need to hack a bit:
Code:
Picture pic = getPicture(url);
Image placeHolder = pic.getImage();
schedule(1000);
void timerEvent(Timer timer)
{
Image img = pic.getImage();
if (image != placeHolder) {
//img is the loaded image, or error placeholder ;(
} else {
//not loaded yet, lets wait one more second
schedule(1000);
}
}
Hope this helps,
/render