GRASS 8 Programmer's Manual
8.6.0dev(2026)-c83afef6d3
Loading...
Searching...
No Matches
pngdriver/graph_close.c
Go to the documentation of this file.
1
/*!
2
\file lib/pngdriver/graph_close.c
3
4
\brief GRASS png display driver - close graphics processing
5
6
SPDX-FileCopyrightText: 2003-2014 Glynn Clements
7
SPDX-FileCopyrightText: GRASS Development Team
8
SPDX-License-Identifier: GPL-2.0-or-later
9
10
\author Per Henrik Johansen (original contributor)
11
\author Glynn Clements
12
*/
13
14
#include <
unistd.h
>
15
#include <
fcntl.h
>
16
#include <sys/types.h>
17
#include <
sys/stat.h
>
18
#ifdef _WIN32
19
#include <windows.h>
20
#else
21
#include <sys/mman.h>
22
#endif
23
24
#include <
grass/gis.h
>
25
#include "
pngdriver.h
"
26
27
static
void
unmap_file(
void
)
28
{
29
size_t
size =
30
HEADER_SIZE
+ (
size_t
)
png
.width *
png
.height *
sizeof
(
unsigned
int
);
31
void
*ptr = (
char
*)
png
.grid -
HEADER_SIZE
;
32
33
if
(!
png
.mapped)
34
return
;
35
36
#ifdef _WIN32
37
UnmapViewOfFile
(ptr);
38
CloseHandle
(
png
.handle);
39
#else
40
munmap
(ptr, size);
41
#endif
42
43
png
.mapped = 0;
44
}
45
46
/*!
47
\brief Close down the graphics processing. This gets called only at driver
48
termination time.
49
*/
50
void
PNG_Graph_close
(
void
)
51
{
52
write_image
();
53
54
if
(
png
.mapped)
55
unmap_file();
56
else
57
G_free
(
png
.grid);
58
}
HEADER_SIZE
#define HEADER_SIZE
Definition
cairodriver.h:45
AMI_STREAM
Definition
ami_stream.h:153
G_free
void G_free(void *)
Free allocated memory.
Definition
gis/alloc.c:145
fcntl.h
Header file for msvc/fcntl.c.
gis.h
PNG_Graph_close
void PNG_Graph_close(void)
Close down the graphics processing. This gets called only at driver termination time.
Definition
pngdriver/graph_close.c:50
png
struct png_state png
Definition
pngdriver/graph_set.c:31
pngdriver.h
GRASS png display driver - header file.
write_image
void write_image(void)
Definition
pngdriver/write.c:21
stat.h
unistd.h
lib
pngdriver
graph_close.c
Generated on Fri Sep 11 2026 06:57:49 for GRASS 8 Programmer's Manual by
1.9.8