跳转到主要内容
Linux 和 macOS 上未实现此方法
此方法使用内存缓冲区中的数据设置训练用图像。 图像应为各向同性图像 (即水平分辨率应与垂直分辨率相同) ,并且是每像素 1 位编码的黑白图像。 图像在缓冲区中按从上到下的顺序连续逐行存储。黑白图像的一行存储为至少 N = ceil ( width / 8 ) 个字节的序列。每个字节对相邻 8 个像素的颜色进行编码,第一个字节的最高有效位对应该行最左侧的像素。位值为 0 表示白色像素,值为 1 表示黑色像素。如果 width 不是 8 的倍数,则忽略第 N 个字节的最低有效位。

语法

C++

HRESULT SetBitmapBits(
  int     Height,
  int     Width,
  __int64 RawDataPointer
);

C#

void SetBitmapBits(
  int   Height,
  int   Width,
  Int64 RawDataPointer
);

Visual Basic .NET

Sub SetBitmapBits( _
  Height As Integer, _
  Width As Integer, _
  RawDataPointer As Int64 _
)

参数

Height [in] 指定训练用图像的高度 (以像素为单位) 。 Width [in] 指定训练用图像的宽度 (以像素为单位) 。 RawDataPointer [in] 此参数被视为指向包含图像数据的内存缓冲区的句柄。该句柄以 __int64 类型传递。

返回值

对于 Windows:该方法没有特定的返回值。它返回 ABBYY FineReader Engine 函数的标准返回值 对于 Linux 和 macOS:该方法返回 E_NOTIMPL。

备注

只要相应的 TrainingImage 对象存在,图像数据就应一直保留。

示例

// bitmap 的格式应与 FineReader Engine 中的格式相同。
// 如果图像采用其他格式,可以使用 Image.GetBitmap 方法。
// IntPtr hBitmap = document.Pages[0].ImageDocument.BlackWhiteImage.GetBitmap(null).Handle;
// Bitmap bitmap = new Bitmap( Image.FromHbitmap( hBitmap ) );
Bitmap bitmap = new Bitmap(imagePath);
Rectangle imageRect = new Rectangle(0, 0, bitmap.Size.Width, bitmap.Size.Height);
System.Drawing.Imaging.BitmapData data = bitmap.LockBits(imageRect, System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format1bppIndexed);
FREngine.ITrainingImage trainingImage = engineLoader.Engine.CreateTrainingImage();
trainingImage.SetBitmapBits(bitmap.Size.Height, bitmap.Size.Width, data.Scan0.ToInt64());

另请参阅

TrainingImage