home *** CD-ROM | disk | FTP | other *** search
Wrap
/* Program to use ADPro to make sets of thumbnail miniatures of all the pictures in a directory, including subdirectories. They can be in a variey of formats. They will be rendered in Hi-Res Interlace, 16-colour or Ham-8. The dither mode currently in force is used. */ /* If it jams up while trying to load in a file which it thinks (wrongly) is a Targa or PCX image, just click on Abort. */ /* Written by Don Cox, Nov. '93. Bug Fix June 94. PCX bug fix Oct 95. Copyright, not Public Domain. */ /* $VER:Thumbnails76 Oct 95 */ /* call open("STDERR","ram:traceTN","W") trace r */ options results numeric digits 14 /* Screen type definitions - do not alter */ hires = 1 interlace = 2 pal = 4 /* NTSC if off */ hoverscan = 8 voverscan = 16 vga = 32 superhires = 64 super72 = 128 default = 256 /* ++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++ */ /* These presets can be edited by the user */ backcolour = "80 80 80" /* colours in RGB format - don't forget the quotes */ framecolour = "190 190 190" highlightcolour = "220 220 220" /* 3D effect on frames */ shadowcolour = "80 80 80" textcolour = "0 0 0" textfont = "Folio-Medium" /* Must be in Fonts: directory */ textsize = 13 bigwidth = 640 /* width of final Catalogue image */ bigheight = 512 /* height of final image */ columns = 7 /* layout of final picture */ rows = 6 dithertype = 8 /* This is small ordered */ ditheramount = 16 /* How much dither */ screentype = hires + interlace + pal /* +++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++ */ address "ADPro" ADPRO_TO_FRONT getdir '"Select source directory"' if rc=10 then exit directory = ADPro_Result getdir '"Select directory for saving"' if rc=10 then exit sdirectory = ADPro_Result if upper(sdirectory) = "RAM DISK:" then sdirectory = "Ram:" if right(sdirectory,1) ~=":" then sdirectory = sdirectory||"/" getdir '"Select directory for temporary files"' '"ram:"' if rc=10 then exit tdirectory = ADPro_Result if right(tdirectory,1) ~=":" then tdirectory = tdirectory||"/" hammer = "HAM8" okay2 "OK for Ham8, Cancel for 16 colours" hammit = rc if hammit = 0 then hammer = 16 lformat "UNIVERSAL" sformat "IFF" pstatus "UNLOCKED" load_type "REPLACE" smallwidth = trunc(bigwidth/columns) smallheight = trunc(bigheight/rows) /* Make index chart files of one directory and its descendents */ address command 'list >ram:dirlist 'directory' dirs all LFORMAT="%P%S"' call open("dirinput","ram:dirlist","r") /* First make index charts for pics in root diectory */ 'delete ram:filelist1' 'delete ram:filelist' 'list >ram:filelist1 'directory' files LFORMAT="%P%S"' call open(input,"ram:filelist1","r") /* test in case it's empty */ listtest = readln(input) call close input if listtest~="" then do 'sort from ram:filelist1 to ram:filelist' pos1 = lastpos("/",directory) if pos1 = 0 then pos1 = lastpos(":",directory) basename = substr(directory,pos1+1) if basename = "" then basename = strip(directory,'T',":") if length(basename)>18 then basename = left(basename,18) basename = basename||".index." address "ADPro" call dirchart end /* Now do all the subdirectories */ do d = 1 to 700 dirname = readln("dirinput") if dirname = "" then break pos1 = lastpos("/",dirname) if pos1 = 0 then pos1 = lastpos(":",dirname) basename = substr(dirname,pos1+1) if length(basename)>18 then basename = left(basename,18) basename = basename||".index." address command 'delete ram:filelist1' 'delete ram:filelist' 'list >ram:filelist1 'dirname' files LFORMAT="%P%S"' call open(input,"ram:filelist1","r") /* test in case it's empty */ listtest = readln(input) call close input if listtest~="" then do 'sort from ram:filelist1 to ram:filelist' address "ADPro" call dirchart end end address "ADPro" ADPRO_TO_FRONT OKAY1 "Finished..." exit end /* ++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++ */ getpath: arg allname pos1 = lastpos("/",allname) if pos1 = 0 then pos1 = lastpos(":",allname) filepath = left(allname,pos1) return filepath getname: arg allname pos1 = lastpos("/",allname) if pos1 = 0 then pos1 = lastpos(":",allname) justname = substr(allname,pos1+1) return justname /* +++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++ */ /* Make a single screen full of little pictures */ makechart: lformat "BACKDROP" LOAD "XXX" bigwidth bigheight "COLOR" lformat "IFF" LOAD_TYPE "COMPOSE" do p = 0 to lastpic pp = p+1 /* position by rows & columns, and adjust for centring */ xpos = ((p//columns)* smallwidth) ypos = ((p%columns) * smallheight) xpos2 = xpos + ((smallwidth-scalewidth.pp)%2) /* centring - use integer division to avoid half-pixels */ ypos2 = ypos + ((imageheight-scaleheight.pp)%2) pnumber = right(pp,3,"0") loadname = tdirectory||"tpic"||pnumber OPERATOR "RECTANGLE" xpos ypos smallwidth smallheight "-1" backcolour /* grey background */ LOAD loadname xpos2 ypos2 OPERATOR "RECTANGLE" (xpos) (ypos) (smallwidth-1) (imageheight) 1 highlightcolour OPERATOR "RECTANGLE" (xpos+1) (ypos+1) (smallwidth-1) (smallheight-1) 1 shadowcolour OPERATOR "RECTANGLE" xpos ypos smallwidth smallheight 1 framecolour OPERATOR "RECTANGLE" xpos (ypos+imageheight) smallwidth textsize "-1" framecolour xoff = trunc(xpos+4) yoff = trunc(ypos+smallheight-textsize) OPERATOR "TEXT_VISUAL", FONT_TYPE "BITMAPPED", FONT_DIR "Fonts:", FONT_NAME textfont, SET_FONT_SIZE textsize, SET_BLUR "-1", EMBOSS_DIRECTION "OFF", RENDER_TYPE "MIX", SET_COLORS textcolour, SET_RENDER 100, SET_XOFFSET xoff, SET_YOFFSET yoff, STRING picname.pp , TEXT_HANDLE "LEFT", DRAW success = rc end SCREEN_TYPE screentype DITHER dithertype DITHER_AMOUNT ditheramount RENDER_TYPE hammer /* Ham8 or 16-colour */ CONTRAST 1 EXECUTE ADPRO_DISPLAY PAUSE 150 pnumber = right(picnumber,3,"0") savename = sdirectory||basename||pnumber if exists(savename) then do q=1 to 10 ADPRO_TO_FRONT okay2 '"File exists. Overwrite it?"' if rc ~= 0 then break /* User wants to overwrite */ getstring "'Type new basename for files'" basename if rc~=0 then exit basename = ADPRO_RESULT savename = sdirectory||basename||pnumber if ~exists(savename) then break /* break if new name provided */ end SAVE savename "IMAGE" PAUSE 150 picnumber = picnumber + 1 LOAD_TYPE "REPLACE" return /* ++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++ */ /* Make a set of charts for all the pics in a directory */ dirchart: address "ADPro" tn = 1 /* thumbnail pic number as saved to temp. storage */ picnumber = 1 /* final chart pic number */ call open(input,"ram:filelist","r") do i = 1 to 7000 /* safety limit of 7000 files */ filename = readln(input) if filename = "" then break slashpos = lastpos("/",filename) dotpos = lastpos(".",filename) if dotpos<slashpos then dotpos = 0 /* not dots in directory names */ if dotpos~=0 then extension = substr(filename,dotpos) else extension = "" if upper(extension) = ".INFO" then iterate if upper(extension) = ".PSFONT" then iterate if upper(extension) = ".FONT" then iterate if upper(extension) = ".PDFONT" then iterate if upper(extension) = ".PFB" then iterate if upper(extension) = ".AFM" then iterate if upper(extension) = ".METRIC" then iterate if upper(extension) = ".LIB" then iterate if upper(extension) = ".DEM" then iterate if upper(extension) = ".DOC" then iterate if upper(extension) = ".ZIP" then iterate if upper(extension) = ".LHA" then iterate if upper(extension) = ".ARC" then iterate if upper(extension) = ".ME" then iterate if upper(extension) = ".DAT" then iterate if upper(extension) = ".TF" then iterate if upper(extension) = ".DB" then iterate if upper(extension) = ".C" then iterate if upper(extension) = ".H" then iterate if upper(extension) = ".GF" then iterate if upper(extension) = ".PPRX" then iterate if upper(extension) = ".PDRX" then iterate if upper(extension) = ".REXX" then iterate if upper(extension) = ".ADPRO" then iterate /* Now some common PC extensions */ if upper(extension) = "." then iterate if upper(extension) = ".HLP" then iterate if upper(extension) = ".GAL" then iterate if upper(extension) = ".EXE" then iterate if upper(extension) = ".INI" then iterate if upper(extension) = ".COM" then iterate if upper(extension) = ".BAT" then iterate if word(filename,2) = "files" then iterate /* This line not a file name */ if word(filename,1) = "TOTAL:" then break /* or this one */ load_type "REPLACE" lformat "UNIVERSAL" call open("picinput",filename,"R") chunks = readch("picinput",1000) call seek("picinput",3,'B') /* position 3 to read 4th byte */ EGAbyte = readch("picinput",1) /* looking out for 1-bit PCXs */ EGAtest = c2d(EGAbyte,1) call close("picinput") if substr(chunks,9,4) = "ANIM" then do lformat "ANIM" load '"'filename'"' FRAME 1 end else load '"'filename'"' /* Quotes allow file names with spaces */ if rc ~=0 then iterate /* if load fails, try the next one */ pos1 = lastpos("/",filename) if pos1 = 0 then pos1 = lastpos(":",filename) picname.tn = '"'||substr(filename,pos1+1)||'"' imagetype = 24bit /* if in doubt */ IMAGE_TYPE itype = ADPRO_RESULT if left(itype,8)="BITPLANE" then imagetype = bitplane else if left(itype,5) = "COLOR" then imagetype = 24bit else if left(itype,4) = "GRAY" then imagetype = gray if imagetype = bitplane then iterate /* can't scale if no 24-bit or 8-bit data - i.e. picture too big for memory */ /* EGAbyte = substr(chunks,4,1) EGAtest = b2c(EGAbyte)*/ if (upper(extension) = ".PCX" & EGAtest=1) then do /* deal with palette problems */ EXECUTE ppoke 0 0 0 0 ppoke 1 255 255 255 OPERATOR "RENDERED_TO_RAW" end /* Get size of loaded image, before scaling */ xsize inputwidth = ADPro_result ysize inputheight = ADPro_result /* Adjusting proportions */ CONTRAST "-1" /* Prevents ADPro's scaling artefacts, seen on 0 or 255 colours */ OPERATOR "APPLY_MAP" prop = 1 /* for starters */ /* If it's an IFF file, the CAMG chunk should tell us its proportions */ CAMG = "null" /* just a dummy string */ binCAMG = "null" filetype = left(chunks,4) if filetype = "FORM" then do CAMG = substr(chunks,pos("CAMG",chunks)+10,2) if pos("CAMG",chunks)=0 then break binCAMG = c2b(CAMG) binCAMG = overlay("000000000000",binCAMG,2) /* don't want these bits */ picformat = "null" /* These comparisons only just work, with numeric digits at 14, as the last 2 digits don't matter */ select when binCAMG = "0000000000000000" then do picformat = "lores" prop=1 end when binCAMG = "1000000000000000" then do picformat = "medres" prop=0.5 end when binCAMG = "0000000000000100" then do picformat = "interlace" prop=2 end when binCAMG = "1000000000000100" then do picformat = "hires" prop=1 end otherwise do picformat = "unknown" prop=1 end end end imageheight = smallheight-textsize /* allow for label */ scalewidth.tn = smallwidth proportion = (inputheight)/(inputwidth*prop) scaleheight.tn = trunc(scalewidth.tn * proportion ) /* keep proportions */ if scaleheight.tn >imageheight then do /* vertical pics */ proportion = inputwidth*prop/inputheight scalewidth.tn = trunc(imageheight* proportion ) scaleheight.tn = imageheight end ABS_SCALE scalewidth.tn scaleheight.tn tnumber = right(tn,3,"0") /* make 6 be 006, etc */ savename = tdirectory||"tpic"||tnumber SAVE savename "RAW" tn = tn + 1 lastpic = tn - 2 if tn = (rows*columns)+1 then do call makechart /* assemble pics together */ tn = 1 end end /* end of directory */ call close(input) lastpic = tn - 2 if tn~=1 then call makechart /* do the remaining pics */ ADPRO_UNDISPLAY return