bitmap file draw

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

  • bitmap file draw

    #include <GUI.h>
    #include <windows.h>
    #include <stdio.h>

    #define FILE_DEST_PATH "C:\\Users\\user\\Desktop\\STM32F4-DISCOVRY CODE\\EXAMPLECODE\\Application\\1_ScreenShot.bmp"
    static char _acBuffer[0x1000];

    /*********************************************************************
    *
    * _WriteByte2File
    *
    * Function description
    * This function will be called by GUI_BMP_Serialize to write the
    * bytes to the file
    */
    static void _WriteByte2File(U8 Data, void * p) {
    U32 nWritten;

    WriteFile(*((HANDLE *)p), &Data, 1, &nWritten, NULL);
    }

    /*********************************************************************
    *
    * _ExportToFile
    *
    * Function description
    * Demonstrates the use of GUI_BMP_Serialize
    */
    void _ExportToFile(void) {
    HANDLE hFile;

    hFile = CreateFile(FILE_DEST_PATH, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
    GUI_BMP_Serialize(_WriteByte2File, &hFile);
    CloseHandle(hFile);

    GUI_Delay(500);
    }



    static int _GetData(void * p, const U8 ** ppData, unsigned NumBytesReq, U32 Off) {
    DWORD NumBytesRead;
    HANDLE * phFile;

    phFile = (HANDLE *)p;
    //
    // Check buffer size
    //
    if (NumBytesReq > sizeof(_acBuffer)) {
    NumBytesReq = sizeof(_acBuffer);
    }
    //
    // Set file pointer to the required position
    //
    SetFilePointer(*phFile, Off, 0, FILE_BEGIN);
    //
    // Read data into buffer
    //
    ReadFile(*phFile, _acBuffer, NumBytesReq, &NumBytesRead, NULL);
    //
    // Set data pointer to the beginning of the buffer
    //
    *ppData = _acBuffer;
    //
    // Return number of available bytes
    //
    return NumBytesRead;
    }

    /*******************************************************************
    *
    * _ShowBMP
    *
    * Function description
    * Shows the contents of a bitmap file
    */
    static void _ShowBMP(void) {
    HANDLE hFile;

    hFile = CreateFile(FILE_DEST_PATH, GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
    if (!GUI_BMP_DrawEx(_GetData, &hFile, 0, 0)) {
    GUI_Delay(2000);
    }
    CloseHandle(hFile);
    }


    /*********************************************************************
    *
    * Public code
    *
    **********************************************************************
    */
    /*********************************************************************
    *
    * MainTask
    */
    void ShowSnshotTask(void) {
    //GUI_Init();


    //while (1) {
    _ShowBMP();

    //}
    }






    Please let me know. I referenced 2DGL_DrawBMP but can not apply it to my code. The following code is the code that takes a screenshot and loads the file.

    What should I do? Please tell me how.

    The post was edited 1 time, last by zoechoeng ().