1; 2; AC 28/01/2010 3; 4; quick test reading back and displaying a JPEG 5; 6; What is tested ? 7; -- reading back a small (600x259) JPEG image 8; -- using well positions index in TVSCL 9; -- reading a color image in Grayscale ... (09/11/2011) 10; 11pro TEST_READ_JPEG, filename=filename, path=path, factor=factor, $ 12 help=help, test=test, debug=debug, verbose=verbose 13; 14if KEYWORD_SET(help) then begin 15 print, 'pro TEST_READ_JPEG, filename=filename, path=path, factor=factor, $' 16 print, ' help=help, test=test, debug=debug, verbose=verbose' 17 print, '' 18 print, 'You can provide any JPEG image using FILENAME=' 19 print, 'We look in !Path. You can provide alternate paths with PATH=' 20 return 21endif 22; 23if N_ELEMENTS(path) EQ 0 then path=!path 24if N_ELEMENTS(filename) EQ 0 then filename='Saturn.jpg' 25; 26if N_ELEMENTS(factor) EQ 0 then factor=1 27; 28title0='the 3 channels in Grayscale' 29title1='<<'+filename+'>> in Colors' 30title2='read in Grayscale only' 31; 32full_file=FILE_SEARCH_FOR_TESTSUITE(filename, /quiet) 33; 34if (STRLEN(full_file) EQ 0) then begin 35 MESSAGE, /continue, 'No file founded ...' 36 MESSAGE, /continue, 'File : '+filename 37 HELP, /PATH 38 return 39endif 40; 41if KEYWORD_SET(verbose) then begin 42 MESSAGE, 'reading : '+full_file, /continue 43endif 44; 45READ_JPEG, full_file, image 46; 47xy_img=(SIZE(image,/dim))[1:2] 48xy_screen=GET_SCREEN_SIZE() 49loose=50 ; perte (surtout en vertical: la/les barre(s) de menu KDE/Gnome 50xy_screen=xy_screen-loose 51; 52vertical=-1 53; rentre-t-on dans de l'horizontal ? 54if (xy_screen[0] GT 3*xy_img[0]) AND (xy_screen[1] GT xy_img[1]) then begin 55 vertical=0 56 xy_win0=xy_img 57 xy_win0[0]=xy_win0[0]*3 58 xy_win1=xy_img 59endif 60; rentre-t-on dans du vertical ? (on prefere ce mode-ci) 61if (xy_screen[0] GT xy_img[0]) AND (xy_screen[1] GT 3*xy_img[1]) then begin 62 vertical=1 63 xy_win0=xy_img 64 xy_win0[1]=xy_win0[1]*3 65 xy_win1=xy_img 66endif 67; 68if (vertical EQ -1) then begin 69 MESSAGE, /continue, 'Soo small screen/too big image ! automatic rescaling !!' 70 MESSAGE, /continue, 'Some part of the image may be cut (top and right sides)' 71 ;; 72 factor_h_x=ROUND(1+xy_img[0]*3/xy_screen[0]) 73 factor_h_y=ROUND(1+xy_img[1]/xy_screen[1]) 74 factor_v_x=ROUND(1+xy_img[0]/xy_screen[0]) 75 factor_v_y=ROUND(1+xy_img[1]*3/xy_screen[1]) 76 factor_h=MAX([factor_h_x,factor_h_y]) 77 factor_v=MAX([factor_v_x,factor_v_y]) 78 factor=MIN([factor_h,factor_v],vertical) 79 ;; 80 xy_win1=xy_img/factor 81 image=REBIN(image[*,0:xy_win1[0]*factor-1,0:xy_win1[1]*factor-1],3,xy_win1[0],xy_win1[1]) 82 ;; 83 xy_win0=xy_img/factor 84 if (vertical EQ 1) then begin 85 xy_win0[1]=xy_win0[1]*3 86 endif else begin 87 xy_win0[0]=xy_win0[0]*3 88 endelse 89endif 90; 91; just a trick to be able to test for small screens 92if KEYWORD_SET(debug) then half=debug 93; 94WINDOW, 0, xsize=xy_win0[0], ysize=xy_win0[1], title=title0 95TVSCL, image[0,*,*], 0 96TVSCL, image[1,*,*], 1 97TVSCL, image[2,*,*], 2 98; 99WINDOW, 1, xsize=xy_win1[0], ysize=xy_win1[1], title=title1 100TVSCL, image, /true 101; 102; is the /Grayscale keyword OK ? 103; 104READ_JPEG, full_file, image_gray, /GRAY 105WINDOW, 2, xsize=xy_win1[0], ysize=xy_win1[1], title=title2 106image_gray=REBIN(image_gray[0:xy_win1[0]*factor-1,0:xy_win1[1]*factor-1],xy_win1[0],xy_win1[1]) 107TVSCL, image_gray 108; 109if KEYWORD_SET(test) then STOP 110; 111end 112 113