我正在编写一个应用程序,要求我采用专有的位图格式(MVTec Halcon HImage)并将其转换为C#中的System.Drawing.Bitmap.
给我的唯一专有功能是帮助我这样做,这涉及到我写入文件,除了使用"获取指针"功能.
这个功能很棒,它给了我一个指向像素数据,宽度,高度和图像类型的指针.
我的问题是,当我使用构造函数创建System.Drawing.Bitmap时:
new System.Drawing.Bitmap(width, height, stride, format, scan)
Run Code Online (Sandbox Code Playgroud)
我需要指定一个4的倍数的"步幅".这可能是一个问题,因为我不确定我的函数将被命中的大小位图.假设我最终得到一个111x111像素的位图,除了在我的图像中添加一个伪列或减去3列之外,我无法运行此功能.
有没有办法可以绕过这个限制?
我正在使用以下代码:
f = fopen( _stringhelper.STR("%s.bmp", filename), "wb" );
if( !f ) {
_core.Error( ERC_ASSET, "ncImageLoader::CreateImage - Couldn't create %s image.\n", filename );
return false;
}
int w = width;
int h = height;
int i;
int filesize = 54 + 3 * w * h;
byte bmpfileheader[14] = {
'B', 'M',
0, 0, 0, 0,
0, 0,
0, 0,
54, 0, 0, 0 };
byte bmpinfoheader[40] = { 40, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0, …Run Code Online (Sandbox Code Playgroud)