GUI_MBITMAP_CreateEx example

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

    • GUI_MBITMAP_CreateEx example

      Is there an example how to create in-memory bitmap of an image stored in external .dta file?
      We have plenty of RAM and want to store all bitmaps on SD card and then, on power-up, load them in to RAM
      for faster access.

      - Dejan
    • Hello,

      just had such a code based on GUI_MBITMAP_Create() sample under WIN32. For using in WIN32 simulation add opengl32.lib in the linker input.

      C Source Code: Main.c

      1. #include "DIALOG.h"
      2. #include "windows.h"
      3. #define FILE_PATH "C:\\Image.dta"
      4. HANDLE hFile;
      5. GUI_MBITMAP * pMBitmap;
      6. IMAGE_Handle hImage;
      7. int _GetData(void * p, const U8 ** ppData, unsigned NumBytes, U32 Off) {
      8. HANDLE * phFile;
      9. DWORD NumBytesRead;
      10. U8 * pData;
      11. pData = (U8 *)*ppData;
      12. phFile = (HANDLE *)p;
      13. SetFilePointer(*phFile, Off, 0, FILE_BEGIN);
      14. ReadFile(*phFile, pData, NumBytes, &NumBytesRead, NULL);
      15. return NumBytesRead;
      16. }
      17. void MainTask(void) {
      18. GUI_Init();
      19. WM_MULTIBUF_Enable(1);
      20. hFile = CreateFile(FILE_PATH, GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
      21. pMBitmap = GUI_MBITMAP_CreateEx(GUI_MBITMAP_DTA_EX, _GetData, &hFile);
      22. hImage = IMAGE_CreateEx(10, 10,
      23. GUI_MBITMAP_2BITMAP(pMBitmap)->XSize,
      24. GUI_MBITMAP_2BITMAP(pMBitmap)->YSize,
      25. WM_HBKWIN,
      26. WM_CF_SHOW,
      27. 0,
      28. GUI_ID_IMAGE0);
      29. IMAGE_SetBitmap(hImage, GUI_MBITMAP_2BITMAP(pMBitmap));
      30. while (1) {
      31. GUI_Delay(50);
      32. }
      33. }
      Display All
      Regards,

      Anthony