/usr/share/gnudatalanguage/lib/read_png.pro is in libgnudatalanguage0 0.9.7-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | ;+
;
; NAME: READ_PNG
;
; PURPOSE: Reads a PNG file into memory (Function OR Procedure)
;
; CATEGORY: Images (IO)
;
; CALLING SEQUENCE: 2 ways: Pro or Func
;
; Function: image=READ_PNG(filename,r,g,b)
; Procedure: READ_PNG, filename, image, r,g,b
;
; KEYWORD PARAMETERS:
; ORDER: flip the image in the vertical
; VERBOSE: Not used yet
; TRANSPARENT: Transparent
;
; OUTPUTS: For true color images, data is a three dimensional array
; with interleaving set by TRUE keyword
;
; OPTIONAL OUTPUTS: For pseudocolor only
; red : the Red colormap vector (for PseudoColor images)
; green: the Green colormap vector (for PseudoColor images)
; blue : the Blue colormap vector (for PseudoColor images)
;
; RESTRICTIONS:
; Requires ImageMagick (tests added)
;
; PROCEDURE:
; Use ImageMagick to read the data as requested
;
; EXAMPLE:
; See "test_read_standard_images.pro" in testsuite/
;
; MODIFICATION HISTORY:
; Written by: Christopher Lee 2004-05-23
; 2011-Aug-18, Alain Coulais : More checks on inputs; now verify if
; compiled with ImageMagick support !
; 2012-Feb-02, Alain Coulais : the effective order of reading was bad ...
; now it is OK on all tested PNG images, including images with transparency
; see 3 examples:
; * testsuite/Saturn.jpg default conversion by Image Magick in PNG
; * http://www.gnu.org/graphics/meditate_fel.png (big, no transparency)
; * http://www.gnu.org/graphics/meditate.png (transparency)
;
; 2012-Feb-07, Alain Coulais : new test cases in testsuite:
; test_read_standard_images.pro : 2 JPEG and 4 PNG (2 with transparency)
; The transpose for 2D image is no more need.
;
; 2012-May-25, Alain Coulais : fake INTERNAL_READ_PNG to have both
; pro/func working transparently without pre-compilation
;
; 2014-Aug-09, AC : FORWARD_FUNCTION
;
;-
; LICENCE:
; Copyright (C) 2004, 2011, 2012, 2014
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
;-
;
function INTERNAL_READ_PNG, filename, red, green, blue, $
order=order, transparent=transparent, $
test=test, verbose=verbose
;
; this line allows to compile also in IDL ...
FORWARD_FUNCTION MAGICK_EXISTS, MAGICK_PING, MAGICK_READ
;
; Do we have access to ImageMagick functionnalities ??
;
if (MAGICK_EXISTS() EQ 0) then begin
MESSAGE, /continue, "GDL was compiled without ImageMagick support."
MESSAGE, "You must have ImageMagick support to use this functionaly."
endif
;
if (N_PARAMS() EQ 0) then MESSAGE, "Incorrect number of arguments."
if ~((N_PARAMS() EQ 1) OR (N_PARAMS() EQ 4)) then $
MESSAGE, "Only 1 or 4 arguments allowed."
;
if (SIZE(filename,/type) NE 7) then MESSAGE, "String expression required in this context: filename"
if (N_ELEMENTS(filename) GT 1) then MESSAGE, "Only one file at once !"
if (STRLEN(filename) EQ 0) then MESSAGE, "Null filename not allowed."
if ((FILE_INFO(filename)).exists EQ 0) then MESSAGE, "Error opening file. File: "+filename
if (FILE_TEST(filename, /regular) EQ 0) then MESSAGE, "Not a regular File: "+filename
;
; testing whether the format is as expected
;
if ~MAGICK_PING(filename, 'PNG') then begin
MESSAGE, /continue, "PNG error: Not a PNG file:"
if MAGICK_PING(filename, 'JPEG') then MESSAGE, "seems to be a JPEG file"
if MAGICK_PING(filename, 'GIF') then MESSAGE, "seems to be a GIF file"
if MAGICK_PING(filename, 'PDF') then MESSAGE, "seems to be a PDF file"
MESSAGE, "unknown/untested format file"
endif
;
mid=MAGICK_OPEN(filename)
;
;;flip if order is set
;
if (KEYWORD_SET(order)) then MAGICK_FLIP, mid
if (magick_IndexedColor(mid)) then begin
image=MAGICK_READINDEXES(mid)
MAGICK_READCOLORMAPRGB, mid, red, green, blue
colortable=[[red],[green],[blue]]
endif else begin
;; AC 2012-Feb-02 the effective order of reading was bad ...
;; now it is OK on all tested PNG images, including images with transparency
image=MAGICK_READ(mid, rgb=1)
endelse
;
MAGICK_CLOSE, mid
;
if KEYWORD_SET(test) then STOP
;
return, image
;
end
;
; ----------------------------- Procedure ------------------------
;
pro READ_PNG, filename, image, red, green, blue, $
order=order, transparent=transparent, $
help=help, test=test, verbose=verbose
;
ON_ERROR, 2
;
if KEYWORD_SET(help) then begin
print, 'pro READ_PNG, filename, red, green, blue, $'
print, ' order=order, transparent=transparent, $'
print, ' help=help, test=test, verbose=verbose'
return
endif
;
image=INTERNAL_READ_PNG(filename, red, green, blue, $
order=order, transparent=transparent, $
test=test, verbose=verbose)
;
end
;
; ----------------------------- Function ------------------------
;
function READ_PNG, filename, red, green, blue, $
order=order, transparent=transparent, $
help=help, test=test, verbose=verbose
;
ON_ERROR, 2
;
if KEYWORD_SET(help) then begin
print, 'function READ_PNG, filename, red, green, blue, $'
print, ' order=order, transparent=transparent, $'
print, ' help=help, test=test, verbose=verbose'
return, -1
endif
;
image=INTERNAL_READ_PNG(filename, red, green, blue, $
order=order, transparent=transparent, $
test=test, verbose=verbose)
;
return, image
;
end
|