Is there a reason why Graphics.COLOR_TRANSPARENT does not match the background?

I use Graphics.COLOR_TRANSPARENT as the background color for my text so as to match the background of the watch face. I find now that it provides just a white background... this can be easily seen with the Analog sample provided with the sdk.

Sample text below

//Use white to draw the hour and minute hands
targetDc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_TRANSPARENT);

Output is as follows 

Suggestions?

Jeff

  • Which SDK and which target device?  Have you modified the analog sample?

  • The SDK is 3.1 and the target device is FR 935... what is interesting is that if I try it on other watches, it allows me to use the target sdk version 1.2, 1.3 or 1.4 and then I have no problem... 

    I did modify the foreground color to something other than white so I could see the numbers, but moved them back to white once I saw it working with other models/SDKs...

    So... I guess this is only a problem with the later target SDKs? BTW... the Garmin SDK that I downloaded to run my simulations is 4.0.5 which was just released in August ...

  • Here's what I see with the 4.0.5 SDK, it's analog sample and a 935 target:

    I'm guessing you changed something else in the code.  Maybe with the buffered bitmap?

  • I just downloaded the analog code again and it works. Embarrassing, but thanks for following up so quickly...

  • Hi Jim,

       OK... so I looked at the Analog watch face code from 4.0.4 ... (I assume 4.0.5 was corrupted by me)... this was the code for putting the numbers on the watch face

    // Draw the 3, 6, 9, and 12 hour labels.
    var font = _font;
    if (font != null) {
    targetDc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_DK_GRAY);
    targetDc.drawText(width / 2, 2, font, "12", Graphics.TEXT_JUSTIFY_CENTER);
    targetDc.drawText(width - 2, (height / 2) - 15, font, "3", Graphics.TEXT_JUSTIFY_RIGHT);
    targetDc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_BLACK);
    targetDc.drawText(width / 2, height - 30, font, "6", Graphics.TEXT_JUSTIFY_CENTER);
    targetDc.drawText(2, (height / 2) - 15, font, "9", Graphics.TEXT_JUSTIFY_LEFT);
    }

    Note that the code changes the background color of the numbers (as opposed to using transparent) in order to make it seem transparent... can you check this with the code on your end!! I know with earlier SDK versions, this wasn't necessary and using transparent would change the background of the font to match the background of the watch automatically...

    Doing a little more digging: 

    I changed the color of the background from COLOR_DK_GRAY to COLOR_TRANSPARENT. This affects the numbers 12 and 3.

    I changed the device to vivoactive and set the sdk version to 1.4 ... color_transparent works!!

    Then I changed the device to vivoactive3 and set the sdk version to 3.1 and it no longer matches the background for the 12 and the 3!!  COLOR_TRANSPARENT also doesn't work for vivoactivehr and sdk version 2.4...

    Thoughts?

    Jeff

  • This problem only occurs if the device supports the buffered bitmap function.
    There is an error in this example. The color "Graphics.COLOR_TRANSPARENT" is not added to the palette. But even if you add it, the text on a COLOR_TRANSPARENT background does not work. It seems to me that COLOR_TRANSPARENT "burns" through the bitmap and shows what is under it.

    Previously, this problem was only in the emulator, on devices everything was displayed correctly. But now the owners of 945LTE and Venu2 who have this error in their device contact me.

  • The venu2 is different as it has CIQ 4.0, so the graphics pool is involved and you create buffered bitmaps differently.

  • This error in BufferedBitmap and createBufferedBitmap

  • If I'm wrong, show an example with transparent text in the buffer. Not over the buffer with a bitmap, but in the buffer.
    For Fenix5/6 and Venu1/2.

    Thanks a lot in advance!

  • 1. The problem manifests itself only in a simulated one, on a real watch it works as it should.

    2. I create BufferedBitmap to full size of the screen - I will draw on it. Including non-aliased fonts.

    3. Then I display this BufferedBitmap on the screen. When drawing the second hand, I again bring out the entire buffer, the limited area where the second hand was - to erase the second hand.

    4. In the simulator, the inscriptions are displayed on a white background, despite the fact that I painted them with a transparent background.

    function onUpdate(dc) {
    ....
    dcOffscreenBuffer = new Gfx.BufferedBitmap({
        :width=>(center)*2,
        :height=>(center)*2,
            :palette=> [
            BGC,
            0x000000,
            0x555555,
            0xaaaaaa,
            0xffffff,
            LC,
            AC,
            DC,
        ]
    });
    
    var tdc = dcOffscreenBuffer.getDc();
    
    .....
    if (cIcon!=' ') {
        tdc.setColor(AC, -1);
        tdc.drawText(center-d*5*k, 170*k-s, iFont, cIcon, a);
    }
    tdc.setColor(LC, -1);
    tdc.drawText(center-d*25*k, 170*k-s, label, v, a);
    .....
    dc.drawBitmap(0, 0, dcOffscreenBuffer);
    .....
    } // onUpdate(dc)

    I repeat - this happens only in the simulator and only when using the palette for the BufferedBitmap.