Changeset 69 for trunk/ToBeReviewed/IMAGE
- Timestamp:
- 05/11/06 12:35:53 (18 years ago)
- Location:
- trunk/ToBeReviewed/IMAGE
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ToBeReviewed/IMAGE/.idlwave_catalog
r68 r69 2 2 ;; IDLWAVE catalog for library saxo 3 3 ;; Automatically Generated -- do not edit. 4 ;; Created by idlwave_catalog on T ue Jan 24 17:06:1920064 ;; Created by idlwave_catalog on Thu May 4 08:42:55 2006 5 5 ;; 6 6 (setq idlwave-library-catalog-libname "saxo") … … 22 22 ("IMDISP_IMSIZE" pro nil (lib "imdisp.pro" nil "saxo") "%s, IMAGE, X0, Y0, XSIZE, YSIZE" (nil ("ASPECT") ("MARGIN") ("POSITION"))) 23 23 ("IMDISP" pro nil (lib "imdisp.pro" nil "saxo") "%s, IMAGE" (nil ("_EXTRA") ("ASPECT") ("AXIS") ("BACKGROUND") ("BOTTOM") ("CHANNEL") ("DITHER") ("ERASE") ("INTERP") ("MARGIN") ("NCOLORS") ("NEGATIVE") ("NORESIZE") ("NOSCALE") ("ORDER") ("OUT_POS") ("POSITION") ("RANGE") ("USEPOS"))) 24 ("SAVEIMAGE" pro nil (lib "saveimage.pro" nil "saxo") "%s, FILE" (nil ("BMP") (" DITHER") ("JPEG") ("PICT") ("PNG") ("QUALITY") ("QUIET") ("TIFF")))24 ("SAVEIMAGE" pro nil (lib "saveimage.pro" nil "saxo") "%s, FILE" (nil ("BMP") ("CUBE") ("DITHER") ("JPEG") ("MULTIPLE") ("PICT") ("PNG") ("QUALITY") ("QUIET") ("TIFF"))) 25 25 ("SHOWIMAGE" pro nil (lib "showimage.pro" nil "saxo") "%s, FILE" (nil ("CURRENT") ("DITHER"))))) -
trunk/ToBeReviewed/IMAGE/saveimage.pro
r23 r69 1 1 PRO SAVEIMAGE, FILE, BMP=BMP, PNG=PNG, PICT=PICT, JPEG=JPEG, TIFF=TIFF, $ 2 QUALITY=QUALITY, DITHER=DITHER, QUIET=QUIET2 QUALITY=QUALITY, DITHER=DITHER, CUBE=CUBE, QUIET=QUIET, MULTIPLE = multiple 3 3 4 4 ;+ … … 28 28 ; INPUTS: 29 29 ; FILE Name of the output file (GIF format by default). 30 ; 30 ; 31 31 ; OPTIONAL INPUTS: 32 32 ; None. 33 ; 33 ; 34 34 ; KEYWORD PARAMETERS: 35 35 ; BMP Set this keyword to create BMP format (8-bit with color table). … … 42 42 ; 100 ("excellent"). Smaller quality values yield higher 43 43 ; compression ratios and smaller output files. 44 ; DITHER Set this keyword to dither the output image when creating 8-bit 45 ; GIF or BMP format (default is no dithering). 44 ; DITHER If set, dither the output image when creating 8-bit output 45 ; which is read from a 24-bit display (default is no dithering). 46 ; CUBE If set, use the color cube method to quantize colors when 47 ; creating 8-bit output which is read from a 24-bit display 48 ; (default is to use the statistical method). This may improve 49 ; the accuracy of colors in the output image, especially white. 46 50 ; QUIET Set this keyword to suppress the information message 47 51 ; (default is to print an information message). 52 ; MULTIPLE to write multiple gif image 48 53 ; 49 54 ; OUTPUTS: … … 60 65 ; 61 66 ; RESTRICTIONS: 62 ; Requires IDL 5. 1 or higher.67 ; Requires IDL 5.0 or higher (square bracket array syntax). 63 68 ; 64 69 ; EXAMPLE: 65 70 ; 66 ;openr, 1, filepath('hurric.dat', subdir='examples/data')67 ;image = bytarr(440, 3 40)68 ;readu, 1, image69 ; close, 171 ;openr, lun, filepath('hurric.dat', subdir='examples/data'), /get_lun 72 ;image = bytarr(440, 330) 73 ;readu, lun, image 74 ;free_lun, lun 70 75 ;loadct, 13 71 76 ;tvscl, image … … 74 79 ; MODIFICATION HISTORY: 75 80 ; Liam.Gumley@ssec.wisc.edu 81 ; http://cimss.ssec.wisc.edu/~gumley 76 82 ; $Id$ 83 ; 84 ; Copyright (C) 1999 Liam E. Gumley 85 ; 86 ; This program is free software; you can redistribute it and/or 87 ; modify it under the terms of the GNU General Public License 88 ; as published by the Free Software Foundation; either version 2 89 ; of the License, or (at your option) any later version. 90 ; 91 ; This program is distributed in the hope that it will be useful, 92 ; but WITHOUT ANY WARRANTY; without even the implied warranty of 93 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 94 ; GNU General Public License for more details. 95 ; 96 ; You should have received a copy of the GNU General Public License 97 ; along with this program; if not, write to the Free Software 98 ; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 77 99 ;- 78 100 101 rcs_id = '$Id$' 102 79 103 ;------------------------------------------------------------------------------- 80 104 ;- CHECK INPUT 81 105 ;------------------------------------------------------------------------------- 82 106 83 ;- Check IDL version84 85 if float(!version.release) lt 5.1 then begin86 message, 'IDL 5.1 or higher is required', /continue87 return88 endif89 90 107 ;- Check arguments 91 92 if n_params() ne 1 then begin 93 message, 'Usage: SAVEIMAGE, FILE', /continue 94 return 95 endif 96 if n_elements(file) eq 0 then message, 'Argument FILE is undefined' 97 if n_elements(file) gt 1 then message, 'Argument FILE must be a scalar string' 108 if (n_params() ne 1) then message, 'Usage: SAVEIMAGE, FILE' 109 if (n_elements(file) eq 0) then message, 'Argument FILE is undefined' 110 if (n_elements(file) gt 1) then message, 'Argument FILE must be a scalar string' 98 111 99 112 ;- Check keywords 100 101 113 output = 'GIF' 102 114 if keyword_set(bmp) then output = 'BMP' … … 105 117 if keyword_set(jpeg) then output = 'JPEG' 106 118 if keyword_set(tiff) then output = 'TIFF' 107 if n_elements(quality) eq 0 then quality = 75 108 109 ;- Check for window capable device with an open window, and get visual depth 110 111 if (!d.flags and 256) eq 0 then message, 'Unsupported graphics device' 112 if !d.window lt 0 then message, 'No graphics windows are open' 113 device, get_visual_depth=depth 119 if (n_elements(quality) eq 0) then quality = 75 120 121 ;- Check for TVRD capable device 122 if ((!d.flags and 128)) eq 0 then message, 'Unsupported graphics device' 123 124 ;- Check for open window 125 if (!d.flags and 256) ne 0 then begin 126 if (!d.window lt 0) then message, 'No graphics windows are open' 127 endif 128 129 ;- Get display depth 130 depth = 8 131 if (!d.n_colors gt 256) then depth = 24 114 132 115 133 ;------------------------------------------------------------------------------- … … 117 135 ;------------------------------------------------------------------------------- 118 136 119 ;- Save display order, then set images to display from bottom up 120 121 current_order = !order 122 !order = 0 123 124 ;- Copy the contents of the current display to a pixmap 125 126 current_window = !d.window 127 xsize = !d.x_size 128 ysize = !d.y_size 129 window, /free, /pixmap, xsize=xsize, ysize=ysize 130 device, copy=[0, 0, xsize, ysize, 0, 0, current_window] 137 ;- Handle window devices (other than the Z buffer) 138 if (!d.flags and 256) ne 0 then begin 139 140 ;- Copy the contents of the current display to a pixmap 141 current_window = !d.window 142 xsize = !d.x_size 143 ysize = !d.y_size 144 window, /free, /pixmap, xsize=xsize, ysize=ysize, retain=2 145 device, copy=[0, 0, xsize, ysize, 0, 0, current_window] 146 147 ;- Set decomposed color mode for 24-bit displays 148 version = float(!version.release) 149 if (depth gt 8) then begin 150 if (version gt 5.1) then device, get_decomposed=entry_decomposed 151 device, decomposed=1 152 endif 153 154 endif 131 155 132 156 ;- Read the pixmap contents into an array 133 134 if depth gt 8 then image = tvrd(true=1) else image = tvrd() 135 136 ;- Delete the pixmap 137 138 wdelete, !d.window 139 wset, current_window 157 if (depth gt 8) then begin 158 image = tvrd(order=0, true=1) 159 endif else begin 160 image = tvrd(order=0) 161 endelse 162 163 ;- Handle window devices (other than the Z buffer) 164 if (!d.flags and 256) ne 0 then begin 165 166 ;- Restore decomposed color mode for 24-bit displays 167 if (depth gt 8) then begin 168 if (version gt 5.1) then begin 169 device, decomposed=entry_decomposed 170 endif else begin 171 device, decomposed=0 172 if (keyword_set(quiet) eq 0) then $ 173 print, 'Decomposed color was turned off' 174 endelse 175 endif 176 177 ;- Delete the pixmap 178 wdelete, !d.window 179 wset, current_window 180 181 endif 140 182 141 183 ;- Get the current color table 142 143 184 tvlct, r, g, b, /get 144 185 145 186 ;- If an 8-bit image was read, reduce the number of colors 146 147 if depth le 8 then begin 187 if (depth le 8) then begin 148 188 reduce_colors, image, index 149 189 r = r[index] 150 190 g = g[index] 151 191 b = b[index] 152 endif 153 154 ;- Restore display order 155 156 !order = current_order 192 endif 157 193 158 194 ;------------------------------------------------------------------------------- … … 160 196 ;------------------------------------------------------------------------------- 161 197 162 ;- Save the image in 8-bit or 24-bit format163 164 198 case 1 of 165 199 166 200 ;- Save the image in 8-bit output format 167 168 201 (output eq 'GIF') or (output eq 'BMP') or $ 169 202 (output eq 'PICT') or (output eq 'PNG') : begin 170 203 171 if depth gt 8then begin204 if (depth gt 8) then begin 172 205 173 206 ;- Convert 24-bit image to 8-bit 174 175 image = color_quan(image, 1, r, g, b, colors=256, $ 176 dither=keyword_set(dither)) 207 case keyword_set(cube) of 208 0 : image = color_quan(image, 1, r, g, b, colors=256, $ 209 dither=keyword_set(dither)) 210 1 : image = color_quan(image, 1, r, g, b, cube=6) 211 endcase 177 212 178 213 ;- Sort the color table from darkest to brightest 179 180 214 table_sum = total([[long(r)], [long(g)], [long(b)]], 2) 181 215 table_index = sort(table_sum) … … 186 220 oldimage = image 187 221 image[*] = image_index[temporary(oldimage)] 188 222 189 223 endif 190 224 191 225 ;- Save the image 192 193 226 case output of 194 'GIF' : write_gif, file, image, r, g, b 227 'GIF' : write_gif, file, image, r, g, b, MULTIPLE = multiple 195 228 'BMP' : write_bmp, file, image, r, g, b 196 229 'PNG' : write_png, file, image, r, g, b 197 230 'PICT' : write_pict, file, image, r, g, b 198 231 endcase 199 232 200 233 end 201 234 202 235 ;- Save the image in 24-bit output format 203 204 236 (output eq 'JPEG') or (output eq 'TIFF') : begin 205 237 206 238 ;- Convert 8-bit image to 24-bit 207 208 if depth le 8 then begin 209 dims = size(image, /dimensions) 210 nx = dims[0] 211 ny = dims[1] 239 if (depth le 8) then begin 240 info = size(image) 241 nx = info[1] 242 ny = info[2] 212 243 true = bytarr(3, nx, ny) 213 244 true[0, *, *] = r[image] … … 218 249 219 250 ;- If TIFF format output, reverse image top to bottom 220 221 if output eq 'TIFF' then image = reverse(temporary(image), 3) 222 251 if (output eq 'TIFF') then image = reverse(temporary(image), 3) 252 223 253 ;- Write the image 224 225 254 case output of 226 255 'JPEG' : write_jpeg, file, image, true=1, quality=quality 227 256 'TIFF' : write_tiff, file, image, 1 228 257 endcase 229 258 230 259 end 231 260 232 261 endcase 233 262 234 263 ;- Print information for the user 235 236 if not keyword_set(quiet) then $ 264 if (keyword_set(quiet) eq 0) then $ 237 265 print, file, output, format='("Created ",a," in ",a," format")' 238 266 239 267 END -
trunk/ToBeReviewed/IMAGE/showimage.pro
r23 r69 10 10 ; The input formats supported are: 11 11 ; GIF 8-bit with color table, 12 ; PNG 8-bit with color table,13 12 ; BMP 8-bit with color table or 24-bit true-color, 14 13 ; PICT 8-bit with color table, … … 58 57 ; MODIFICATION HISTORY: 59 58 ; Liam.Gumley@ssec.wisc.edu 59 ; http://cimss.ssec.wisc.edu/~gumley 60 60 ; $Id$ 61 ; 62 ; Copyright (C) 1999 Liam E. Gumley 63 ; 64 ; This program is free software; you can redistribute it and/or 65 ; modify it under the terms of the GNU General Public License 66 ; as published by the Free Software Foundation; either version 2 67 ; of the License, or (at your option) any later version. 68 ; 69 ; This program is distributed in the hope that it will be useful, 70 ; but WITHOUT ANY WARRANTY; without even the implied warranty of 71 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 72 ; GNU General Public License for more details. 73 ; 74 ; You should have received a copy of the GNU General Public License 75 ; along with this program; if not, write to the Free Software 76 ; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 61 77 ;- 78 79 rcs_id = '$Id$' 62 80 63 81 ;------------------------------------------------------------------------------- … … 123 141 if result eq 0 then result = query_tiff(file, info) 124 142 if result eq 0 then result = query_jpeg(file, info) 125 if result eq 0 then result = query_png(file, info)126 143 if result eq 0 then begin 127 144 message, 'File format not recognized', /continue … … 138 155 139 156 'GIF' : read_gif, file, image, r, g, b 140 141 'PNG' : read_png, file, image, r, g, b142 157 143 158 'BMP' : begin … … 205 220 206 221 device, get_screen_size=screen 207 if nx gt (0.95 * screen[0]) then begin 208 xsize = 0.85 * nx 222 screen_xsize = screen[0] 223 screen_ysize = screen[1] 224 if (nx gt screen_xsize) then begin 225 xsize = 0.9 * screen_xsize 209 226 scroll = 1 210 227 endif 211 if ny gt (0.95 * screen[1]) then begin212 ysize = 0. 85 * ny228 if (ny gt screen_ysize) then begin 229 ysize = 0.9 * screen_ysize 213 230 scroll = 1 214 231 endif
Note: See TracChangeset
for help on using the changeset viewer.