void CGdiApp1Dlg::OnPaint()
{
CPaintDC dc1(this); SendMessage(WM_ICONERASEBKGND, (WPARAM) dc1.GetSafeHdc(), 0);
Graphics graphics1(dc1.GetSafeHdc()); // Create a GDI+ graphics object USES_CONVERSION;
Bitmap bitmap(L"D:\\GdiPlus\\GdiApp1\\Debug\\ylsb2.bmp"); graphics1.DrawImage(&bitmap, 0, 0, bitmap.GetWidth(), bitmap.GetHeight()); CDialog::OnPaint();
}
何时用 Image 呢?是用GDI+好还是用别的库如CxImage好呢?
{
CPaintDC dc1(this); SendMessage(WM_ICONERASEBKGND, (WPARAM) dc1.GetSafeHdc(), 0);
Graphics graphics1(dc1.GetSafeHdc()); // Create a GDI+ graphics object USES_CONVERSION;
Bitmap bitmap(L"D:\\GdiPlus\\GdiApp1\\Debug\\ylsb2.bmp"); graphics1.DrawImage(&bitmap, 0, 0, bitmap.GetWidth(), bitmap.GetHeight()); CDialog::OnPaint();
}
何时用 Image 呢?是用GDI+好还是用别的库如CxImage好呢?
解决方案 »
- socket的sento老是出错!谁要是给我解决,你让我随便干嘛,都行..谢谢啦!真心求助啊!
- 关于struct tm *p的一个很奇怪的问题
- 关于shell上下文菜单的问题
- directshow怎么停止捕捉后再捕捉!
- 使用ctreectrl控件的createdragimage函数失败
- 子类化问题
- 我写了一个静态链接库a(扩展名lib),a定义了一个_declspec(dllexport)的classA?
- 如何用程序方式给CRichEdit追加文字
- 如何使一个菜单项无效?
- 菜鸟入门问题:SDK怎样去编,放到那去编译?是VC吗?
- 已知文件的目录路径,怎么查找以dsw为后缀名的文件?
- 随机产生16个数的数组,这16个数分别为1-16,数据不能重复,1-16各个数必须用到,数组的各个数是随机产生的,求教算法.
Bitmap bitmap(L"D:\\GdiPlus\\GdiApp1\\Debug\\ylsb2.png");
Bitmap bitmap(L"D:\\GdiPlus\\GdiApp1\\Debug\\ylsb2.gif");Bitmap并不是只能读取.bmp的位图.
DWORD token;
GdiplusStartupInput input; //是个结构 晕
GdiplusStartup(&token,&input,0);
测试通过显示屏幕估计是因为这句
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc1.GetSafeHdc(), 0);
GdiplusStartupInput m_gdiplusStartupInput;
ULONG_PTR m_gdiplusToken; 在InitInstance()中
GdiplusStartup(&m_gdiplusToken, &m_gdiplusStartupInput, NULL);
在ExitInstance() 中
GdiplusShutdown(m_gdiplusToken);然后在Dlg::OnPaint()中加如上代码, 但显示的是Desktop上的背景图片, 详细情况就是这样.
如果用Image image(L"D:\\GdiPlus\\GdiApp1\\Debug\\ylsb2.bmp"); 运行时还会出错.这是用GDI+显示图片的最简单的例子了,哪未朋友发给我一个完整的例子,能编译运行,显示出图片,就象我做的那样简单的那种, 不要复杂的. 谢谢 !