问题描述
通过最新的NFC标签,可以存储多达8K就可以了。
所以,我想知道如何存储的照片上的标记,像恩智浦是否tagwriter应用程序?
我没有发现任何关于它的信息。
在此先感谢
With the latest nfc tags, it is possible to store up to 8k on it.So I would like to know how store picture on a tag, like the tagwriter Application by NXP does ?I found no information about it.Thanks in advance
推荐答案
您可以使用MIME类型的记录存储在NFC标签的图像。如果,例如,你的图像是JPEG图像,你可以使用MIME类型为图像/ JPEG。你NDEF记录然后可以是这样的:
You can use MIME type records to store images on NFC tags. If, for instance, your image is a JPEG image, you would use the MIME type "image/jpeg". You NDEF record could then look like this:
+----------------------------------------+
+ MB=1, ME=1, CF=0, SR=0, IL=0, TNF=MIME +
+----------------------------------------+
+ Type Length = 10 +
+----------------------------------------+
+ Payload Length = N +
+----------------------------------------+
+ image/jpeg +
+----------------------------------------+
+ <Your image data (N bytes)> +
+----------------------------------------+
在Android上,您使用可以创建这样的记录
On Android, you could create such a record using
byte[] myImage = ...;
NdefRecord myImageRecord = NdefRecord.createMime("image/jpeg", myImage);
,或使用构造 NdefRecord
:
byte[] myImage = ...;
NdefRecord myImageRecord = new NdefRecord(
NdefRecord.TNF_MIME_MEDIA,
"image/jpeg".getBytes("US-ASCII"),
null,
myImage
);
一旦你有一个标签
的NDEF标签的柄(即通过接收和NFC发现意向),然后你可以写NDEF记录到标签:
Once you have a Tag
handle of an NDEF tag (i.e. through receiving and NFC discovery intent), you could then write the NDEF record to the tag:
NdefMessage ndefMsg = new NdefMessage(new NdefRecord[] { myImageRecord });
Tag tag = ...;
Ndef ndefTag = Ndef.get(tag);
if (ndefTag != null) {
ndefTag.connect();
ndefTag.writeNdefMessage(ndefMsg);
ndefTag.close();
} else {
NdefFormatable ndefFormatable = NdefFormatable.get(tag);
if (ndefFormatable != null) {
ndefFormatable.connect();
ndefFormatable.format(ndefMsg);
ndefFormatable.close();
}
}
这篇关于图片上的NFC标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!