summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Peter Nilsson <peppe@pappkartong.se>2011-02-05 13:22:01 +0100
committerJan-Peter Nilsson <peppe@pappkartong.se>2011-02-05 13:22:01 +0100
commitb5544adc9328ab783c27ef526c700166f8de9592 (patch)
tree3265c8a1e1966ef2f61e8aeeca74d665b2527656
parent9db690139fa7296daf0bda734a01d9d86b0705ee (diff)
Remove gd dependency
-rw-r--r--Makefile2
-rw-r--r--test.c39
2 files changed, 6 insertions, 35 deletions
diff --git a/Makefile b/Makefile
index 4eed0da..5998ec9 100644
--- a/Makefile
+++ b/Makefile
@@ -1,2 +1,2 @@
test: test.c
- gcc -Wall -std=c99 -o test test.c -lgd
+ gcc -g -Wall -std=c99 -o test test.c -lpng
diff --git a/test.c b/test.c
index 7b54cb6..52b0769 100644
--- a/test.c
+++ b/test.c
@@ -2,7 +2,6 @@
#include <stdint.h>
#include <assert.h>
#include <stdlib.h>
-#include <gd.h>
#include <png.h>
@@ -65,37 +64,7 @@ int main()
fread(bitmap, width*height, 4, fp);
fclose(fp);
- //Draw image
- int col[128];
- gdImagePtr im, im2;
- im = gdImageCreate(width, height);
- im2 = gdImageCreate(width*2, height*2);
- gdImageColorAllocate(im, 0, 0, 0);
- col[0] = gdImageColorAllocate(im, 0xFF, 0xFF, 0xFF);
- col[1] = gdImageColorAllocate(im, 0xFF, 0x00, 0x00);
-
- //Make a red square beind the char
- int c = 'E';
- gdImageFilledRectangle(im, data[c].top_left.x*width, data[c].top_left.y*height, data[c].bottom_right.x*width, data[c].bottom_right.y*height, col[1]);
-
- for(int i = 0; i < width*height; i++)
- {
- if((bitmap[i]&0xFFFFFF) != 0 && (bitmap[i]&0xFF000000))
- {
- gdImageSetPixel(im, i%height, i/height, col[0]);
- }
- }
-
- gdImageCopyResized(im2, im, 0, 0, 0, 0, (width*2), (height*2), width, height);
-
- fp = fopen("test.png", "wb");
- gdImagePng(im2, fp);
- fclose(fp);
-
- gdImageDestroy(im2);
- gdImageDestroy(im);
-
- //Using libpng
+ //Save image using libpng
png_structp png_ptr;
png_infop info_ptr;
png_bytep row;
@@ -115,8 +84,10 @@ int main()
row = (png_bytep) malloc(4 * width * sizeof(png_byte));
//Write image data
- for (int y=0 ; y<height ; y++) {
- for (int x=0 ; x<width ; x++) {
+ for (int y=0 ; y<height ; y++)
+ {
+ for (int x=0 ; x<width ; x++)
+ {
int* data = (int*)&(row[x*4]);
*data = bitmap[x+y*width];
}