This article is a mirror article of machine translation, please click here to jump to the original article.

View: 21811|Reply: 0

[Source] Unsupported pixel format of the source or template image

[Copy link]
Posted on 11/23/2015 3:46:28 PM | | | |
Today, the following error was reported when using aforgr.net for image processing:





Unsupported pixel format of the source or template image
The pixel format is not supported for the source or template image

I found a solution from a foreign forum:

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;
    }
The Chinese translation is as follows:
class implements a complete template matching algorithm for scanned images, comparing each pixel and comparing it to the template of the corresponding pixel.
The class can only handle grayscale and color images24 8 BPP BPP.
So, these are the image formats you must use.
As required, converting to a specific pixel format, this can be done:
Public static bitmap converttoformat (this image, pixel format format)
{
bitmap copy = new bitmap (image.width, image. height, format);
Use (Graphic GR = Graphic Image (Copy). )
{
gr.drawimage(image, new rectangle (0,0, width, height copy. Copy. ));
}
Return to the copy;
}





Previous:c# Connect to the Mysql database
Next:C# image compression algorithm
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com