Print Screen

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

  • Hello Ayman,

    emWin offers creating screenshots as BMP file. This can be done using the function GUI_BMP_Serialize() to make a complete screenshot or GUI_BMP_SerializeEx() to make a screenshot of a given rectangle.

    Please refer to the according function descriptions in the emWin documenation (Chapter 8 "Displaying bitmap files"). Please also refer to our emWin sample application 2DGL_BMPExport which can be downloaded from segger.com: emWin samples

    Best regards,
    Adrian

    The post was edited 1 time, last by SEGGER - Adrian ().

  • I used both APIs GUI_BMP_Serialize() & GUI_BMP_SerializeEx(), when I used
    GUI_BMP_SerializeEx(), with different rectangle size, I noticed that in case of small rectangle size, all the screen with these dimensions are drawn with no problem, when I increase the the rectangle dimensions but still smaller than the LCD size, some of the screen with these dimensions not drawn, part of it only, why, and how to fix it?


    Also when I used GUI_BMP_Serialize(), not all the screen has been drawn, sometimes it create a picture with problems in the drawings.


    More over both APIs take too much time my LCD size is 480 * 800, it create a file of 750KB in case of GUI_BMP_Serialize(), how to create a smaller file to take less time?


    Thanks
  • hi,

    find below my code:
    I think the error in drawing because of file system mount issue, I will see about it, but my major problem that I don't know how to fix it is the long time it take to finish drawing and create my .bmp file, it take about 2min, and create 750 kB file size, how to fix such a problem?


    find below my code:


    void SaveScreen_OK_Action (void)
    {
    T_uezFile file;
    T_uezError error;
    T_uezDevice dev_fs;

    char filename[40] = "";
    char text[10];

    WM_HWIN hItem2;
    hItem2 = WM_GetDialogItem(hPopUp_EditWindow, ID_EDIT_0);
    EDIT_GetText(hItem2, text, 10);

    sprintf(filename, "1:/%s.bmp", text);

    WM_DeleteWindow(hPopUp_EditWindow);
    GUI_Exec();

    //UEZFileSystemMount(dev_fs, "/");
    error = UEZFileOpen(filename, FILE_FLAG_WRITE, &file);

    if (error == UEZ_ERROR_NONE)
    {
    GUI_BMP_Serialize(_WriteByte2File, &file);
    //GUI_BMP_SerializeEx( _WriteByte2File, 0, 0, 800, 480, &file);

    UEZFileClose(file);
    }
    }



    static void _WriteByte2File(U8 Data, void * p)
    {
    U32 nWritten;
    T_uezError error;

    error = UEZFileWrite( *((T_uezFile *)p), &Data, 1, &nWritten);
    }
  • Hello Ayman,

    Unfortunately I can not reproduce the problem, since the uez-symbols are unknown in my emWin project. Nevertheless I believe to see problem. It seems like your function _WriteByte2File() writes each byte immediately to the file. I recommend making the _WriteByte2File() function store the data in a buffer before it is written to a file. After GUI_BMP_Serialize() returned, the content of the buffer can be written to the file at once.

    Could you please tell me, if using a buffer solves the problem?

    Best regards,
    Adrian
  • Hi,

    I did your suggestion, by creating a 512 byte buffer and write this buffer to file when it's full as following, but it doesn't work properly, the file is damaged?


    #define BufferSize 512
    static void _WriteByte2File(U8 Data, void * p)
    {
    U32 nWritten;
    T_uezError error;

    //error = UEZFileWrite( *((T_uezFile *)p), &Data, 1, &nWritten);
    U8 Buffer[BufferSize];
    static int ii = 0;

    int size = sizeof(Buffer);
    Buffer[ii] = Data;

    ii++;

    if(ii >= BufferSize)
    {
    error = UEZFileWrite( *((T_uezFile *)p), Buffer, sizeof(Buffer), &nWritten);
    ii = 0;
    }
    }


    void SaveScreen_OK_Action (void)
    {
    T_uezFile file;
    T_uezError error;
    T_uezDevice dev_fs;

    char filename[40] = "";
    char text[10];

    WM_HWIN hItem2;
    hItem2 = WM_GetDialogItem(hPopUp_EditWindow, ID_EDIT_0);
    EDIT_GetText(hItem2, text, 10);

    sprintf(filename, "1:/%s.bmp", text);

    WM_DeleteWindow(hPopUp_EditWindow);
    GUI_Exec();

    //UEZFileSystemMount(dev_fs, "/");
    error = UEZFileOpen(filename, FILE_FLAG_WRITE, &file);

    if (error == UEZ_ERROR_NONE)
    {
    //GUI_BMP_Serialize(_WriteByte2File, &file);
    //GUI_BMP_SerializeEx( _WriteByte2File, 0, 0, 800, 480, &file);
    GUI_BMP_Serialize(_WriteByte2File, &file);

    UEZFileClose(file);
    }
    }