2021-09-21 21:37:43 +00:00
|
|
|
#define PROGRAM_NAME "png_dimensions"
|
|
|
|
#define USAGE_OPTS "front.png front.dimensions"
|
2016-08-25 01:56:07 +00:00
|
|
|
|
2021-09-21 21:37:43 +00:00
|
|
|
#include "common.h"
|
2016-08-25 01:56:07 +00:00
|
|
|
|
2021-09-02 22:37:36 +00:00
|
|
|
uint8_t read_png_dimensions(const char *filename) {
|
2022-03-03 02:39:13 +00:00
|
|
|
uint32_t width_px = read_png_width(filename);
|
2021-09-02 04:21:10 +00:00
|
|
|
if (width_px != 40 && width_px != 48 && width_px != 56) {
|
2021-09-02 07:04:40 +00:00
|
|
|
error_exit("Not a valid width for \"%s\": %" PRIu32 " px\n", filename, width_px);
|
2017-12-28 06:25:25 +00:00
|
|
|
}
|
2021-09-02 04:21:10 +00:00
|
|
|
uint8_t width_tiles = (uint8_t)(width_px / 8);
|
|
|
|
return (width_tiles << 4) | width_tiles;
|
2016-08-25 01:56:07 +00:00
|
|
|
}
|
|
|
|
|
2021-09-02 04:21:10 +00:00
|
|
|
int main(int argc, char *argv[]) {
|
2016-08-25 01:56:07 +00:00
|
|
|
if (argc < 3) {
|
2021-09-21 21:37:43 +00:00
|
|
|
usage_exit(1);
|
2016-08-25 01:56:07 +00:00
|
|
|
}
|
2021-09-02 05:21:15 +00:00
|
|
|
|
2021-09-02 22:37:36 +00:00
|
|
|
uint8_t output_byte = read_png_dimensions(argv[1]);
|
2021-09-02 04:21:10 +00:00
|
|
|
write_u8(argv[2], &output_byte, 1);
|
2016-08-25 01:56:07 +00:00
|
|
|
return 0;
|
|
|
|
}
|