VS2013Form窗体工程应用程序开发之GDI绘图开发之 ---- 在pictureBox控件中绘图

本文介绍了在VS2013 Form窗体应用中利用GDI进行绘图,特别是如何在pictureBox控件中实现绘图。讲解了StretchBlt和BitBlt两个函数的用法,分别用于缩放和直接复制图像,并提供了源码示例及工程配置中的gdi32.dll依赖说明。最后展示了运行截图。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

备注:最后一个参数使用的是:SRCCOPY

1、bool StretchBlt(HDC hdcDest, int xDest, int yDest, int wDest, int hDest, HDC hdcSrc, int xSrc, int ySrc, int wSrc, int hSrc, DWORD rop);这个会进行缩放。

2、bool BitBlt(HDC hdc, int x, int y, int cx, int cy, HDC hdcSrc, int x1, int y1, DWORD rop);这个就是从指定的位置开始指定长度和宽度的复制了。

正文开始:

1、在窗体的源码.h文件中添加:

namespace JIMMY_GDI_API{
		using namespace System::Runtime::InteropServices;
		typedef void* HDC;
		[DllImport("gdi32", EntryPoint = "StretchBlt")]
		extern "C" bool StretchBlt(HDC hdcDest, int xDest, int yDest, int wDest, int hDest, HDC hdcSrc, int xSrc, int ySrc, int wSrc, int hSrc, DWORD rop);
		[DllImport("gdi32", EntryPoint = "BitBlt")]
		extern "C" bool BitBlt(HDC hdc, int x, int y, int cx, int cy, HDC hdcSrc, int x1, int y1, DWORD rop);
	}

2、使用示例:

#include "windows.h"

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
		HDC hdc = ::Ge
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值