shithub: ifilter

Download patch

ref: 84b72ac10d75b4b93b9149ec1d3cbb9984ad533c
parent: d6b3a92f9317c5c2fd1b38f8332225005a212eb0
author: phil9 <telephil9@gmail.com>
date: Thu Dec 8 07:08:49 EST 2022

pixelate: fix wrong color use

--- a/pixelate.c
+++ b/pixelate.c
@@ -19,9 +19,9 @@
 			for(oy = y; oy < y+size; oy++){
 				for(ox = x; ox < x+size; ox++){
 					oi = (ox + w * oy) * depth;
-					sr += data[oi + 0]*data[oi + 0];
-					sg += data[oi + 1]*data[oi + 0];
-					sb += data[oi + 2]*data[oi + 0];
+					sr += data[oi + Cred]   * data[oi + Cred];
+					sg += data[oi + Cgreen] * data[oi + Cgreen];
+					sb += data[oi + Cblue]  * data[oi + Cblue];
 				}
 			}
 			sr = sqrt(sr/(size*size));
@@ -30,9 +30,9 @@
 			for(oy = y; oy < y+size; oy++){
 				for(ox = x; ox < x+size; ox++){
 					oi = (ox + w * oy) * depth;
-					out[oi + 0] = sr;
-					out[oi + 1] = sg;
-					out[oi + 2] = sb;
+					out[oi + Cred]   = sr;
+					out[oi + Cgreen] = sg;
+					out[oi + Cblue]  = sb;
 				}
 			}
 		}