·

这是main函数中的 调用

int main() {
    int i, j;
    ST_BITMAP* st_tp_bitmap = NULL;
    U4 offset1;
    U4 width1;
    U4 height1;
    U2 bitCount1;
    FILE* fps;
    errno_t err;
    err = fopen_s(&fps, "adc_p0.bmp", "rb");//读取同目录下的image.bmp文件。
    if (err)
    {
        printf("打开'image.bmp'失败!\n");
        return -1;
    }
    unsigned short  fileType;
    fread(&fileType, 1, sizeof(unsigned short), fps);
    if (fileType = 0x4d42)
    {
        printf("文件类型标识正确!");
        printf("\n文件标识符:%d\n", fileType);
        fread(&fileHeader, 1, sizeof(BITMAPFILEHEADER), fps);
        showBmpHead(fileHeader);
        fread(&infoHeader, 1, sizeof(BITMAPINFOHEADER), fps);
        showBmpInfoHead(infoHeader);

        width1 = infoHeader.biWidth;
        height1 = infoHeader.biHeight;
        bitCount1 = infoHeader.biBitCount;
        offset1 = fileHeader.bfOffBits;

        Point** pix;

        //每一个像素申请内存

        pix = (Point**)malloc(sizeof(Point*) * height1);

        for (i = 0; i < height1; i++)

            *(pix + i) = (Point*)malloc(sizeof(Point) * width1);

        getData1(fps, pix, height1, width1, offset1);
        do
        {
            // create bitmap, size:20x10 format:RGB555->16
            // also support format RGB888->24 and RGBA8888->32
            st_tp_bitmap = st_g_CreateBitmap(width1, height1, bitCount1);
            if (st_tp_bitmap == NULL)
                break;

            // draw pixels on bitmap
            for (i = 0; i < width1; i++) {
                for (j = 0; j < height1; j++) {
                    vd_SetBitmapPixel(st_tp_bitmap, i, j, BMP_RGB24(&pix[i][j].r, &pix[i][j].g, &pix[i][j].b)); // red
                    //vd_SetBitmapPixel(st_tp_bitmap, i, j, BMP_RGB24(0, &pix[i][j].g, 0)); // green
                    //vd_SetBitmapPixel(st_tp_bitmap, i, j, BMP_RGB24(0, 0, &pix[i][j].b)); // blue
                }
            }
            // save to file
            vd_g_SaveBitmap(st_tp_bitmap, "test.bmp");
            for (i = 0; i < height1; i++) {

                for (j = 0; j < width1; j++)

                    printf("%4d", pix[i][j].r);

                printf("\n");
            }

            printf("g的位图矩阵\n");

            for (i = 0; i < height1; i++) {

                for (j = 0; j < width1; j++)

                    printf("%4d", pix[i][j].g);

                printf("\n");
            }

            printf("b的位图矩阵\n");

            for (i = 0; i < height1; i++) {

                for (j = 0; j < width1; j++)

                    printf("%4d", pix[i][j].b);

                printf("\n");
            }


        } while (FALSE);