Ticket Created
over 4 years ago

CIQQA-377

SDK 4.0.2 simulator - buffered bitmaps colors only black and white

The simulator does not display the correct color palette for buffered bitmaps.

When I build for a F6X and SDK 3.2.0 and start the simulator all buffered bitmaps only use black and white.

Code sample:

function bufferedBitmapFactory(options as {:width as Number, :height as Number, :palette as Array<ColorType>, :colorDepth as Number, :bitmapResource as WatchUi.BitmapResource}) as BufferedBitmapReference or BufferedBitmap {
        if (Graphics has :createBufferedBitmap) {
            return Graphics.createBufferedBitmap(options);
        } else {
            return new Graphics.BufferedBitmap(options);
        }
    }
    
function createBufferedBitmaps() {
        buffer1 = bufferedBitmapFactory({:width=>10, :height=>10, :palette=>[color1, color2, color3, color4]});
        buffer2 = bufferedBitmapFactory({:width=>10, :height=>10, :palette=>[color1, color2, color3]});
        buffer3 = bufferedBitmapFactory({:width=>20, :height=>20, :palette=>[color1, color2, color3, color4, color5]});
    }

  • Hi, the code exist since 2 years and works perfectly until sdk version v4.x. The screen dc is cleared correctly in onUpdate.

    Is it also needed to clear the dc of all newly created buffered bitmaps? (since sdk v4.x?)

    What about my question above with the color palette issues with the strange behaviour when you change the color order in the palette?

    I think the problem is related to the transparent color in the buffered bitmap color palette. Can you please verify that? Thanks.

    An example code for a f6x (sdk 3.x device) coded with sdk v4.0 would be nice. If the code is like the older skd(s) then it is not needed, but please provide some support for the not working simulator.

  • hmm... the code exists since more then 2 years (including clear screens and others) and it works perfectly on the simulator up to the sdk 3.2.5. With v4.0 the troubles begin.

    This is how I clean the dc. Is it also necessary to clear all dc(s) of all the buffered bitmaps that are created? That was never required in any SDK before.

    ...
    function onUpdate(dc) {
    ...
        dc.clearClip();
        dc.setColor(backgroundColor, backgroundColor);
        dc.clear();
    ...
    }

    And what about my question above about the troubles of the color palettet order?

    I think this issue is caused by the transparent color value (-1) in the color palette!

    Thanks for you help.

    An example for a device with sdk support 3.2.x (f6x) coded with the new v4.0 and new version of the buffered bitmaps would be nice!

    If the code is like the older sdk(s) then it is not needed, but please provide some help for the not working simulator.

  • Hey.  I talked with one of our developers and he suggested trying to clear the screen dc before setting the colors. Also I missed from your comments about how you were wondering how to get bufferedbitmaps to work on 4.0. Do you still need an example given?

  • do you have any solution or example with transparent color palette for buffered bitmaps?

  • I figured out that the issue is based on the color palette configuration. The problem is that I'm using 5 different colors in the palette (transparent, black, white, dark blue, light blue) and when I set the color the false color is used in the simulator. Another issue that I've found is that when I change the order of the colors in the palette also the false colors are used.

    I think there is something wrong in the simulator. When I define a color palette the order of that colors should not influence the colors while drawing.

    //--- sample code ---
    
    var bitmapBuffer = new Gfx.BufferedBitmap({:width=>280, :height=>100, :palette=>[-1, black, white, blue, red]});
    var bitmapDc = bitmapBuffer.getDc();
    
    bitmapDc.setColor(blue, -1);
    bitmapDc.drawLine(...);//not the blue color is displayed in the simulator it's black with transparent background
    
    // change color order
    bitmapBuffer = new Gfx.BufferedBitmap({:width=>280, :height=>100, :palette=>[blue, red, black, white, -1]});
    bitmapDc.setColor(blue, -1);
    bitmapDc.drawLine(...);//not the blue color is displayed in the simulator it's red with blue background