Home » Archimedes archive » Acorn Computing » 1995 01.adf » 9501 » TechForum/Thumbnails/Thumbs/!Thumbs/!Help

TechForum/Thumbnails/Thumbs/!Thumbs/!Help

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Archimedes archive » Acorn Computing » 1995 01.adf » 9501
Filename: TechForum/Thumbnails/Thumbs/!Thumbs/!Help
Read OK:
File size: 0791 bytes
Load address: 0000
Exec address: 0000
File contents
Thumbnail making demo:

See magazine for details of what this is all about & move directory 'Thumbs'
to a writable medium before running !Thumbs.

Demo reads sprite file 'Input' from !Thumbs parent directory. Attempts to
create a thumbnail for each sprite within it - only 256 colour sources can
currently be dealt with {modify c.minisprs function 'plotinto', if you want
to handle other source sprites}. Saves all resulting thumbnails to sprite
file 'Output' in same directory as 'Input'.

Note, thumbnail mode will be based on current screen mode, such that if
current mode has pixel aspect 1:2, then so will thumbnail, else thumbnail
gets pixel aspect 1:1.

Code allows above to be changed so that pixel aspect is based on the source
sprite pixel aspect {call sprsdisp_miniusesourceaspect(TRUE) prior to
mini_make}, though you could of course adopt any method you like.

Thumbnails maintain aspect ratio of source, & are fitted to lie within a
square of side SDmaxsize os units. SDmaxsize is an int variable. In this
demo it can be modified by altering the value following !RunImage in the
last line of the !Run file (it should be a multiple of 8).

Note, time taken by code is proportionate to thumbnail size, & almost
entirely independent of source size. For SDmaxsize=128, times are typically
low & much quicker than ChangeFSI, however you could increase speed still
further by recoding 'plotprocess' in assembler.

If you use this code in your own programs where speed is important & where
many mini sprites are being made in one batch, be careful about time taken
to extend the miniarea sprite area upon each mini_make call.

The total time used to flex_extend it may be greater than that required by
all other computations! - in such a situation it is better to flex_extend it
prior to processing the batch, in order to leave enough free space in the
mini_area for all the expected mini sprites. This is not done in this demo.
00000000  0a 54 68 75 6d 62 6e 61  69 6c 20 6d 61 6b 69 6e  |.Thumbnail makin|
00000010  67 20 64 65 6d 6f 3a 0a  0a 53 65 65 20 6d 61 67  |g demo:..See mag|
00000020  61 7a 69 6e 65 20 66 6f  72 20 64 65 74 61 69 6c  |azine for detail|
00000030  73 20 6f 66 20 77 68 61  74 20 74 68 69 73 20 69  |s of what this i|
00000040  73 20 61 6c 6c 20 61 62  6f 75 74 20 26 20 6d 6f  |s all about & mo|
00000050  76 65 20 64 69 72 65 63  74 6f 72 79 20 27 54 68  |ve directory 'Th|
00000060  75 6d 62 73 27 0a 74 6f  20 61 20 77 72 69 74 61  |umbs'.to a writa|
00000070  62 6c 65 20 6d 65 64 69  75 6d 20 62 65 66 6f 72  |ble medium befor|
00000080  65 20 72 75 6e 6e 69 6e  67 20 21 54 68 75 6d 62  |e running !Thumb|
00000090  73 2e 0a 0a 44 65 6d 6f  20 72 65 61 64 73 20 73  |s...Demo reads s|
000000a0  70 72 69 74 65 20 66 69  6c 65 20 27 49 6e 70 75  |prite file 'Inpu|
000000b0  74 27 20 66 72 6f 6d 20  21 54 68 75 6d 62 73 20  |t' from !Thumbs |
000000c0  70 61 72 65 6e 74 20 64  69 72 65 63 74 6f 72 79  |parent directory|
000000d0  2e 20 41 74 74 65 6d 70  74 73 20 74 6f 0a 63 72  |. Attempts to.cr|
000000e0  65 61 74 65 20 61 20 74  68 75 6d 62 6e 61 69 6c  |eate a thumbnail|
000000f0  20 66 6f 72 20 65 61 63  68 20 73 70 72 69 74 65  | for each sprite|
00000100  20 77 69 74 68 69 6e 20  69 74 20 2d 20 6f 6e 6c  | within it - onl|
00000110  79 20 32 35 36 20 63 6f  6c 6f 75 72 20 73 6f 75  |y 256 colour sou|
00000120  72 63 65 73 20 63 61 6e  0a 63 75 72 72 65 6e 74  |rces can.current|
00000130  6c 79 20 62 65 20 64 65  61 6c 74 20 77 69 74 68  |ly be dealt with|
00000140  20 7b 6d 6f 64 69 66 79  20 63 2e 6d 69 6e 69 73  | {modify c.minis|
00000150  70 72 73 20 66 75 6e 63  74 69 6f 6e 20 27 70 6c  |prs function 'pl|
00000160  6f 74 69 6e 74 6f 27 2c  20 69 66 20 79 6f 75 20  |otinto', if you |
00000170  77 61 6e 74 0a 74 6f 20  68 61 6e 64 6c 65 20 6f  |want.to handle o|
00000180  74 68 65 72 20 73 6f 75  72 63 65 20 73 70 72 69  |ther source spri|
00000190  74 65 73 7d 2e 20 53 61  76 65 73 20 61 6c 6c 20  |tes}. Saves all |
000001a0  72 65 73 75 6c 74 69 6e  67 20 74 68 75 6d 62 6e  |resulting thumbn|
000001b0  61 69 6c 73 20 74 6f 20  73 70 72 69 74 65 0a 66  |ails to sprite.f|
000001c0  69 6c 65 20 27 4f 75 74  70 75 74 27 20 69 6e 20  |ile 'Output' in |
000001d0  73 61 6d 65 20 64 69 72  65 63 74 6f 72 79 20 61  |same directory a|
000001e0  73 20 27 49 6e 70 75 74  27 2e 0a 0a 4e 6f 74 65  |s 'Input'...Note|
000001f0  2c 20 74 68 75 6d 62 6e  61 69 6c 20 6d 6f 64 65  |, thumbnail mode|
00000200  20 77 69 6c 6c 20 62 65  20 62 61 73 65 64 20 6f  | will be based o|
00000210  6e 20 63 75 72 72 65 6e  74 20 73 63 72 65 65 6e  |n current screen|
00000220  20 6d 6f 64 65 2c 20 73  75 63 68 20 74 68 61 74  | mode, such that|
00000230  20 69 66 0a 63 75 72 72  65 6e 74 20 6d 6f 64 65  | if.current mode|
00000240  20 68 61 73 20 70 69 78  65 6c 20 61 73 70 65 63  | has pixel aspec|
00000250  74 20 31 3a 32 2c 20 74  68 65 6e 20 73 6f 20 77  |t 1:2, then so w|
00000260  69 6c 6c 20 74 68 75 6d  62 6e 61 69 6c 2c 20 65  |ill thumbnail, e|
00000270  6c 73 65 20 74 68 75 6d  62 6e 61 69 6c 0a 67 65  |lse thumbnail.ge|
00000280  74 73 20 70 69 78 65 6c  20 61 73 70 65 63 74 20  |ts pixel aspect |
00000290  31 3a 31 2e 0a 0a 43 6f  64 65 20 61 6c 6c 6f 77  |1:1...Code allow|
000002a0  73 20 61 62 6f 76 65 20  74 6f 20 62 65 20 63 68  |s above to be ch|
000002b0  61 6e 67 65 64 20 73 6f  20 74 68 61 74 20 70 69  |anged so that pi|
000002c0  78 65 6c 20 61 73 70 65  63 74 20 69 73 20 62 61  |xel aspect is ba|
000002d0  73 65 64 20 6f 6e 20 74  68 65 20 73 6f 75 72 63  |sed on the sourc|
000002e0  65 0a 73 70 72 69 74 65  20 70 69 78 65 6c 20 61  |e.sprite pixel a|
000002f0  73 70 65 63 74 20 7b 63  61 6c 6c 20 73 70 72 73  |spect {call sprs|
00000300  64 69 73 70 5f 6d 69 6e  69 75 73 65 73 6f 75 72  |disp_miniusesour|
00000310  63 65 61 73 70 65 63 74  28 54 52 55 45 29 20 70  |ceaspect(TRUE) p|
00000320  72 69 6f 72 20 74 6f 0a  6d 69 6e 69 5f 6d 61 6b  |rior to.mini_mak|
00000330  65 7d 2c 20 74 68 6f 75  67 68 20 79 6f 75 20 63  |e}, though you c|
00000340  6f 75 6c 64 20 6f 66 20  63 6f 75 72 73 65 20 61  |ould of course a|
00000350  64 6f 70 74 20 61 6e 79  20 6d 65 74 68 6f 64 20  |dopt any method |
00000360  79 6f 75 20 6c 69 6b 65  2e 0a 0a 54 68 75 6d 62  |you like...Thumb|
00000370  6e 61 69 6c 73 20 6d 61  69 6e 74 61 69 6e 20 61  |nails maintain a|
00000380  73 70 65 63 74 20 72 61  74 69 6f 20 6f 66 20 73  |spect ratio of s|
00000390  6f 75 72 63 65 2c 20 26  20 61 72 65 20 66 69 74  |ource, & are fit|
000003a0  74 65 64 20 74 6f 20 6c  69 65 20 77 69 74 68 69  |ted to lie withi|
000003b0  6e 20 61 0a 73 71 75 61  72 65 20 6f 66 20 73 69  |n a.square of si|
000003c0  64 65 20 53 44 6d 61 78  73 69 7a 65 20 6f 73 20  |de SDmaxsize os |
000003d0  75 6e 69 74 73 2e 20 53  44 6d 61 78 73 69 7a 65  |units. SDmaxsize|
000003e0  20 69 73 20 61 6e 20 69  6e 74 20 76 61 72 69 61  | is an int varia|
000003f0  62 6c 65 2e 20 49 6e 20  74 68 69 73 0a 64 65 6d  |ble. In this.dem|
00000400  6f 20 69 74 20 63 61 6e  20 62 65 20 6d 6f 64 69  |o it can be modi|
00000410  66 69 65 64 20 62 79 20  61 6c 74 65 72 69 6e 67  |fied by altering|
00000420  20 74 68 65 20 76 61 6c  75 65 20 66 6f 6c 6c 6f  | the value follo|
00000430  77 69 6e 67 20 21 52 75  6e 49 6d 61 67 65 20 69  |wing !RunImage i|
00000440  6e 20 74 68 65 0a 6c 61  73 74 20 6c 69 6e 65 20  |n the.last line |
00000450  6f 66 20 74 68 65 20 21  52 75 6e 20 66 69 6c 65  |of the !Run file|
00000460  20 28 69 74 20 73 68 6f  75 6c 64 20 62 65 20 61  | (it should be a|
00000470  20 6d 75 6c 74 69 70 6c  65 20 6f 66 20 38 29 2e  | multiple of 8).|
00000480  0a 0a 4e 6f 74 65 2c 20  74 69 6d 65 20 74 61 6b  |..Note, time tak|
00000490  65 6e 20 62 79 20 63 6f  64 65 20 69 73 20 70 72  |en by code is pr|
000004a0  6f 70 6f 72 74 69 6f 6e  61 74 65 20 74 6f 20 74  |oportionate to t|
000004b0  68 75 6d 62 6e 61 69 6c  20 73 69 7a 65 2c 20 26  |humbnail size, &|
000004c0  20 61 6c 6d 6f 73 74 0a  65 6e 74 69 72 65 6c 79  | almost.entirely|
000004d0  20 69 6e 64 65 70 65 6e  64 65 6e 74 20 6f 66 20  | independent of |
000004e0  73 6f 75 72 63 65 20 73  69 7a 65 2e 20 46 6f 72  |source size. For|
000004f0  20 53 44 6d 61 78 73 69  7a 65 3d 31 32 38 2c 20  | SDmaxsize=128, |
00000500  74 69 6d 65 73 20 61 72  65 20 74 79 70 69 63 61  |times are typica|
00000510  6c 6c 79 0a 6c 6f 77 20  26 20 6d 75 63 68 20 71  |lly.low & much q|
00000520  75 69 63 6b 65 72 20 74  68 61 6e 20 43 68 61 6e  |uicker than Chan|
00000530  67 65 46 53 49 2c 20 68  6f 77 65 76 65 72 20 79  |geFSI, however y|
00000540  6f 75 20 63 6f 75 6c 64  20 69 6e 63 72 65 61 73  |ou could increas|
00000550  65 20 73 70 65 65 64 20  73 74 69 6c 6c 0a 66 75  |e speed still.fu|
00000560  72 74 68 65 72 20 62 79  20 72 65 63 6f 64 69 6e  |rther by recodin|
00000570  67 20 27 70 6c 6f 74 70  72 6f 63 65 73 73 27 20  |g 'plotprocess' |
00000580  69 6e 20 61 73 73 65 6d  62 6c 65 72 2e 0a 0a 49  |in assembler...I|
00000590  66 20 79 6f 75 20 75 73  65 20 74 68 69 73 20 63  |f you use this c|
000005a0  6f 64 65 20 69 6e 20 79  6f 75 72 20 6f 77 6e 20  |ode in your own |
000005b0  70 72 6f 67 72 61 6d 73  20 77 68 65 72 65 20 73  |programs where s|
000005c0  70 65 65 64 20 69 73 20  69 6d 70 6f 72 74 61 6e  |peed is importan|
000005d0  74 20 26 20 77 68 65 72  65 0a 6d 61 6e 79 20 6d  |t & where.many m|
000005e0  69 6e 69 20 73 70 72 69  74 65 73 20 61 72 65 20  |ini sprites are |
000005f0  62 65 69 6e 67 20 6d 61  64 65 20 69 6e 20 6f 6e  |being made in on|
00000600  65 20 62 61 74 63 68 2c  20 62 65 20 63 61 72 65  |e batch, be care|
00000610  66 75 6c 20 61 62 6f 75  74 20 74 69 6d 65 20 74  |ful about time t|
00000620  61 6b 65 6e 0a 74 6f 20  65 78 74 65 6e 64 20 74  |aken.to extend t|
00000630  68 65 20 6d 69 6e 69 61  72 65 61 20 73 70 72 69  |he miniarea spri|
00000640  74 65 20 61 72 65 61 20  75 70 6f 6e 20 65 61 63  |te area upon eac|
00000650  68 20 6d 69 6e 69 5f 6d  61 6b 65 20 63 61 6c 6c  |h mini_make call|
00000660  2e 0a 0a 54 68 65 20 74  6f 74 61 6c 20 74 69 6d  |...The total tim|
00000670  65 20 75 73 65 64 20 74  6f 20 66 6c 65 78 5f 65  |e used to flex_e|
00000680  78 74 65 6e 64 20 69 74  20 6d 61 79 20 62 65 20  |xtend it may be |
00000690  67 72 65 61 74 65 72 20  74 68 61 6e 20 74 68 61  |greater than tha|
000006a0  74 20 72 65 71 75 69 72  65 64 20 62 79 0a 61 6c  |t required by.al|
000006b0  6c 20 6f 74 68 65 72 20  63 6f 6d 70 75 74 61 74  |l other computat|
000006c0  69 6f 6e 73 21 20 2d 20  69 6e 20 73 75 63 68 20  |ions! - in such |
000006d0  61 20 73 69 74 75 61 74  69 6f 6e 20 69 74 20 69  |a situation it i|
000006e0  73 20 62 65 74 74 65 72  20 74 6f 20 66 6c 65 78  |s better to flex|
000006f0  5f 65 78 74 65 6e 64 20  69 74 0a 70 72 69 6f 72  |_extend it.prior|
00000700  20 74 6f 20 70 72 6f 63  65 73 73 69 6e 67 20 74  | to processing t|
00000710  68 65 20 62 61 74 63 68  2c 20 69 6e 20 6f 72 64  |he batch, in ord|
00000720  65 72 20 74 6f 20 6c 65  61 76 65 20 65 6e 6f 75  |er to leave enou|
00000730  67 68 20 66 72 65 65 20  73 70 61 63 65 20 69 6e  |gh free space in|
00000740  20 74 68 65 0a 6d 69 6e  69 5f 61 72 65 61 20 66  | the.mini_area f|
00000750  6f 72 20 61 6c 6c 20 74  68 65 20 65 78 70 65 63  |or all the expec|
00000760  74 65 64 20 6d 69 6e 69  20 73 70 72 69 74 65 73  |ted mini sprites|
00000770  2e 20 54 68 69 73 20 69  73 20 6e 6f 74 20 64 6f  |. This is not do|
00000780  6e 65 20 69 6e 20 74 68  69 73 20 64 65 6d 6f 2e  |ne in this demo.|
00000790  0a                                                |.|
00000791