【发布时间】:2016-04-11 16:54:54
【问题描述】:
我创建了一张 VCard / 名片。我需要从该 Vcard 创建 QR 码。当用户扫描二维码时,会显示将该电子名片保存在联系人列表中的选项。我可以从字符串生成二维码,但我不知道如何生成 StorageFile / Vcard 的二维码。
这是我的代码。
protected async override void OnNavigatedTo(NavigationEventArgs e)
{
vcard = e.Parameter as StorageFile;
IBarcodeWriter writer = new BarcodeWriter
{
Format = BarcodeFormat.QR_CODE,
Options = new ZXing.Common.EncodingOptions
{
Height = 300,
Width = 300
}
};
var result2 = vcard;
// Result2 contain vcard. but writer.Write() need string formate.
// below commented line display error. because result2 is not string
// var result = writer.Write(result2);
var result = writer.Write(result2.ToString());
var wb = result.ToBitmap() as WriteableBitmap;
//add to image component
bar_image.Source = wb;
}
【问题讨论】:
-
除非您发现自己有一个用于读取信息的 vCard 库,否则您必须自己打开文件并对其进行解码。一些有用的链接:en.wikipedia.org/wiki/VCard
-
我自己创建了这个 Vcard。现在我想生成这个 VCard 的二维码。以上链接用于生成 VCard。
-
您可以将联系人信息(如姓名电子邮件等)从 Vcard 附加到一个字符串并将其传递给编写器函数
-
是的,我这样做了,由此生成的 QR 码.. 但是当用户扫描该 QR 码时,所有数据都以字符串形式显示。不是电子名片。
-
@ChubosaurusSoftware 你能帮我解决这个问题吗? stackoverflow.com/questions/43122189/…
标签: c# windows-phone-8.1 windows-store-apps qr-code vcf-vcard