c#将HImage对象保存成图片

c#将HImage对象保存成图片

halcon图片对象HImage用C#代码保存到指定目录

复制代码
/// <summary>
/// 将HImage对象保存成图片
/// </summary>
/// <param name="hImage"></param>
/// <param name="savePath">图像保存目录(注意只是目录)</param>
/// <returns></returns>
public bool SaveImageByHImage(HImage hImage, string savePath = "")
{
    var isOk = false;
    if (hImage != null)
    {
        var saveImagePath = "E://test//" + name;
        if (!string.IsNullOrEmpty(savePath))
        {
            saveImagePath = savePath;
        }
        if (!Directory.Exists(saveImagePath))
        {
            Directory.CreateDirectory(saveImagePath);
        }
        saveImagePath= saveImagePath + "//Ng";
        if (!Directory.Exists(saveImagePath))
        {
            Directory.CreateDirectory(saveImagePath);
        }
        HOperatorSet.WriteImage(hImage, "bmp", 0, saveImagePath + "//" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".bmp");
        isOk = true;
    }
    return isOk;
}
相关推荐
狐5718 小时前
2026-01-22-LeetCode刷题笔记-3507-移除最小数对使数组有序I
笔记·leetcode
2501_9444241218 小时前
Flutter for OpenHarmony游戏集合App实战之连连看路径连线
android·开发语言·前端·javascript·flutter·游戏·php
C系语言18 小时前
python用pip生成requirements.txt
开发语言·python·pip
燃于AC之乐18 小时前
深入解剖STL Vector:从底层原理到核心接口的灵活运用
开发语言·c++·迭代器·stl·vector·源码分析·底层原理
wrj的博客1 天前
python环境安装
python·学习·环境配置
优雅的潮叭1 天前
c++ 学习笔记之 chrono库
c++·笔记·学习
星火开发设计1 天前
C++ 数组:一维数组的定义、遍历与常见操作
java·开发语言·数据结构·c++·学习·数组·知识
TTGGGFF1 天前
控制系统建模仿真(一):掌握控制系统设计的 MAD 流程与 MATLAB 基础运算
开发语言·matlab
星幻元宇VR1 天前
走进公共安全教育展厅|了解安全防范知识
学习·安全·虚拟现实
2501_944424121 天前
Flutter for OpenHarmony游戏集合App实战之贪吃蛇食物生成
android·开发语言·flutter·游戏·harmonyos