3
* draw a line between two given points in the current color.
6
* Cont_abs() in ../lib/Cont_abs.c
11
#include "pngdriver.h"
14
#define min(a,b) ((a)<(b)?(a):(b))
17
#define max(a,b) ((a)>(b)?(a):(b))
20
void PNG_draw_bitmap(int ncols, int nrows, int threshold,
21
const unsigned char *buf)
23
int i0 = max(clip_left - cur_x, 0);
24
int i1 = min(clip_rite - cur_x, ncols);
25
int j0 = max(clip_top - cur_y, 0);
26
int j1 = min(clip_bot - cur_y, nrows);
31
for (j = j0; j < j1; j++) {
34
for (i = i0; i < i1; i++) {
36
unsigned int k = buf[j * ncols + i];
37
unsigned int *p = &grid[y * width + x];
48
get_pixel(currentColor, &r1, &g1, &b1, &a1);
50
for (j = j0; j < j1; j++) {
53
for (i = i0; i < i1; i++) {
55
unsigned int k = buf[j * ncols + i];
56
unsigned int *p = &grid[y * width + x];
57
unsigned int a0, r0, g0, b0;
58
unsigned int a, r, g, b;
60
get_pixel(*p, &r0, &g0, &b0, &a0);
62
a = (a0 * (255 - k) + a1 * k) / 255;
63
r = (r0 * (255 - k) + r1 * k) / 255;
64
g = (g0 * (255 - k) + g1 * k) / 255;
65
b = (b0 * (255 - k) + b1 * k) / 255;
67
*p = get_color(r, g, b, a);