diff options
author | Laslo Hunhold <dev@frign.de> | 2017-04-14 22:15:25 +0200 |
---|---|---|
committer | Laslo Hunhold <dev@frign.de> | 2017-04-14 22:15:25 +0200 |
commit | a5a5706f16408ce181775d319b264d03e67819f3 (patch) | |
tree | 48c8a9ae8deed6b70dcc70bf123bcd79fc77457a /ff2ppm.c | |
parent | 6afe09e729e3428a5317c57c8315897f7110bffa (diff) |
Improve readability of alpha-blending sections
Diffstat (limited to 'ff2ppm.c')
-rw-r--r-- | ff2ppm.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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) { |