728x90
반응형

 

 

             xmlns:zx="clr-namespace:ZXing.Net.Mobile.Forms;assembly=ZXing.Net.Mobile.Forms"

             xmlns:zxcm="clr-namespace:ZXing.Common;assembly=zxing.portable"

 

            <zx:ZXingBarcodeImageView x:Name="barcodeImage" BarcodeFormat="QR_CODE" BarcodeValue="{Binding QrCodeString}" WidthRequest="180" HeightRequest="180">

                <zx:ZXingBarcodeImageView.BarcodeOptions>

                    <zxcm:EncodingOptions Width="450" Height="450" />

                </zx:ZXingBarcodeImageView.BarcodeOptions>

            </zx:ZXingBarcodeImageView>

 

 

 

반응형
728x90
반응형

 

 

public Stream ConvertImageStream(string text, int width = 300, int height = 300)

{

var barcodeWriter = new ZXing.Mobile.BarcodeWriter

{

Format = ZXing.BarcodeFormat.QR_CODE,

Options = new ZXing.Common.EncodingOptions

{

Width = width,

Height = height,

Margin = 10

}

};

 

barcodeWriter.Renderer = new ZXing.Mobile.BitmapRenderer();

var bitmap = barcodeWriter.Write(text);

var stream = new MemoryStream();

bitmap.Compress(Bitmap.CompressFormat.Png, 100, stream);

stream.Position = 0;

return stream;

}

 

 

반응형

+ Recent posts