Mercurial > octave
annotate src/display-available.c @ 31212:55415fa6a20f
svgconvert: Use Lossless encoding of images when available (bug #52193)
* acinclude.m4: Check that QPainter::LosslessImageRendering flag is available.
* octave-svgconvert.cc (draw): Use new flag if available.
* print.m (doc): Update word of caution about svgconvert and images.
author | Pantxo Diribarne <pantxo.diribarne@gmail.com> |
---|---|
date | Mon, 29 Aug 2022 16:36:34 +0200 |
parents | 796f54d4ddbf |
children | 597f3ee61a48 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
3 // Copyright (C) 2012-2022 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
19785
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
22003
2d3972b802ff
use consistent style for including config.h in source files
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
27 # include "config.h" |
19785
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 #endif |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
30 #include <stdlib.h> |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 #if defined (OCTAVE_USE_WINDOWS_API) |
22003
2d3972b802ff
use consistent style for including config.h in source files
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
33 # include <windows.h> |
19785
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
34 #elif defined (HAVE_FRAMEWORK_CARBON) |
22003
2d3972b802ff
use consistent style for including config.h in source files
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
35 # include <Carbon/Carbon.h> |
19785
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
36 #elif defined (HAVE_X_WINDOWS) |
22003
2d3972b802ff
use consistent style for including config.h in source files
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
37 # include <X11/Xlib.h> |
19785
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 #endif |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
40 #include "display-available.h" |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
41 |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
42 const char * |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
43 display_available (int *dpy_avail) |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
44 { |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
45 *dpy_avail = 0; |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
46 |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
47 const char *err_msg = ""; |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
48 |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
49 #if defined (OCTAVE_USE_WINDOWS_API) |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
50 |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
51 HDC hdc = GetDC (0); |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
52 |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
53 if (hdc) |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
54 *dpy_avail = 1; |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
55 else |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
56 err_msg = "no graphical display found"; |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
57 |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
58 #elif defined (HAVE_FRAMEWORK_CARBON) |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
59 |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
60 CGDirectDisplayID display = CGMainDisplayID (); |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
61 |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
62 if (display) |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
63 *dpy_avail = 1; |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
64 else |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
65 err_msg = "no graphical display found"; |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
66 |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
67 #elif defined (HAVE_X_WINDOWS) |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
68 |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
69 const char *display_name = getenv ("DISPLAY"); |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
70 |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
71 if (display_name && *display_name) |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
72 { |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
73 Display *display = XOpenDisplay (display_name); |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
74 |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
75 if (display) |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
76 { |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
77 Screen *screen = DefaultScreenOfDisplay (display); |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
78 |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
79 if (! screen) |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
80 err_msg = "X11 display has no default screen"; |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
81 |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
82 XCloseDisplay (display); |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
83 |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
84 *dpy_avail = 1; |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
85 } |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
86 else |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
87 err_msg = "unable to open X11 DISPLAY"; |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
88 } |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
89 else |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
90 err_msg = "X11 DISPLAY environment variable not set"; |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
91 |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
92 #else |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
93 |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
94 err_msg = "no graphical display found"; |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
95 |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
96 #endif |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
97 |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
98 return err_msg; |
299fe39163a2
avoid C-style cast warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
99 } |