LoginSignup
1
2

More than 3 years have passed since last update.

QRCodeEncoderDecoderLibraryを用いてQRコードをデコードする(読み込む)Csharpの単体アプリを作る

Last updated at Posted at 2019-03-21

QRCodeEncoderDecoderLibraryを用いてQRコードをデコードする(読み込む)Csharpの単体アプリを作る

※ライブラリは以下参照
QR Code Encoder and Decoder .NET Class Library
https://www.codeproject.com/Articles/1250071/QR-Code-Encoder-and-Decoder-NET-Class-Library-Writ

QRCodeEncoderDecoderLibrary.dll
QRCodeEncoderDecoderLibrary.dll

sample_qr_decode
//c:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /reference:QRCodeEncoderDecoderLibrary.dll /target:winexe sample_qr_decode.cs

using System;
using System.Windows.Forms;
using System.Drawing;
using QRCodeEncoderDecoderLibrary;

public class sample_qr_decode
{
 public static void Main(string[] args)
 {
    QRDecoder   QRCodeDecoder;
    Bitmap      QRCodeInputImage;

    QRCodeDecoder = new QRDecoder();

    QRCodeInputImage = new Bitmap(@".\\QR.png",true);

    byte[][] DataByteArray = QRCodeDecoder.ImageDecoder(QRCodeInputImage);

    //string Result = System.Text.Encoding.GetEncoding(932).GetString(DataByteArray[0]);
    string Result = System.Text.Encoding.UTF8.GetString(DataByteArray[0]);

    MessageBox.Show(Result);

 }

}

コンパイル(csc.exeのパスは、適宜修正。DLLは、ソースと同階層に置いてある前提。)

c:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /reference:QRCodeEncoderDecoderLibrary.dll /target:winexe sample_qr_decode.cs

実行(同階層の、QR.pngを読み込んでいる。ソース参照)

sample_qr_decode.exe

注:GetEncoding(932)は、SJIS
注:エンコード(作成)とデコード(読込)で、文字コードをあわせないと、処理オチすることが多い。

結果
キャプチャ.PNG
QR.PNG

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2