StretchBlt MFC C ++问题 [英] StretchBlt MFC C++ problem

查看:153
本文介绍了StretchBlt MFC C ++问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!我使用StretchBlt 加载位图图像并将其显示在屏幕上.
我还在基于对话框的应用程序中使用了双缓冲区.

我写了一个显示图像的函数:

Hello! I use StretchBlt to load bitmap image and show it on screen.
I also use double buffer in my application, which is dialog based.

I wrote a function that displays the image:

void CPlay::OnBackground(CBitmap* p, CDC* pDC)
{
    CDC dcMemory;
    BITMAP bm;
    dcMemory.CreateCompatibleDC(pDC);
    dcMemory.SelectObject(p);
    p->GetBitmap(&bm);

	pDC->StretchBlt(0, 0, screenX, screenY, &dcMemory, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
}



然后,使CBitmap 变量并加载图像:



Then I make CBitmap variable and load the image:

variable.LoadBitmap(RESOURCE);



我称这个功能OnBackground(&variable, &pDC);
pDC 是CDC变量;
screenXscreenY 是我的屏幕分辨率:



I call the function OnBackground(&variable, &pDC);
pDC is CDC variable;
screenX, screenY are my screen resolution:

	screenX = GetSystemMetrics(SM_CXSCREEN);
	screenY = GetSystemMetrics(SM_CYSCREEN);



如果我保留我的分辨率(1280x1024),则效果很好.但是,如果我更改它,我的CPU开始使用50-60%,并且速度变慢.
如果我使用StretchBlt错误,请通知我.
希望您能明白我的意思,这就是为什么我以前会详细写它的原因. 谢谢!



If I keep my resol(1280x1024), it works well. But if I change it, my CPU starts using 50-60% and it is slowed down.
If I''m wrong using StretchBlt, please let me know.
I hope you can get my point, that''s why I used to write it in a detailed manner.
Thanks!

推荐答案

您可以立即创建调整大小位图,而不必一次又一次地拉伸原始位图.查看我的纯C重采样DLL" [
You may create at once a resized bitmap instead of stretching again and again the original one. See if my "Plain C Resampling DLL"[^] article helps.
:)


是指更改它,还是更改之后?如果要更改它,它会一遍又一遍地绘制图像,因此当然会使用处理器.
Do you mean AS you change it, or AFTER you change it ? If you''re changing it, it''s drawing the image over and over, so of course that uses the processor.


在更改分辨率之前,请尝试清洁DC.我相信它将产生巨大的影响.
Try to clean your DC before you change your resolution. It will produce a great effect I believe.


这篇关于StretchBlt MFC C ++问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆