Ignore:
Timestamp:
05/11/06 12:35:53 (18 years ago)
Author:
smasson
Message:

debug + new xxx

Location:
trunk/ToBeReviewed/IMAGE
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ToBeReviewed/IMAGE/.idlwave_catalog

    r68 r69  
    22;; IDLWAVE catalog for library saxo 
    33;; Automatically Generated -- do not edit. 
    4 ;; Created by idlwave_catalog on Tue Jan 24 17:06:19 2006 
     4;; Created by idlwave_catalog on Thu May  4 08:42:55 2006 
    55;; 
    66(setq idlwave-library-catalog-libname "saxo") 
     
    2222   ("IMDISP_IMSIZE" pro nil (lib "imdisp.pro" nil "saxo") "%s, IMAGE, X0, Y0, XSIZE, YSIZE" (nil ("ASPECT") ("MARGIN") ("POSITION"))) 
    2323   ("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"))) 
    2525   ("SHOWIMAGE" pro nil (lib "showimage.pro" nil "saxo") "%s, FILE" (nil ("CURRENT") ("DITHER"))))) 
  • trunk/ToBeReviewed/IMAGE/saveimage.pro

    r23 r69  
    11PRO SAVEIMAGE, FILE, BMP=BMP, PNG=PNG, PICT=PICT, JPEG=JPEG, TIFF=TIFF, $ 
    2   QUALITY=QUALITY, DITHER=DITHER, QUIET=QUIET 
     2  QUALITY=QUALITY, DITHER=DITHER, CUBE=CUBE, QUIET=QUIET, MULTIPLE = multiple 
    33 
    44;+ 
     
    2828; INPUTS: 
    2929;    FILE     Name of the output file (GIF format by default). 
    30 ;     
     30; 
    3131; OPTIONAL INPUTS: 
    3232;    None. 
    33 ;        
     33; 
    3434; KEYWORD PARAMETERS: 
    3535;    BMP      Set this keyword to create BMP format (8-bit with color table). 
     
    4242;             100 ("excellent"). Smaller quality values yield higher 
    4343;             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. 
    4650;    QUIET    Set this keyword to suppress the information message 
    4751;             (default is to print an information message). 
     52;    MULTIPLE to write multiple gif image 
    4853; 
    4954; OUTPUTS: 
     
    6065; 
    6166; RESTRICTIONS: 
    62 ;    Requires IDL 5.1 or higher. 
     67;    Requires IDL 5.0 or higher (square bracket array syntax). 
    6368; 
    6469; EXAMPLE: 
    6570; 
    66 ;openr, 1, filepath('hurric.dat', subdir='examples/data') 
    67 ;image = bytarr(440, 340) 
    68 ;readu, 1, image 
    69 ;close, 1 
     71;openr, lun, filepath('hurric.dat', subdir='examples/data'), /get_lun 
     72;image = bytarr(440, 330) 
     73;readu, lun, image 
     74;free_lun, lun 
    7075;loadct, 13 
    7176;tvscl, image 
     
    7479; MODIFICATION HISTORY: 
    7580; Liam.Gumley@ssec.wisc.edu 
     81; http://cimss.ssec.wisc.edu/~gumley 
    7682; $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. 
    7799;- 
    78100 
     101rcs_id = '$Id$' 
     102 
    79103;------------------------------------------------------------------------------- 
    80104;- CHECK INPUT 
    81105;------------------------------------------------------------------------------- 
    82106 
    83 ;- Check IDL version 
    84  
    85 if float(!version.release) lt 5.1 then begin 
    86   message, 'IDL 5.1 or higher is required', /continue 
    87   return 
    88 endif 
    89  
    90107;- 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' 
     108if (n_params() ne 1) then message, 'Usage: SAVEIMAGE, FILE' 
     109if (n_elements(file) eq 0) then message, 'Argument FILE is undefined' 
     110if (n_elements(file) gt 1) then message, 'Argument FILE must be a scalar string' 
    98111 
    99112;- Check keywords 
    100  
    101113output = 'GIF' 
    102114if keyword_set(bmp)  then output = 'BMP' 
     
    105117if keyword_set(jpeg) then output = 'JPEG' 
    106118if 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 
     119if (n_elements(quality) eq 0) then quality = 75 
     120 
     121;- Check for TVRD capable device 
     122if ((!d.flags and 128)) eq 0 then message, 'Unsupported graphics device' 
     123 
     124;- Check for open window 
     125if (!d.flags and 256) ne 0 then begin 
     126  if (!d.window lt 0) then message, 'No graphics windows are open' 
     127endif 
     128 
     129;- Get display depth 
     130depth = 8 
     131if (!d.n_colors gt 256) then depth = 24 
    114132 
    115133;------------------------------------------------------------------------------- 
     
    117135;------------------------------------------------------------------------------- 
    118136 
    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) 
     138if (!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 
     154endif 
    131155 
    132156;- 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 
     157if (depth gt 8) then begin 
     158  image = tvrd(order=0, true=1) 
     159endif else begin 
     160  image = tvrd(order=0) 
     161endelse 
     162 
     163;- Handle window devices (other than the Z buffer) 
     164if (!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 
     181endif 
    140182 
    141183;- Get the current color table 
    142  
    143184tvlct, r, g, b, /get 
    144185 
    145186;- If an 8-bit image was read, reduce the number of colors 
    146  
    147 if depth le 8 then begin 
     187if (depth le 8) then begin 
    148188  reduce_colors, image, index 
    149189  r = r[index] 
    150190  g = g[index] 
    151191  b = b[index] 
    152 endif             
    153  
    154 ;- Restore display order 
    155  
    156 !order = current_order 
     192endif 
    157193 
    158194;------------------------------------------------------------------------------- 
     
    160196;------------------------------------------------------------------------------- 
    161197 
    162 ;- Save the image in 8-bit or 24-bit format 
    163  
    164198case 1 of 
    165199 
    166200  ;- Save the image in 8-bit output format 
    167    
    168201  (output eq 'GIF')  or (output eq 'BMP') or $ 
    169202  (output eq 'PICT') or (output eq 'PNG') : begin 
    170203 
    171     if depth gt 8 then begin 
     204    if (depth gt 8) then begin 
    172205 
    173206      ;- 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 
    177212 
    178213      ;- Sort the color table from darkest to brightest 
    179        
    180214      table_sum = total([[long(r)], [long(g)], [long(b)]], 2) 
    181215      table_index = sort(table_sum) 
     
    186220      oldimage = image 
    187221      image[*] = image_index[temporary(oldimage)] 
    188        
     222 
    189223    endif 
    190      
     224 
    191225    ;- Save the image 
    192  
    193226    case output of 
    194       'GIF'  : write_gif,  file, image, r, g, b 
     227      'GIF'  : write_gif,  file, image, r, g, b, MULTIPLE = multiple 
    195228      'BMP'  : write_bmp,  file, image, r, g, b 
    196229      'PNG'  : write_png,  file, image, r, g, b 
    197230      'PICT' : write_pict, file, image, r, g, b 
    198231    endcase 
    199      
     232 
    200233  end 
    201    
     234 
    202235  ;- Save the image in 24-bit output format 
    203    
    204236  (output eq 'JPEG') or (output eq 'TIFF') : begin 
    205237 
    206238    ;- 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] 
    212243      true = bytarr(3, nx, ny) 
    213244      true[0, *, *] = r[image] 
     
    218249 
    219250    ;- 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 
    223253    ;- Write the image 
    224      
    225254    case output of 
    226255      'JPEG' : write_jpeg, file, image, true=1, quality=quality 
    227256      'TIFF' : write_tiff, file, image, 1 
    228257    endcase 
    229      
     258 
    230259  end 
    231    
     260 
    232261endcase 
    233262 
    234263;- Print information for the user 
    235  
    236 if not keyword_set(quiet) then $ 
     264if (keyword_set(quiet) eq 0) then $ 
    237265  print, file, output, format='("Created ",a," in ",a," format")' 
    238    
     266 
    239267END 
  • trunk/ToBeReviewed/IMAGE/showimage.pro

    r23 r69  
    1010;    The input formats supported are: 
    1111;    GIF   8-bit with color table, 
    12 ;    PNG   8-bit with color table, 
    1312;    BMP   8-bit with color table or 24-bit true-color, 
    1413;    PICT  8-bit with color table, 
     
    5857; MODIFICATION HISTORY: 
    5958; Liam.Gumley@ssec.wisc.edu 
     59; http://cimss.ssec.wisc.edu/~gumley 
    6060; $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. 
    6177;- 
     78 
     79rcs_id = '$Id$' 
    6280 
    6381;------------------------------------------------------------------------------- 
     
    123141if result eq 0 then result = query_tiff(file, info) 
    124142if result eq 0 then result = query_jpeg(file, info) 
    125 if result eq 0 then result = query_png(file, info) 
    126143if result eq 0 then begin 
    127144  message, 'File format not recognized', /continue 
     
    138155 
    139156  'GIF' : read_gif, file, image, r, g, b 
    140  
    141   'PNG' : read_png, file, image, r, g, b 
    142157 
    143158  'BMP' : begin 
     
    205220 
    206221  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 
    209226    scroll = 1 
    210227  endif 
    211   if ny gt (0.95 * screen[1]) then begin 
    212     ysize = 0.85 * ny 
     228  if (ny gt screen_ysize) then begin 
     229    ysize = 0.9 * screen_ysize 
    213230    scroll = 1 
    214231  endif 
Note: See TracChangeset for help on using the changeset viewer.