Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
35
QR Code scanner - not decoding for static png/jpg images
posted

I am trying something like this in my WPF application,

Uri ur = new Uri("\\Samples\\Infragistics_Barcode_Reader_01.png", UriKind.RelativeOrAbsolute);
            var test = Application.GetResourceStream(ur);
           
            BitmapImage bi = new BitmapImage(ur);
            Bitmap bmp1 = new Bitmap(test.Stream);
            MemoryStream ms = new MemoryStream();
            bmp1.Save(ms, ImageFormat.Png);
            ms.Seek(0, SeekOrigin.Begin);

            BitmapImage bmap = new BitmapImage();
            bmap.BeginInit();
            bmap.StreamSource = ms;
           
            bmap.EndInit();
             BitmapDecoder bitmapDecoder = BitmapDecoder.Create( ms,
                BitmapCreateOptions.PreservePixelFormat,
                BitmapCacheOption.OnLoad);

            // This will disconnect the stream from the image completely...
            WriteableBitmap writable =
            new WriteableBitmap(bitmapDecoder.Frames.Single()); 

writable.Freeze();

            BarcodeReader barcodeReader = new BarcodeReader();            
            barcodeReader.DecodeComplete += new EventHandler<ReaderDecodeArgs>(BarcodeReader_DecodeComplete);
            barcodeReader.Decode(writable);

However, it doesnt decode, and the e.SymbolFound and value properties remain unchanged. Am i doing something wrong or does it require a bitmapsource in a specific format?
I am using a standard QR code image.

Parents
No Data
Reply
  • 138253
    Offline posted

    Hello,

     

    I am just checking the progress of this issue and was wondering if you managed to achieve your goal or if you need any further assistance on the matter.

Children
No Data