2017-05-04 03:06:50 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "loadpng.h"
|
2019-09-04 19:49:53 +00:00
|
|
|
#include "rle_common.h"
|
2017-08-13 20:24:57 +00:00
|
|
|
|
2017-07-10 18:52:24 +00:00
|
|
|
|
2017-12-15 19:15:26 +00:00
|
|
|
|
2017-12-15 20:25:26 +00:00
|
|
|
/*****************************************/
|
|
|
|
/* \/ \/ */
|
|
|
|
/* Converts a PNG to RLE compressed data */
|
|
|
|
/*****************************************/
|
|
|
|
|
|
|
|
|
2017-12-15 19:15:26 +00:00
|
|
|
|
|
|
|
/* Converts a PNG to RLE compressed data */
|
|
|
|
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
|
|
|
|
unsigned char *image;
|
|
|
|
int xsize,ysize;
|
|
|
|
int size=0;
|
|
|
|
int out_type=OUTPUT_C;
|
|
|
|
|
|
|
|
if (argc<4) {
|
|
|
|
fprintf(stderr,"Usage:\t%s type INFILE varname\n\n",argv[0]);
|
2018-09-28 01:10:08 +00:00
|
|
|
fprintf(stderr,"\ttype: c or asm or raw\n");
|
2018-02-16 05:12:53 +00:00
|
|
|
fprintf(stderr,"\tvarname: label for graphic\n");
|
|
|
|
fprintf(stderr,"\n");
|
|
|
|
|
2017-12-15 19:15:26 +00:00
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!strcmp(argv[1],"c")) {
|
|
|
|
out_type=OUTPUT_C;
|
|
|
|
}
|
|
|
|
else if (!strcmp(argv[1],"asm")) {
|
|
|
|
out_type=OUTPUT_ASM;
|
|
|
|
}
|
2018-09-28 01:10:08 +00:00
|
|
|
else if (!strcmp(argv[1],"raw")) {
|
|
|
|
out_type=OUTPUT_RAW;
|
|
|
|
}
|
2017-12-15 19:15:26 +00:00
|
|
|
|
2019-09-04 19:49:53 +00:00
|
|
|
if (loadpng(argv[2],&image,&xsize,&ysize,PNG_WHOLETHING)<0) {
|
2017-12-15 19:15:26 +00:00
|
|
|
fprintf(stderr,"Error loading png!\n");
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
|
2020-03-04 21:14:41 +00:00
|
|
|
fprintf(stderr,"Loaded image %s,%d by %d\n",argv[2],xsize,ysize);
|
2017-12-15 19:15:26 +00:00
|
|
|
|
2017-12-15 20:25:26 +00:00
|
|
|
// size=rle_original(out_type,argv[3],
|
|
|
|
// xsize,ysize,image);
|
|
|
|
|
|
|
|
size=rle_smaller(out_type,argv[3],
|
2017-12-15 19:15:26 +00:00
|
|
|
xsize,ysize,image);
|
|
|
|
|
2017-08-13 20:24:57 +00:00
|
|
|
fprintf(stderr,"Size %d bytes\n",size);
|
2017-07-08 05:19:06 +00:00
|
|
|
|
2017-05-04 03:06:50 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2017-12-15 19:15:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|