当前位置: 代码迷 >> WinCE >> 新开一贴,研究画图的有关问题
  详细解决方案

新开一贴,研究画图的有关问题

热度:78   发布时间:2016-04-28 13:04:34.0
新开一贴,研究画图的问题
看了画图大家都比较关心,于是我将我写了几个EXE,分别测试Ce下的刷图函数的
大家可以下载一下,然后测试

http://download.csdn.net/detail/hudaweikevin/4260273

代码我贴在下面,大家看一下这样写有没有问题


#define WIDETH_PIXEL_UNIT 800 
#define HEIGHT_PIXEL_UNIT 480

int nBitsPixel= 16;

void DDCreate24BitmapInfo(PBITMAPINFO pbminfo,int dx,int dy)
{
ZeroMemory(pbminfo, sizeof(BITMAPINFO)); 

// setup bitmap info  
pbminfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); 
pbminfo->bmiHeader.biWidth = dx; 
pbminfo->bmiHeader.biHeight = dy; 
pbminfo->bmiHeader.biPlanes = 1; 
pbminfo->bmiHeader.biBitCount = 24;  
pbminfo->bmiHeader.biCompression = BI_RGB; 
pbminfo->bmiHeader.biSizeImage = dx * dy * 3;// 图片缓冲区大小 
return;
}

void
DDCreate16BitmapInfo(PBITMAPINFO pbminfo,int dx,int dy)
{
ZeroMemory(pbminfo, sizeof(BITMAPINFO)); 

// setup bitmap info  
pbminfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); 
pbminfo->bmiHeader.biWidth = dx; 
pbminfo->bmiHeader.biHeight = dy; 
pbminfo->bmiHeader.biPlanes = 1; 
pbminfo->bmiHeader.biBitCount = 16;  
pbminfo->bmiHeader.biCompression = BI_RGB; 
pbminfo->bmiHeader.biSizeImage = dx * dy * 2;// 图片缓冲区大小 
return;
}


void Cpaint_time_testDlg::OnBnClickedButton1()
{
// TODO: Add your control notification handler code here
HDC hdc = ::GetDC(m_hWnd); 
BITMAPINFO bmi; 
if(nBitsPixel == 16)
DDCreate16BitmapInfo(&bmi,WIDETH_PIXEL_UNIT,HEIGHT_PIXEL_UNIT);
else
DDCreate24BitmapInfo(&bmi,WIDETH_PIXEL_UNIT,HEIGHT_PIXEL_UNIT);

UCHAR * pdata=(UCHAR *)malloc(WIDETH_PIXEL_UNIT*HEIGHT_PIXEL_UNIT*3);


UCHAR temp=0;
int sum=0;
for (int i=0;i<10;i++)
{
memset(pdata,temp,WIDETH_PIXEL_UNIT*HEIGHT_PIXEL_UNIT);
temp=temp+0x44;
memset(pdata+WIDETH_PIXEL_UNIT*HEIGHT_PIXEL_UNIT,temp,WIDETH_PIXEL_UNIT*HEIGHT_PIXEL_UNIT);
temp=temp+0x44;
if(nBitsPixel == 24)
{
memset(pdata+WIDETH_PIXEL_UNIT*HEIGHT_PIXEL_UNIT*2,temp,WIDETH_PIXEL_UNIT*HEIGHT_PIXEL_UNIT);
temp=temp+0x44;
}

int startTime=GetTickCount();
StretchDIBits(hdc,0,0,WIDETH_PIXEL_UNIT,HEIGHT_PIXEL_UNIT,0,0,WIDETH_PIXEL_UNIT,HEIGHT_PIXEL_UNIT,pdata,&bmi,DIB_RGB_COLORS,SRCCOPY);
//SetDIBitsToDevice(hdc,0,0,WIDETH_PIXEL_UNIT,HEIGHT_PIXEL_UNIT,0,0,0,HEIGHT_PIXEL_UNIT,pdata,&bmi,DIB_RGB_COLORS);
int endTime=GetTickCount();
//Sleep(1000);
sum = sum + (endTime -startTime);
}

::ReleaseDC(m_hWnd,hdc) ;
CString result=L"";
result.Format(L"%d",sum/10);
SetDlgItemText(IDC_EDIT1,result);

free(pdata);  
}

另外三个测试函数,大概就是替换了
SetDIBitsToDevice(hdc,0,0,WIDETH_PIXEL_UNIT,HEIGHT_PIXEL_UNIT,0,0,0,HEIGHT_PIXEL_UNIT,pdata,&bmi,DIB_RGB_COLORS);
StretchBlt(hdc,0,0,WIDETH_PIXEL_UNIT,HEIGHT_PIXEL_UNIT,hdcMem,0,0,WIDETH_PIXEL_UNIT,HEIGHT_PIXEL_UNIT,SRCCOPY);
BitBlt(hdc,0,0,WIDETH_PIXEL_UNIT,HEIGHT_PIXEL_UNIT,hdcMem,0,0,SRCCOPY); 

另外我也贴一下我的测试结果:


测试环境 (A)
1024*600的16位深度 RGB16(ms) RGB24(ms)
DM3730,主频800 
————————————————————————————————
1024*480 stretchDIBBits 94 stretchDIBBits 101
  SetDIBitsToDevice 94 SetDIBitsToDevice 81
  StretchBlt 94 StretchBlt 81
  BitBlt 94 BitBlt 81
——————————————————————————————————————
800*480 stretchDIBBits 75 stretchDIBBits 79
  相关解决方案