Q: Insert image on a watch face

Hello all,

at the moment i am working on my first watch face and have a small issue with inserting images. My Solution is working, but i think i am not using the correct way.
In my current solution i load the image ressource on the onLayout function and display it with the onUpdate function. For this i use the two following lines:

image = Ui.loadResource(Rez.Drawables.id_test);

dc.drawBitmap(20, 20, image);

This is working as expected and the image is shown.


Now i want add some text with a label and redraw the layout with View.onUpdate(dc); Now the dc.draBitmap Function is overwritten and no image is shown. As quick solution i can move the drawBitmap line under the onUpdate line and everythink is working, but i think there is a better solution.

So have someone a better way for me to insert 2-3 images?

Thanks for your help.
  • Former Member
    Former Member over 9 years ago
    Hello all,

    at the moment i am working on my first watch face and have a small issue with inserting images. My Solution is working, but i think i am not using the correct way.
    In my current solution i load the image ressource on the onLayout function and display it with the onUpdate function. For this i use the two following lines:

    image = Ui.loadResource(Rez.Drawables.id_test);

    dc.drawBitmap(20, 20, image);

    This is working as expected and the image is shown.


    Now i want add some text with a label and redraw the layout with View.onUpdate(dc); Now the dc.draBitmap Function is overwritten and no image is shown. As quick solution i can move the drawBitmap line under the onUpdate line and everythink is working, but i think there is a better solution.

    So have someone a better way for me to insert 2-3 images?

    Thanks for your help.


    Hi, as far as I now, that is the supposed behavior if you mix layouts and drawing yourself. One solution woul be to also draw the label yourself (I think this will also save you some memory). The other solution would be to insert the image into your layout.
  • When you say "2-3 images", do you want to have the images rotate in the background? Will the images be the background for the text? Do you want to support more than one device (some are only 16 color, so it may be hard to find pictures that look good on those).

    If you are just building for a vivoactive - 64 color (for example), you may just want to skip the layouts and use dc calls for everything.. Here's a case where I did that with a single image, and am able to add stuff like a move alert in an interesting way!



    If you are rotating images, you may also find using dc calls a bit easier if you want to change the position, color, etc of text based on which image is being displayed.
  • So thanks for your support. It is working when i draw the Text and the background.
  • If you want to use layouts, that is fine, you just need to put a bitmap into the layout. If you want to change the image used, you can call findDrawableById() to get the Ui.Bitmap in the layout given its id, and then you can call setBitmap() on that to change the bitmap that is rendered.

    Travis
  • @Jim_m_58 

    Instead of calling the bitmap image using the DC call - How can I use layout and control the image? I would like  adjust things like the color, location and size? 

    what are the benefits of using dc call for images?

    I see the commands below from Travis.vitek but this doesn't seem to work the way I tried to configure it can someone post the full command?