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;
}
|