我正在尝试使用单声道渲染内存中的位图。此图像应显示在 Adafruits 2.8"touch TFT (320*240) 上。该程序是使用 Visual Studio 2013 Community Edition 开发的。我想托管一个 ASP.NET Web Api 并显示 显示器上的一些数据。 ASP.NET 部分工作正常并且图像已呈现。我的想法是将图像写入帧缓冲区输入,但这样做我得到一个异常,说文件太大了。我只是在写没有 BMP header 的原始数据。有人设法做到这一点吗?也许图像的创建是 错误的。 似乎发生了一些事情,因为显示发生了变化,我可以看到可能来 self 的图像的白色区域。 我不想使用任何额外的库来保持简单。所以我的想法是直接用FBI。有谁知道这个问题和解决方案吗?
这是我的一些代码:
using (Bitmap bmp = new Bitmap(240, 320, PixelFormat.Format16bppRgb555))
{
[...]
Byte[] image = null;
using(MemoryStream memoryStream = new MemoryStream())
{
bitmap.Save(memoryStream, ImageFormat.Bmp);
Byte[] imageTemp = memoryStream.GetBuffer();
//Remove BMP header
image = new Byte[imageTemp.Length - 54];
Buffer.BlockCopy(imageTemp, 54, image, 0, image.Length);
//153600 byte
using (FileStream fb1 = new FileStream("/dev/fb1", FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite))
{
fb1.Write(image, 0, image.Length);
fb1.Close();
}
}
}
最佳答案
看看http://computerstruggles.blogspot.de/2013/02/how-to-program-directfb-in-c-on.html - 这个想法是安装 directfb 库并通过 C# 和 PInvoke 使用它。该博客的作者使用 C 中的迷你包装器使其使用起来更加容易。顺便说一句,您为什么不喜欢安装额外的库并从其他人为您完成的工作中获利?
关于c# - Raspberry Pi 和单声道帧缓冲区输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28713227/