sjlim70 / aforge

Automatically exported from code.google.com/p/aforge
Other
0 stars 0 forks source link

ProcessImage support for 32bpp #398

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Currently ExhaustiveTemplateMatching.ProcessImage only supports 8bpp or 24bpp.  
Many sources produce 32bpp images.

Looks simple and straight forward to use pixelSize of 4 in the case of 32bpp.  
This code worked for 32bpp images tested:

            int pixelSize = PixelSize(image.PixelFormat);

        private static int PixelSize(PixelFormat pixelFormat)
        {
            switch (pixelFormat)
            {
                case PixelFormat.Format8bppIndexed:  // 8 bits per pixel
                    return 1;
                case PixelFormat.Format24bppRgb:    // 8 bits per color (Red Green Blue)
                    return 3;
                case PixelFormat.Format32bppRgb:    // 8 bits per color (Red Green Blue)
                case PixelFormat.Format32bppArgb:   // 8 bits per color (Alpha Red Green Blue )
                case PixelFormat.Format32bppPArgb:  // 8 bits per color (Alpha Red Green Blue premultiplied
                    return 4;
                default:
                    throw new UnsupportedImageFormatException("Unsupported image pixel format.");
            }
        }

Original issue reported on code.google.com by commenti...@gmail.com on 4 Mar 2015 at 3:30

Attachments: