/usr/share/gnudatalanguage/lib/write_bmp.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 | ;+
;
; NAME: WRITE_BMP
;
; PURPOSE: write a image from memory to a bitmap
;
; CATEGORY: Images (IO)
;
; CALLING SEQUENCE:
; write_bmp,filename,image,red,green,blue,[RGB=RGB,FOUR_BIT=FOUR_BIT,$
; IHDR=IHDR,$
; HEADER_DEFINE=HEADER_DEFINE])
;
; KEYWORD PARAMETERS:
; RGB : Set to reverse the color ordering from BGR
; FOUR_BIT : Four bit data file
; IHDR : Structure fo head information
; HEADER_INFO: returns a blank IHDR structure if HEADER_INFO is
; defined before the call
;
;
; OPTIONAL INPUTS: 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 (tested)
;
; PROCEDURE:
; Use ImageMagick to write the data as requested
;
; EXAMPLE:
; See "image_test.pro" in testsuite/
;
; MODIFICATION HISTORY:
;
; Written by: Christopher Lee 2004-05-17
;
; Modifications
; Alain Coulais, 30-AUG-2011:
; - adding check on ImageMagick/GraphicMagick MAGICK_EXISTS()
; Alain Coulais, 10-AUG-2014:
; - FORWARD_FUNCTION
;
;-
; LICENCE:
; Copyright (C) 2004, 2011, 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.
;
;-
;
pro WRITE_BMP, filename, image, red, green, blue, $
rgb=rgb, four_bit=four_bit, $
ihdr=ihdr,header_define=header_define, $
test=test, help=help, debug=debug
;
; this line allows to compile also in IDL ...
FORWARD_FUNCTION MAGICK_EXISTS, MAGICK_PING, MAGICK_READ
;
if ~KEYWORD_SET(test) then ON_ERROR, 2
;
if KEYWORD_SET(help) then begin
print, 'pro WRITE_BMP, filename, image, red, green, blue, $'
print, ' rgb=rgb, four_bit=four_bit, $'
print, ' ihdr=ihdr,header_define=header_define, $'
print, ' help=help, test=test, debug=debug'
return
endif
;
; 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(KEYWORD_SET(header_define)) then begin
MESSAGE, "header define not yet supported"
endif else begin
n=SIZE(image, /n_dimensions)
s=SIZE(image,/dimensions)
if (n EQ 2) then begin
;;pseudocolor
if (N_PARAMS() lt 5) then TVLCT, red, green, blue, /get
;;
;;colorvectors provided
mid=MAGICK_CREATE(s[0],s[1])
_image=TRANSPOSE([[[blue[image]]],[[green[image]]],[[red[image]]]],[2,0,1])
;;
MAGICK_WRITE, mid,_image,rgb=rgb
if (N_ELEMENTS(red) eq N_ELEMENTS(green) and $
N_ELEMENTS(red) eq N_ELEMENTS(blue)) then begin
MAGICK_QUANTIZE,mid,long(N_ELEMENTS(red))
;;
;; MAGICK_WRITEIndexes,mid,image
;; MAGICK_WRITEColorTable,mid,red,green,blue
;;
MAGICK_WRITEFILE, mid, filename, "BMP"
MAGICK_CLOSE, mid
endif
endif else if(n eq 3) then begin
mid=MAGICK_CREATE(s[1],s[2])
MAGICK_WRITE, mid, image, rgb=rgb
MAGICK_WRITEFILE, mid, filename, "BMP"
MAGICK_CLOSE, mid
endif
endelse
;
if KEYWORD_SET(test) OR KEYWORD_SET(debug) then STOP
;
end
|