Add image height check to cabi.c

An image converted using the cabi utility must have a height that is
a multiple of 8 pixels. An error is now reported if not.

Also, the README.md file for cabi was updated with this requirement.
This commit is contained in:
Scott Allen 2020-09-27 21:58:57 -04:00
parent 2baca75689
commit 500d81abb7
2 changed files with 14 additions and 5 deletions

View File

@ -77,10 +77,13 @@ given and a non-zero exit code will be returned.
## Input file decoding
The input file should be a PNG file containing the image to be converted. The
image will be translated to a raw array of 32 bit RGBA (Red, Green, Blue, Alpha)
pixels internally before being processed to output. Ideally, pixels that are to
be drawn (represented as a 1 in the image output) should be fully white.
The input file should be a PNG file containing the image to be converted.
The height of the image must be a multiple of 8 pixels (8, 16, 24, 32, ...).
The width can be any size.
The image will be translated to a raw array of 32 bit RGBA (Red, Green, Blue,
Alpha) pixels internally before being processed to output. Ideally, pixels that
are to be drawn (represented as a 1 in the image output) should be fully white.
Non-drawn (0) pixels should be fully black. Pixels intended to be masked out of
the image (represented as a 0 in both the image and mask output), should be
fully transparent and their color doesn't matter.

View File

@ -11,7 +11,7 @@ https://www.lexaloffle.com/bbs/?uid=1
https://twitter.com/lexaloffle
Contributed to Team A.R.G.
Modifications by Scott Allen - July 2016
Modifications by Scott Allen - July 2020, September 2020
To the extent possible under law, the author(s) have dedicated all copyright
and related and neighboring rights to this software to the public domain
@ -332,6 +332,12 @@ int main(int argc, char **argv)
exit(result);
}
if (h % 8 != 0) {
printf("error 120: file %s: image height must be a multiple of 8 but is %u\n", argv[1], h);
free(bmp);
exit(120);
}
// generate sprite and mask
rawlen = w * (h+7) / 8;