读书人

关于dc的有关问题

发布时间: 2012-10-23 12:12:22 作者: rapoo

关于dc的问题
请看代码[code=C/C++][/code]void TiButton::DispPic( HDC hdc,POINT& start_pos )
{
if(back_png_ == NULL)
return;

int width = back_png_->nWidth;
int height = back_png_->nHeight;

CDC mem_dc;
CBitmap mem_bitmap;
mem_dc.CreateCompatibleDC(hdc);
mem_bitmap.CreateCompatibleBitmap(hdc, width,height );
mem_dc.SelectBitmap(mem_bitmap);

mem_dc.BitBlt(0, 0,width, height, bk_dc_, 0, 0, SRCCOPY);

CDCHandle pDC = hdc;
if(back_png_)
{
Png32_Show(mem_dc,0,0,back_png_->nWidth,back_png_->nHeight,back_png_,0,0);
}

if(front_png_)
{
int temp_left = (back_png_->nWidth - front_png_->nWidth) / 2;
int temp_top = (back_png_->nHeight - front_png_->nHeight) / 2;
Png32_Show(mem_dc,temp_left,temp_top,front_png_->nWidth,front_png_->nHeight,front_png_,0,0);
}
if (front_front_png_ && is_front_front_)
{
int temp_left = (back_png_->nWidth - front_front_png_->nWidth) / 2;
int temp_top = (back_png_->nHeight - front_front_png_->nHeight) / 2;
Png32_Show(mem_dc,temp_left,temp_top,front_front_png_->nWidth,front_front_png_->nHeight,front_front_png_,0,0);

}
pDC.BitBlt(start_pos.x, start_pos.y,width+start_pos.x, height+start_pos.y, mem_dc, 0, 0, SRCCOPY);

mem_bitmap.DeleteObject();
mem_dc.DeleteDC();
}

[解决办法]
code=C/C++]代码要贴在这对方括号中间,而不是后面[/code
[解决办法]
怎么是HDC 啊
[解决办法]
这不太可能吧,int赋值而已。

探讨

有时会在里面出错.
int width = back_png_->nWidth;
int height = back_png_->nHeight;
这个 back_png_->nWidth;back_png_->nHeight;有值
但是 width height 没取到 导致后面的
mem_bitmap.CreateCompatibleBitmap(hdc, width,height……

[解决办法]
除了代码之外,再说两句?
[解决办法]
GetLastError?

读书人网 >C++

热点推荐