summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKushal K S V S <kkushal32@gmail.com>2017-07-12 02:51:02 +0530
committerKushal K S V S <kkushal32@gmail.com>2017-07-12 02:51:02 +0530
commitffd3e561641d29e8d8959c14260c552affe5a51d (patch)
treedb05e4e56e4c83bf52629bc7d099f7f8d0902ebd
parent870f1f4bbfcaea9c7a709caef6a32a2b281223c2 (diff)
downloadfreetype2-ffd3e561641d29e8d8959c14260c552affe5a51d.tar.gz
Add another Effect and put both effects in one function
-rw-r--r--tests/make_png/bitmap.c77
-rw-r--r--tests/make_png/bitmap.h7
2 files changed, 67 insertions, 17 deletions
diff --git a/tests/make_png/bitmap.c b/tests/make_png/bitmap.c
index 143894117..76218f8ed 100644
--- a/tests/make_png/bitmap.c
+++ b/tests/make_png/bitmap.c
@@ -330,8 +330,8 @@ void Read_PNG(char *filename, IMAGE * after_effect) {
fclose(fp);
}
-void Add_effect_1(IMAGE* base, IMAGE* test, IMAGE* out){
-
+void Add_effect(IMAGE* base, IMAGE* test, IMAGE* out, int Effect_ID)
+{
out->pixels = (PIXEL*)malloc(base->width * base->height * sizeof(PIXEL));
for(int y = 0; y < base->height; y++) {
@@ -341,20 +341,23 @@ void Add_effect_1(IMAGE* base, IMAGE* test, IMAGE* out){
PIXEL * pixel_test = Pixel_At ( test, x, y);
PIXEL * pixel_out = Pixel_At ( out, x, y);
- if (pixel_base->red == 255 &&
- pixel_base->green == 255 &&
- pixel_base->blue == 255 &&
- pixel_base->alpha == 255 )
+ if (Effect_ID == 1)
{
- pixel_out->red = 255;
- pixel_out->green = 255;
- pixel_out->blue = 255;
- pixel_out->alpha = 255;
- }else{
- pixel_out->red = 127;
- pixel_out->green = 127;
- pixel_out->blue = 127;
- pixel_out->alpha = 255;
+ if (pixel_base->red == 255 &&
+ pixel_base->green == 255 &&
+ pixel_base->blue == 255 &&
+ pixel_base->alpha == 255 )
+ {
+ pixel_out->red = 255;
+ pixel_out->green = 255;
+ pixel_out->blue = 255;
+ pixel_out->alpha = 255;
+ }else{
+ pixel_out->red = 127;
+ pixel_out->green = 127;
+ pixel_out->blue = 127;
+ pixel_out->alpha = 255;
+ }
}
if (pixel_base->red != pixel_test->red ||
@@ -366,7 +369,51 @@ void Add_effect_1(IMAGE* base, IMAGE* test, IMAGE* out){
pixel_out->green = 0;
pixel_out->blue = 0;
pixel_out->alpha = 255;
+ }else{
+ if (Effect_ID == 2)
+ {
+ pixel_out->red = pixel_base->red;
+ pixel_out->green = pixel_base->green;
+ pixel_out->blue = pixel_base->blue;
+ pixel_out->alpha = pixel_base->alpha;
+ }
}
}
}
}
+
+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 1d7606c13..51b949c25 100644
--- a/tests/make_png/bitmap.h
+++ b/tests/make_png/bitmap.h
@@ -67,6 +67,9 @@ int Generate_PNG (IMAGE *bitmap, const char *path,int render_mode);
// Read PNG
void Read_PNG(char *filename, IMAGE * after_effect);
// Add an effect using two PNG images
-// Base Glyph = Gray {127,0,0,255}
+// Base Glyph = Gray {127,0,0,255} OR as it is
// Differences = Red {255,0,0,255}
-void Add_effect_1(IMAGE* base, IMAGE* test, IMAGE* out);
+// Effect_ID = {1 or 2}
+void Add_effect(IMAGE* base, IMAGE* test, IMAGE* out, int Effect_ID);
+// Stitch 2 PNG files
+void Stitch(IMAGE* left, IMAGE* right, IMAGE* result);