public HTuple hv_ExpDefaultWinHandle;
Int64 Input_Image_Width = 0, Input_Image_Height = 0;
private void action(int type, IntPtr ptr, String filePath = "")
{
try
{
HObject ho_Image;
HOperatorSet.GenEmptyObj(out ho_Image);
HTuple win_Width, win_Height, win_Col, win_Row;
HOperatorSet.GetWindowExtents(hv_ExpDefaultWinHandle, out win_Row, out win_Col, out win_Width, out win_Height);
HOperatorSet.SetDraw(hv_ExpDefaultWinHandle, "margin");
HOperatorSet.SetColor(hv_ExpDefaultWinHandle, "red");
HOperatorSet.SetWindowParam(hv_ExpDefaultWinHandle, "graphics_stack_max_element_num", 500000);
if (type == 0 || type == 1)
{
if (!string.IsNullOrEmpty(filePath))
{
HOperatorSet.ReadImage(out ho_Image, filePath);
}
else if (ptr != IntPtr.Zero)
{
HOperatorSet.GenImage1(out ho_Image, "byte", Input_Image_Width, Input_Image_Height, ptr);
}
}
else if (type == 3)
{
HOperatorSet.GenImageConst(out ho_Image, "byte", Input_Image_Width, Input_Image_Height);
}
HTuple Width, Height;
HOperatorSet.GetImageSize(ho_Image, out Width, out Height);
HTuple ScaleWidth = Width / (win_Width * 1.0);
HTuple ScaleHeight = Height / (win_Height * 1.0);
HTuple row1, column1, row2, column2;
row1 = 0;
column1 = -(1.0) * ((win_Width * ScaleHeight) - Width) / 2;
row2 = row1 + win_Height * ScaleHeight;
column2 = column1 + win_Width * ScaleHeight;
HOperatorSet.SetPart(hv_ExpDefaultWinHandle, row1, column1, row2, column2);
HOperatorSet.ClearWindow(hv_ExpDefaultWinHandle);
HOperatorSet.DispObj(ho_Image, hv_ExpDefaultWinHandle);
}
catch (Exception ex)
{
throw new Exception("[action]图像加载失败,ex:" + ex.Message);
}
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)