~ubuntu-branches/ubuntu/wily/grass/wily

« back to all changes in this revision

Viewing changes to lib/pngdriver/Draw_bitmap.c

Tags: 7.0.0~rc1+ds1-1~exp1
* New upstream release candidate.
* Repack upstream tarball, remove precompiled Python objects.
* Add upstream metadata.
* Update gbp.conf and Vcs-Git URL to use the experimental branch.
* Update watch file for GRASS 7.0.
* Drop build dependencies for Tcl/Tk, add build dependencies:
  python-numpy, libnetcdf-dev, netcdf-bin, libblas-dev, liblapack-dev
* Update Vcs-Browser URL to use cgit instead of gitweb.
* Update paths to use grass70.
* Add configure options: --with-netcdf, --with-blas, --with-lapack,
  remove --with-tcltk-includes.
* Update patches for GRASS 7.
* Update copyright file, changes:
  - Update copyright years
  - Group files by license
  - Remove unused license sections
* Add patches for various typos.
* Fix desktop file with patch instead of d/rules.
* Use minimal dh rules.
* Bump Standards-Version to 3.9.6, no changes.
* Use dpkg-maintscript-helper to replace directories with symlinks.
  (closes: #776349)
* Update my email to use @debian.org address.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
/*
3
 
 * draw a line between two given points in the current color.
4
 
 *
5
 
 * Called by:
6
 
 *     Cont_abs() in ../lib/Cont_abs.c
7
 
 */
8
 
 
9
 
#include <math.h>
10
 
 
11
 
#include "pngdriver.h"
12
 
 
13
 
#ifndef min
14
 
#define min(a,b) ((a)<(b)?(a):(b))
15
 
#endif
16
 
#ifndef max
17
 
#define max(a,b) ((a)>(b)?(a):(b))
18
 
#endif
19
 
 
20
 
void PNG_draw_bitmap(int ncols, int nrows, int threshold,
21
 
                     const unsigned char *buf)
22
 
{
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);
27
 
 
28
 
    if (!true_color) {
29
 
        int i, j;
30
 
 
31
 
        for (j = j0; j < j1; j++) {
32
 
            int y = cur_y + j;
33
 
 
34
 
            for (i = i0; i < i1; i++) {
35
 
                int x = cur_x + i;
36
 
                unsigned int k = buf[j * ncols + i];
37
 
                unsigned int *p = &grid[y * width + x];
38
 
 
39
 
                if (k > threshold)
40
 
                    *p = currentColor;
41
 
            }
42
 
        }
43
 
    }
44
 
    else {
45
 
        int r1, g1, b1, a1;
46
 
        int i, j;
47
 
 
48
 
        get_pixel(currentColor, &r1, &g1, &b1, &a1);
49
 
 
50
 
        for (j = j0; j < j1; j++) {
51
 
            int y = cur_y + j;
52
 
 
53
 
            for (i = i0; i < i1; i++) {
54
 
                int x = cur_x + 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;
59
 
 
60
 
                get_pixel(*p, &r0, &g0, &b0, &a0);
61
 
 
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;
66
 
 
67
 
                *p = get_color(r, g, b, a);
68
 
            }
69
 
        }
70
 
    }
71
 
 
72
 
    modified = 1;
73
 
}