Bitmap Converter, transparency and compression

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • Bitmap Converter, transparency and compression

    Hi folks,
    I'm using Bitmap Converter (BmpCvtST.exe, v5.26, STemWin package) to convert images for display. Ordinarily when I save I select the "High color [565] compressed" output format and all is well. At the moment I am working with an image that has an Alpha channel and transparent portions. When I 'Save As' that option does not come up. The closest is "High color with Alpha [565]" but that doesn't work well. The image is a red X (255,0 0) and it appears black (but the transparency part works.)

    The option that provides the visual results I like (Red X, background otherwise visible ) is when I save with the option "True color with alpha channel" but it uses gobs of flash since it is not compressed. I have tried "True color with alpha channel, compressed" and nothing appears when the code issues the call to draw the image.

    Is there any to draw a compressed image with transparency on the LCD? The LCD is configured for 16 bit (565) color.

    Code that draws the image looks like:

    case ID_BUTTON_1: // Notifications sent by 'Submit'
    switch(NCode) {
    case WM_NOTIFICATION_CLICKED:
    // USER START (Optionally insert code for reacting on notification message)
    hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE_2);
    IMAGE_SetBitmap(hItem, &bmRedX);
    // USER END
    break;
    case WM_NOTIFICATION_RELEASED:
    // USER START (Optionally insert code for reacting on notification message)
    hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE_2);
    IMAGE_SetBitmap(hItem, &bmclear);
    // USER END
    break;
    // USER START (Optionally insert additional code for further notification handling)
    // USER END
    }
    break;

    bmRedX is the image with transparency and bmclear is a 1x1 pixel transparent image. The red X is painted when the button is touched and removed when the button is released. (That party works brilliantly assuming the button actually appears. ;) )


    Thanks!

    (Uh, sorry. The forum S/W has hopelessly mangled the code if I use the 'code' tags. It looks better if I just copy and paste?)
  • Thank you for the suggestion. I will try displaying the image using GUI_BMP_Draw() (as I believe that is what you mean.)

    In the mean time, here is the image I start with.

    Thanks!

    Edit: No joy yet with GUI_BMP_Draw() but I have something else to try WRT that.


    The manual also mentions drawing PNG files directly after they are converted using Bin2C.exe. I cannot find that tool in the (ST) distribution. Is it something I can download directly from Segger?


    Edit2: No positive results trying to draw w/out using an IMAGE widget. Nothing appears on the screen. I also tried eliminating the underlying IMAGE widgets (I have one 'stacked' on another) and that made no difference. Of course the WINDOW widget which roots this display is still there.


    I am passing a GUI_BITMAP pointer to GUI_BMP_Draw() and it's not obvious that this is the correct argument. (As an aside, I really dislike void pointers which cast aside any type safety!)


    I suppose there is some coordination required between the Window Manager and lower level code that is required for this to work (and which is not needed when an IMAGE widget is used.) A quick glance at the manual did not clue me in but I could have easily overlooked it. And FWIW the code uses a MEMDEV and is configured for two layers - and I'm sure that matters when trying to coordinate with the Window Manager.


    And lastly, I cannot rule out that some of the lower level calls are not implemented correctly. I have tried to copy them faithfully from ST example code that uses the same processor and same display configuration (16 bpp, 565) and at least some of them are working. Behind the scenes emWin may be using different calls depending on the format of the data that is provided.
    Images
    • RedX.png

      14.58 kB, 60×60, viewed 1,656 times

    The post was edited 2 times, last by hbarta ().

  • Hello,

    Please note that there are different functions for different types of images.

    The function GUI_BMP_Draw() should be used to display BMP images. It is not possible to pass a GUI_BITMAP pointer to this function, since it expects a pointer to binary BMP data. If you want to display a bitmap described by a GUI_BITMAP structure, please use the function GUI_DrawBitmap().

    Best regards,
    Adrian