Exemplo n.º 1
0
//------------------------------------------------------------------------
void pixel_map::create(unsigned width,
                       unsigned height,
                       unsigned clear_val)
{
    destroy();
    if(width == 0)  width = 1;
    if(height == 0) height = 1;

    unsigned row_len = calc_row_len(width, m_bpp);
    unsigned img_size = row_len * height;

    m_buf = new unsigned char[img_size];

    if(clear_val <= 255) {
        memset(m_buf, clear_val, img_size);
    }

    m_rbuf_window.attach(m_buf, width, height, row_len);

    if (m_format != m_sys_format)
    {
        row_len = calc_row_len(width, m_sys_bpp);
        img_size = row_len*height;
        m_buf2 = new unsigned char[img_size];
        if (clear_val <= 255) {
            memset(m_buf2, clear_val, img_size);
        }
        m_rbuf_window2.attach(m_buf2, width, height, row_len);
    }

}
Exemplo n.º 2
0
    //static
    //------------------------------------------------------------------------
    BITMAPINFO* pixel_map::create_bitmap_info(unsigned width, 
                                              unsigned height, 
                                              unsigned bits_per_pixel)
    {
        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;

        return bmp;
    }
Exemplo n.º 3
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);
        }
    }
Exemplo n.º 4
0
 //private
 //------------------------------------------------------------------------
 HBITMAP pixel_map::create_dib_section_from_args(HDC h_dc,
                                                 unsigned width, 
                                                 unsigned height, 
                                                 unsigned bits_per_pixel)
 {
     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;
     
     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;
     
     void*   img_ptr  = 0;
     HBITMAP h_bitmap = ::CreateDIBSection(h_dc, bmp, DIB_RGB_COLORS, &img_ptr, NULL, 0);
     
     if(img_ptr)
     {
         m_img_size  = calc_row_len(width, bits_per_pixel) * height;
         m_full_size = 0;
         m_bmp       = bmp;
         m_buf       = (unsigned char *) img_ptr;
     }
     
     return h_bitmap;
 }
Exemplo n.º 5
0
    //------------------------------------------------------------------------
    void pixel_map::create(unsigned width, 
                           unsigned height, 
                           org_e    org,
                           unsigned clear_val)
    {
        destroy();
        if(width == 0)  width = 1;
        if(height == 0) height = 1;
        m_bpp = org;
        
        Rect	r;
    	int		row_bytes = calc_row_len (width, m_bpp);
    	MacSetRect(&r, 0, 0, width, height);
    	m_buf = new unsigned char[m_img_size = row_bytes * height];
 		// The Quicktime version for creating GWorlds is more flexible than the classical function.
    	QTNewGWorldFromPtr (&m_pmap, m_bpp, &r, nil, nil, 0, m_buf, row_bytes);

        // create_gray_scale_palette(m_pmap);  I didn't care about gray scale palettes so far.
        if(clear_val <= 255)
        {
            memset(m_buf, clear_val, m_img_size);
        }
    }
Exemplo n.º 6
0
 //------------------------------------------------------------------------
 int pixel_map::stride() const
 {
     return calc_row_len(m_bmp->bmiHeader.biWidth, 
                         m_bmp->bmiHeader.biBitCount);
 }
Exemplo n.º 7
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;
}
Exemplo n.º 8
0
int            pixel_map::stride() {
    return calc_row_len(width(), m_bpp);
}
Exemplo n.º 9
0
    //------------------------------------------------------------------------
    int pixel_map::row_bytes() const
    {
        if(m_pmap == nil) return 0;
 		PixMapHandle	pm = GetGWorldPixMap (m_pmap);
        return calc_row_len(width(), GetPixDepth(pm));
    }