示例#1
0
    //private
    //------------------------------------------------------------------------
    void pixel_map::create_from_bmp(BITMAPINFO *bmp)
    {
        if(bmp)
        {
            m_img_size  = calc_row_len(bmp->bmiHeader.biWidth, 
                                       bmp->bmiHeader.biBitCount) * 
                          bmp->bmiHeader.biHeight;

            m_full_size = calc_full_size(bmp);
            m_bmp       = bmp;
            m_buf       = calc_img_ptr(bmp);
        }
    }
示例#2
0
void Win32Window::drawImageGray(unsigned char *buffer, int width, int height, int x, int y)
{
    //TODO

    //create buffer
    unsigned char *tmpBuf = malloc(width * height);
    for (int i  = 0; i < ; ++i)
    {



    }

    //create paired BITMAP

    {
        unsigned line_len = calc_row_len(width, bits_per_pixel);
        unsigned img_size = line_len * height;
        unsigned rgb_size = calc_palette_size(0, bits_per_pixel) * sizeof(RGBQUAD);
        unsigned full_size = sizeof(BITMAPINFOHEADER) + rgb_size + img_size;

        BITMAPINFO *bmp = (BITMAPINFO *) new unsigned char[full_size];

        bmp->bmiHeader.biSize   = sizeof(BITMAPINFOHEADER);
        bmp->bmiHeader.biWidth  = width;
        bmp->bmiHeader.biHeight = height;
        bmp->bmiHeader.biPlanes = 1;
        bmp->bmiHeader.biBitCount = (unsigned short)bits_per_pixel;
        bmp->bmiHeader.biCompression = 0;
        bmp->bmiHeader.biSizeImage = img_size;
        bmp->bmiHeader.biXPelsPerMeter = 0;
        bmp->bmiHeader.biYPelsPerMeter = 0;
        bmp->bmiHeader.biClrUsed = 0;
        bmp->bmiHeader.biClrImportant = 0;
    }

    {
            m_img_size  = calc_row_len(bmp->bmiHeader.biWidth, 
                                       bmp->bmiHeader.biBitCount) * 
                          bmp->bmiHeader.biHeight;

            m_full_size = calc_full_size(bmp);
            m_bmp       = bmp;
            m_buf       = calc_img_ptr(bmp);
    }

    ::SetDIBitsToDevice(
    hDc,            // handle to device context
    dvc_x,           // x-coordinate of upper-left corner of 
    dvc_y,           // y-coordinate of upper-left corner of 
    dvc_width,       // source rectangle width
    dvc_height,      // source rectangle height
    bmp_x,           // x-coordinate of lower-left corner of 
    bmp_y,           // y-coordinate of lower-left corner of 
    0,               // first scan line in array
    bmp_height,      // number of scan lines
    m_buf,           // address of array with DIB bits
    m_bmp,           // address of structure BITMAPINFO
    DIB_RGB_COLORS   // RGB or palette indexes
    );


    free tmpBuf;
}