Introduction
Introduction Statistics Contact Development Disclaimer Help
Improve readability of alpha-blending sections - farbfeld - suckless image form…
git clone git://git.suckless.org/farbfeld
Log
Files
Refs
README
LICENSE
---
commit a5a5706f16408ce181775d319b264d03e67819f3
parent 6afe09e729e3428a5317c57c8315897f7110bffa
Author: Laslo Hunhold <[email protected]>
Date: Fri, 14 Apr 2017 22:15:25 +0200
Improve readability of alpha-blending sections
Diffstat:
M ff2jpg.c | 6 ++++--
M ff2ppm.c | 6 ++++--
2 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/ff2jpg.c b/ff2jpg.c
@@ -106,9 +106,11 @@ main(int argc, char *argv[])
for (j = 0, k = 0; j < rowlen; j += 4, k += 3) {
a = ntohs(row[j + 3]);
for (l = 0; l < 3; l++) {
+ /* alpha blending and 8-bit-reduction */
rowout[k + l] = (a * ntohs(row[j + l]) +
- (65535 - a) * mask[l]) /
- (257 * 65535);
+ (UINT16_MAX - a) * mask[l]) /
+ (UINT16_MAX *
+ (UINT16_MAX / UINT8_MAX));
}
}
jpeg_write_scanlines(&jcomp, &rowout, 1);
diff --git a/ff2ppm.c b/ff2ppm.c
@@ -66,9 +66,11 @@ main(int argc, char *argv[])
for (j = 0, k = 0; j < rowlen; j += 4, k += 3) {
a = ntohs(row[j + 3]);
for (l = 0; l < 3; l++) {
+ /* alpha blending and 8-bit-reduction */
rowout[k + l] = (a * ntohs(row[j + l]) +
- (65535 - a) * mask[l]) /
- (257 * 65535);
+ (UINT16_MAX - a) * mask[l]) /
+ (UINT16_MAX *
+ (UINT16_MAX / UINT8_MAX));
}
}
if (fwrite(rowout, sizeof(uint8_t), rowoutlen, stdout) != rowo…
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.