FreeImage - 将 zTXt 标签写入 PNG

发布于 2024-09-11 06:03:20 字数 845 浏览 7 评论 0原文

这实在是让我很头疼。由于某种原因,我可以向 PNG 文件添加特定标签,但它没有按照我想要的方式添加,而且我不知道如何让它按照我想要的方式编写

给定代码;

    Dim FImage As FIBITMAP = FreeImage.CreateFromBitmap(Image)

    Dim FTag As New Metadata.MetadataTag(FREE_IMAGE_MDMODEL.FIMD_COMMENTS)
    FTag.Key = "Description"
    FTag.ID = 270

    FTag.Value = Encoding.ASCII.GetBytes(DescString.ToString)
    FTag.AddToImage(FImage)


    FreeImage.Save(FREE_IMAGE_FORMAT.FIF_PNG, FImage, fbSaveTo.SelectedPath & "\TEST.dmi", FREE_IMAGE_SAVE_FLAGS.EXR_ZIP Or FREE_IMAGE_SAVE_FLAGS.PNG_Z_BEST_COMPRESSION)

假设 Image 是有效的,而 DescString 也是有效的(它是一个字符串生成器)。我正在尝试添加图像描述标签,我想将其专门编写为PNG文件中的zTXt块,因为我需要具有该格式以便使该文件与另一个目标程序(Dream Maker)兼容。相反,它会写入一个 iTXt 标记,Dream Maker 不会读取该标记,这使得该文件毫无用处。

任何熟悉 FreeImage 的人都可以帮助我吗?或者有人可以推荐一个可以集成到我的程序中的替代方案吗?

This is really causing me a headache. For some reason or another, I can add a specific tag to a PNG file, but it's not adding the way I'd like and I don't know how to get it to write the way I want

Given the code;

    Dim FImage As FIBITMAP = FreeImage.CreateFromBitmap(Image)

    Dim FTag As New Metadata.MetadataTag(FREE_IMAGE_MDMODEL.FIMD_COMMENTS)
    FTag.Key = "Description"
    FTag.ID = 270

    FTag.Value = Encoding.ASCII.GetBytes(DescString.ToString)
    FTag.AddToImage(FImage)


    FreeImage.Save(FREE_IMAGE_FORMAT.FIF_PNG, FImage, fbSaveTo.SelectedPath & "\TEST.dmi", FREE_IMAGE_SAVE_FLAGS.EXR_ZIP Or FREE_IMAGE_SAVE_FLAGS.PNG_Z_BEST_COMPRESSION)

Assume that Image is valid and that DescString is too (it's a stringbuilder). I'm trying to add the Image Description tag, which I want to have written specifically as a zTXt chunk in the PNG file, as I need to have that format in order for the file to be compatible with another target program (Dream Maker). Instead, it writes an iTXt tag, which Dream Maker doesn't read which makes the file useless.

Can anyone familiar with FreeImage help me out, or could anyone recommend an alternative that I can integrate into my program?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文