1
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
2
/* If you are missing that file, acquire a complete release at teeworlds.com. */
4
#include <base/system.h>
5
#include <engine/external/pnglite/pnglite.h>
9
unsigned char r, g, b, a;
12
static void TilesetBorderset(int w, int h, CPixel *pSrc, CPixel *pDest)
17
for(int tx = 0; tx < 16; tx++)
19
for(int ty = 0; ty < 16; ty++)
21
for(int x = 0; x < TileW; x++)
23
for(int y = 0; y < TileH; y++)
25
#define TILE_INDEX(tx_, ty_, x_, y_) (((ty_) * TileH + (y_)) * w + (tx_) * TileW + (x_))
26
pDest[TILE_INDEX(tx, ty, x, y)] = pSrc[TILE_INDEX(tx, ty, clamp(x, 2, TileW - 3), clamp(y, 2, TileH - 3))];
34
int FixFile(const char *pFileName)
37
CPixel *pBuffer[2] = {0,0};
40
png_open_file(&Png, pFileName);
42
if(Png.color_type != PNG_TRUECOLOR_ALPHA)
44
dbg_msg("tileset_borderset", "%s: not an RGBA image", pFileName);
51
pBuffer[0] = (CPixel*)mem_alloc(w*h*sizeof(CPixel), 1);
52
pBuffer[1] = (CPixel*)mem_alloc(w*h*sizeof(CPixel), 1);
53
png_get_data(&Png, (unsigned char *)pBuffer[0]);
56
TilesetBorderset(w, h, pBuffer[0], pBuffer[1]);
59
png_open_file_write(&Png, pFileName);
60
png_set_data(&Png, w, h, 8, PNG_TRUECOLOR_ALPHA, (unsigned char *)pBuffer[1]);
66
int main(int argc, const char **argv)
71
dbg_msg("Usage", "%s FILE1 [ FILE2... ]", argv[0]);
75
for(int i = 1; i < argc; i++)