Complete
over 2 years ago

WERETECH-12048

Fix will be applied to next SDK release.

Devices affected will have firmware updates in a future firmware build.

No more transparency for font background on bufferd bitmap since SDK 4.0

Hi, 

I use a bufferedBitmap with color palette and custom bitmap fonts without antialiasing.

Since SDK 4.0 the font background  is not more transparent. The color is defined before:

dc.setColor(CustomColor, gfx.COLOR_TRANSPARENT);
   

The code is running many years without problem.

I don't understand, what's going wrong with new SDK

  • In SDK 4.x simulator, if you use a buffered bitmap with a palette following the Analog SDK sample, drawing text with transparent background into the buffer produces text with random foreground color and background that is definitely not transparent.

    It looks like for drawing text into the offscreen buffer the graphics engine gets confused when transparent color is not present in the palette.

    Adding transparent color (-1) to the palette fixes the randomness, but it shows another problem:

    After drawing text into the buffer, the resulting bitmap appears to retain the 'transparent attribute' for the pixels of the transparent text background. So when this buffer is copied to the screen, these 'transparent' pixels preserve the previous content of the screen.

    This doesn't make sense and it is not happening with other draw operations, e.g. line, circle or rectangle.

    It looks like for text drawing we have confusion between 'SOURCE transparency' (target pixel color should be kept) and 'TARGET transparency' (target pixel color should be void).

    Sadly the latter is now making its way into the real firmware in the field, as seen on 945 LTE.

    Can we please have it back the way it was in SDK 3.x? Use 'SOURCE transparency' when drawing transparent pixels and do not require the transparent color to be defined in the palette? It is not needed there unless 'TARGET transparency' is employed, but then it should be consistent for all drawing operations not just text, and there should be another way to achieve 'SOURCE transparency'.

  • To reproduce this sample is a little bit complex. But I have another sample, it is simple

    The digital time with this look is created with a dseg7 font, which is printed in white and then with offset 1px in black.

    This is only working with a transparent font background. For the always on second hand is a buffered bitmap created with palette.

                if (offscreenBuffer == null) {
                	offscreenBuffer = new Gfx.BufferedBitmap({
                    :width=> VA_Width-12,
                    :height=>VA_Height-12,
                    :palette=> [ProfileColors[0], ProfileColors[1], ProfileColors[2], ProfileColors[3], 
                    			ProfileColors[8], ProfileColors[7], ProfileColors[9], Gfx.COLOR_GREEN,
                    			CustomColorHands, CustomColorHandsShadow, DigColor, DigColorShadow]
               	 	});
    
                	targetDc = offscreenBuffer.getDc();
                	
                }

    The colors are defined with different color profiles

    And this print the digitaltime string:

     

            if (DigitalTimeType == 3 && !ClassicHands && HideElements == 0) {  // some conditions to draw shadow 
            	dc.setColor(DigColorShadow, Gfx.COLOR_TRANSPARENT);
            	dc.drawText(X-1, Y-1, fontDseg7, timeString, Gfx.TEXT_JUSTIFY_CENTER);
            }
            dc.setColor(HideElements > 1? ProfileColors[1] : DigColor, Gfx.COLOR_TRANSPARENT);
            dc.drawText(X , Y, fontDseg7, timeString, Gfx.TEXT_JUSTIFY_CENTER);

    Have you a question, please give me a hint

    best regards

  • Hi, would you be able to share an example of the problem code? I can understand you may not want to share your entire project, but a code snippet involving the creation of the bufferedbitmap would be very helpful. 

  • I have one watch face online, which is based on a transparent font background. It is AnalogSwitch Sports. With SDK 3.2 it shows normaly on a VA3 or fenix5/6:

    to safe energy the static elements are only write on watch face start or change settings to a buffered bitmap with palette of some colors. The right half circle is based not on a complete bitmap, then I can't change the color with settings, it is based on a custom font with all tiles of this half circle. So I can draw the buffered bitmap every minute and don't create the picture from tiles every minute.

    This is working since many years.

    With SDK 4.x it shows now:

    All tiles have loose the transparent background. I can't update the watchface anymore to support more new devices.

    thanks 2aCD

  • Hi Travis,

    this problem occurs only on devices which not support the new createBufferedBitmap, fenix 6 and older and only with defined palette for bufferedBitmap.

    On a Vivoactive4 I don’t see this, but this device have enough memory to use a full palette for bufferedBitmap. Therefore I have not test the transparent font background on this device.