Esempio n. 1
0
    //------------------------------------------------------------------------
    void platform_specific::display_pmap(HDC dc, const rendering_buffer* rbuf,
    									 int draw_x, int draw_y,
    									 int draw_width, int draw_height)
    {
        if(m_sys_format == m_format)
        {
            if (m_bimage == 0)

            {
                m_bimage = dib.create_image(rbuf, m_bpp);
            }
            dib.put_image(dc, m_bimage, draw_x, draw_y, draw_width, draw_height);
            return;
        }
        
        // Optimization hint: make pmap_tmp as a private class member and reused it when possible.
        pixel_map pmap_tmp(rbuf->width(), rbuf->height(), m_sys_format, 256, m_flip_y);
        rendering_buffer* rbuf2 = &pmap_tmp.rbuf();
        
        switch(m_format)
        {
        case pix_format_rgb565:
            color_conv(rbuf2, rbuf, color_conv_rgb565_to_rgb555());
            break;
            
        case pix_format_rgb24:
            color_conv(rbuf2, rbuf, color_conv_rgb24_to_bgr24());
            break;
            
        case pix_format_abgr32:
            color_conv(rbuf2, rbuf, color_conv_abgr32_to_bgra32());
            break;
            
        case pix_format_argb32:
            color_conv(rbuf2, rbuf, color_conv_argb32_to_bgra32());
            break;
            
        case pix_format_rgba32:
            color_conv(rbuf2, rbuf, color_conv_rgba32_to_bgra32());
            break;
            
        case pix_format_gray8:
        case end_of_pix_formats: 
        case pix_format_undefined:
            ;
        }

        // This will ultimately call back to us, going to the top if branch since
        // the pix_format is compatible.
        pmap_tmp.draw(dc, draw_x, draw_y, draw_width, draw_height);
        
    }
Esempio n. 2
0
void window_win32::display_pmap(HDC dc, const agg::rendering_buffer* src, const agg::rect_base<int> *ri) {
    agg::rect_base<int> r(0, 0, src->width(), src->height());
    if (ri) {
        r = agg::intersect_rectangles(r, *ri);
    }

    const int w = r.x2 - r.x1, h = r.y2 - r.y1;

    // In a previous version the bmp was stored in the class in m_bmp_draw and
    // was used by resizing to avoid allocating memory each time.
    BITMAPINFO *bmp = pixel_map::create_bitmap_info(w, h, org_e(m_sys_bpp));
    // bitmap_info_resize (m_bmp_draw, w, h);

    pixel_map pmap;
    pmap.attach_to_bmp(bmp);

    rendering_buffer rbuf_tmp;
    pixel_map_attach(pmap, &rbuf_tmp, graphics::flip_y);

    rendering_buffer_ro src_view;
    rendering_buffer_get_const_view(src_view, *src, r, graphics::bpp / 8);

    if (m_sys_format == graphics::pixel_format)
    {
        rbuf_tmp.copy_from(src_view);
    }
    else
    {
        if (m_sys_format == pix_format_bgr24 && graphics::pixel_format == pix_format_rgb24)
        {
            my_color_conv(&rbuf_tmp, &src_view, color_conv_rgb24_to_bgr24());
        }
    }

    unsigned int wh = src->height();
    RECT wrect;
    wrect.left   = r.x1;
    wrect.right  = r.x2;
    wrect.bottom = wh - r.y1;
    wrect.top    = wh - r.y2;

    RECT brect;
    brect.left   = 0;
    brect.right  = w;
    brect.bottom = h;
    brect.top    = 0;

    pmap.draw(dc, &wrect, &brect);

    delete [] (unsigned char*) bmp;
}
Esempio n. 3
0
    //------------------------------------------------------------------------
    bool platform_specific::save_pmap(const char* fn, unsigned idx, 
                                      const rendering_buffer* src)
    {
        if(m_sys_format == m_format)
        {
            return m_pmap_img[idx].save_as_qt(fn);
        }
        else
        {
            pixel_map pmap_tmp;
            pmap_tmp.create(m_pmap_img[idx].width(), 
                            m_pmap_img[idx].height(),
                            org_e(m_sys_bpp));

            rendering_buffer rbuf_tmp;
            rbuf_tmp.attach(pmap_tmp.buf(),
                            pmap_tmp.width(),
                            pmap_tmp.height(),
                            m_flip_y ?
                             -pmap_tmp.row_bytes() :
                              pmap_tmp.row_bytes());
            switch(m_format)
            {
            case pix_format_gray8:
                return false;

            case pix_format_rgb565:
                color_conv(&rbuf_tmp, src, color_conv_rgb565_to_rgb555());
                break;

            case pix_format_rgb24:
                color_conv(&rbuf_tmp, src, color_conv_rgb24_to_bgr24());
                break;

            case pix_format_abgr32:
                color_conv(&rbuf_tmp, src, color_conv_abgr32_to_bgra32());
                break;

            case pix_format_argb32:
                color_conv(&rbuf_tmp, src, color_conv_argb32_to_bgra32());
                break;

            case pix_format_rgba32:
                color_conv(&rbuf_tmp, src, color_conv_rgba32_to_bgra32());
                break;
            }
            return pmap_tmp.save_as_qt(fn);
        }
        return true;
    }
Esempio n. 4
0
	//------------------------------------------------------------------------
	static void convert_pmap(rendering_buffer* dst, 
							 const rendering_buffer* src, 
							 pix_format_e format)
	{
		switch(format)
		{
		case pix_format_gray8:
			break;

		case pix_format_gray16:
			color_conv(dst, src, color_conv_gray16_to_gray8());
			break;

		case pix_format_rgb565:
			color_conv(dst, src, color_conv_rgb565_to_rgb555());
			break;

		case pix_format_rgbAAA:
			color_conv(dst, src, color_conv_rgbAAA_to_bgr24());
			break;

		case pix_format_bgrAAA:
			color_conv(dst, src, color_conv_bgrAAA_to_bgr24());
			break;

		case pix_format_rgbBBA:
			color_conv(dst, src, color_conv_rgbBBA_to_bgr24());
			break;

		case pix_format_bgrABB:
			color_conv(dst, src, color_conv_bgrABB_to_bgr24());
			break;

		case pix_format_rgb24:
			color_conv(dst, src, color_conv_rgb24_to_bgr24());
			break;

		case pix_format_rgb48:
			color_conv(dst, src, color_conv_rgb48_to_bgr24());
			break;

		case pix_format_bgr48:
			color_conv(dst, src, color_conv_bgr48_to_bgr24());
			break;

		case pix_format_abgr32:
			color_conv(dst, src, color_conv_abgr32_to_bgra32());
			break;

		case pix_format_argb32:
			color_conv(dst, src, color_conv_argb32_to_bgra32());
			break;

		case pix_format_rgba32:
			color_conv(dst, src, color_conv_rgba32_to_bgra32());
			break;

		case pix_format_bgra64:
			color_conv(dst, src, color_conv_bgra64_to_bgra32());
			break;

		case pix_format_abgr64:
			color_conv(dst, src, color_conv_abgr64_to_bgra32());
			break;

		case pix_format_argb64:
			color_conv(dst, src, color_conv_argb64_to_bgra32());
			break;

		case pix_format_rgba64:
			color_conv(dst, src, color_conv_rgba64_to_bgra32());
			break;
		}
	}
Esempio n. 5
0
    //------------------------------------------------------------------------
    bool platform_specific::load_pmap(const char* fn, unsigned idx, 
                                      rendering_buffer* dst)
    {
        pixel_map pmap_tmp;
        if(!pmap_tmp.load_from_qt(fn)) return false;

        rendering_buffer rbuf_tmp;
        rbuf_tmp.attach(pmap_tmp.buf(),
                        pmap_tmp.width(),
                        pmap_tmp.height(),
                        m_flip_y ?
                         -pmap_tmp.row_bytes() :
                          pmap_tmp.row_bytes());

        m_pmap_img[idx].create(pmap_tmp.width(), 
                               pmap_tmp.height(), 
                               org_e(m_bpp),
                               0);

        dst->attach(m_pmap_img[idx].buf(),
                    m_pmap_img[idx].width(),
                    m_pmap_img[idx].height(),
                    m_flip_y ?
                      -m_pmap_img[idx].row_bytes() :
                       m_pmap_img[idx].row_bytes());

        switch(m_format)
        {
        case pix_format_gray8:
            return false;
            break;

        case pix_format_rgb555:
            switch(pmap_tmp.bpp())
            {
            case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_rgb555()); break;
            case 24: color_conv(dst, &rbuf_tmp, color_conv_rgb24_to_rgb555()); break;
            case 32: color_conv(dst, &rbuf_tmp, color_conv_argb32_to_rgb555()); break;
            }
            break;

        case pix_format_rgb565:
            switch(pmap_tmp.bpp())
            {
            case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_rgb565()); break;
            case 24: color_conv(dst, &rbuf_tmp, color_conv_rgb24_to_rgb565()); break;
            case 32: color_conv(dst, &rbuf_tmp, color_conv_argb32_to_rgb565()); break;
            }
            break;

        case pix_format_rgb24:
            switch(pmap_tmp.bpp())
            {
            case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_rgb24()); break;
            case 24: color_conv(dst, &rbuf_tmp, color_conv_rgb24_to_rgb24()); break;
            case 32: color_conv(dst, &rbuf_tmp, color_conv_argb32_to_rgb24()); break;
            }
            break;

        case pix_format_bgr24:
            switch(pmap_tmp.bpp())
            {
            case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_bgr24()); break;
            case 24: color_conv(dst, &rbuf_tmp, color_conv_rgb24_to_bgr24()); break;
            case 32: color_conv(dst, &rbuf_tmp, color_conv_argb32_to_bgr24()); break;
            }
            break;

        case pix_format_abgr32:
            switch(pmap_tmp.bpp())
            {
            case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_abgr32()); break;
            case 24: color_conv(dst, &rbuf_tmp, color_conv_rgb24_to_abgr32()); break;
            case 32: color_conv(dst, &rbuf_tmp, color_conv_argb32_to_abgr32()); break;
            }
            break;

        case pix_format_argb32:
            switch(pmap_tmp.bpp())
            {
            case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_argb32()); break;
            case 24: color_conv(dst, &rbuf_tmp, color_conv_rgb24_to_argb32()); break;
            case 32: color_conv(dst, &rbuf_tmp, color_conv_argb32_to_argb32()); break;
            }
            break;

        case pix_format_bgra32:
            switch(pmap_tmp.bpp())
            {
            case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_bgra32()); break;
            case 24: color_conv(dst, &rbuf_tmp, color_conv_rgb24_to_bgra32()); break;
            case 32: color_conv(dst, &rbuf_tmp, color_conv_argb32_to_bgra32()); break;
            }
            break;

        case pix_format_rgba32:
            switch(pmap_tmp.bpp())
            {
            case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_rgba32()); break;
            case 24: color_conv(dst, &rbuf_tmp, color_conv_rgb24_to_rgba32()); break;
            case 32: color_conv(dst, &rbuf_tmp, color_conv_argb32_to_rgba32()); break;
            }
            break;
        }
        
        return true;
    }