cropng: switches for toggling horizontal/vertical cropping

mkfont: auto-offset by 1,1 when full outline is enabled
mkfont: better handling of glyph offsets
fuzz: added Child of Ash palette
This commit is contained in:
Marisa the Magician 2022-04-11 14:03:30 +02:00
commit b2a3b5063b
3 changed files with 82 additions and 18 deletions

View file

@ -207,6 +207,8 @@ int savepng( const char *fname, uint8_t *odata, uint32_t w, uint32_t h, int32_t
return 1;
}
int nocropx = 0, nocropy = 0;
void processpic( const char *fname )
{
printf("Processing '%s'...\n",fname);
@ -266,6 +268,16 @@ void processpic( const char *fname )
printf(" Crop region: (%u,%u) (%u,%u).\n",cropx,cropy,cropw,croph);
cropw -= cropx-1;
croph -= cropy-1;
if ( nocropx )
{
cropx = 0;
cropw = w;
}
if ( nocropy )
{
cropy = 0;
croph = h;
}
uint8_t *odata = calloc(cropw*croph,pxsize);
uint32_t ow = cropw, oh = croph;
int32_t ox = x-cropx, oy = y-cropy;
@ -291,14 +303,29 @@ void processpic( const char *fname )
int main( int argc, char **argv )
{
if ( argc < 2 )
int ac = 1;
if ( (argc > ac) && !strcmp(argv[ac],"-nx") )
{
nocropx = 1;
ac++;
}
if ( (argc > ac) && !strcmp(argv[ac],"-ny") )
{
nocropy = 1;
ac++;
}
if ( argc <= ac )
{
fprintf(stderr,
"usage: cropng <file> ...\n"
"usage: cropng [-nx] [-ny] <file> ...\n"
"\n"
"cropng will trim excess transparency from PNG images while updating grAb\n"
"offsets to compensate (existing ones will be re-used as a base)\n"
"\n"
"if the -nx argument is passed, it won't trim the width.\n"
"if the -ny argument is passed, it won't trim the height.\n"
"(if both arguments are passed, the program will not alter the image data)\n"
"\n"
"files are updated in-place, but a backup will be kept in case errors happen.\n"
"\n"
"cropng supports paletted, color and grayscale PNGs at both 8bpc and 16bpc.\n"
@ -308,6 +335,6 @@ int main( int argc, char **argv )
);
return 1;
}
for ( int i=1; i<argc; i++ ) processpic(argv[i]);
for ( int i=ac; i<argc; i++ ) processpic(argv[i]);
return 0;
}