简体   繁体   English

如何在Android中读取/编写自定义PNG元数据?

[英]How to read/write custom PNG metadata in Android?

I have to associate a couple of text parameters (a UUID and a couple of strings representing integers) to a PNG image in a way they can follow the image when the PNG file is passed from an Android device to another through the Net. 当PNG文件通过网络从Android设备传递到另一个设备时,我必须将一些文本参数(一个UUID和一些表示整数的字符串)与PNG图像关联起来。 This is the typical situation in which I would use a couple of custom auxiliary chuncks (similar to EXIF fields ) to store my data inside the PNG image itself. 这是典型的情况,我会使用一些自定义辅助组块(类似于EXIF字段)将我的数据存储在PNG图像本身中。

Maybe it is just me but the only info I was able to find about reading and writing PNG custom metadata from Java code on Android was this SO post: 也许只是我,但我能找到的关于从Android上的Java代码读取和编写PNG自定义元数据的唯一信息是这个SO帖子:

Writing image metadata in Java, preferably PNG 用Java编写图像元数据,最好是PNG

that even offers some code (quite verbose, as usual with Java). 甚至提供了一些代码(与Java一样,非常冗长)。

Those same SO post refers also to PNGJ: http://code.google.com/p/pngj/ 那些相同的SO帖子也指PNGJ: http//code.google.com/p/pngj/

To be honest, I would be happy to not use yet another library in this project. 说实话,我很乐意在这个项目中不再使用另一个库。

Does anybody know of others ways to write and read text metadata in a PNG file in Android? 有人知道其他人在Android的PNG文件中编写和阅读文本元数据的方法吗? Maybe a less verbose way... Maybe a way that does not require a separated library.... 也许是一种不那么冗长的方式......也许是一种不需要分离库的方式....

Any other source of information? 还有其他任何信息来源吗? Any tutorial? 任何教程? Any example? 任何例子?

I'm open to use a different (but equivalent) image file format, if needed (JPEG, whatever). 如果需要,我可以使用不同的(但等效的)图像文件格式(JPEG,无论如何)。

A solution working also on iOS and Windows 8 Phone would be a plus but it is not actually required. 在iOS和Windows 8 Phone上运行的解决方案也是一个优势,但实际上并不需要。

I had to do something similar lately, so I had to study the subject. 我最近不得不做类似的事情,所以我不得不研究这个主题。 Android offers you no option of manipulating png metadata. Android不提供操作png元数据的选项。 You will have to use an external library (PNGJ seems like a good option). 您将不得不使用外部库(PNGJ似乎是一个很好的选择)。 In my case, since I am making changes to the Android frameworks, I didn't use an external lib, but made changes to skia (the Android graphics library instead). 在我的情况下,由于我正在对Android框架进行更改,我没有使用外部库,而是对skia(Android图形库)进行了更改。

If you need more info on that I can give you, but I think it's irrelevant in your case. 如果您需要更多信息,我可以给您,但我认为这与您的情况无关。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM