Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Image Expander  (Read 7345 times)

0 Members and 1 Guest are viewing this topic.

Hapax

  • Hero Member
  • *****
  • Posts: 3462
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Image Expander
« on: October 21, 2025, 01:22:06 am »
Image Expander: expands the outside pixels of rectangular portions of an image.

A common issue people have with tilemaps is that there are sometimes noticeable gaps, especially when scaling or using some other transformation.
This is generally due to Open GL picking the 'wrong' pixel, where it chooses to use the pixel directly outside of the given rectangle.

That's where this may come in handy!

As long as all of your tiles are at least 2 pixels apart, all you need to do is load the image as normal, use this Image Expander on each tile by specifying its rectangle within the image you should notice a significant decrease in these unwanted artifacts (it should fix it entirely).

Here is an example image (the example used to create it is shown on the wiki page):

The original tileset (tiles are spaced 2 pixels apart) is on the left, the processed image (using Image Expander) is on the right.

Here is that processed image at double size:


Here is the wiki page for the code (function and example) and more information:
https://github.com/SFML/SFML/wiki/Source:-Image-Expander
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*