在.net紧凑框架中将图像转换为1 bpp位图
我有一张签名图像,我试图将其另存为 1 bpp 位图以节省文件空间。完整的 .NET Framework 具有枚举 PixelFormat.Format1bppIndexed
,但 .NET Compact Framework 不支持它。
有人发现了一种在 Windows Mobile 中实现此目的的方法吗?
I have an image of a signature I am trying to save as 1 bpp bitmap to save file space. The full .NET Framework has the enum PixelFormat.Format1bppIndexed
, but the .NET Compact Framework does not supported it.
Has any one discovered a way to accomplish this in Windows Mobile?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
过去我必须这样做才能生成黑色和白色。通过蓝牙打印白色报告(彩色或灰度图像对于打印机的缓冲区来说太大)。结果我必须使用本机代码创建图像。
下面是一个片段:
然后,我使用 Graphics.FromHdc 获取一个托管图形对象,我可以在该对象上绘制报告。
我确实用 BinaryWriter 进行了保存,但那是在 CF 1.0 时代,当时 Bitmap 类没有 Save,所以你在那里是自由和清晰的。
I had to do this in the past for generating black & white reports printed via Bluetooth (color or greyscale images were too large for the printer's buffer). Turned out I had to create the images using native code.
Here's a snippet:
I then used Graphics.FromHdc to get a managed graphics object that I could paint the report onto.
I did saving with a BinaryWriter, but that was in CF 1.0 days when the Bitmap class didn't have a Save, so you're free and clear there.
感谢您为我指明了正确的方向,ctacke。
我无法使用 Bitmap 类来保存图像数据。它不断抛出
OutOfMemoryException
。正如您所建议的,我求助于使用 BinaryWriter 写出位图。我的最终解决方案返回一个字节数组,您可以使用它选择写入磁盘、保存到数据库、传输等。
Thanks for pointing me in the right direction, ctacke.
I was unable to use the
Bitmap
class to save the image data. It continually threw anOutOfMemoryException
. I resorted to writing the bitmap out using a BinaryWriter, like you suggested.My end solution returns a byte array, with which you can choose to write to disk, save to a database, transmit, etc.
即使在完整的框架中,创建和保存双色调位图也是有问题的。
我之前写过一篇文章讨论这个涉及到的问题。
http://www.codeproject.com/KB/GDI-plus/BitonalImageConverter。 。
我在紧凑框架的上下文中重新访问了这段代码,并发现枚举值不存在,因此您无法从头开始创建双色调图像
我很想知道您是否可以在紧凑框架中加载预先存在的双色调图像。如果您可以加载预先存在的双色调位图,那么可能可以进入较低级别并将位图图像格式直接写入磁盘或内存流,而不是使用 GDI+ 对象,但这样做并不简单。
Creating and saving a bitonal bitmap is problematic even in the full framework.
I previously authored an article on this issues involved.
http://www.codeproject.com/KB/GDI-plus/BitonalImageConverter.aspx
I revisited this code in the context of the compact framework and discovered as you did that the enum value does not exist, so you can't create a bitonal image from scratch.
I'd be interested to know if you can load pre-existing bitonal images in the compact framework. If you can load pre-existing bitonal bitmaps, then it might be possible to go lower level and write the bitmap image format to disk or a memory stream directly, rather than use the GDI+ objects, but it would be non-trivial to do so.