I'm decoding the PDF417 2D Barcode in a scanned image using Zxing.Net library. So far, I have found the gray-scale scanned image(8bit depth) is working fine and the color scanned image(24 bit depth) is not working. I tried to covert the color scanned image to the gray-scale image using the below method.
private BitmapSource ConvertGray(BitmapSource bi)
{
FormatConvertedBitmap newFormatedBitmapSource = new FormatConvertedBitmap();
newFormatedBitmapSource.BeginInit();
newFormatedBitmapSource.Source = bi;
newFormatedBitmapSource.DestinationFormat = PixelFormats.Gray8;
newFormatedBitmapSource.EndInit();
return newFormatedBitmapSource;
}
But, the Zxing.net could not detect the PDF417 2D Barcode in the converted gray-scale image. How I can convert the color scanned image to the gray-scale image that is same format as the gray-scale scanned image.