mirror of
https://github.com/deater/dos33fsprogs.git
synced 2025-01-29 21:31:53 +00:00
gr-utils: add new png2gr_text util
This commit is contained in:
parent
e441cd4420
commit
3eb5e013fa
@ -2,7 +2,7 @@ include ../Makefile.inc
|
||||
|
||||
CFLAGS = -g -Wall -O2
|
||||
|
||||
all: png2gr png2rle png_to_40x48d png_to_40x96
|
||||
all: png2gr png2gr_text png2rle png_to_40x48d png_to_40x96
|
||||
|
||||
|
||||
###
|
||||
@ -21,6 +21,14 @@ png2gr.o: png2gr.c loadpng.h
|
||||
|
||||
###
|
||||
|
||||
png2gr_text: png2gr_text.o loadpng.o
|
||||
$(CC) $(LFLAGS) -lpng -o png2gr_text png2gr_text.o loadpng.o
|
||||
|
||||
png2gr_text.o: png2gr_text.c loadpng.h
|
||||
$(CC) $(CFLAGS) -c png2gr_text.c
|
||||
|
||||
###
|
||||
|
||||
png2rle: png2rle.o loadpng.o
|
||||
$(CC) $(LFLAGS) -lpng -o png2rle png2rle.o loadpng.o
|
||||
|
||||
@ -48,8 +56,8 @@ png_to_40x96.o: png_to_40x96.c
|
||||
###
|
||||
|
||||
install:
|
||||
cp png2gr png2rle png_to_40x48d png_to_40x96 $(INSTALL_LOC)
|
||||
cp png2gr png2gr_text png2rle png_to_40x48d png_to_40x96 $(INSTALL_LOC)
|
||||
|
||||
clean:
|
||||
rm -f *~ *.o png2gr png2rle png_to_40x48d png_to_40x96
|
||||
rm -f *~ *.o png2gr png2gr_text png2rle png_to_40x48d png_to_40x96
|
||||
|
||||
|
@ -40,7 +40,7 @@ int main(int argc, char **argv) {
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
printf("Loaded image %d by %d\n",xsize,ysize);
|
||||
fprintf(stderr,"Loaded image %d by %d\n",xsize,ysize);
|
||||
|
||||
short gr_offsets[]={
|
||||
0x400,0x480,0x500,0x580,0x600,0x680,0x700,0x780,
|
||||
|
63
gr-utils/png2gr_text.c
Normal file
63
gr-utils/png2gr_text.c
Normal file
@ -0,0 +1,63 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "loadpng.h"
|
||||
|
||||
/* Converts a PNG to a GR file you can BLOAD to 0x400 */
|
||||
/* HOWEVER you *never* want to do this in real life */
|
||||
/* as it will clobber important values in the memory holes */
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
int row=0;
|
||||
int col=0;
|
||||
int x;
|
||||
unsigned char out_buffer[1024];
|
||||
|
||||
unsigned char *image;
|
||||
int xsize,ysize;
|
||||
FILE *outfile;
|
||||
|
||||
if (argc<3) {
|
||||
fprintf(stderr,"Usage:\t%s INFILE OUTFILE\n\n",argv[0]);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
outfile=fopen(argv[2],"w");
|
||||
if (outfile==NULL) {
|
||||
fprintf(stderr,"Error! Could not open %s\n",argv[2]);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (loadpng(argv[1],&image,&xsize,&ysize)<0) {
|
||||
fprintf(stderr,"Error loading png!\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
fprintf(stderr,"Loaded image %d by %d\n",xsize,ysize);
|
||||
|
||||
short gr_offsets[]={
|
||||
0x400,0x480,0x500,0x580,0x600,0x680,0x700,0x780,
|
||||
0x428,0x4a8,0x528,0x5a8,0x628,0x6a8,0x728,0x7a8,
|
||||
0x450,0x4d0,0x550,0x5d0,0x650,0x6d0,0x750,0x7d0,
|
||||
};
|
||||
|
||||
memset(out_buffer,0,1024);
|
||||
for(row=0;row<24;row++) {
|
||||
for(col=0;col<40;col++) {
|
||||
out_buffer[(gr_offsets[row]-0x400)+col]=image[row*xsize+col];
|
||||
}
|
||||
}
|
||||
|
||||
for(x=0;x<1024;x++) fputc( out_buffer[x],outfile);
|
||||
|
||||
fclose(outfile);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user