retroforth/source/embedimage.c
crc 183c5bae38 Initial checkin (from 58fa921 in the old git repo)
FossilOrigin-Name: d2b8467883db80cb179089e1db1b1ed4dff1f11b4bee7086ee46d83f3ee0136e
2017-10-16 16:09:39 +00:00

47 lines
980 B
C

/* ____ ____ ______ ____ ___
|| \\ || | || | || \\ // \\
||_// ||== || ||_// (( ))
|| \\ ||___ || || \\ \\_//
a personal, minimalistic forth
This loads an image file and generates a C formatted
output. It's used to create the `image.c` that gets
linked into `rre`.
Copyright (c) 2016, 2017 Charles Childers
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include "nga.c"
void output_header(int size) {
printf("#include <stdint.h>\n");
printf("int32_t ngaImageCells = %d;\n", size);
printf("int32_t ngaImage[] = { ");
}
int main(int argc, char **argv) {
ngaPrepare();
int32_t size = 0;
if (argc == 2)
size = ngaLoadImage(argv[1]);
else
size = ngaLoadImage("ngaImage");
output_header(size);
int32_t i;
i = 0;
while (i < size) {
if (i+1 < size)
printf("%d,", memory[i]);
else
printf("%d };\n", memory[i]);
i++;
}
exit(0);
}