This project is read-only.

Skewed writable Bitmap

Apr 16, 2012 at 12:04 AM

I need to display a QR code in "Image" control in WPF.  I followed the example found in the "Documentation" part of this site.  The writable bitmap displayed when added to the Image's source property is skewed by about 45 degrees and the QR code looks as if it was cut into 3 separate, obliquely-oriented sections.  Sorry if that's not a better description but I couldn't figure out how to attach a screen shot.

 Could someone please tell me what I'm doing wrong or is this a known issue?  I'm running VS2010, Windows 7 (64-bit).

Thanks for such a great project otherwise.

Apr 16, 2012 at 2:46 AM

Check code under namespace Gma.QrCodeNet.Encoding.Windows.WPF, There is a control I did early which called QrCodeImgControl. You can either use that or according to code I did inside to create your own. 


I will also given out latest version out this week. I have recreate all WPF, Winform controls. It should be a proper example for you. Check back later you should find it under source code. 

Apr 16, 2012 at 5:11 AM
Edited Apr 16, 2012 at 5:20 AM

Check in 15096. 

You should find out new QrCodeImgControl under Gma.QrCodeNet.Encoding.Windows.WPF. 

It's now have most of properties change to DependencyProperty.  Also it's theme based. Check Xaml file under Theme folder. 

Lock and Freeze is useful when you want change more than 1 property in a row. Thus lock image update could increase performance. If not use those, bitmap will redraw everytime QrCode property changes. 

Lock is for ErrorCorrectLevel and Text change event, while Freeze is for property that dealing with visual effect. For example quietzone size, brush, DPI etc. 


Check in 15987

That one change function GetQrMatrix, so you could get a proper bitmatrix from control and use for wirtetostream method. Instead of encode again

Apr 16, 2012 at 12:44 PM

I think I got same issue as what you had before. Currently if I use Pbgra32 to create writeablebitmap, there won't be any issue. I will look into it and see if I can find out what exactly happen behind. 

Apr 17, 2012 at 2:25 AM

Found problem. It's memory issue. WriteableBitmap's data saved as int32 array, not byte. So when we use Gray8, every byte count as one colour. Which I thought maximum data will be pixelwidth * pixelheight. Which is not. row data which is pixelwidth / 4(int 32), if result is not integer, then they will give one more int32 for that row. It end up 1~3 byte more than pixelwidth. 

Pbgra32 does not have such issue because Pbgra32 present as int32, so pixelwidth * 4 = row byte. Where gray8 will sometime screw up. 

I will fix code and give proper implementation later today or tomorrow. 

Thanks for report this issue. 

Apr 17, 2012 at 5:46 AM

Fixed with check in 15134

Apr 17, 2012 at 9:08 AM

Silverlancer - many thanks.  I've been using your WPF control.  Absolutely brilliant and couldn't be easier to use.  Thanks again for your tremendous efforts.

Apr 17, 2012 at 10:02 PM

Glade you like it. Thanks for bug report.