How to Change DPI in Java

If designing a Java application that shows off images, you will find it important for the images to be the proper size. The dots per inch (dpi) image resolution is typically applied to printing, and so specifying the size will be different straightaway. If you are handling a PNG image, the unit is dots per millimeter and, if you are using a JPG, the unit is decimeter per dot. Therefore, you will need to convert the wanted dpi to represent your image size in the appropriate format. For this purpose, it is easiest to use PNG images.

Instructions

    • 1

      Open your Java application.

    • 2

      Locate the image tag in your Java script.

    • 3

      Insert the following lines of code before the image, replacing each "value" with the value of the dots per millimeter you want to use:

      <!ELEMENT "HorizontalPixelSize" EMPTY>

      <!-- The width of a pixel, in millimeters,

      as it should be rendered on media -->

      <!ATTLIST "HorizontalPixelSize" "value" #CDATA #REQUIRED>

      <!-- Data type: Float -->

      <!ELEMENT "VerticalPixelSize" EMPTY>

      <!-- The height of a pixel, in millimeters,

      as it should be rendered on media -->

      <!ATTLIST "VerticalPixelSize" "value" #CDATA #REQUIRED>

      <!-- Data type: Float -->

    • 4

      Convert dpi to dpm (dots per millimeter). Multiply the desired inches by 25.4 to find the dots per millimeter you want to use.

Related Searches:

References

Comments

Related Ads

Featured