~ubuntu-branches/ubuntu/vivid/grass/vivid-proposed

« back to all changes in this revision

Viewing changes to lib/pngdriver/write_bmp.c

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-02-20 23:12:08 UTC
  • mfrom: (8.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20150220231208-1u6qvqm84v430b10
Tags: 7.0.0-1~exp1
* New upstream release.
* Update python-ctypes-ternary.patch to use if/else instead of and/or.
* Drop check4dev patch, rely on upstream check.
* Add build dependency on libpq-dev to grass-dev for libpq-fe.h.
* Drop patches applied upstream, refresh remaining patches.
* Update symlinks for images switched from jpg to png.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*!
 
2
  \file lib/pngdriver/write_bmp.c
 
3
 
 
4
  \brief GRASS png display driver - write bitmap (lower level functions)
 
5
 
 
6
  (C) 2007-2014 by Glynn Clements and the GRASS Development Team
 
7
  
 
8
  This program is free software under the GNU General Public License
 
9
  (>=v2). Read the file COPYING that comes with GRASS for details.
 
10
  
 
11
  \author Glynn Clements
 
12
*/
1
13
 
2
14
#include <stdio.h>
3
15
#include <stdlib.h>
31
43
    *p++ = 'B';
32
44
    *p++ = 'M';
33
45
 
34
 
    p = put_4(p, HEADER_SIZE + width * height * 4);
 
46
    p = put_4(p, HEADER_SIZE + png.width * png.height * 4);
35
47
    p = put_4(p, 0);
36
48
    p = put_4(p, HEADER_SIZE);
37
49
 
38
50
    p = put_4(p, 40);
39
 
    p = put_4(p, width);
40
 
    p = put_4(p, -height);
 
51
    p = put_4(p, png.width);
 
52
    p = put_4(p, -png.height);
41
53
    p = put_2(p, 1);
42
54
    p = put_2(p, 32);
43
55
    p = put_4(p, 0);
44
 
    p = put_4(p, width * height * 4);
 
56
    p = put_4(p, png.width * png.height * 4);
45
57
    p = put_4(p, 0);
46
58
    p = put_4(p, 0);
47
59
    p = put_4(p, 0);
55
67
    int x, y;
56
68
    unsigned int *p;
57
69
 
58
 
    output = fopen(file_name, "wb");
 
70
    output = fopen(png.file_name, "wb");
59
71
    if (!output)
60
 
        G_fatal_error("PNG: couldn't open output file %s", file_name);
 
72
        G_fatal_error("PNG: couldn't open output file %s", png.file_name);
61
73
 
62
74
    memset(header, 0, sizeof(header));
63
75
    make_bmp_header(header);
64
76
    fwrite(header, sizeof(header), 1, output);
65
77
 
66
 
    for (y = 0, p = grid; y < height; y++) {
67
 
        for (x = 0; x < width; x++, p++) {
 
78
    for (y = 0, p = png.grid; y < png.height; y++) {
 
79
        for (x = 0; x < png.width; x++, p++) {
68
80
            unsigned int c = *p;
69
81
            int r, g, b, a;
70
82
 
71
 
            get_pixel(c, &r, &g, &b, &a);
 
83
            png_get_pixel(c, &r, &g, &b, &a);
72
84
 
73
85
            fputc((unsigned char)b, output);
74
86
            fputc((unsigned char)g, output);