首页>
技术资讯>
详情

bmp565 wince显示

2016-05-12 来源:佚名 阅读量: 0
关键词: WINCE

    // #include "stdafx.h"

    #include <Windows.h>

    #include <vector>

    HWND g_hWnd;

    HDC g_hTopDc = NULL;

    HBITMAP g_hBitMap  = NULL;

    UINT g_iWidth, g_iHeight;

    LRESULT MainWndProc(

    HWND hWnd,

    UINT Msg,

    WPARAM wParam,

    LPARAM lParam

    );

    struct BitmapFileHeader {

    WORD    bfType;

    DWORD   bfSize;

    WORD    bfReserved1;

    WORD    bfReserved2;

    DWORD   bfOffBits;

    };

    //Bitmap information header

    //provides information specific to the image data

    struct BitmapInfoHeader {

    DWORD  biSize;

    long   biWidth;

    long   biHeight;

    WORD   biPlanes;

    WORD   biBitCount;

    DWORD  biCompression;

    DWORD  biSizeImage;

    LONG   biXPelsPerMeter;

    LONG   biYPelsPerMeter;

    DWORD  biClrUsed;

    DWORD  biClrImportant;

    };

    //Colour palette

    struct RGBQuad {

    BYTE    rgbBlue;

    BYTE    rgbGreen;

    BYTE    rgbRed;

    BYTE    rgbReserved;

    };

    enum Format { // I: integer format, F: floating point format

    I8BITS,

    I16BITS,

    I32BITS,

    I16BITS_5_5_5_1,

    I16BITS_5_6_5,

    F16BITS,

    F32BITS,

    F64BITS

    };

    int m_width,m_height,m_nChannels,m_bytesPerPixel,m_bytesPerChannel;

    std::vector<unsigned char>m_data;

    Format m_format;

    BITMAPINFO* m_lpBitsInfo;

    BYTE *tmpData;

    BYTE *g_fileData;

    bool loadBMP(const std::string &fname)

    {

    // read bitmap header

    BitmapFileHeader fheader;

    BitmapInfoHeader iheader;

    for (int i=0; i<14; ++i) ((char*)&fheader)[i] = 3;

    FILE *fp = fopen(fname.c_str(), "rb");

    if (!fp)

    return false;

    long lBegin = ftell(fp);

    fseek(fp,0,SEEK_END);

    long lEnd = ftell(fp);

    long lSize =   lEnd - lBegin;

    fseek(fp,0,SEEK_SET);

    fread(&fheader.bfType, 2, 1, fp);

    fread(&fheader.bfSize, 4, 1, fp);

    fread(&fheader.bfReserved1, 2, 1, fp);

    fread(&fheader.bfReserved2, 2, 1, fp);

    fread(&fheader.bfOffBits, 4, 1, fp);

    g_fileData = (BYTE *)malloc(lSize);

    fread(g_fileData,1,lSize - sizeof(BitmapFileHeader),fp);

    fseek(fp,-lSize + sizeof(BitmapFileHeader),SEEK_CUR);

    fread(&iheader, 40, 1, fp);

    m_width = iheader.biWidth;

    m_height = abs(iheader.biHeight);

    //ASSERT(iheader.biPlanes == 1);

    if (iheader.biCompression != BI_RGB &&

    iheader.biCompression != BI_BITFIELDS ) {

    fclose(fp);

    return false;

    }

    m_nChannels = 3;

    if (iheader.biCompression == BI_RGB )

    {

    if (iheader.biBitCount != 24) {

  &nbs

热门推荐 查看更多