GDI+在8位图像绘图

robojun 2016-09-07 10:54:08
请教一个问题,在GDI+中24位绘图是g.DrawLine(&Pen(Color::Black),Point(0,0),Point(100,100));现在由于我要画得图像是黑白的,所以我不需要32位我只要8位。因为32位图像在内存中的存储是BGR BGR BGR XX。。。我希望在8bpp上面绘制图像以减少绘图用时,请问我的Pen怎么写
...全文
200 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
robojun 2016-09-09
  • 打赏
  • 举报
回复
No, anti-aliasing doesn't work with 8-bpp. If you need faster updates, consider doing your drawing with something like OpenGL instead of via GDI. With OpenGL, the drawing will normally be done entirely by the graphics hardware, so even at 32-bpp, the drawing will usually be faster than GDI doing 8-bpp. It's also worth noting that you'd probably be better off with 32-bpp than either 8- or 24-bpp in any case. GDI can use (some) hardware acceleration, but it's usually at its best with 32-bpp. CSDN看到的。。。可能不能这么加速吧,有大神看到加我QQ和我说一声813078405
robojun 2016-09-07
  • 打赏
  • 举报
回复
LTimeCount tt; tt.Start(); int nImgw = Real2Pix(m_PnlRoundRect.GetWidth())+EXTEND_PIX; int nImgh = Real2Pix(m_PnlRoundRect.GetHight())+EXTEND_PIX; int T = m_ADShapeVector.size(); m_pbitmap=new Bitmap(nImgw,nImgh,PixelFormat24bppRGB); t_pgraphics=Graphics::FromImage(m_pbitmap); for (int i=0;i<T;i++) { if (!m_ADShapeVector[i].bFinish) { m_ADShapeVector[i].bFinish = true; DrawADShape(&m_ADShapeVector[i]); } } m_ADShapeVector.clear();//0.2s CLSID t_encoderClsid; GetEncoderClsid(L"image/bmp",&t_encoderClsid); CString strBmp; strBmp.Format(_T("D:\\%sb.bmp"),m_strPnlName); USES_CONVERSION; m_pbitmap->Save(T2W(strBmp.GetBuffer()),&t_encoderClsid,NULL); strBmp.ReleaseBuffer(); tt.End(); TRACE("DrawImg Time:%.5f\n",tt.GetUseTime()); delete m_pbitmap; delete t_pgraphics; t_pgraphics=NULL; m_pbitmap=NULL; 完整代码,现在想创建8bpp,望大神帮忙
robojun 2016-09-07
  • 打赏
  • 举报
回复
不用DC啊。Graphics直接来自在内存生成的图像Bitmap;最后也是2维绘图画完保存位bmp图像。所以8位和32位肯定有影响的,内存占用就很大影响了
draculamx 2016-09-07
  • 打赏
  • 举报
回复
不论是GDI还是GDI+,绘图的最终目的地还是DC,所以你只要把你的DC设置成8位色的就可以了。。 还有,不论你是8位还是32位,在绘图速度上应该都没有变化的。。。 如果你希望使用8位来加快绘图速度,除非你自己写一个Drawline函数,当然,绝大部分情况下,你自己写的这个函数,不可能比GDI或者GDI+快。。。

1,221

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧