DrawImage调查
Status DrawImage(
[in] Image *image,
[in] const Point *destPoints,
[in] INT count,
[in] INT srcx,
[in] INT srcy,
[in] INT srcwidth,
[in] INT srcheight,
[in] Unit srcUnit,
[in] ImageAttributes *imageAttributes,
[in] DrawImageAbort callback,
[in] VOID *callbackData
);
imageAttributes [in]
Pointer to an ImageAttributes object that specifies the color and size attributes of the image to be drawn. The default value is NULL.
callback [in]
DrawImageAbort
Callback method used to cancel the drawing in progress. The default value is NULL. This method is called frequently to check whether to stop execution of the DrawImage method according to application-determined criteria.
callbackData [in]
VOID
Pointer to additional data used by the method specified by the callback parameter. The default value is NULL.
Remarks
The portion of the source image to be drawn is scaled to fit the parallelogram.
Demo模式
声明
BOOL CALLBACK DrawImageCallback(VOID* callbackdata);
定义
BOOL CALLBACK DrawImageCallback(VOID* callbackdata)
{
// Test for call that passes callBackData parameter.
if(reinterpret_cast<LPCTSTR>(callbackdata) == L"Not Draw")
{
// If no callBackData passed, abort DrawImage method.
return TRUE;
}
else
{
// If callBackData passed, continue DrawImage method.
return FALSE;
}
}
调用
DrawImageAbort DrawImageCallbackPtr = DrawImageCallback;
graphics.DrawImage(
&image,
destRect,
srcX,
srcY,
srcWidth,
srcHeight,
UnitPixel,
&remapAttributes,
DrawImageCallbackPtr,
L"Not Draw");
// L"Draw");
类型定义
GdiPlusTypes.h
extern "C" {
typedef BOOL (CALLBACK * ImageAbort)(VOID *);
typedef ImageAbort DrawImageAbort;
typedef ImageAbort GetThumbnailImageAbort;
}
WinDef.h
#define CALLBACK __stdcall
Test模式
BOOL CALLBACK DrawImageCallback(VOID* callbackdata)
{
int* ptrCount = reinterpret_cast<int*>(callbackdata);
if (10 == *ptrCount)
{
return TRUE;
}
else
{
++(*ptrCount);
return FALSE;
}
}
调用
int iCount = 0;
DrawImageAbort DrawImageCallbackPtr = DrawImageCallback;
graphics.DrawImage(
&image,
destRect,
srcX,
srcY,
srcWidth,
srcHeight,
UnitPixel,
&remapAttributes,
DrawImageCallbackPtr,
&iCount);
Remark
如之前的参数描述,在DrawImage过程中,DrawImageAbort会多次被调用,以时刻检查绘图过程中是否符合停止绘图的条件,一旦条件满足则停止绘图,本次绘图不产生任何图像,此时函数返回Aborted。
一个未知问题:调试DrawImage时,在DrawImageCallback里设断点,当快速连按F5时,该函数只走了几次,而慢慢点的时候则会走很多次。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 25岁的心里话
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现