Tower Unite

Tower Unite

评价数不足
How to remove that ugly border on transparent canvases
由 CarbonCopyCat 制作
Unnecessarily comprehensive guide on how to remove the (commonly white) fringing around transparent canvases. Uses GIMP.
   
奖励
收藏
已收藏
取消收藏
Introduction
When applying transparent images to canvases in your condo (particularly lower-resolution images), you might run into a weird white/black border around the opaque portions of your image, like so:


It's also possible that you might get strange white/black lines at the edges of the canvas:


This guide goes through how you can remove these fringes around your canvas images.
Technical Explanation (you can skip this)
Color fringe around opaque areas
Transparent images are made up of four fully opaque black and white images, combined together to form a full color image with transparency. Three of these are color channels (red, green, and blue), and one is the alpha channel, which dictates what portions of the image are transparent (black = 100% transparent, white = 100% opaque, shades of gray = partial transparency with amount depending on the shade).

When a pixel is marked as transparent, that pixel is marked black in the alpha channel, but still has values in the RGB (red, green, and blue) channels. As those RGB values aren't visible to the end user (because the pixel is transparent), this usually isn't an issue, but due to how Tower processes the image's alpha channel in-game, the RGB values of transparent pixels are visible as a border surrounding opaque pixels. Basically, when outlines are white, the surrounding transparent pixels are white, and when outlines are black, those pixels are black. If you can change the color (RGB values) of those transparent pixels, it will eliminate any visible outline as the color bleed from the transparent pixels will be the same color as the opaque pixels.

Lines on edges of the canvas
When an image is mapped onto a canvas, the canvas material appears to only show one instance of the image. However, in reality, the canvas material tiles the image, repeating it infinitely along the sides and top/bottom.


Because of this, the color bleed around the opaque pixels on one side of the image wraps around to the opposite side, causing a line to form on the edge of the other side of the image.
Requirements
This guide uses GIMP[www.gimp.org], as it's free and allows control over what color transparent pixels are, even when they're fully transparent. You're free to try other programs, but other image editors may discard the values of transparent pixels to reduce file size (setting them all to either black or white).
Step 1: Removing lines on the edge of the image
As the lines on the edges of the image are caused by image wrapping, you can eliminate them by adding a one-pixel border of transparent pixels around the image. This method adds a border on both the top/bottom and the sides, but if your image only has line artifacts on one side of the image, you can just add a one-pixel border to the side opposite to the affected edge instead (rather than on all four sides).
If the edges of your image look fine, you can skip this step.

Step 1:


Open your image, then navigate to "Image" → "Canvas Size".

Step 2:


Increase the height/width of your image by two pixels, select "Center", then click "Resize".
Step 2: Changing the colors of the transparent pixels
Step 1


Add a new layer by clicking the new layer icon.

Step 2


With the new layer selected, use the brush tool to paint the transparent pixels an appropriate color. To make the outline completely invisible, you'll want to make a transparent pixel the same color as the opaque pixel bordering it, but how detailed you actually want to go is up to you.
You can paint into the opaque portions of the image and can leave some transparent parts of the image transparent; you just want to make sure *all transparent pixels bordering opaque pixels are colored*.

Then, select the down arrow in the layer pane to move the layer underneath the original image's layer.

Step 3

Right click the original image's layer and select "Alpha to Selection".

Step 4

Right click the new layer and select "Add Layer Mask".

Step 5

Have the layer mask initialize to "Selection", then click "Add."

The image should now have the same alpha channel as it had originally, but with different RGB values for the transparent pixels.
Step 3: Saving the image properly
Step 1


Open the export dialog by navigating to "File" → "Export As..."

Step 2


Set your filename as [file].png, then hit Export.

Step 3


In the following menu, make sure "Save color values from transparent pixels" is checked, or else the colors of those transparent pixels will be discarded.

You can then upload your exported image to an image host for use in your condo.