[hackers] [farbfeld] Improve readability of alpha-blending sections || Laslo Hunhold

From: <git_AT_suckless.org>
Date: Fri, 14 Apr 2017 22:15:45 +0200 (CEST)

commit a5a5706f16408ce181775d319b264d03e67819f3
Author: Laslo Hunhold <dev_AT_frign.de>
AuthorDate: Fri Apr 14 22:15:25 2017 +0200
Commit: Laslo Hunhold <dev_AT_frign.de>
CommitDate: Fri Apr 14 22:15:25 2017 +0200

    Improve readability of alpha-blending sections

diff --git a/ff2jpg.c b/ff2jpg.c
index 1f87fdd..23a506b 100644
--- a/ff2jpg.c
+++ b/ff2jpg.c
_AT_@ -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
index 4383dc4..b34d870 100644
--- a/ff2ppm.c
+++ b/ff2ppm.c
_AT_@ -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) != rowoutlen) {
Received on Fri Apr 14 2017 - 22:15:45 CEST

This archive was generated by hypermail 2.3.0 : Fri Apr 14 2017 - 22:24:27 CEST