Screenshots using GUI_BMP_SerializeExBpp

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

  • Screenshots using GUI_BMP_SerializeExBpp

    Hello,

    i am using emWin in one of our µ-Controller Projects. I try to make a 'screenshot' of the GUI using the following Code:

    C Source Code

    1. char buffer[100];
    2. int counter;
    3. static void _WriteByte2File(U8 Data, void * p)
    4. {
    5. FILE* bmpFile;
    6. bmpFile = (FILE*) p;
    7. buffer[counter] = Data;
    8. counter++;
    9. if (counter == 100)
    10. {
    11. fwrite(&buffer, sizeof(U8), counter, bmpFile);
    12. fflush(bmpFile);
    13. counter = 0;
    14. }
    15. }
    16. static void vMakeScreenshot()
    17. {
    18. FILE * bmpFile;
    19. counter = 0;
    20. bmpFile = fopen( "M0:\\temp\\temp.bmp", "w" );
    21. GUI_BMP_SerializeExBpp( _WriteByte2File, 320, 240, 50, 50, bmpFile, 16);
    22. // Write rest of buffer
    23. fwrite(&buffer, sizeof(U8), counter, bmpFile);
    24. fflush(bmpFile);
    25. fclose(bmpFile);
    26. }
    Display All



    However, i can't get a working screenshot. Am i doing something wrong here? While debugging i also saw that 'Data' ist just 0x00 most of the time. Is this correct?!



    Hope someone can help me with this.

    Thanks in advance and kind Regards

    The post was edited 3 times, last by kain2609 ().

  • Hello,

    I am sorry. It seemed to me that this identifier has been declared twice.

    Please note that the function GUI_BMP_SerializeExBpp() uses 320, 240 as starting positions. Could you please tell me what is the dimension of your display? Thank you.

    Best regards,
    Adrian
  • Hey Adrian,

    i figured out one error in my software when i tried to copy the Bitmap over Ethernet, now i access it directly from my sd card.

    However, i just get unicolored bitmaps, for example i tried to save a 320x240 screenshot but the bitmap is just completely red (i uploaded it as attachement).

    Do you have any idea why this is that way?

    Kind Regards,
    Files
    • TEMP.BMP

      (153.65 kB, downloaded 948 times, last: )
  • Hey Adrian,

    okay, i just want to write the content of the LCD to the BMP file.
    I inserted

    Source Code

    1. GUI_MEMDEV_Select(0);

    just before GUI_BMP_SerializeExBpp, but the Bitmaps are still empty. Or do i have to use a memory device to get the Bitmap?


    Kind Regards
  • Hey Adrian,

    i posted my function in the first post and you said that this function works very well on your end?

    Even if i debug and step through my implementation, i see that the Bytes passed to the

    C Source Code

    1. _WriteByte2File
    function are correctly written into the buffer array and then to the file.



    Kind Regards,
  • Hey Adrian,

    the '_WriteByte2File()' seemed to work well, the header of the Bitmap is written correct.
    However i simplified the function to write each byte instantly to the file:

    C Source Code

    1. static void _WriteByte2File(U8 Data, void * p)
    2. {
    3. FILE* bmpFile;
    4. bmpFile = (FILE*) p;
    5. fwrite(&Data, sizeof(U8), 1, bmpFile);
    6. fflush(bmpFile);
    7. }
    8. static void vMakeScreenshot()
    9. {
    10. FILE * bmpFile;
    11. GUI_MEMDEV_Select(0);
    12. bmpFile = fopen( "M0:\\temp\\temp.bmp", "w" );
    13. GUI_BMP_SerializeExBpp( _WriteByte2File, 0, 0, 20, 20, bmpFile, 8);
    14. fclose(bmpFile);
    15. }
    Display All


    So this does not seem to be the error, since i got *.bmp Files that i can open with any ImageViewer. However, the image is still just black.
    Do i have to change something else?
    Is the way i select the LCD as device the wrong way?

    Kind Regards,
  • Hello,

    i digged more into our implementation and saw the following:
    We are using the 'GUIDRV_FLEXCOLOR'-Driver and the mode 'GUICC_M565'.
    When i try to take the screenshot using 'GUI_BMP_Serialize' the function 'pfReadM16_A1' is called multiple times to read the data from the LCD.

    C Source Code

    1. void pfReadM16_A1( unsigned short * pData, int iNumItems )
    2. {
    3. for( ; iNumItems; iNumItems-- )
    4. {
    5. *pData = *m_pusLCDReadData;
    6. pData++;
    7. }
    8. }

    For example this function returns 3 2-byte-elements:
    0xF79E
    0xF79E
    0x0000

    The BMP-File is generated by:

    C Source Code

    1. static void _WriteByte2File(U8 Data, void * p)
    2. {
    3. FILE* bmpFile;
    4. bmpFile = (FILE*) p;
    5. fwrite(&Data, sizeof(U8), 1, bmpFile);
    6. fflush(bmpFile);
    7. }
    8. static void vMakeScreenshot()
    9. {
    10. FILE * bmpFile;
    11. bmpFile = fopen("M0:\\temp\\temp.bmp", "w" );
    12. GUI_BMP_Serialize( _WriteByte2File, bmpFile);
    13. fclose(bmpFile);
    14. }
    Display All


    The '_WriteByte2File' functions works as expected since every byte that is passed to it can be found in the resulting BMP-file later on.
    But:
    After some 'header'(?) the BMP-File justs consists of 0x4C and 0x00 bytes (i attached a screenshot with a hexadecimal view of the file) but the data that is read by the 'pfReadM16_A1' function never occurs in the BMP-File.

    Do you have any ideas where the error could be or how i could investigate the problem more?


    Kind Regards,
    Images
    • hex.PNG

      16.18 kB, 675×406, viewed 732 times
  • Hello,

    this is the LCDConf.c
    (i attached the file because the post was too long)

    And these are the defined API functions:

    C Source Code

    1. /**********************************************************************************************/
    2. /* FUNKTION FÜR GUI : Kommando an LCD Controller schreiben (Adressleitung A0 = 0) */
    3. /* !!! Der Treiber der GUI verwendet die Funktion für den Zugriff auf den LCD Controller. */
    4. /* !!! Der Inhalt der Funktion muss entsprechend dem verwendeten Controller angepasst sein. */
    5. /**********************************************************************************************/
    6. void vLCD_WriteCommand( unsigned short usData )
    7. {
    8. *m_pusLCDWriteCommand = usData;
    9. }
    10. /**********************************************************************************************/
    11. /* FUNKTION FÜR GUI : Datenbyte an LCD Controller schreiben (Adressleitung A0 = 1) */
    12. /* !!! Der Treiber der GUI verwendet die Funktion für den Zugriff auf den LCD Controller. */
    13. /* !!! Der Inhalt der Funktion muss entsprechend dem verwendeten Controller angepasst sein. */
    14. /**********************************************************************************************/
    15. void vLCD_WriteData( unsigned short usData )
    16. {
    17. *m_pusLCDWriteData = usData;
    18. }
    19. /**********************************************************************************************/
    20. /* FUNKTION FÜR GUI : Mehrere Datenbytes an LCD Controller schreiben (Adressleitung A0 = 1) */
    21. /* !!! Der Treiber der GUI verwendet die Funktion für den Zugriff auf den LCD Controller. */
    22. /* !!! Der Inhalt der Funktion muss entsprechend dem verwendeten Controller angepasst sein. */
    23. /**********************************************************************************************/
    24. void vLCD_WriteMultipleData( unsigned short * pData, int iNumItems )
    25. {
    26. for( ; iNumItems; iNumItems-- )
    27. { *m_pusLCDWriteData = (*pData++); }
    28. }
    29. /**********************************************************************************************/
    30. /* FUNKTION FÜR GUI : Mehrere Datenbytes von LCD Controller lesen (Adressleitung A1 = 1) */
    31. /* !!! Der Treiber der GUI verwendet die Funktion für den Zugriff auf den LCD Controller. */
    32. /* !!! Der Inhalt der Funktion muss entsprechend dem verwendeten Controller angepasst sein. */
    33. /**********************************************************************************************/
    34. void vLCD_ReadMultipleData( unsigned short * pData, int iNumItems )
    35. {
    36. for( ; iNumItems; iNumItems-- )
    37. {
    38. *pData = *m_pusLCDReadData;
    39. pData++;
    40. }
    41. }
    Display All
    Files
    • LCDConf.c.txt

      (11.58 kB, downloaded 744 times, last: )
  • Hello,

    Thank you for sending your configuration file. I was able to find a problem which is hopefully caused for the same reason as the one you are experiencing. We will have to have a closer look at this.

    What I can tell for now is that the problem I found does not occur when using a display driver cache. You are currently using the GUIDRV_FLEXCOLOR_M16C0B16 mode. The cache can be enabled using GUIDRV_FLEXCOLOR_M16C0B16. Please note that a cache requires additional RAM. Please refer to the chapter "Display drivers" in the emWin user manual for details on how to calculate the exact size.

    Of course the problem will be solved in a future emWin version.

    Best regards,
    Adrian