Now that we have a sample 4.0 device to play with, I decided to see how the new graphics/bitmap handling will affect my widget. It appears that I am going to need to make some changes to how I handle receiving bitmaps through the makeImageRequest function.
On existing devices I check that the data is actually a bitmap resource. If it is, I save it to a class variable (bitmap) which I then display on the screen with the next onUpdate. What I am seeing is the data does not pass the instanceof check for BitmapResource on the 4.0 device. Below is my call back method being used.
function onReceiveImage(responseCode, data) { System.println("view fctn recieveimg"); if(responseCode==200) { if(data instanceof Ui.BitmapResource) { System.println("IMAGE OK"); bitmap = data; Ui.requestUpdate(); } else { System.println("IMAGE NOT OK"); } } else { data = null; System.println("imgstatus="+DisplayError); Ui.requestUpdate(); } }
On the 3.x and below devices, the Image Ok will print and the bitmap will display. On the 4.0 sample device, I get Image Not Ok, thus the bitmap is not set. The makeImageRequest documentation says that the callback should expect two inputs and the data should be a BitmapResource or null.
responseCallback as Method(responseCode as Number, data as BitmapResource or Null)
My question is because of the new graphics pool, do I need to wrap the data in the new createBufferedBitmap method to save the downloaded resource for display?