1
私はQRコードを完全に生成しているQRコントロールを持っています。私はそれを私の電話でスキャンすると完全に動作します。しかし、イメージに変換することができないので、データベースに保存することができます。私は彼らのウェブサイトを見てきましたが、何も見つけることができません.WinFormsには何もWPFやWebがありません。ここ は、私はQRコードUltraQRCodeBarcode Infragistics WinFormsコントロールをイメージに変換するにはどうすればよいですか?
private void btnGenerate_Click(object sender, EventArgs e)
{
string data = string.Empty;
var fullName = txtFirstName + " " + txtMiddleName + " " + txtLastName;
if (!string.IsNullOrEmpty(txtLicenceNumber.Text))
{
data = fullName;
data += ", " + Environment.NewLine + txtDistrict.Text;
data += ", " + Environment.NewLine + txtLicenceNumber.Text;
data += ", " + Environment.NewLine + txtRegistrationCode;
}
ultraQRCodeBarcode1.Data = data;
}
を生成し、これは私がバイトコードにそれを変換し、 を保存しようとしている。しかし、私はこの中の画像のように何のプロパティがありません成功しないんだけど、私の保存方法がいかにあります1。
user.QrCode = ImageToByteArray(ultraQRCodeBarcode1.);
画像変換
private byte[] ImageToByteArray(string imagePath)
{
byte[] data = null;
var fileInfo = new FileInfo(imagePath);
long numBytes = fileInfo.Length;
var fileStream = new FileStream(imagePath, FileMode.Open, FileAccess.Read);
var binaryReader = new BinaryReader(fileStream);
data = binaryReader.ReadBytes((int)numBytes);
return data;
}