Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProcessImage support for 32bpp #398

Open
GoogleCodeExporter opened this issue Apr 17, 2016 · 0 comments
Open

ProcessImage support for 32bpp #398

GoogleCodeExporter opened this issue Apr 17, 2016 · 0 comments

Comments

@GoogleCodeExporter
Copy link

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 [email protected] on 4 Mar 2015 at 3:30

Attachments:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant