如何重新设置BMP文件的分辨率(DPI)指示器? [英] How do I re-set a BMP file's resolution (DPI) indicator?

查看:880
本文介绍了如何重新设置BMP文件的分辨率(DPI)指示器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的BMP标记为299 DPI分辨率。我想将其改为99 DPI。

I have a BMP tagged as 299 DPI resolution. I'd like to change that to 99 DPI.

重要的是,BMP中的DPI标记没有结构意义。图像在像素中具有一定的宽度和高度。显示应用程序可以以英寸为单位显示任何宽度的图像。

Importantly, the DPI marker in a BMP has no structural meaning. An image has a certain width and height in pixels. The displaying application can show the image at any width in inches.

所以,DPI只是一个提示。

So, the DPI is just a hint.

但是,我正在处理一些第三方软件,这些软件的行为会因标记而异,所以我需要重新设置它。

However, I am dealing with some third-party software which behaves differently depending on this marker, so I need to re-set it.

我将非常感谢有关如何以Java编程方式以及GUI图形工具(例如Gimp)执行此操作的建议。

I will appreciate suggestions on how to do this programmatically in Java, as well as in GUI graphics tools (e.g. Gimp).

推荐答案

对于Java部分,您可以使用 img4j 库。
您有BMP编码器和解码器。 InfoHeader 类有一个iXpixelsPerM和iYpixelsPerM到设定分辨率。您可以查看BMP文件格式此处以获取更多信息。

for the Java part, you can use the img4j library. You have an encoder and a decoder for BMP. The InfoHeader class has a iXpixelsPerM and iYpixelsPerM to set the resolution. You chan check the BMP file format here to have more information.

此外,由于库是开源的,您将能够检查并了解代码的工作方式,并且您将能够根据自己的需要进行调整(如果它符合您的许可模式。)

Moreover, as the library is opensource, you'll be able to check and understand how the code is working and you'll be able to adapt it to fit your needs (if it complies with your licensing model).

(新年快乐!:)

这篇关于如何重新设置BMP文件的分辨率(DPI)指示器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆