/// <summary>
/// 灰度图像 HObject -> Bitmap
/// </summary>
public static Bitmap HObject2Bitmap(HObject ho)
{
try
{
HTuple type, width, height, pointer;
//HOperatorSet.AccessChannel(ho, out ho, 1);
HOperatorSet.GetImagePointer1(ho, out pointer, out type, out width, out height);
//himg.GetImagePointer1(out type, out width, out height); Bitmap bmp = new Bitmap(width.I, height.I, PixelFormat.Format8bppIndexed);
ColorPalette pal = bmp.Palette;
for (int i = 0; i <= 255; i++)
{
pal.Entries[i] = Color.FromArgb(255, i, i, i);
}
bmp.Palette = pal;
BitmapData bitmapData = bmp.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, PixelFormat.Format8bppIndexed);
int PixelSize = Bitmap.GetPixelFormatSize(bitmapData.PixelFormat) / 8;
int stride = bitmapData.Stride;
int ptr = bitmapData.Scan0.ToInt32();
for (int i = 0; i < height; i++)
{
CopyMemory(ptr, pointer, width * PixelSize);
pointer += width;
ptr += bitmapData.Stride;
} bmp.UnlockBits(bitmapData);
return bmp;
}
catch (Exception exc)
{
return null;
}
}
/// <summary>
/// 灰度图像 HObject -> HImage1
/// </summary>
public HImage HObject2HImage1(HObject hObj)
{
HImage image = new HImage();
HTuple type, width, height, pointer;
HOperatorSet.GetImagePointer1(hObj, out pointer,out type, out width, out height);
image.GenImage1(type, width, height, pointer);
return image;
} /// <summary>
/// 彩色图像 HObject -> HImage3
/// </summary>
public HImage HObject2HImage3(HObject hObj)
{
HImage image = new HImage();
HTuple type, width, height, pointerRed, pointerGreen, pointerBlue;
HOperatorSet.GetImagePointer3(hObj, out pointerRed, out pointerGreen, out pointerBlue,
out type, out width, out height);
image.GenImage3(type, width, height, pointerRed, pointerGreen, pointerBlue);
return image;
}

最新文章

  1. Mac 热键大全
  2. eclipse报错“Undefined variable from import: ...”解决方案
  3. 1. K线基础知识一
  4. backup
  5. Ubuntu14.04安装OpenCV2.4.9
  6. Windows消息大全(转)
  7. strut2的拦截器之对request和session的封装
  8. iOS系统提供开发环境下命令行编译工具:xcodebuild
  9. 去除UITableView中多余的分割线或者隐藏cell间的分割线
  10. hdu3746 KMP
  11. 关于JavaScript中apply与call的用法意义及区别(转)
  12. ASP.NET的SEO:Linq to XML---网站地图和RSS Feed
  13. HTML5 乱记
  14. Lucene查询条数限制
  15. 部署项目到weblogic时提示文件被锁,导致报错
  16. [福大软工] Z班 第5次成绩排行榜
  17. 记录一次mysql查询速度慢造成CPU使用率很高情况
  18. Python Web Service
  19. Python--Django学习笔记1
  20. MySQL升5.6引发的问题

热门文章

  1. MongDB 数据结构
  2. Tutorial中的Hello2代码
  3. 在docker中安装mysql
  4. dhtmlx Gantt实例介绍分析
  5. js表单提交到后台对象接收
  6. HC32F003与STM8S003资源对比,只是对比,大家评论~!
  7. WithOne 实体关系引起 EF Core 自动删除数据
  8. 爬虫-----selenium模块自动爬取网页资源
  9. LINQ交集/并集/差集/去重
  10. defaultdict(list)