コード例 #1
0
ファイル: pf.cpp プロジェクト: sweetdark/navi
	//------------------------------------------------------------------------
	void platform_specific::display_pmap(HDC dc, const rendering_buffer* src)
	{
		if(m_sys_format == m_format)
		{
			m_pmap_window.draw(dc);
		}
		else
		{
			pixel_map pmap_tmp;
			pmap_tmp.create(m_pmap_window.width(), 
							m_pmap_window.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.stride() :
							 -pmap_tmp.stride());

			convert_pmap(&rbuf_tmp, src, m_format);
			pmap_tmp.draw(dc);
		}
	}
コード例 #2
0
ファイル: pf.cpp プロジェクト: sweetdark/navi
	//------------------------------------------------------------------------
	void platform_specific::create_pmap(unsigned width, 
										unsigned height,
										rendering_buffer* wnd)
	{
		m_pmap_window.create(width, height, org_e(m_bpp));
		wnd->attach(m_pmap_window.buf(), 
					m_pmap_window.width(),
					m_pmap_window.height(),
					  m_flip_y ?
					  m_pmap_window.stride() :
					 -m_pmap_window.stride());
	}
コード例 #3
0
ファイル: window_win32.cpp プロジェクト: franko/libcanvas
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;
}
コード例 #4
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;
    }
コード例 #5
0
    //------------------------------------------------------------------------
    void platform_specific::display_pmap(WindowRef window, const rendering_buffer* src)
    {
        if(m_sys_format == m_format)
        {
            m_pmap_window.draw(window);
        }
        else
        {
            pixel_map pmap_tmp;
            pmap_tmp.create(m_pmap_window.width(), 
                            m_pmap_window.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;

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

            case pix_format_bgr24:
                color_conv(&rbuf_tmp, src, color_conv_bgr24_to_rgb24());
                break;

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

            case pix_format_bgra32:
                color_conv(&rbuf_tmp, src, color_conv_bgra32_to_argb32());
                break;

            case pix_format_rgba32:
                color_conv(&rbuf_tmp, src, color_conv_rgba32_to_argb32());
                break;
            }
            pmap_tmp.draw(window);
        }
    }
コード例 #6
0
ファイル: pf.cpp プロジェクト: sweetdark/navi
	HBITMAP platform_specific::create_dib_pmap(HDC h_dc,
										unsigned width, 
										unsigned height,
										rendering_buffer* wnd)
	{
		HBITMAP bm = m_pmap_window.create_dib_section(h_dc, width, height, org_e(m_bpp));
		wnd->attach(m_pmap_window.buf(), 
					m_pmap_window.width(),
					m_pmap_window.height(),
					  m_flip_y ?
					  m_pmap_window.stride() :
					 -m_pmap_window.stride());

		return bm;
	}
コード例 #7
0
ファイル: pf.cpp プロジェクト: sweetdark/navi
 //------------------------------------------------------------------------
 bool platform_support::create_img(unsigned idx, unsigned width, unsigned height)
 {
     if(idx < max_images)
     {
         if(width  == 0) width  = m_specific->m_pmap_window.width();
         if(height == 0) height = m_specific->m_pmap_window.height();
         m_specific->m_pmap_img[idx].create(width, height, org_e(m_specific->m_bpp));
         m_rbuf_img[idx].attach(m_specific->m_pmap_img[idx].buf(), 
                                m_specific->m_pmap_img[idx].width(),
                                m_specific->m_pmap_img[idx].height(),
                                m_flip_y ?
                                 m_specific->m_pmap_img[idx].stride() :
                                -m_specific->m_pmap_img[idx].stride());
         return true;
     }
     return false;
 }
コード例 #8
0
ファイル: pf.cpp プロジェクト: sweetdark/navi
	//------------------------------------------------------------------------
	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_bmp(fn);
		}

		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.stride() :
						  -pmap_tmp.stride());

		convert_pmap(&rbuf_tmp, src, m_format);
		return pmap_tmp.save_as_bmp(fn);
	}
コード例 #9
0
ファイル: pf.cpp プロジェクト: sweetdark/navi
	//------------------------------------------------------------------------
	bool platform_specific::load_pmap(const char* fn, unsigned idx, 
									  rendering_buffer* dst)
	{
		pixel_map pmap_tmp;
		if(!pmap_tmp.load_from_bmp(fn)) return false;

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

		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].stride() :
					  -m_pmap_img[idx].stride());

		switch(m_format)
		{
		case pix_format_gray8:
			switch(pmap_tmp.bpp())
			{
			//case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_gray8()); break;
			case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_gray8()); break;
			//case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_gray8()); break;
			}
			break;

		case pix_format_gray16:
			switch(pmap_tmp.bpp())
			{
			//case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_gray16()); break;
			case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_gray16()); break;
			//case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_gray16()); break;
			}
			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_bgr24_to_rgb555()); break;
			case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_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_bgr24_to_rgb565()); break;
			case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_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_bgr24_to_rgb24()); break;
			case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_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_bgr24_to_bgr24()); break;
			case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_bgr24()); break;
			}
			break;

		case pix_format_rgb48:
			switch(pmap_tmp.bpp())
			{
			//case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_rgb48()); break;
			case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_rgb48()); break;
			//case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_rgb48()); break;
			}
			break;

		case pix_format_bgr48:
			switch(pmap_tmp.bpp())
			{
			//case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_bgr48()); break;
			case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_bgr48()); break;
			//case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_bgr48()); 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_bgr24_to_abgr32()); break;
			case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_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_bgr24_to_argb32()); break;
			case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_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_bgr24_to_bgra32()); break;
			case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_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_bgr24_to_rgba32()); break;
			case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_rgba32()); break;
			}
			break;

		case pix_format_abgr64:
			switch(pmap_tmp.bpp())
			{
			//case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_abgr64()); break;
			case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_abgr64()); break;
			//case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_abgr64()); break;
			}
			break;

		case pix_format_argb64:
			switch(pmap_tmp.bpp())
			{
			//case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_argb64()); break;
			case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_argb64()); break;
			//case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_argb64()); break;
			}
			break;

		case pix_format_bgra64:
			switch(pmap_tmp.bpp())
			{
			//case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_bgra64()); break;
			case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_bgra64()); break;
			//case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_bgra64()); break;
			}
			break;

		case pix_format_rgba64:
			switch(pmap_tmp.bpp())
			{
			//case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_rgba64()); break;
			case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_rgba64()); break;
			//case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_rgba64()); break;
			}
			break;

		}

		return true;
	}