vc++2008 gdi+ 绘图
使用的是VC++2008;想要用gdi+将"I:\123\测试图片.png"绘制到form1上,方法?长期学习、长期在线,可远程操作指导.....最大程度加分542209...
使用的是VC++2008
;想要用gdi+将"I:\123\测试图片.png"绘制到form1上,方法?
长期学习、长期在线,可远程操作指导.....最大程度加分
542209396@qq.com 展开
;想要用gdi+将"I:\123\测试图片.png"绘制到form1上,方法?
长期学习、长期在线,可远程操作指导.....最大程度加分
542209396@qq.com 展开
3个回答
展开全部
给你贴个小例子
#include <Windows.h>
#include <math.h>
#include <GdiPlus.h>
#pragma comment(lib,"GdiPlus.lib")
using namespace Gdiplus;
LRESULT CALLBACK WinProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
);
void drawbitmap(HDC hdc)
{
Graphics grap(hdc);
Image img(L"E:\\宽屏壁纸\\图片\\jiani.jpg");
grap.DrawImage(&img,0,0);
}
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow
)
{
TCHAR szname[]=TEXT("classname");
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
// Initialize GDI+.
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
wndclass.style= CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc=WinProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndclass.hInstance=hInstance;
wndclass.lpszClassName=szname;
wndclass.lpszMenuName=NULL;
RegisterClass(&wndclass);
hwnd=CreateWindow(szname,TEXT("windowsnametest"),WS_OVERLAPPEDWINDOW,100,100,300,300,NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg,hwnd,0,0)>0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
UnregisterClass(szname,hInstance);
GdiplusShutdown(gdiplusToken);
return 1;
}
LRESULT CALLBACK WinProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
switch(uMsg)
{
HDC hdc;
case WM_PAINT:
hdc = GetDC(hwnd);
drawbitmap(hdc);
ReleaseDC(hwnd,hdc);
break;
case WM_CLOSE:
DestroyWindow(hwnd);
PostQuitMessage(1);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
#include <Windows.h>
#include <math.h>
#include <GdiPlus.h>
#pragma comment(lib,"GdiPlus.lib")
using namespace Gdiplus;
LRESULT CALLBACK WinProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
);
void drawbitmap(HDC hdc)
{
Graphics grap(hdc);
Image img(L"E:\\宽屏壁纸\\图片\\jiani.jpg");
grap.DrawImage(&img,0,0);
}
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow
)
{
TCHAR szname[]=TEXT("classname");
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
// Initialize GDI+.
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
wndclass.style= CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc=WinProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndclass.hInstance=hInstance;
wndclass.lpszClassName=szname;
wndclass.lpszMenuName=NULL;
RegisterClass(&wndclass);
hwnd=CreateWindow(szname,TEXT("windowsnametest"),WS_OVERLAPPEDWINDOW,100,100,300,300,NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg,hwnd,0,0)>0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
UnregisterClass(szname,hInstance);
GdiplusShutdown(gdiplusToken);
return 1;
}
LRESULT CALLBACK WinProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
switch(uMsg)
{
HDC hdc;
case WM_PAINT:
hdc = GetDC(hwnd);
drawbitmap(hdc);
ReleaseDC(hwnd,hdc);
break;
case WM_CLOSE:
DestroyWindow(hwnd);
PostQuitMessage(1);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
追问
此代码通过远程已在本机上实践通过~
东莞大凡
2024-08-07 广告
2024-08-07 广告
OpenCV标定板是东莞市大凡光学科技有限公司在相机标定中常用的工具。它通常由黑白格点按一定规则排列在平面上组成,如棋盘格或圆形格等。在相机标定时,将标定板置于不同位置和姿态下拍摄图像,利用OpenCV库中的函数检测标定板上的角点或圆心,进...
点击进入详情页
本回答由东莞大凡提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |