【发布时间】:2013-09-02 05:47:02
【问题描述】:
我正在尝试使用 c# 获取 1280 x 960 图像的位图。我没有获得单个 1280 x 960 图像,而是获得 3 个 426 x 320 的复制图像,覆盖 1280 x 960 区域的顶部 1/3,而其余 2/3 为黑色。
这是上传的图片:
这是我正在使用的代码。
using System.Runtime.InteropServices;
byte[] frame;
//... code
frame = new byte[1280 * 960 * 3];
// code to get the frame
System.Runtime.InteropServices.GCHandle pinnedArray =
GCHandle.Alloc(frame, GCHandleType.Pinned);
IntPtr pointer = pinnedArray.AddrOfPinnedObject();
Bitmap bmp = new Bitmap(width, height, 3 * width,
PixelFormat.Format24bppRgb, pointer);
MemoryStream JPEGStream = new MemoryStream ();
bmp.Save(filepath, System.Drawing.Imaging.ImageFormat.Bmp);
我想要一张覆盖整个区域的 1280 x 960 图像。
【问题讨论】:
-
显示获取帧的代码,“像素”和颜色字节如何在您的
frame数组中编制索引 -
位图 bmp = new Bitmap(width, height, 3 * width, PixelFormat.Format24bppRgb, 指针); 3* 宽度在那里做什么??
-
这是一个硬件故障,现在它正在工作。谢谢
标签: c# image opencv bitmap aforge