架构师_程序员_码农网

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 11425|回复: 0

[资料] Unsupported pixel format of the source or template image

[复制链接]
发表于 2015-11-23 15:46:28 | 显示全部楼层 |阅读模式
今天 在用aforgr.net做图像处理的时候报了以下错误:
QQ截图20151123154312.jpg




Unsupported pixel format of the source or template image
源或模板图像不支持的像素格式

从国外论坛找了一下解决办法:

The class implements exhaustive template matching algorithm, which performs complete scan of source image, comparing each pixel with corresponding pixel of template.

The class processes only grayscale 8 bpp and color 24 bpp images.
So, those are the image formats you must use.

As requested, to convert to a specific pixel format, you can do this:

    public static Bitmap ConvertToFormat(this Image image, PixelFormat format)
    {
        Bitmap copy = new Bitmap(image.Width, image.Height, format);
        using (Graphics gr = Graphics.FromImage(copy))
        {
            gr.DrawImage(image, new Rectangle(0, 0, copy.Width, copy.Height));
        }
        return copy;
    }
中文翻译如下:
类实现了一个完整的扫描图像的模板匹配算法,对每个像素进行比较,并与相应像素的模板进行比较。
类只能处理灰度和彩色图像24 8 BPP BPP。
所以,这些都是你必须使用的图像格式。
按照要求,转换到一个特定的像素格式,可以做到这一点:
公共静态位图converttoformat(这个图像,像素格式格式)
{
位图拷贝=新的位图(image.width,图像。高度,格式);
使用(图形GR =图形图像(复制)。)
{
gr.drawimage(图像,新的矩形(0,0,宽度,高度复制。复制。));
}
返回副本;
}





上一篇:c# 连接Mysql数据库
下一篇:C#图片压缩算法
码农网,只发表在实践过程中,遇到的技术难题,不误导他人。
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

免责声明:
码农网所发布的一切软件、编程资料或者文章仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。如有侵权请邮件与我们联系处理。

Mail To:help@itsvse.com

QQ|手机版|小黑屋|架构师 ( 鲁ICP备14021824号-2 )|网站地图

GMT+8, 2024-3-28 20:44

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表