freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2] GSoC-2017-kushal 9afcf3d 16/52: Add PNG effect 1 (Gray + Red


From: Kushal K S V S
Subject: [freetype2] GSoC-2017-kushal 9afcf3d 16/52: Add PNG effect 1 (Gray + Red)
Date: Fri, 25 Aug 2017 15:09:36 -0400 (EDT)

branch: GSoC-2017-kushal
commit 9afcf3d7ef02f1e71a2fc0c453e5b9c335e68605
Author: Kushal K S V S <address@hidden>
Commit: Kushal K S V S <address@hidden>

    Add PNG effect 1 (Gray + Red)
---
 tests/make_png/bitmap.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 tests/make_png/bitmap.h |  4 ++++
 2 files changed, 46 insertions(+)

diff --git a/tests/make_png/bitmap.c b/tests/make_png/bitmap.c
index 3f3ca4a..0f62321 100644
--- a/tests/make_png/bitmap.c
+++ b/tests/make_png/bitmap.c
@@ -337,3 +337,45 @@ void Read_PNG(char *filename, IMAGE * after_effect) {
   fclose(fp);
 }
 
+void Add_effect_1(IMAGE* base, IMAGE* test, IMAGE* out){
+
+  out->pixels = (PIXEL*)malloc(base->width * base->height * sizeof(PIXEL));
+
+  PIXEL temp;
+
+  for(int y = 0; y < base->height; y++) {
+    for(int x = 0; x < base->width; x++ ) {
+
+      PIXEL * pixel_base = Pixel_At ( base, x, y);
+      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 )
+      {
+        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    ||
+          pixel_base->green != pixel_test->green  ||
+          pixel_base->blue  != pixel_test->blue   ||
+          pixel_base->alpha != pixel_test->alpha  )
+      {
+        pixel_out->red    = 255;
+        pixel_out->green  = 0;
+        pixel_out->blue   = 0;
+        pixel_out->alpha  = 255;
+      }
+    }
+  }
+}
diff --git a/tests/make_png/bitmap.h b/tests/make_png/bitmap.h
index bed203d..da3c03e 100644
--- a/tests/make_png/bitmap.h
+++ b/tests/make_png/bitmap.h
@@ -66,3 +66,7 @@ void Make_PNG(FT_Bitmap* bitmap,char* name,int i,int 
render_mode);
 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}
+// Differences = Red {255,0,0,255}
+void Add_effect_1(IMAGE* base, IMAGE* test, IMAGE* out);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]