Problems with BUTTON_SetBitmap()

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

  • Problems with BUTTON_SetBitmap()

    Hi everyone,

    I'm using emWin 4.18 and would like to set the bitmap of a button. But the bitmap is not known during compile time, so i cant use something like that (which would work, btw):

    C Source Code

    1. GUI_CONST_STORAGE GUI_BITMAP bmUNTITLED = {
    2. 32, /* XSize */
    3. 32, /* YSize */
    4. 4, /* BytesPerLine */
    5. 1, /* BitsPerPixel */
    6. acUNTITLED, /* Pointer to picture data (indices) */
    7. &PalUNTITLED /* Pointer to palette */
    8. };


    instead i want to do something like this:

    C Source Code

    1. GUI_COLOR colors[2];
    2. GUI_LOGPALETTE palette;
    3. GUI_BITMAP bitmap;
    4. //set palette colors
    5. colors[0] = GUI_BLACK;
    6. colors[1] = GUI_WHITE;
    7. //fill palette with values
    8. palette.NumEntries = 2;
    9. palette.HasTrans = 1;
    10. palette.pPalEntries = &colors[0];
    11. //fill bitmap with values
    12. bitmap.XSize = 24;
    13. bitmap.YSize = 24;
    14. bitmap.BytesPerLine = 3;
    15. bitmap.BitsPerPixel = 1;
    16. bitmap.pData = acMyBitmapData; //This data is read from a flash memory, so not known at compile time
    17. bitmap.pPal = &palette;
    18. bitmap.pMethods = NULL;
    Display All


    This works fine when I draw it on the screen with

    C Source Code

    1. GUI_DrawBitmap(&bitmap, 0, 0);


    But when I use

    C Source Code

    1. BUTTON_SetBitmap(hButton, BUTTON_BI_UNPRESSED, &bitmap);

    the application crashes.

    Can anyone help please.

    Thank you,
    Florian