Introduction
Introduction Statistics Contact Development Disclaimer Help
Fix alpha blending - sent - simple plaintext presentation tool
git clone git://git.suckless.org/sent
Log
Files
Refs
README
LICENSE
---
commit 68ac6486b106751f79e2ff2f4d53e56843521ce5
parent b0ad67036e35bc148ebda08184881375e716ec0b
Author: FRIGN <[email protected]>
Date: Sun, 31 Jan 2016 11:05:00 +0100
Fix alpha blending
- "/ 257", because 255 * 257 = UINT16_MAX
- "/ 255", because that's the maximum possible RGB value
Diffstat:
M sent.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
---
diff --git a/sent.c b/sent.c
@@ -258,15 +258,15 @@ int ffread(Image *img)
nbytes += count;
}
for (x = 0; x < rowlen / 2; x += 4) {
- fg_r = ntohs(row[x + 0]) / 256;
- fg_g = ntohs(row[x + 1]) / 256;
- fg_b = ntohs(row[x + 2]) / 256;
- opac = ntohs(row[x + 3]) / 256;
+ fg_r = ntohs(row[x + 0]) / 257;
+ fg_g = ntohs(row[x + 1]) / 257;
+ fg_b = ntohs(row[x + 2]) / 257;
+ opac = ntohs(row[x + 3]) / 257;
/* blend opaque part of image data with window backgro…
* emulate transparency */
- img->buf[off++] = (fg_r * opac + bg_r * (255 - opac)) …
- img->buf[off++] = (fg_g * opac + bg_g * (255 - opac)) …
- img->buf[off++] = (fg_b * opac + bg_b * (255 - opac)) …
+ img->buf[off++] = (fg_r * opac + bg_r * (255 - opac)) …
+ img->buf[off++] = (fg_g * opac + bg_g * (255 - opac)) …
+ img->buf[off++] = (fg_b * opac + bg_b * (255 - opac)) …
}
}
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.