Problem disabling bitmap tiling in emWin

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

    • Problem disabling bitmap tiling in emWin

      Hello,

      I am having trouble disabling tiling for a certain bitmap in my application.
      The attached images displays the following:
      - Here is the bitmap being drawn using a callback override
      - Here is the declaration of the bitmap (acWarningIcon2 was originally a png but exported and turned into a bitmap from AppWizard)
      - Notice the undesired tiling effect of the warning icon

      Any help is appreciated and thanks.
      Images
      • 2021-03-04 01_21_33-Simulation_VS2015_2017_Lib - Microsoft Visual Studio.png

        20.95 kB, 700×480, viewed 170 times
      • 2021-03-04 01_22_14-Simulation_VS2015_2017_Lib - Microsoft Visual Studio.png

        18.75 kB, 875×458, viewed 171 times
      • 2021-03-04 01_22_53-Simulation_VS2015_2017_Lib - Microsoft Visual Studio.png

        15.69 kB, 1,543×171, viewed 72 times
      • 2021-03-04 01_24_03-Simulation_VS2015_2017_Lib (Running) - Microsoft Visual Studio.png

        38.6 kB, 606×344, viewed 157 times
    • Hi Josh,

      A few things are unclear to me. Do you have created the IMAGE widget with the AppWizard? If so, you cannot set a custom callback to that widget, only to widgets created manually with emWin.

      If the bitmap is just a simple icon, you won't have to pass the IMAGE_CF_MEMDEV flag since a memory device won't be necessary for a small icon.

      Also, I'm not sure why you are setting a custom callback to the IMAGE widget that has a WM_PAINT case. Note that when you are drawing in WM_PAINT of a window/widget, the coordinates are relative, meaning (0,0) would be the top-left coordinate of the widget and not the LCD.

      My suggestion would be to remove the IMAGE callback and simply call IMAGE_SetBitmap() instead. Then, the widget will draw the bitmap by itself.

      There is also no need to disable tiling mode manually, as it is disabled by default.

      Best regards,
      Florian
    • Hey Florian,

      The widget is not created through AppWizard, but through emWin code.

      I think the problem is with the way I am setting up the GUI_BITMAP structure:

      const GUI_BITMAP WarningImageBitmap = {
      18, // XSize
      16, // YSize
      40, // BytesPerLine
      32, // BitsPerPixel
      (unsigned char*)acWarningIcon2, // Pointer to picture data
      &testPalette, // Pointer to palette
      #if (GUI_USE_ARGB == 1)
      GUI_DRAW_BMPM8888I
      #else
      GUI_DRAW_BMP8888
      #endif
      };


      const unsigned char acWarningIcon2[1168UL + 1] = {
      0x42, 0x4D, 0x1D, 0x00, 0x12, 0x00, 0x10, 0x00, 0x48, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x25, 0x25, 0xFF, 0x30, 0x27, 0x27, 0xFF, 0xDF, 0x27, 0x27, 0xFF, 0xDF, 0x28, 0x28, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x27, 0x27, 0xFF, 0xC0,
      0x27, 0x27, 0xFF, 0xFF, 0x27, 0x27, 0xFF, 0xFF, 0x27, 0x27, 0xFF, 0xBF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

      Can you explain to me how I derive bytes per line from the exported bitmap data from AppWizard? (partial bitmap data shown above)
      Images
      • 2021-03-04 01_21_33-Simulation_VS2015_2017_Lib - Microsoft Visual Studio.png

        20.95 kB, 700×480, viewed 64 times
    • Hi,

      BytesPerLine are calculated as follows: ((BitsPerPixel / 8 * XSize). The bits per pixel depend on the bitmap format. GUI_DRAW_BMPM8888I is a 32bpp format, therefore for your bitmap the BytesPerLine would be ((32 / 8 * 18) = 72.

      But the data in the char array is a streamed bitmap in binary format, instead of a normal bitmap.

      You also don't have to set up bitmap structures manually. I would advise you to use the Bitmap Converter, you can download a free demo version on our website. You simply have to load your image into the Bitmap Converter, select a format and the image will be converted into a bitmap that emWin can use.

      Best regards,
      Florian