Gearhead RPG Wikia

Guides:Dithering[]

Contents[]

[hide]

  • 1 Converting 32-bit images with alpha channels to 24-bit dithered images
    • 1.1 Step one: Generate an image with an alpha channel
    • 1.2 Step two: Decrease the color-depth of the alpha channel
    • 1.3 Step three: Remove all information masked by the alpha channel
    • 1.4 Step four: Remove the alpha channel and save your image
    • 1.5 Example ImageMagick command-line

[edit]

Converting 32-bit images with alpha channels to 24-bit dithered images[]

Sometimes you need the benifits of having varied opacity (such as when creating effects that are overlayed on top of sprites, like fire or smoke), but for technical reasons can't utilize 8-bit transparency. In these cases you can use the information in the alpha channel to dither the image in order to approximate the effect.

[edit]

Step one: Generate an image with an alpha channel[]

You can use a ray-tracer, such as POV-Ray, for this. Make sure it utilizes the alpha channel for the transparency information. Using anti-aliasing also can't hurt since there's no colored background for edges to bleed into.

[edit]

Step two: Decrease the color-depth of the alpha channel[]

Open your image in an image editor, such as The GIMP. Decrease the color-depth of the alpha channel (a.k.a. the mask layer) to 1 bit (2 colors). (You may have to export the alpha channel as a new image, first.)

[edit]

Step three: Remove all information masked by the alpha channel[]

Select all pixels in the alpha channel that aren't white. Apply the selection to the other channels and cut these pixels to make them pure blue (RGB 0,0,1).

[edit]

Step four: Remove the alpha channel and save your image[]

Delete the alpha channel (the mask), as it's no longer needed. Then save your image.

[edit]

Example ImageMagick command-line[]

Here's an example command-line for ImageMagick that can be used in a batch file to automate the process:

set InName="Walls_Arena11.png"
set OutName="Walls_Arena11_output.png"
convert %InName% ( -channel A -ordered-dither 2x1 ) ( -compose CopyOpacity -composite ) %OutName%
convert %OutName% ( -background blue -flatten ) %OutName%
convert %OutName% ( -transparent blue ) %OutName%