自学内容网 自学内容网

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;
}


原文地址:https://blog.csdn.net/cjh16606260986/article/details/136388564

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!