summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Peter Nilsson <peppe@pappkartong.se>2011-02-10 19:27:10 +0100
committerJan-Peter Nilsson <peppe@pappkartong.se>2011-02-10 19:27:10 +0100
commit2aa918d8595cb5d17cfd75222e6d9fdfaea1f1d3 (patch)
treefa46429647d3977e37381a703db3c76055bbb14e
parentb5544adc9328ab783c27ef526c700166f8de9592 (diff)
Write XML file
-rw-r--r--Makefile2
-rw-r--r--test.c24
2 files changed, 21 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 5998ec9..16ee8c4 100644
--- a/Makefile
+++ b/Makefile
@@ -1,2 +1,2 @@
test: test.c
- gcc -g -Wall -std=c99 -o test test.c -lpng
+ gcc -g -Wall -pedantic -ansi -std=c99 -o test test.c -lpng
diff --git a/test.c b/test.c
index 52b0769..6f54d81 100644
--- a/test.c
+++ b/test.c
@@ -1,5 +1,4 @@
#include <stdio.h>
-#include <stdint.h>
#include <assert.h>
#include <stdlib.h>
#include <png.h>
@@ -56,14 +55,31 @@ int main()
printf("%s\n", filename);
fp = fopen(filename, "rb");
assert(fp);
- uint32_t width, height;
+ int width, height;
int* bitmap;
- fread(&width, sizeof(uint32_t), 1, fp);
- fread(&height, sizeof(uint32_t), 1, fp);
+ fread(&width, sizeof(int), 1, fp);
+ fread(&height, sizeof(int), 1, fp);
bitmap = calloc(width*height, 4);
fread(bitmap, width*height, 4, fp);
fclose(fp);
+ //Write xml file
+ fp = fopen("something.xml", "w");
+ assert(fp);
+ fprintf(fp, "<Font>\n");
+ for(int i = 0; i < 256; i++)
+ {
+ int x1 = data[i].top_left.x*width;
+ int y1 = data[i].top_left.y*height;
+ if(data[i].width == 0 && data[i].height == 0)
+ continue;
+ //int w = data[i].top_right.x*width - x1;
+ //int h = data[i].bottom_left.y*height - y1;
+ fprintf(fp, " <Code index=\"%d\" coord=\"%d %d %.0f %.0f\" ascent=\"%0.0f\"/>\n", i, x1, y1, data[i].width, data[i].height, data[i].ascent);
+ }
+ fprintf(fp, "</Font>\n");
+ fclose(fp);
+
//Save image using libpng
png_structp png_ptr;
png_infop info_ptr;