Hi,
I am working on displaying images from external memory. I am having problems displaying the complete picture. I can display image up until 170*240, after which when I try to expand x value I see white background and nothing else on the LCD.
Please see the below code and image attached with this thread.
Could someone tell me what I could be doing wrong?
P.S: I have tried displaying images on buttons using the same functions and it works.
Display All
Thanks and regards,
BMD
I am working on displaying images from external memory. I am having problems displaying the complete picture. I can display image up until 170*240, after which when I try to expand x value I see white background and nothing else on the LCD.
Please see the below code and image attached with this thread.
Could someone tell me what I could be doing wrong?
P.S: I have tried displaying images on buttons using the same functions and it works.
C Source Code
- /*********************************************************************
- * *
- * SEGGER Microcontroller GmbH *
- * Solutions for real time microcontroller applications *
- * *
- **********************************************************************
- * *
- * C-file generated by: *
- * *
- * GUI_Builder for emWin version 5.48 *
- * Compiled Jun 13 2018, 10:51:02 *
- * (c) 2018 Segger Microcontroller GmbH *
- * *
- **********************************************************************
- * *
- * Internet: www.segger.com Support: support@segger.com *
- * *
- **********************************************************************
- */
- // USER START (Optionally insert additional includes)
- // USER END
- #include "project.h"
- #include <stddef.h>
- #include <string.h>
- #include "WIDGET.h"
- #include "WM.h"
- #include "BUTTON.h"
- #include "DIALOG.h"
- #include "FS.h"
- /*********************************************************************
- *
- * Defines
- *
- **********************************************************************
- */
- #define ID_WINDOW_0 (GUI_ID_USER + 0x00)
- #define RECOMMENDED_MEMORY (1024L * 5)
- //extern void _OnPaint();
- //extern void DrawDTA();
- // USER START (Optionally insert additional defines)
- // USER END
- /*********************************************************************
- *
- * Static data
- *
- **********************************************************************
- */
- // USER START (Optionally insert additional static data)
- // USER END
- /*********************************************************************
- *
- * _aDialogCreate
- */
- static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
- { WINDOW_CreateIndirect, "Window", ID_WINDOW_0, 0, 0, 320, 240, 0, 0x0, 0 },
- { IMAGE_CreateIndirect, "SplashScreen", GUI_ID_IMAGE0, 0, 0, 320, 240, 0, 0x0, 0 },
- // USER START (Optionally insert additional widgets)
- // USER END
- };
- /*********************************************************************
- *
- * Static code
- *
- **********************************************************************
- */
- int APP_GetDataBMP(void * p, const U8 ** ppData, unsigned NumBytes, U32 Off)
- {
- static U8 acBuffer[512];
- FS_FILE * pFile;
- int NumBytesRead;
- pFile = (FS_FILE *)p;
- //
- // Check buffer size
- //
- if (NumBytes > sizeof(acBuffer))
- {
- NumBytes = sizeof(acBuffer);
- }
- //
- // Set file pointer to the required position
- //
- FS_SetFilePos(pFile, Off, FS_FILE_BEGIN);
- //
- // Read data into buffer
- //
- NumBytesRead = FS_FRead(acBuffer, 1, NumBytes, pFile);
- //
- // Set data pointer to the beginning of the buffer
- //
- *ppData = (const U8 *)acBuffer;
- //
- // Return number of available bytes
- //
- return NumBytesRead;
- }
- /*********************************************************************
- *
- * MainTask
- */
- void _OnPaint(const char * filename)
- {
- FS_FILE * pFile;
- char acVolumeName[10];
- //
- // Enable long file name support
- //
- FS_FAT_SupportLFN();
- //
- // Mount volume
- //
- FS_GetVolumeName(0, acVolumeName, sizeof(acVolumeName));
- if (FS_Mount(acVolumeName) > 0)
- {
- //
- // Open file
- //
- pFile = FS_FOpen(filename, "rb");
- }
- //
- // Draw the bmp image by passing a pointer to the file handle and the GetData function
- //
- GUI_BMP_DrawEx(APP_GetDataBMP, pFile,0, 0);
- //
- // Close file
- //
- FS_FClose(pFile);
- }
- static void _cbDrawSplashScreen(WM_MESSAGE * pMsg)
- {
- switch (pMsg->MsgId)
- {
- case WM_PAINT:
- _OnPaint("Tree.dta");
- // USER START (Optionally insert additional message handling)
- // USER END
- break;
- default:
- IMAGE_Callback(pMsg);
- break;
- }
- }
- // USER START (Optionally insert additional static code)
- // USER END
- /*********************************************************************
- *
- * _cbDialog
- */
- static void _cbDialog(WM_MESSAGE * pMsg)
- {
- WM_HWIN hItem;
- IMAGE_Handle hImage;
- hItem = pMsg -> hWin;
- switch (pMsg->MsgId)
- {
- case WM_INIT_DIALOG:
- hImage = WM_GetDialogItem(pMsg -> hWin,GUI_ID_IMAGE0);
- WM_SetCallback(hImage, _cbDrawSplashScreen);
- // USER START (Optionally insert additional message handling)
- // USER END
- break;
- default:
- WM_DefaultProc(pMsg);
- }
- }
- /*********************************************************************
- *
- * Public code
- *
- **********************************************************************
- */
- /*********************************************************************
- *
- * CreateWindow
- */
- void CreateSplashScreen(void)
- {
- //
- // Check if recommended memory for the sample is available
- //
- if (GUI_ALLOC_GetNumFreeBytes() < RECOMMENDED_MEMORY)
- {
- GUI_ErrorOut("Not enough memory available.");
- return;
- }
- //
- // Use memory devices for all windows
- //
- #if GUI_SUPPORT_MEMDEV
- WM_SetCreateFlags(WM_CF_MEMDEV);
- WM_EnableMemdev(WM_HBKWIN);
- #endif
- WM_SetDesktopColor(GUI_BLACK);
- while(1)
- {
- GUI_ExecDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), &_cbDialog, 0, 0, 0);
- GUI_Delay(10);
- }
- }
- // USER START (Optionally insert additional public code)
- // USER END
- /*************************** End of file ****************************/
BMD