summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKushal K S V S <kkushal32@gmail.com>2017-07-12 01:33:31 +0530
committerKushal K S V S <kkushal32@gmail.com>2017-07-12 01:33:31 +0530
commit8631de58831409ea7e44825c7cfd990b2f5098d9 (patch)
tree1d919cdc3fa9ed84e2d2b8380e31561accec6f23
parent1843f93d75878178d7e17868cb7f1469651db5b8 (diff)
downloadfreetype2-8631de58831409ea7e44825c7cfd990b2f5098d9.tar.gz
Adding code to stitch 2 PNG files
-rw-r--r--tests/make_png/bitmap.c46
-rw-r--r--tests/make_png/bitmap.h2
2 files changed, 43 insertions, 5 deletions
diff --git a/tests/make_png/bitmap.c b/tests/make_png/bitmap.c
index 0f6232160..a57e1cff7 100644
--- a/tests/make_png/bitmap.c
+++ b/tests/make_png/bitmap.c
@@ -281,7 +281,7 @@ void Make_PNG(FT_Bitmap* bitmap,char* name,int i,int render_mode){
free (fruit.pixels);
}
-void Read_PNG(char *filename, IMAGE * after_effect) {
+void Read_PNG(char *filename, IMAGE * bitmap) {
int width, height;
png_bytep *row_pointers;
@@ -305,8 +305,8 @@ void Read_PNG(char *filename, IMAGE * after_effect) {
width = png_get_image_width(png, info);
height = png_get_image_height(png, info);
- after_effect->width = width;
- after_effect->height = height;
+ bitmap->width = width;
+ bitmap->height = height;
row_pointers = (png_bytep*)malloc(sizeof(png_bytep) * height);
for(int y = 0; y < height; y++) {
@@ -315,7 +315,7 @@ void Read_PNG(char *filename, IMAGE * after_effect) {
png_read_image(png, row_pointers);
- after_effect->pixels = (PIXEL*)malloc(width * height * sizeof(PIXEL));
+ bitmap->pixels = (PIXEL*)malloc(width * height * sizeof(PIXEL));
for(int y = 0; y < height; y++) {
@@ -325,7 +325,7 @@ void Read_PNG(char *filename, IMAGE * after_effect) {
png_bytep px = &(row[x * 4]);
- PIXEL * pixel = Pixel_At ( after_effect, x, y);
+ PIXEL * pixel = Pixel_At ( bitmap, x, y);
pixel->red = px[0];
pixel->green = px[1];
@@ -379,3 +379,39 @@ void Add_effect_1(IMAGE* base, IMAGE* test, IMAGE* out){
}
}
}
+
+void Stitch(IMAGE* left, IMAGE* right, IMAGE* result){
+
+ result->width = left->width + right->width;
+ result->height = left->height; // Horizontal clipping
+
+ result->pixels = (PIXEL*)malloc(result->width * result->height * sizeof(PIXEL));
+
+ for (int y = 0; y < left->height; ++y)
+ {
+ for (int x = 0; x < left->width; ++x)
+ {
+ PIXEL * pixel_left = Pixel_At ( left, x, y);
+ PIXEL * pixel_result = Pixel_At ( result, x, y);
+
+ pixel_result->red = pixel_left->red;
+ pixel_result->green = pixel_left->green;
+ pixel_result->blue = pixel_left->blue;
+ pixel_result->alpha = pixel_left->alpha;
+ }
+ }
+
+ for (int y = 0; y < right->height; ++y)
+ {
+ for (int x = left->width; x < result->width; ++x)
+ {
+ PIXEL * pixel_right = Pixel_At ( right, x - left->width, y);
+ PIXEL * pixel_result = Pixel_At ( result, x, y);
+
+ pixel_result->red = pixel_right->red;
+ pixel_result->green = pixel_right->green;
+ pixel_result->blue = pixel_right->blue;
+ pixel_result->alpha = pixel_right->alpha;
+ }
+ }
+}
diff --git a/tests/make_png/bitmap.h b/tests/make_png/bitmap.h
index da3c03e10..51609e85f 100644
--- a/tests/make_png/bitmap.h
+++ b/tests/make_png/bitmap.h
@@ -70,3 +70,5 @@ void Read_PNG(char *filename, IMAGE * after_effect);
// Base Glyph = Gray {127,0,0,255}
// Differences = Red {255,0,0,255}
void Add_effect_1(IMAGE* base, IMAGE* test, IMAGE* out);
+// Stitch two PNG files side by side
+void Stitch(IMAGE* left, IMAGE* right, IMAGE* result);