home *** CD-ROM | disk | FTP | other *** search
/ Mac Power 1997 January / macpower199701.bin / AMUG / Programming_10 / Videotoolbox 96-08-22-c.sit / VideoToolbox / VideoToolboxSources / NoiseFill.c < prev    next >
MacBinary  |  1995-05-27  |  8.3 KB  |  [TEXT/CWIE]

open in: MacOS 8.1     |     Win98     |     DOS

view JSON data     |     view as text

This file was processed as: MacBinary (archive/macBinary).

You can browse this item here: NoiseFill.c

ConfidenceProgramDetectionMatch TypeSupport
66% dexvert Compact Compressed (Unix) (archive/compact) ext Supported
10% dexvert MacBinary (archive/macBinary) fallback Supported
1% dexvert Text File (text/txt) fallback Supported
100% file MacBinary II, inited, Sat May 27 01:26:48 1995, modified Sat May 27 01:26:48 1995, creator 'CWIE', type ASCII, 7415 bytes "NoiseFill.c" , at 0x1d77 860 bytes resource default (weak)
99% file data default
74% TrID Macintosh plain text (MacBinary) default
25% TrID MacBinary 2 default (weak)
100% siegfried fmt/1762 MacBinary (II) default
100% lsar MacBinary default


id metadata
keyvalue
macFileType[TEXT]
macFileCreator[CWIE]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 00 0b 4e 6f 69 73 65 46 | 69 6c 6c 2e 63 00 00 00 |..NoiseF|ill.c...|
|00000010| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 54 45 58 54 43 57 49 | 45 01 00 00 00 00 00 00 |.TEXTCWI|E.......|
|00000050| 00 00 00 00 00 1c f7 00 | 00 03 5c ab ec 68 98 ab |........|..\..h..|
|00000060| ec 68 98 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |.h......|........|
|00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 8c ae 00 00 |........|........|
|00000080| 2f 2a 20 4e 6f 69 73 65 | 46 69 6c 6c 2e 63 0d a9 |/* Noise|Fill.c..|
|00000090| 20 31 39 38 39 2d 31 39 | 39 34 20 44 65 6e 69 73 | 1989-19|94 Denis|
|000000a0| 20 47 2e 20 50 65 6c 6c | 69 2e 0d 09 65 72 72 6f | G. Pell|i...erro|
|000000b0| 72 3d 4e 6f 69 73 65 46 | 69 6c 6c 28 77 69 6e 64 |r=NoiseF|ill(wind|
|000000c0| 6f 77 2c 26 72 65 63 74 | 2c 64 78 2c 64 79 2c 72 |ow,&rect|,dx,dy,r|
|000000d0| 61 6e 64 6f 6d 50 68 61 | 73 65 29 3b 20 0d 46 69 |andomPha|se); .Fi|
|000000e0| 6c 6c 73 20 74 68 65 20 | 72 65 63 74 20 69 6e 20 |lls the |rect in |
|000000f0| 74 68 65 20 77 69 6e 64 | 6f 77 20 77 69 74 68 20 |the wind|ow with |
|00000100| 6e 6f 69 73 65 2e 20 54 | 68 65 20 6e 6f 69 73 65 |noise. T|he noise|
|00000110| 20 69 73 20 6d 61 64 65 | 20 75 70 20 6f 66 20 62 | is made| up of b|
|00000120| 6c 61 63 6b 20 26 20 77 | 68 69 74 65 0d 63 68 65 |lack & w|hite.che|
|00000130| 63 6b 73 2c 20 65 61 63 | 68 20 64 78 20 70 69 78 |cks, eac|h dx pix|
|00000140| 65 6c 73 20 77 69 64 65 | 20 62 79 20 64 79 20 70 |els wide| by dy p|
|00000150| 69 78 65 6c 73 20 68 69 | 67 68 2e 20 52 61 6e 64 |ixels hi|gh. Rand|
|00000160| 6f 6d 20 70 68 61 73 65 | 20 69 73 20 6f 70 74 69 |om phase| is opti|
|00000170| 6f 6e 61 6c 2e 20 28 64 | 78 20 61 6e 64 0d 64 79 |onal. (d|x and.dy|
|00000180| 20 61 72 65 20 64 6f 75 | 62 6c 65 73 2c 20 61 6e | are dou|bles, an|
|00000190| 64 20 6e 65 65 64 20 6e | 6f 74 20 62 65 20 69 6e |d need n|ot be in|
|000001a0| 74 65 67 72 61 6c 2e 20 | 54 68 65 20 6e 6f 69 73 |tegral. |The nois|
|000001b0| 65 20 69 73 20 73 79 6e | 74 68 65 73 69 7a 65 64 |e is syn|thesized|
|000001c0| 20 77 69 74 68 20 31 2d | 70 69 78 65 6c 0d 63 68 | with 1-|pixel.ch|
|000001d0| 65 63 6b 73 20 61 6e 64 | 20 65 78 70 61 6e 64 65 |ecks and| expande|
|000001e0| 64 20 62 79 20 43 6f 70 | 79 42 69 74 73 2c 20 77 |d by Cop|yBits, w|
|000001f0| 68 69 63 68 20 69 73 20 | 63 61 70 61 62 6c 65 20 |hich is |capable |
|00000200| 6f 66 20 65 78 70 61 6e | 73 69 6f 6e 20 62 79 20 |of expan|sion by |
|00000210| 6e 6f 6e 2d 69 6e 74 65 | 67 72 61 6c 0d 61 6d 6f |non-inte|gral.amo|
|00000220| 75 6e 74 73 2e 29 0d 0d | 09 65 72 72 6f 72 3d 4e |unts.)..|.error=N|
|00000230| 6f 69 73 65 46 69 6c 6c | 42 69 74 73 28 70 69 78 |oiseFill|Bits(pix|
|00000240| 6d 61 70 50 74 72 2c 26 | 72 65 63 74 2c 64 78 2c |mapPtr,&|rect,dx,|
|00000250| 64 79 2c 72 61 6e 64 6f | 6d 50 68 61 73 65 29 3b |dy,rando|mPhase);|
|00000260| 0d 53 61 6d 65 2c 20 62 | 75 74 20 61 63 63 65 70 |.Same, b|ut accep|
|00000270| 74 73 20 61 20 70 69 78 | 2f 62 69 74 6d 61 70 20 |ts a pix|/bitmap |
|00000280| 70 74 72 20 69 6e 20 70 | 6c 61 63 65 20 6f 66 20 |ptr in p|lace of |
|00000290| 74 68 65 20 77 69 6e 64 | 6f 77 2e 0d 0d 09 65 72 |the wind|ow....er|
|000002a0| 72 6f 72 3d 4d 61 6b 65 | 4e 6f 69 73 65 31 28 64 |ror=Make|Noise1(d|
|000002b0| 78 2c 64 79 2c 72 61 6e | 64 6f 6d 50 68 61 73 65 |x,dy,ran|domPhase|
|000002c0| 2c 70 69 78 6d 61 70 50 | 74 72 29 3b 0d 53 61 6d |,pixmapP|tr);.Sam|
|000002d0| 65 2c 20 62 75 74 20 66 | 69 6c 6c 73 20 74 68 65 |e, but f|ills the|
|000002e0| 20 77 68 6f 6c 65 20 70 | 69 78 2f 62 69 74 6d 61 | whole p|ix/bitma|
|000002f0| 70 2c 20 69 2e 65 2e 20 | 75 73 65 73 20 70 69 78 |p, i.e. |uses pix|
|00000300| 6d 61 70 50 74 72 2d 3e | 62 6f 75 6e 64 73 20 61 |mapPtr->|bounds a|
|00000310| 73 20 74 68 65 20 72 65 | 63 74 2e 0d 4f 62 73 6f |s the re|ct..Obso|
|00000320| 6c 65 74 65 2c 20 72 65 | 74 61 69 6e 65 64 20 73 |lete, re|tained s|
|00000330| 6f 6c 65 6c 79 20 66 6f | 72 20 63 6f 6d 70 61 74 |olely fo|r compat|
|00000340| 69 62 69 6c 69 74 79 2e | 0d 0d 57 65 20 75 73 65 |ibility.|..We use|
|00000350| 20 74 68 65 20 63 75 72 | 72 65 6e 74 20 70 6f 72 | the cur|rent por|
|00000360| 74 27 73 20 46 6f 72 65 | 43 6f 6c 6f 72 20 61 6e |t's Fore|Color an|
|00000370| 64 20 42 61 63 6b 43 6f | 6c 6f 72 20 74 6f 20 6d |d BackCo|lor to m|
|00000380| 61 6b 65 20 74 68 65 20 | 6e 6f 69 73 65 2e 20 28 |ake the |noise. (|
|00000390| 49 66 0d 62 61 73 65 41 | 64 64 72 3d 3d 4e 55 4c |If.baseA|ddr==NUL|
|000003a0| 4c 2c 20 77 65 20 73 68 | 61 72 65 20 74 68 65 20 |L, we sh|are the |
|000003b0| 63 6f 6c 6f 72 20 74 61 | 62 6c 65 20 6f 66 20 74 |color ta|ble of t|
|000003c0| 68 65 20 63 75 72 72 65 | 6e 74 20 64 65 76 69 63 |he curre|nt devic|
|000003d0| 65 2e 29 20 41 70 70 6c | 65 27 73 0d 47 65 74 47 |e.) Appl|e's.GetG|
|000003e0| 57 6f 72 6c 64 20 61 6e | 64 20 53 65 74 47 57 6f |World an|d SetGWo|
|000003f0| 72 6c 64 20 63 61 6c 6c | 73 20 61 72 65 20 61 20 |rld call|s are a |
|00000400| 63 6f 6e 76 65 6e 69 65 | 6e 74 20 77 61 79 20 6f |convenie|nt way o|
|00000410| 66 20 67 65 74 74 69 6e | 67 2c 20 63 68 61 6e 67 |f gettin|g, chang|
|00000420| 69 6e 67 2c 20 61 6e 64 | 0d 72 65 73 74 6f 72 69 |ing, and|.restori|
|00000430| 6e 67 20 74 68 65 20 63 | 75 72 72 65 6e 74 20 70 |ng the c|urrent p|
|00000440| 6f 72 74 20 61 6e 64 20 | 64 65 76 69 63 65 2e 0d |ort and |device..|
|00000450| 0d 49 66 20 70 69 78 6d | 61 70 50 74 72 2d 3e 62 |.If pixm|apPtr->b|
|00000460| 61 73 65 41 64 64 72 3d | 3d 4e 55 4c 4c 20 74 68 |aseAddr=|=NULL th|
|00000470| 65 6e 20 74 68 65 20 64 | 61 74 61 20 61 72 65 61 |en the d|ata area|
|00000480| 20 77 69 6c 6c 20 62 65 | 20 61 6c 6c 6f 63 61 74 | will be| allocat|
|00000490| 65 64 20 66 6f 72 20 79 | 6f 75 2e 20 59 6f 75 0d |ed for y|ou. You.|
|000004a0| 6d 75 73 74 20 73 65 74 | 20 70 69 78 6d 61 70 50 |must set| pixmapP|
|000004b0| 74 72 2d 3e 62 6f 75 6e | 64 73 20 61 6e 64 20 70 |tr->boun|ds and p|
|000004c0| 69 78 6d 61 70 50 74 72 | 2d 3e 70 69 78 65 6c 53 |ixmapPtr|->pixelS|
|000004d0| 69 7a 65 3b 20 74 68 65 | 20 72 65 73 74 20 6f 66 |ize; the| rest of|
|000004e0| 20 74 68 65 20 50 69 78 | 4d 61 70 0d 73 74 72 75 | the Pix|Map.stru|
|000004f0| 63 74 20 77 69 6c 6c 20 | 62 65 20 66 69 6c 6c 65 |ct will |be fille|
|00000500| 64 20 69 6e 20 62 79 20 | 4e 6f 69 73 65 46 69 6c |d in by |NoiseFil|
|00000510| 6c 42 69 74 73 2e 20 49 | 74 20 77 69 6c 6c 20 69 |lBits. I|t will i|
|00000520| 6e 73 74 61 6c 6c 20 61 | 20 68 61 6e 64 6c 65 20 |nstall a| handle |
|00000530| 74 6f 20 74 68 65 0d 63 | 75 72 72 65 6e 74 20 64 |to the.c|urrent d|
|00000540| 65 76 69 63 65 27 73 20 | 63 6f 6c 6f 72 20 74 61 |evice's |color ta|
|00000550| 62 6c 65 2e 20 54 68 65 | 20 76 61 6c 75 65 73 20 |ble. The| values |
|00000560| 66 69 6c 6c 65 64 20 69 | 6e 74 6f 20 74 68 65 20 |filled i|nto the |
|00000570| 66 69 65 6c 64 73 20 61 | 72 65 20 6e 65 63 65 73 |fields a|re neces|
|00000580| 73 61 72 69 6c 79 0d 73 | 6f 6d 65 77 68 61 74 20 |sarily.s|omewhat |
|00000590| 61 72 62 69 74 72 61 72 | 79 2e 20 46 6f 72 20 6d |arbitrar|y. For m|
|000005a0| 6f 72 65 20 63 6f 6e 74 | 72 6f 6c 2c 20 66 69 6c |ore cont|rol, fil|
|000005b0| 6c 20 69 6e 20 74 68 65 | 20 66 69 65 6c 64 73 20 |l in the| fields |
|000005c0| 79 6f 75 72 73 65 6c 66 | 2c 20 75 73 69 6e 67 0d |yourself|, using.|
|000005d0| 4e 65 77 50 69 78 4d 61 | 70 28 29 2c 20 61 6e 64 |NewPixMa|p(), and|
|000005e0| 20 61 6c 6c 6f 63 61 74 | 65 20 74 68 65 20 64 61 | allocat|e the da|
|000005f0| 74 61 20 61 72 65 61 20 | 79 6f 75 72 73 65 6c 66 |ta area |yourself|
|00000600| 20 62 65 66 6f 72 65 20 | 63 61 6c 6c 69 6e 67 20 | before |calling |
|00000610| 4e 6f 69 73 65 46 69 6c | 6c 42 69 74 73 28 29 2e |NoiseFil|lBits().|
|00000620| 0d 0d 48 49 53 54 4f 52 | 59 3a 0d 36 2f 32 31 2f |..HISTOR|Y:.6/21/|
|00000630| 38 39 20 64 67 70 09 63 | 68 61 6e 67 65 64 20 66 |89 dgp.c|hanged f|
|00000640| 72 61 6d 65 42 79 74 65 | 73 20 61 6e 64 20 62 75 |rameByte|s and bu|
|00000650| 66 66 65 72 42 79 74 65 | 73 20 74 6f 20 6c 6f 6e |fferByte|s to lon|
|00000660| 67 20 73 6f 20 74 68 61 | 74 20 74 68 69 73 20 63 |g so tha|t this c|
|00000670| 6f 64 65 20 77 6f 6e 27 | 74 20 63 72 61 73 68 0d |ode won'|t crash.|
|00000680| 09 09 09 69 66 20 74 68 | 65 20 70 69 78 65 6c 53 |...if th|e pixelS|
|00000690| 69 7a 65 20 69 73 20 67 | 72 65 61 74 65 72 20 74 |ize is g|reater t|
|000006a0| 68 61 6e 20 31 20 62 69 | 74 2e 0d 38 2f 35 2f 38 |han 1 bi|t..8/5/8|
|000006b0| 39 20 64 67 70 09 77 72 | 6f 74 65 20 61 6e 64 20 |9 dgp.wr|ote and |
|000006c0| 69 6e 73 74 61 6c 6c 65 | 64 20 72 61 6e 64 55 28 |installe|d randU(|
|000006d0| 29 2c 20 77 68 69 63 68 | 20 79 69 65 6c 64 73 20 |), which| yields |
|000006e0| 74 77 6f 20 72 61 6e 64 | 6f 6d 20 62 79 74 65 73 |two rand|om bytes|
|000006f0| 20 70 65 72 20 63 61 6c | 6c 2c 20 69 6e 73 74 65 | per cal|l, inste|
|00000700| 61 64 0d 09 09 09 6f 66 | 20 72 61 6e 64 28 29 20 |ad....of| rand() |
|00000710| 77 68 69 63 68 20 79 69 | 65 6c 64 73 20 6f 6e 6c |which yi|elds onl|
|00000720| 79 20 6f 6e 65 2c 20 61 | 6c 6c 6f 77 69 6e 67 20 |y one, a|llowing |
|00000730| 74 68 65 20 6e 6f 69 73 | 65 20 67 65 6e 65 72 61 |the nois|e genera|
|00000740| 74 69 6f 6e 20 74 6f 20 | 67 6f 20 74 77 69 63 65 |tion to |go twice|
|00000750| 0d 09 09 09 61 73 20 66 | 61 73 74 2e 0d 33 2f 31 |....as f|ast..3/1|
|00000760| 31 2f 39 30 20 64 67 70 | 09 43 68 61 6e 67 65 64 |1/90 dgp|.Changed|
|00000770| 20 64 78 20 61 6e 64 20 | 64 79 20 66 72 6f 6d 20 | dx and |dy from |
|00000780| 69 6e 74 20 74 6f 20 64 | 6f 75 62 6c 65 2e 20 54 |int to d|ouble. T|
|00000790| 68 69 73 20 61 6c 6c 6f | 77 73 20 6e 6f 6e 75 6e |his allo|ws nonun|
|000007a0| 69 66 6f 72 6d 20 63 65 | 6c 6c 20 73 69 7a 65 2c |iform ce|ll size,|
|000007b0| 0d 09 09 09 77 68 69 63 | 68 20 61 72 69 73 65 73 |....whic|h arises|
|000007c0| 20 77 68 65 6e 20 43 6f | 70 79 42 69 74 73 20 65 | when Co|pyBits e|
|000007d0| 78 70 61 6e 64 73 20 62 | 79 20 74 68 65 73 65 20 |xpands b|y these |
|000007e0| 6e 6f 6e 69 6e 74 65 67 | 72 61 6c 20 66 61 63 74 |noninteg|ral fact|
|000007f0| 6f 72 73 2e 20 52 65 73 | 75 6c 74 73 0d 09 09 09 |ors. Res|ults....|
|00000800| 77 69 6c 6c 20 62 65 20 | 73 61 6d 65 20 61 73 20 |will be |same as |
|00000810| 62 65 66 6f 72 65 20 77 | 68 65 6e 20 69 6e 74 65 |before w|hen inte|
|00000820| 67 72 61 6c 20 76 61 6c | 75 65 73 20 61 72 65 20 |gral val|ues are |
|00000830| 73 75 70 70 6c 69 65 64 | 2e 0d 09 09 09 4d 61 64 |supplied|.....Mad|
|00000840| 65 20 74 68 65 20 63 6f | 73 6d 65 74 69 63 20 63 |e the co|smetic c|
|00000850| 68 61 6e 67 65 20 6f 66 | 20 72 65 70 6c 61 63 69 |hange of| replaci|
|00000860| 6e 67 20 22 75 6e 73 69 | 67 6e 65 64 20 6c 6f 6e |ng "unsi|gned lon|
|00000870| 67 22 20 62 79 20 22 73 | 69 7a 65 5f 74 22 2e 0d |g" by "s|ize_t"..|
|00000880| 33 2f 32 30 2f 39 30 09 | 64 67 70 09 6d 61 6b 65 |3/20/90.|dgp.make|
|00000890| 20 63 6f 6d 70 61 74 69 | 62 6c 65 20 77 69 74 68 | compati|ble with|
|000008a0| 20 4d 50 57 20 43 2e 0d | 33 2f 33 31 2f 39 30 09 | MPW C..|3/31/90.|
|000008b0| 64 67 70 09 73 65 74 20 | 70 6d 56 65 72 73 69 6f |dgp.set |pmVersio|
|000008c0| 6e 20 74 6f 20 7a 65 72 | 6f 20 66 6f 72 20 63 6f |n to zer|o for co|
|000008d0| 6d 70 61 74 69 62 69 6c | 69 74 79 20 77 69 74 68 |mpatibil|ity with|
|000008e0| 20 51 44 33 32 0d 38 2f | 37 2f 39 30 09 64 67 70 | QD32.8/|7/90.dgp|
|000008f0| 09 4e 6f 77 20 75 73 65 | 73 20 74 68 65 20 63 75 |.Now use|s the cu|
|00000900| 72 72 65 6e 74 20 46 6f | 72 65 43 6f 6c 6f 72 20 |rrent Fo|reColor |
|00000910| 61 6e 64 20 42 61 63 6b | 43 6f 6c 6f 72 20 74 6f |and Back|Color to|
|00000920| 20 6d 61 6b 65 20 74 68 | 65 20 6e 6f 69 73 65 2e | make th|e noise.|
|00000930| 0d 09 09 09 46 6f 72 20 | 66 75 74 75 72 65 20 63 |....For |future c|
|00000940| 6f 6d 70 61 74 69 62 69 | 6c 69 74 79 2c 20 6e 6f |ompatibi|lity, no|
|00000950| 77 20 7a 65 72 6f 65 73 | 20 74 68 65 20 70 61 63 |w zeroes| the pac|
|00000960| 6b 54 79 70 65 2c 20 65 | 74 63 2e 20 66 69 65 6c |kType, e|tc. fiel|
|00000970| 64 73 2e 0d 31 30 2f 31 | 2f 39 30 09 64 67 70 09 |ds..10/1|/90.dgp.|
|00000980| 43 6f 73 6d 65 74 69 63 | 20 63 68 61 6e 67 65 73 |Cosmetic| changes|
|00000990| 3a 20 72 65 70 6c 61 63 | 65 64 20 74 77 6f 20 4f |: replac|ed two O|
|000009a0| 66 66 73 65 74 52 65 63 | 74 20 63 61 6c 6c 73 20 |ffsetRec|t calls |
|000009b0| 62 79 20 43 65 6e 74 65 | 72 52 65 63 74 49 6e 52 |by Cente|rRectInR|
|000009c0| 65 63 74 20 63 61 6c 6c | 2e 0d 31 31 2f 31 36 2f |ect call|..11/16/|
|000009d0| 39 30 20 64 67 70 20 41 | 64 64 65 64 20 52 41 4e |90 dgp A|dded RAN|
|000009e0| 44 4f 4d 5f 50 48 41 53 | 45 2e 0d 34 2f 32 30 2f |DOM_PHAS|E..4/20/|
|000009f0| 39 31 09 64 67 70 09 41 | 64 64 65 64 20 6e 65 77 |91.dgp.A|dded new|
|00000a00| 20 4d 61 6b 65 4e 6f 69 | 73 65 31 28 29 20 74 68 | MakeNoi|se1() th|
|00000a10| 61 74 20 61 63 63 65 70 | 74 73 20 61 20 73 69 6e |at accep|ts a sin|
|00000a20| 67 6c 65 20 50 69 78 4d | 61 70 2c 20 61 6e 64 20 |gle PixM|ap, and |
|00000a30| 61 6c 6c 6f 63 61 74 65 | 73 0d 09 09 09 69 74 73 |allocate|s....its|
|00000a40| 20 64 61 74 61 20 61 72 | 65 61 20 6f 6e 6c 79 20 | data ar|ea only |
|00000a50| 69 66 20 62 61 73 65 41 | 64 64 72 3d 3d 4e 55 4c |if baseA|ddr==NUL|
|00000a60| 4c 2c 20 6f 74 68 65 72 | 77 69 73 65 20 61 73 73 |L, other|wise ass|
|00000a70| 75 6d 69 6e 67 20 74 68 | 61 74 20 69 74 20 61 6c |uming th|at it al|
|00000a80| 72 65 61 64 79 0d 09 09 | 09 65 78 69 73 74 73 2e |ready...|.exists.|
|00000a90| 20 49 20 72 65 77 72 6f | 74 65 20 4d 61 6b 65 4e | I rewro|te MakeN|
|00000aa0| 6f 69 73 65 28 29 20 74 | 6f 20 73 69 6d 70 6c 79 |oise() t|o simply|
|00000ab0| 20 63 61 6c 6c 20 4d 61 | 6b 65 4e 6f 69 73 65 31 | call Ma|keNoise1|
|00000ac0| 28 29 20 72 65 70 65 61 | 74 65 64 6c 79 2e 0d 09 |() repea|tedly...|
|00000ad0| 09 09 4d 61 6b 65 4e 6f | 69 73 65 28 29 20 6e 6f |..MakeNo|ise() no|
|00000ae0| 77 20 73 65 65 6d 73 20 | 6f 62 73 6f 6c 65 74 65 |w seems |obsolete|
|00000af0| 2c 20 62 75 74 20 69 73 | 20 72 65 74 61 69 6e 65 |, but is| retaine|
|00000b00| 64 20 66 6f 72 20 63 6f | 6d 70 61 74 69 62 69 6c |d for co|mpatibil|
|00000b10| 69 74 79 20 77 69 74 68 | 20 6f 6c 64 0d 09 09 09 |ity with| old....|
|00000b20| 70 72 6f 67 72 61 6d 73 | 2e 0d 34 2f 32 34 2f 39 |programs|..4/24/9|
|00000b30| 31 09 64 67 70 09 46 69 | 78 65 64 20 62 75 67 20 |1.dgp.Fi|xed bug |
|00000b40| 69 6e 74 72 6f 64 75 63 | 65 64 20 69 6e 74 6f 20 |introduc|ed into |
|00000b50| 4d 61 6b 65 4e 6f 69 73 | 65 28 29 20 6f 6e 20 34 |MakeNois|e() on 4|
|00000b60| 2f 32 30 2c 20 77 68 69 | 63 68 20 72 65 73 75 6c |/20, whi|ch resul|
|00000b70| 74 65 64 20 69 6e 20 61 | 6c 6c 20 74 68 65 0d 09 |ted in a|ll the..|
|00000b80| 09 09 50 69 78 4d 61 70 | 73 20 75 73 69 6e 67 20 |..PixMap|s using |
|00000b90| 74 68 65 20 73 61 6d 65 | 20 62 75 66 66 65 72 2e |the same| buffer.|
|00000ba0| 0d 38 2f 36 2f 39 31 09 | 64 67 70 09 52 65 70 6c |.8/6/91.|dgp.Repl|
|00000bb0| 61 63 65 64 20 75 73 65 | 20 6f 66 20 72 61 6e 64 |aced use| of rand|
|00000bc0| 55 28 29 20 62 79 20 52 | 61 6e 64 46 69 6c 6c 28 |U() by R|andFill(|
|00000bd0| 29 2c 20 77 68 69 63 68 | 20 69 73 20 74 77 69 63 |), which| is twic|
|00000be0| 65 20 61 73 20 66 61 73 | 74 2e 0d 38 2f 32 34 2f |e as fas|t..8/24/|
|00000bf0| 39 31 09 64 67 70 09 4d | 61 64 65 20 63 6f 6d 70 |91.dgp.M|ade comp|
|00000c00| 61 74 69 62 6c 65 20 77 | 69 74 68 20 54 48 49 4e |atible w|ith THIN|
|00000c10| 4b 20 43 20 35 2e 30 2e | 0d 34 2f 31 37 2f 39 32 |K C 5.0.|.4/17/92|
|00000c20| 09 64 67 70 09 52 65 6d | 6f 76 65 64 20 68 69 64 |.dgp.Rem|oved hid|
|00000c30| 64 65 6e 20 61 73 73 75 | 6d 70 74 69 6f 6e 20 74 |den assu|mption t|
|00000c40| 68 61 74 20 62 69 74 73 | 2d 3e 62 6f 75 6e 64 73 |hat bits|->bounds|
|00000c50| 2e 74 6f 70 20 61 6e 64 | 20 62 69 74 73 2d 3e 62 |.top and| bits->b|
|00000c60| 6f 75 6e 64 73 2e 6c 65 | 66 74 0d 09 09 09 77 65 |ounds.le|ft....we|
|00000c70| 72 65 20 62 6f 74 68 20 | 7a 65 72 6f 2e 20 49 66 |re both |zero. If|
|00000c80| 20 74 68 65 79 20 77 65 | 72 65 20 6e 65 67 61 74 | they we|re negat|
|00000c90| 69 76 65 20 4d 61 6b 65 | 4e 6f 69 73 65 31 20 77 |ive Make|Noise1 w|
|00000ca0| 6f 75 6c 64 20 61 6c 6c | 6f 63 61 74 65 20 74 6f |ould all|ocate to|
|00000cb0| 6f 20 0d 09 09 09 6c 69 | 74 74 6c 65 20 73 70 61 |o ....li|ttle spa|
|00000cc0| 63 65 2c 20 61 6e 64 20 | 74 68 65 6e 20 6f 76 65 |ce, and |then ove|
|00000cd0| 72 77 72 69 74 65 20 6d | 65 6d 6f 72 79 20 61 6e |rwrite m|emory an|
|00000ce0| 64 20 63 72 61 73 68 2e | 0d 34 2f 32 37 2f 39 32 |d crash.|.4/27/92|
|00000cf0| 09 64 67 70 09 49 6e 69 | 74 69 61 6c 69 7a 65 20 |.dgp.Ini|tialize |
|00000d00| 61 6c 6c 20 72 65 6d 61 | 69 6e 69 6e 67 20 66 69 |all rema|ining fi|
|00000d10| 65 6c 64 73 20 6f 66 20 | 74 68 65 20 2a 62 69 74 |elds of |the *bit|
|00000d20| 73 20 50 69 78 4d 61 70 | 2c 20 61 6e 64 20 63 6f |s PixMap|, and co|
|00000d30| 70 79 20 74 68 65 20 63 | 75 72 72 65 6e 74 0d 09 |py the c|urrent..|
|00000d40| 09 09 64 65 76 69 63 65 | 27 73 20 63 6f 6c 6f 72 |..device|'s color|
|00000d50| 20 74 61 62 6c 65 20 68 | 61 6e 64 6c 65 2e 0d 31 | table h|andle..1|
|00000d60| 30 2f 32 32 2f 39 32 20 | 64 67 70 20 43 68 65 63 |0/22/92 |dgp Chec|
|00000d70| 6b 20 66 6f 72 20 65 72 | 72 6f 72 20 69 6e 20 43 |k for er|ror in C|
|00000d80| 6f 70 79 42 69 74 73 2e | 0d 39 2f 35 2f 39 34 20 |opyBits.|.9/5/94 |
|00000d90| 64 67 70 20 72 65 6d 6f | 76 65 64 20 61 73 73 75 |dgp remo|ved assu|
|00000da0| 6d 70 74 69 6f 6e 20 69 | 6e 20 70 72 69 6e 74 66 |mption i|n printf|
|00000db0| 27 73 20 74 68 61 74 20 | 69 6e 74 3d 3d 73 68 6f |'s that |int==sho|
|00000dc0| 72 74 2e 0d 31 31 2f 32 | 31 2f 39 34 20 64 67 70 |rt..11/2|1/94 dgp|
|00000dd0| 20 69 6e 20 72 65 73 70 | 6f 6e 73 65 20 74 6f 20 | in resp|onse to |
|00000de0| 6e 6f 74 65 20 66 72 6f | 6d 20 4d 61 72 74 79 20 |note fro|m Marty |
|00000df0| 57 61 63 68 74 65 72 2c | 20 69 6d 70 72 6f 76 65 |Wachter,| improve|
|00000e00| 20 63 65 6e 74 65 72 69 | 6e 67 20 61 6c 67 6f 72 | centeri|ng algor|
|00000e10| 69 74 68 6d 2c 20 73 6f | 0d 09 09 09 74 68 61 74 |ithm, so|....that|
|00000e20| 20 69 66 20 64 78 20 26 | 20 64 79 20 61 72 65 20 | if dx &| dy are |
|00000e30| 69 6e 74 65 67 72 61 6c | 20 74 68 65 20 66 69 6e |integral| the fin|
|00000e40| 61 6c 20 69 6d 61 67 65 | 20 69 73 20 6d 61 64 65 |al image| is made|
|00000e50| 20 6f 66 20 77 68 6f 6c | 65 20 63 68 65 63 6b 73 | of whol|e checks|
|00000e60| 2e 0d 31 31 2f 32 31 2f | 39 34 20 64 67 70 20 72 |..11/21/|94 dgp r|
|00000e70| 65 6e 61 6d 65 64 20 4e | 6f 69 73 65 46 69 6c 6c |enamed N|oiseFill|
|00000e80| 2e 63 20 61 6e 64 20 61 | 64 64 65 64 20 6e 65 77 |.c and a|dded new|
|00000e90| 20 63 61 6c 6c 69 6e 67 | 20 69 6e 74 65 72 66 61 | calling| interfa|
|00000ea0| 63 65 73 2c 20 61 6e 61 | 6c 6f 67 6f 75 73 20 74 |ces, ana|logous t|
|00000eb0| 6f 20 74 68 6f 73 65 0d | 09 09 09 66 6f 72 20 43 |o those.|...for C|
|00000ec0| 6f 70 79 57 69 6e 64 6f | 77 73 20 61 6e 64 20 43 |opyWindo|ws and C|
|00000ed0| 6f 70 79 42 69 74 73 2e | 0d 2a 2f 0d 23 69 6e 63 |opyBits.|.*/.#inc|
|00000ee0| 6c 75 64 65 20 22 56 69 | 64 65 6f 54 6f 6f 6c 62 |lude "Vi|deoToolb|
|00000ef0| 6f 78 2e 68 22 0d 69 6e | 74 20 4d 61 6b 65 4e 6f |ox.h".in|t MakeNo|
|00000f00| 69 73 65 31 28 64 6f 75 | 62 6c 65 20 64 78 2c 64 |ise1(dou|ble dx,d|
|00000f10| 6f 75 62 6c 65 20 64 79 | 2c 42 6f 6f 6c 65 61 6e |ouble dy|,Boolean|
|00000f20| 20 72 61 6e 64 6f 6d 50 | 68 61 73 65 2c 50 69 78 | randomP|hase,Pix|
|00000f30| 4d 61 70 20 2a 62 69 74 | 73 29 0d 7b 0d 09 72 65 |Map *bit|s).{..re|
|00000f40| 74 75 72 6e 20 4e 6f 69 | 73 65 46 69 6c 6c 42 69 |turn Noi|seFillBi|
|00000f50| 74 73 28 62 69 74 73 2c | 26 62 69 74 73 2d 3e 62 |ts(bits,|&bits->b|
|00000f60| 6f 75 6e 64 73 2c 64 78 | 2c 64 79 2c 72 61 6e 64 |ounds,dx|,dy,rand|
|00000f70| 6f 6d 50 68 61 73 65 29 | 3b 0d 7d 0d 0d 69 6e 74 |omPhase)|;.}..int|
|00000f80| 20 4e 6f 69 73 65 46 69 | 6c 6c 28 43 57 69 6e 64 | NoiseFi|ll(CWind|
|00000f90| 6f 77 50 74 72 20 77 69 | 6e 64 6f 77 2c 52 65 63 |owPtr wi|ndow,Rec|
|00000fa0| 74 20 2a 72 2c 64 6f 75 | 62 6c 65 20 64 78 2c 64 |t *r,dou|ble dx,d|
|00000fb0| 6f 75 62 6c 65 20 64 79 | 2c 42 6f 6f 6c 65 61 6e |ouble dy|,Boolean|
|00000fc0| 20 72 61 6e 64 6f 6d 50 | 68 61 73 65 29 0d 7b 0d | randomP|hase).{.|
|00000fd0| 09 42 6f 6f 6c 65 61 6e | 20 65 72 72 6f 72 2c 6f |.Boolean| error,o|
|00000fe0| 6b 3b 0d 0d 09 69 66 28 | 49 73 47 57 6f 72 6c 64 |k;...if(|IsGWorld|
|00000ff0| 50 74 72 28 77 69 6e 64 | 6f 77 29 29 7b 0d 09 09 |Ptr(wind|ow)){...|
|00001000| 6f 6b 3d 4c 6f 63 6b 50 | 69 78 65 6c 73 28 77 69 |ok=LockP|ixels(wi|
|00001010| 6e 64 6f 77 2d 3e 70 6f | 72 74 50 69 78 4d 61 70 |ndow->po|rtPixMap|
|00001020| 29 3b 0d 09 09 69 66 28 | 21 6f 6b 29 72 65 74 75 |);...if(|!ok)retu|
|00001030| 72 6e 20 32 3b 0d 09 7d | 0d 09 69 66 28 49 73 47 |rn 2;..}|..if(IsG|
|00001040| 72 61 66 50 74 72 28 77 | 69 6e 64 6f 77 29 29 0d |rafPtr(w|indow)).|
|00001050| 09 09 65 72 72 6f 72 3d | 4e 6f 69 73 65 46 69 6c |..error=|NoiseFil|
|00001060| 6c 42 69 74 73 28 28 50 | 69 78 4d 61 70 20 2a 29 |lBits((P|ixMap *)|
|00001070| 26 28 28 57 69 6e 64 6f | 77 50 74 72 29 77 69 6e |&((Windo|wPtr)win|
|00001080| 64 6f 77 29 2d 3e 70 6f | 72 74 42 69 74 73 2c 72 |dow)->po|rtBits,r|
|00001090| 2c 64 78 2c 64 79 2c 72 | 61 6e 64 6f 6d 50 68 61 |,dx,dy,r|andomPha|
|000010a0| 73 65 29 3b 0d 09 65 6c | 73 65 7b 0d 09 09 48 4c |se);..el|se{...HL|
|000010b0| 6f 63 6b 28 28 48 61 6e | 64 6c 65 29 77 69 6e 64 |ock((Han|dle)wind|
|000010c0| 6f 77 2d 3e 70 6f 72 74 | 50 69 78 4d 61 70 29 3b |ow->port|PixMap);|
|000010d0| 0d 09 09 65 72 72 6f 72 | 3d 4e 6f 69 73 65 46 69 |...error|=NoiseFi|
|000010e0| 6c 6c 42 69 74 73 28 2a | 77 69 6e 64 6f 77 2d 3e |llBits(*|window->|
|000010f0| 70 6f 72 74 50 69 78 4d | 61 70 2c 72 2c 64 78 2c |portPixM|ap,r,dx,|
|00001100| 64 79 2c 72 61 6e 64 6f | 6d 50 68 61 73 65 29 3b |dy,rando|mPhase);|
|00001110| 0d 09 09 48 55 6e 6c 6f | 63 6b 28 28 48 61 6e 64 |...HUnlo|ck((Hand|
|00001120| 6c 65 29 77 69 6e 64 6f | 77 2d 3e 70 6f 72 74 50 |le)windo|w->portP|
|00001130| 69 78 4d 61 70 29 3b 0d | 09 7d 0d 09 69 66 28 49 |ixMap);.|.}..if(I|
|00001140| 73 47 57 6f 72 6c 64 50 | 74 72 28 77 69 6e 64 6f |sGWorldP|tr(windo|
|00001150| 77 29 29 55 6e 6c 6f 63 | 6b 50 69 78 65 6c 73 28 |w))Unloc|kPixels(|
|00001160| 77 69 6e 64 6f 77 2d 3e | 70 6f 72 74 50 69 78 4d |window->|portPixM|
|00001170| 61 70 29 3b 0d 09 72 65 | 74 75 72 6e 20 65 72 72 |ap);..re|turn err|
|00001180| 6f 72 3b 0d 7d 0d 0d 69 | 6e 74 20 4e 6f 69 73 65 |or;.}..i|nt Noise|
|00001190| 46 69 6c 6c 42 69 74 73 | 28 50 69 78 4d 61 70 20 |FillBits|(PixMap |
|000011a0| 2a 62 69 74 73 2c 52 65 | 63 74 20 2a 72 2c 64 6f |*bits,Re|ct *r,do|
|000011b0| 75 62 6c 65 20 64 78 2c | 64 6f 75 62 6c 65 20 64 |uble dx,|double d|
|000011c0| 79 2c 42 6f 6f 6c 65 61 | 6e 20 72 61 6e 64 6f 6d |y,Boolea|n random|
|000011d0| 50 68 61 73 65 29 0d 7b | 0d 09 42 69 74 4d 61 70 |Phase).{|..BitMap|
|000011e0| 20 62 75 66 66 65 72 2c | 62 69 67 42 75 66 66 65 | buffer,|bigBuffe|
|000011f0| 72 3b 0d 09 52 65 63 74 | 20 73 72 63 52 65 63 74 |r;..Rect| srcRect|
|00001200| 3b 0d 09 73 69 7a 65 5f | 74 20 66 72 61 6d 65 42 |;..size_|t frameB|
|00001210| 79 74 65 73 2c 62 75 66 | 66 65 72 42 79 74 65 73 |ytes,buf|ferBytes|
|00001220| 3b 0d 09 73 74 61 74 69 | 63 20 63 6f 6e 73 74 20 |;..stati|c const |
|00001230| 52 47 42 43 6f 6c 6f 72 | 20 62 6c 61 63 6b 52 47 |RGBColor| blackRG|
|00001240| 42 3d 7b 30 2c 30 2c 30 | 7d 2c 77 68 69 74 65 52 |B={0,0,0|},whiteR|
|00001250| 47 42 3d 7b 30 78 66 66 | 66 66 2c 30 78 66 66 66 |GB={0xff|ff,0xfff|
|00001260| 66 2c 30 78 66 66 66 66 | 7d 3b 0d 09 52 47 42 43 |f,0xffff|};..RGBC|
|00001270| 6f 6c 6f 72 20 62 61 63 | 6b 52 47 42 2c 66 6f 72 |olor bac|kRGB,for|
|00001280| 65 52 47 42 3b 0d 09 69 | 6e 74 20 65 72 72 6f 72 |eRGB;..i|nt error|
|00001290| 3b 0d 09 0d 09 69 66 28 | 64 78 3c 3d 30 20 7c 7c |;....if(|dx<=0 |||
|000012a0| 20 64 79 3c 3d 30 29 72 | 65 74 75 72 6e 20 33 3b | dy<=0)r|eturn 3;|
|000012b0| 0d 09 73 72 61 6e 64 55 | 28 28 75 6e 73 69 67 6e |..srandU|((unsign|
|000012c0| 65 64 20 69 6e 74 29 72 | 61 6e 64 28 29 29 3b 09 |ed int)r|and());.|
|000012d0| 2f 2a 20 73 65 65 64 20 | 6f 75 72 20 75 6e 73 69 |/* seed |our unsi|
|000012e0| 67 6e 65 64 20 72 61 6e | 64 6f 6d 20 6e 75 6d 62 |gned ran|dom numb|
|000012f0| 65 72 20 67 65 6e 65 72 | 61 74 6f 72 20 2a 2f 0d |er gener|ator */.|
|00001300| 09 47 65 74 42 61 63 6b | 43 6f 6c 6f 72 28 26 62 |.GetBack|Color(&b|
|00001310| 61 63 6b 52 47 42 29 3b | 0d 09 47 65 74 46 6f 72 |ackRGB);|..GetFor|
|00001320| 65 43 6f 6c 6f 72 28 26 | 66 6f 72 65 52 47 42 29 |eColor(&|foreRGB)|
|00001330| 3b 0d 0d 09 2f 2a 20 61 | 6c 6c 6f 63 61 74 65 20 |;.../* a|llocate |
|00001340| 62 75 66 66 65 72 20 42 | 69 74 4d 61 70 20 2a 2f |buffer B|itMap */|
|00001350| 0d 09 53 65 74 52 65 63 | 74 28 26 62 75 66 66 65 |..SetRec|t(&buffe|
|00001360| 72 2e 62 6f 75 6e 64 73 | 2c 30 2c 30 2c 63 65 69 |r.bounds|,0,0,cei|
|00001370| 6c 28 28 72 2d 3e 72 69 | 67 68 74 20 2d 20 72 2d |l((r->ri|ght - r-|
|00001380| 3e 6c 65 66 74 29 2f 64 | 78 29 2c 63 65 69 6c 28 |>left)/d|x),ceil(|
|00001390| 28 72 2d 3e 62 6f 74 74 | 6f 6d 20 2d 20 72 2d 3e |(r->bott|om - r->|
|000013a0| 74 6f 70 29 2f 64 79 29 | 29 3b 0d 09 69 66 28 72 |top)/dy)|);..if(r|
|000013b0| 61 6e 64 6f 6d 50 68 61 | 73 65 29 7b 0d 09 09 62 |andomPha|se){...b|
|000013c0| 75 66 66 65 72 2e 62 6f | 75 6e 64 73 2e 72 69 67 |uffer.bo|unds.rig|
|000013d0| 68 74 2b 2b 3b 0d 09 09 | 62 75 66 66 65 72 2e 62 |ht++;...|buffer.b|
|000013e0| 6f 75 6e 64 73 2e 62 6f | 74 74 6f 6d 2b 2b 3b 0d |ounds.bo|ttom++;.|
|000013f0| 09 7d 0d 09 62 75 66 66 | 65 72 2e 72 6f 77 42 79 |.}..buff|er.rowBy|
|00001400| 74 65 73 3d 28 62 75 66 | 66 65 72 2e 62 6f 75 6e |tes=(buf|fer.boun|
|00001410| 64 73 2e 72 69 67 68 74 | 20 2b 20 33 31 20 26 20 |ds.right| + 31 & |
|00001420| 7e 33 31 29 2f 38 3b 20 | 2f 2a 20 72 6f 75 6e 64 |~31)/8; |/* round|
|00001430| 20 75 70 20 74 6f 20 6d | 75 6c 74 69 70 6c 65 20 | up to m|ultiple |
|00001440| 6f 66 20 33 32 20 62 69 | 74 73 20 2a 2f 0d 09 62 |of 32 bi|ts */..b|
|00001450| 75 66 66 65 72 42 79 74 | 65 73 3d 28 73 69 7a 65 |ufferByt|es=(size|
|00001460| 5f 74 29 20 62 75 66 66 | 65 72 2e 72 6f 77 42 79 |_t) buff|er.rowBy|
|00001470| 74 65 73 20 2a 20 28 73 | 69 7a 65 5f 74 29 20 62 |tes * (s|ize_t) b|
|00001480| 75 66 66 65 72 2e 62 6f | 75 6e 64 73 2e 62 6f 74 |uffer.bo|unds.bot|
|00001490| 74 6f 6d 3b 0d 09 62 75 | 66 66 65 72 2e 62 61 73 |tom;..bu|ffer.bas|
|000014a0| 65 41 64 64 72 3d 28 50 | 74 72 29 20 4e 65 77 50 |eAddr=(P|tr) NewP|
|000014b0| 74 72 28 62 75 66 66 65 | 72 42 79 74 65 73 29 3b |tr(buffe|rBytes);|
|000014c0| 0d 09 69 66 28 62 75 66 | 66 65 72 2e 62 61 73 65 |..if(buf|fer.base|
|000014d0| 41 64 64 72 20 3d 3d 20 | 4e 55 4c 4c 29 72 65 74 |Addr == |NULL)ret|
|000014e0| 75 72 6e 20 34 3b 0d 0d | 09 2f 2a 20 61 6c 6c 6f |urn 4;..|./* allo|
|000014f0| 63 61 74 65 20 62 69 67 | 42 75 66 66 65 72 20 42 |cate big|Buffer B|
|00001500| 69 74 4d 61 70 20 2a 2f | 0d 09 53 65 74 52 65 63 |itMap */|..SetRec|
|00001510| 74 20 28 26 62 69 67 42 | 75 66 66 65 72 2e 62 6f |t (&bigB|uffer.bo|
|00001520| 75 6e 64 73 2c 30 2c 30 | 2c 28 69 6e 74 29 72 6f |unds,0,0|,(int)ro|
|00001530| 75 6e 64 28 62 75 66 66 | 65 72 2e 62 6f 75 6e 64 |und(buff|er.bound|
|00001540| 73 2e 72 69 67 68 74 2a | 64 78 29 2c 0d 09 09 28 |s.right*|dx),...(|
|00001550| 69 6e 74 29 72 6f 75 6e | 64 28 62 75 66 66 65 72 |int)roun|d(buffer|
|00001560| 2e 62 6f 75 6e 64 73 2e | 62 6f 74 74 6f 6d 2a 64 |.bounds.|bottom*d|
|00001570| 79 29 29 3b 0d 09 62 69 | 67 42 75 66 66 65 72 2e |y));..bi|gBuffer.|
|00001580| 72 6f 77 42 79 74 65 73 | 3d 28 62 69 67 42 75 66 |rowBytes|=(bigBuf|
|00001590| 66 65 72 2e 62 6f 75 6e | 64 73 2e 72 69 67 68 74 |fer.boun|ds.right|
|000015a0| 20 2b 20 33 31 20 26 20 | 7e 33 31 29 2f 38 3b 20 | + 31 & |~31)/8; |
|000015b0| 2f 2a 20 72 6f 75 6e 64 | 20 75 70 20 74 6f 20 6d |/* round| up to m|
|000015c0| 75 6c 74 69 70 6c 65 20 | 6f 66 20 33 32 20 62 69 |ultiple |of 32 bi|
|000015d0| 74 73 20 2a 2f 0d 09 62 | 69 67 42 75 66 66 65 72 |ts */..b|igBuffer|
|000015e0| 2e 62 61 73 65 41 64 64 | 72 3d 28 50 74 72 29 20 |.baseAdd|r=(Ptr) |
|000015f0| 4e 65 77 50 74 72 28 28 | 73 69 7a 65 5f 74 29 20 |NewPtr((|size_t) |
|00001600| 62 69 67 42 75 66 66 65 | 72 2e 72 6f 77 42 79 74 |bigBuffe|r.rowByt|
|00001610| 65 73 20 2a 20 28 73 69 | 7a 65 5f 74 29 20 62 69 |es * (si|ze_t) bi|
|00001620| 67 42 75 66 66 65 72 2e | 62 6f 75 6e 64 73 2e 62 |gBuffer.|bounds.b|
|00001630| 6f 74 74 6f 6d 29 3b 0d | 09 69 66 28 62 69 67 42 |ottom);.|.if(bigB|
|00001640| 75 66 66 65 72 2e 62 61 | 73 65 41 64 64 72 20 3d |uffer.ba|seAddr =|
|00001650| 3d 20 4e 55 4c 4c 29 7b | 0d 09 09 44 69 73 70 6f |= NULL){|...Dispo|
|00001660| 73 65 50 74 72 28 62 75 | 66 66 65 72 2e 62 61 73 |sePtr(bu|ffer.bas|
|00001670| 65 41 64 64 72 29 3b 0d | 09 09 72 65 74 75 72 6e |eAddr);.|..return|
|00001680| 20 35 3b 0d 09 7d 0d 09 | 2f 2a 20 69 66 20 6e 65 | 5;..}..|/* if ne|
|00001690| 63 65 73 73 61 72 79 2c | 20 66 69 6c 6c 20 69 6e |cessary,| fill in|
|000016a0| 20 70 69 78 6d 61 70 27 | 73 20 66 69 65 6c 64 73 | pixmap'|s fields|
|000016b0| 20 61 6e 64 20 61 6c 6c | 6f 63 61 74 65 20 69 74 | and all|ocate it|
|000016c0| 73 20 64 61 74 61 20 61 | 72 65 61 20 2a 2f 0d 09 |s data a|rea */..|
|000016d0| 69 66 28 62 69 74 73 2d | 3e 62 61 73 65 41 64 64 |if(bits-|>baseAdd|
|000016e0| 72 20 3d 3d 20 4e 55 4c | 4c 29 7b 0d 09 09 2f 2f |r == NUL|L){...//|
|000016f0| 20 49 66 20 77 65 27 72 | 65 20 61 6c 6c 6f 63 61 | If we'r|e alloca|
|00001700| 74 69 6e 67 2c 20 61 73 | 73 75 6d 65 20 2a 62 69 |ting, as|sume *bi|
|00001710| 74 73 20 69 73 20 61 20 | 50 69 78 4d 61 70 2c 20 |ts is a |PixMap, |
|00001720| 6e 6f 74 20 61 20 42 69 | 74 6d 61 70 2e 0d 09 09 |not a Bi|tmap....|
|00001730| 62 69 74 73 2d 3e 68 52 | 65 73 3d 62 69 74 73 2d |bits->hR|es=bits-|
|00001740| 3e 76 52 65 73 3d 30 78 | 34 38 30 30 30 30 3b 09 |>vRes=0x|480000;.|
|00001750| 2f 2f 20 37 32 20 64 70 | 69 0d 09 09 62 69 74 73 |// 72 dp|i...bits|
|00001760| 2d 3e 70 6d 56 65 72 73 | 69 6f 6e 3d 62 69 74 73 |->pmVers|ion=bits|
|00001770| 2d 3e 70 61 63 6b 54 79 | 70 65 3d 62 69 74 73 2d |->packTy|pe=bits-|
|00001780| 3e 70 61 63 6b 53 69 7a | 65 3d 30 3b 0d 09 09 62 |>packSiz|e=0;...b|
|00001790| 69 74 73 2d 3e 70 6c 61 | 6e 65 42 79 74 65 73 3d |its->pla|neBytes=|
|000017a0| 62 69 74 73 2d 3e 70 6d | 52 65 73 65 72 76 65 64 |bits->pm|Reserved|
|000017b0| 3d 30 3b 0d 09 09 62 69 | 74 73 2d 3e 63 6d 70 43 |=0;...bi|ts->cmpC|
|000017c0| 6f 75 6e 74 3d 31 3b 0d | 09 09 62 69 74 73 2d 3e |ount=1;.|..bits->|
|000017d0| 63 6d 70 53 69 7a 65 3d | 62 69 74 73 2d 3e 70 69 |cmpSize=|bits->pi|
|000017e0| 78 65 6c 53 69 7a 65 3b | 0d 09 09 62 69 74 73 2d |xelSize;|...bits-|
|000017f0| 3e 70 6d 54 61 62 6c 65 | 3d 28 2a 2a 28 2a 2a 47 |>pmTable|=(**(**G|
|00001800| 65 74 47 44 65 76 69 63 | 65 28 29 29 2e 67 64 50 |etGDevic|e()).gdP|
|00001810| 4d 61 70 29 2e 70 6d 54 | 61 62 6c 65 3b 0d 09 09 |Map).pmT|able;...|
|00001820| 62 69 74 73 2d 3e 72 6f | 77 42 79 74 65 73 3d 28 |bits->ro|wBytes=(|
|00001830| 28 62 69 74 73 2d 3e 62 | 6f 75 6e 64 73 2e 72 69 |(bits->b|ounds.ri|
|00001840| 67 68 74 2d 62 69 74 73 | 2d 3e 62 6f 75 6e 64 73 |ght-bits|->bounds|
|00001850| 2e 6c 65 66 74 29 2a 62 | 69 74 73 2d 3e 70 69 78 |.left)*b|its->pix|
|00001860| 65 6c 53 69 7a 65 20 2b | 20 33 31 20 26 20 7e 33 |elSize +| 31 & ~3|
|00001870| 31 29 2f 38 3b 20 2f 2a | 20 72 6f 75 6e 64 20 75 |1)/8; /*| round u|
|00001880| 70 20 74 6f 20 6d 75 6c | 74 69 70 6c 65 20 6f 66 |p to mul|tiple of|
|00001890| 20 33 32 20 62 69 74 73 | 20 2a 2f 0d 09 09 66 72 | 32 bits| */...fr|
|000018a0| 61 6d 65 42 79 74 65 73 | 3d 28 73 69 7a 65 5f 74 |ameBytes|=(size_t|
|000018b0| 29 20 62 69 74 73 2d 3e | 72 6f 77 42 79 74 65 73 |) bits->|rowBytes|
|000018c0| 20 2a 20 28 62 69 74 73 | 2d 3e 62 6f 75 6e 64 73 | * (bits|->bounds|
|000018d0| 2e 62 6f 74 74 6f 6d 2d | 62 69 74 73 2d 3e 62 6f |.bottom-|bits->bo|
|000018e0| 75 6e 64 73 2e 74 6f 70 | 29 3b 0d 09 09 62 69 74 |unds.top|);...bit|
|000018f0| 73 2d 3e 72 6f 77 42 79 | 74 65 73 20 7c 3d 20 30 |s->rowBy|tes |= 0|
|00001900| 78 38 30 30 30 3b 09 2f | 2a 20 6d 61 72 6b 20 69 |x8000;./|* mark i|
|00001910| 74 20 61 73 20 61 20 50 | 69 78 4d 61 70 20 2a 2f |t as a P|ixMap */|
|00001920| 0d 09 09 62 69 74 73 2d | 3e 62 61 73 65 41 64 64 |...bits-|>baseAdd|
|00001930| 72 3d 28 63 68 61 72 20 | 2a 29 20 4e 65 77 50 74 |r=(char |*) NewPt|
|00001940| 72 28 66 72 61 6d 65 42 | 79 74 65 73 29 3b 0d 09 |r(frameB|ytes);..|
|00001950| 09 69 66 28 62 69 74 73 | 2d 3e 62 61 73 65 41 64 |.if(bits|->baseAd|
|00001960| 64 72 20 3d 3d 20 4e 55 | 4c 4c 29 72 65 74 75 72 |dr == NU|LL)retur|
|00001970| 6e 20 36 3b 0d 09 7d 0d | 09 69 66 28 28 73 69 7a |n 6;..}.|.if((siz|
|00001980| 65 5f 74 29 62 69 74 73 | 2d 3e 62 61 73 65 41 64 |e_t)bits|->baseAd|
|00001990| 64 72 25 34 20 21 3d 20 | 30 4c 29 7b 0d 09 09 70 |dr%4 != |0L){...p|
|000019a0| 72 69 6e 74 66 28 22 57 | 41 52 4e 49 4e 47 3a 20 |rintf("W|ARNING: |
|000019b0| 46 72 61 6d 65 20 62 75 | 66 66 65 72 20 61 64 64 |Frame bu|ffer add|
|000019c0| 72 65 73 73 20 69 73 20 | 6e 6f 74 20 6c 6f 6e 67 |ress is |not long|
|000019d0| 20 61 6c 69 67 6e 65 64 | 2e 20 25 73 5c 30 30 37 | aligned|. %s\007|
|000019e0| 5c 6e 22 2c 5f 5f 46 49 | 4c 45 5f 5f 29 3b 0d 09 |\n",__FI|LE__);..|
|000019f0| 7d 0d 0d 09 2f 2a 20 63 | 72 65 61 74 65 20 72 61 |}.../* c|reate ra|
|00001a00| 6e 64 6f 6d 20 6e 6f 69 | 73 65 20 2a 2f 0d 09 2f |ndom noi|se */../|
|00001a10| 2a 20 46 69 72 73 74 20 | 63 72 65 61 74 65 20 61 |* First |create a|
|00001a20| 20 72 61 6e 64 6f 6d 20 | 62 69 74 20 69 6d 61 67 | random |bit imag|
|00001a30| 65 2c 20 61 6c 6c 20 62 | 69 74 73 20 75 6e 63 6f |e, all b|its unco|
|00001a40| 72 72 65 6c 61 74 65 64 | 2e 20 2a 2f 0d 09 52 61 |rrelated|. */..Ra|
|00001a50| 6e 64 46 69 6c 6c 28 62 | 75 66 66 65 72 2e 62 61 |ndFill(b|uffer.ba|
|00001a60| 73 65 41 64 64 72 2c 62 | 75 66 66 65 72 42 79 74 |seAddr,b|ufferByt|
|00001a70| 65 73 29 3b 0d 09 2f 2a | 20 4e 6f 77 20 65 78 70 |es);../*| Now exp|
|00001a80| 61 6e 64 20 69 6d 61 67 | 65 20 73 6f 20 74 68 61 |and imag|e so tha|
|00001a90| 74 20 65 61 63 68 20 72 | 61 6e 64 6f 6d 20 62 69 |t each r|andom bi|
|00001aa0| 74 20 62 65 63 6f 6d 65 | 73 20 61 20 64 78 20 62 |t become|s a dx b|
|00001ab0| 79 20 64 79 20 72 65 63 | 74 61 6e 67 6c 65 2e 20 |y dy rec|tangle. |
|00001ac0| 2a 2f 0d 09 52 47 42 42 | 61 63 6b 43 6f 6c 6f 72 |*/..RGBB|ackColor|
|00001ad0| 28 26 77 68 69 74 65 52 | 47 42 29 3b 0d 09 52 47 |(&whiteR|GB);..RG|
|00001ae0| 42 46 6f 72 65 43 6f 6c | 6f 72 28 26 62 6c 61 63 |BForeCol|or(&blac|
|00001af0| 6b 52 47 42 29 3b 0d 09 | 43 6f 70 79 42 69 74 73 |kRGB);..|CopyBits|
|00001b00| 28 26 62 75 66 66 65 72 | 2c 26 62 69 67 42 75 66 |(&buffer|,&bigBuf|
|00001b10| 66 65 72 2c 26 62 75 66 | 66 65 72 2e 62 6f 75 6e |fer,&buf|fer.boun|
|00001b20| 64 73 2c 26 62 69 67 42 | 75 66 66 65 72 2e 62 6f |ds,&bigB|uffer.bo|
|00001b30| 75 6e 64 73 2c 73 72 63 | 43 6f 70 79 2c 4e 55 4c |unds,src|Copy,NUL|
|00001b40| 4c 29 3b 0d 09 65 72 72 | 6f 72 3d 51 44 45 72 72 |L);..err|or=QDErr|
|00001b50| 6f 72 28 29 3b 0d 09 69 | 66 28 65 72 72 6f 72 29 |or();..i|f(error)|
|00001b60| 70 72 69 6e 74 66 28 22 | 4d 61 6b 65 4e 6f 69 73 |printf("|MakeNois|
|00001b70| 65 31 3a 61 3a 20 43 6f | 70 79 42 69 74 73 20 65 |e1:a: Co|pyBits e|
|00001b80| 72 72 6f 72 20 25 64 5c | 6e 22 2c 65 72 72 6f 72 |rror %d\|n",error|
|00001b90| 29 3b 0d 09 2f 2a 20 46 | 69 6e 61 6c 6c 79 20 63 |);../* F|inally c|
|00001ba0| 6f 70 79 20 69 74 20 69 | 6e 74 6f 20 74 68 65 20 |opy it i|nto the |
|00001bb0| 62 69 74 2f 70 69 78 6d | 61 70 2c 20 74 72 69 6d |bit/pixm|ap, trim|
|00001bc0| 6d 69 6e 67 20 69 74 20 | 64 6f 77 6e 20 74 6f 20 |ming it |down to |
|00001bd0| 74 68 65 20 63 6f 72 72 | 65 63 74 20 73 69 7a 65 |the corr|ect size|
|00001be0| 2e 20 2a 2f 0d 09 52 47 | 42 42 61 63 6b 43 6f 6c |. */..RG|BBackCol|
|00001bf0| 6f 72 28 26 62 61 63 6b | 52 47 42 29 3b 0d 09 52 |or(&back|RGB);..R|
|00001c00| 47 42 46 6f 72 65 43 6f | 6c 6f 72 28 26 66 6f 72 |GBForeCo|lor(&for|
|00001c10| 65 52 47 42 29 3b 0d 09 | 73 72 63 52 65 63 74 3d |eRGB);..|srcRect=|
|00001c20| 2a 72 3b 0d 09 4f 66 66 | 73 65 74 52 65 63 74 28 |*r;..Off|setRect(|
|00001c30| 26 73 72 63 52 65 63 74 | 2c 2d 73 72 63 52 65 63 |&srcRect|,-srcRec|
|00001c40| 74 2e 6c 65 66 74 2c 2d | 73 72 63 52 65 63 74 2e |t.left,-|srcRect.|
|00001c50| 74 6f 70 29 3b 0d 09 69 | 66 28 72 61 6e 64 6f 6d |top);..i|f(random|
|00001c60| 50 68 61 73 65 29 20 4f | 66 66 73 65 74 52 65 63 |Phase) O|ffsetRec|
|00001c70| 74 28 26 73 72 63 52 65 | 63 74 2c 6e 72 61 6e 64 |t(&srcRe|ct,nrand|
|00001c80| 28 64 78 29 2c 6e 72 61 | 6e 64 28 64 79 29 29 3b |(dx),nra|nd(dy));|
|00001c90| 0d 09 65 6c 73 65 20 43 | 65 6e 74 65 72 52 65 63 |..else C|enterRec|
|00001ca0| 74 49 6e 52 65 63 74 28 | 26 73 72 63 52 65 63 74 |tInRect(|&srcRect|
|00001cb0| 2c 26 62 69 67 42 75 66 | 66 65 72 2e 62 6f 75 6e |,&bigBuf|fer.boun|
|00001cc0| 64 73 29 3b 0d 09 43 6f | 70 79 42 69 74 73 28 26 |ds);..Co|pyBits(&|
|00001cd0| 62 69 67 42 75 66 66 65 | 72 2c 28 42 69 74 4d 61 |bigBuffe|r,(BitMa|
|00001ce0| 70 20 2a 29 62 69 74 73 | 2c 26 73 72 63 52 65 63 |p *)bits|,&srcRec|
|00001cf0| 74 2c 72 2c 73 72 63 43 | 6f 70 79 2c 4e 55 4c 4c |t,r,srcC|opy,NULL|
|00001d00| 29 3b 0d 09 65 72 72 6f | 72 3d 51 44 45 72 72 6f |);..erro|r=QDErro|
|00001d10| 72 28 29 3b 0d 09 44 69 | 73 70 6f 73 50 74 72 28 |r();..Di|sposPtr(|
|00001d20| 28 76 6f 69 64 20 2a 29 | 20 62 75 66 66 65 72 2e |(void *)| buffer.|
|00001d30| 62 61 73 65 41 64 64 72 | 29 3b 0d 09 44 69 73 70 |baseAddr|);..Disp|
|00001d40| 6f 73 50 74 72 28 28 76 | 6f 69 64 20 2a 29 20 62 |osPtr((v|oid *) b|
|00001d50| 69 67 42 75 66 66 65 72 | 2e 62 61 73 65 41 64 64 |igBuffer|.baseAdd|
|00001d60| 72 29 3b 0d 09 72 65 74 | 75 72 6e 20 65 72 72 6f |r);..ret|urn erro|
|00001d70| 72 3b 0d 7d 0d 0d 0d 00 | 00 00 00 00 00 00 00 00 |r;.}....|........|
|00001d80| 00 00 01 00 00 00 02 e2 | 00 00 01 e2 00 00 00 7a |........|.......z|
|00001d90| 00 00 13 2d 0b 54 69 6d | 65 43 50 55 2e 66 61 74 |...-.Tim|eCPU.fat|
|00001da0| 02 00 02 00 41 50 50 4c | 3f 3f 3f 3f 01 00 00 dc |....APPL|????....|
|00001db0| 0b 4e 6f 69 73 65 46 69 | 6c 6c 2e 63 02 00 00 00 |.NoiseFi|ll.c....|
|00001dc0| 54 45 58 54 43 57 49 45 | 01 00 00 28 03 c0 00 00 |TEXTCWIE|...(....|
|00001dd0| 00 00 54 45 58 54 43 57 | 49 45 01 00 00 28 03 c0 |..TEXTCW|IE...(..|
|00001de0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001df0| 00 00 aa f6 e1 b7 00 00 | 1c f7 00 00 03 5c 00 00 |........|.....\..|
|00001e00| 00 00 00 00 00 00 13 00 | 00 00 13 2d 0d 54 69 6d |........|...-.Tim|
|00001e10| 65 43 50 55 2e 70 70 63 | 2e b5 02 00 02 00 4d 4d |eCPU.ppc|......MM|
|00001e20| 50 52 4d 50 43 43 01 00 | 00 f0 01 20 00 00 00 00 |PRMPCC..|... ....|
|00001e30| 13 73 00 00 00 00 12 0c | 00 00 16 00 00 00 00 00 |.s......|........|
|00001e40| 05 2e 00 00 16 00 aa 6d | cc 00 aa f0 96 67 00 00 |.......m|.....g..|
|00001e50| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001e60| 00 00 00 00 28 02 00 01 | 00 00 00 00 00 00 00 00 |....(...|........|
|00001e70| 28 03 00 01 00 00 00 00 | 00 00 00 00 00 00 00 00 |(.......|........|
|00001e80| 00 00 00 0a 00 00 10 05 | ff ff 00 00 00 00 00 00 |........|........|
|00001e90| 01 50 00 0b 00 2c 00 00 | 12 78 00 67 00 cb 54 60 |.P...,..|.x.g..T`|
|00001ea0| 80 00 00 29 03 c9 00 90 | 04 6f 94 20 00 00 00 00 |...)....|.o. ....|
|00001eb0| 00 00 0d 62 75 66 66 65 | 72 2e 62 6f 75 6e 64 73 |...buffe|r.bounds|
|00001ec0| 00 1e 00 00 13 ad 00 6e | 00 cb 53 e8 00 00 0f 62 |.......n|..S....b|
|00001ed0| 75 66 66 65 72 2e 72 6f | 77 42 79 74 65 73 00 1a |uffer.ro|wBytes..|
|00001ee0| 00 00 13 fe 00 6f 00 cb | 53 d8 00 00 0b 62 75 66 |.....o..|S....buf|
|00001ef0| 66 65 72 42 79 74 65 73 | 00 30 00 00 14 f8 00 75 |ferBytes|.0.....u|
|00001f00| 00 cb 53 c8 80 00 00 80 | 03 c2 00 e7 04 64 94 20 |..S.....|.....d. |
|00001f10| 00 00 00 00 00 00 11 62 | 69 67 42 75 66 66 65 72 |.......b|igBuffer|
|00001f20| 2e 62 6f 75 6e 64 73 20 | 00 22 00 00 15 6c 00 77 |.bounds |."...l.w|
|00001f30| 00 cb 53 5c 00 00 13 62 | 69 67 42 75 66 66 65 72 |..S\...b|igBuffer|
|00001f40| 2e 72 6f 77 42 79 74 65 | 73 20 00 16 00 00 17 41 |.rowByte|s .....A|
|00001f50| 00 81 00 cb 53 4c 00 00 | 07 2a 66 72 61 6d 65 20 |....SL..|.*frame |
|00001f60| 00 14 00 00 17 41 00 81 | 00 cb 52 a8 00 00 05 66 |.....A..|..R....f|
|00001f70| 72 61 6d 65 00 1a 00 00 | 17 41 00 81 00 cb 52 98 |rame....|.A....R.|
|00001f80| 00 00 0b 66 72 61 6d 65 | 2d 3e 68 52 65 73 00 1a |...frame|->hRes..|
|00001f90| 00 00 18 b0 00 87 00 cb | 52 88 00 00 0b 66 72 61 |........|R....fra|
|00001fa0| 6d 65 42 79 74 65 73 20 | 00 26 00 00 17 25 00 80 |meBytes |.&...%..|
|00001fb0| 00 cb 51 3c 80 00 00 ca | 03 c9 01 9f 04 b7 94 20 |..Q<....|....... |
|00001fc0| 00 00 00 00 00 00 07 2a | 66 72 61 6d 65 20 00 14 |.......*|frame ..|
|00001fd0| 00 00 17 25 00 80 00 cb | 50 cc 00 00 05 66 72 61 |...%....|P....fra|
|00001fe0| 6d 65 00 00 00 28 00 02 | 00 00 0f 19 00 00 0f 19 |me...(..|........|
|00001ff0| 09 4d 61 6b 65 4e 6f 69 | 73 65 00 00 10 f5 00 00 |.MakeNoi|se......|
|00002000| 10 ff 0b 4d 61 6b 65 4e | 6f 69 73 65 31 00 00 00 |...MakeN|oise1...|
|00002010| 00 48 00 09 4d 6f 6e 61 | 63 6f 00 00 00 00 00 00 |.H..Mona|co......|
|00002020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00002030| 00 00 00 00 00 03 00 04 | 00 3c 00 03 01 8c 02 7d |........|.<.....}|
|00002040| 00 3c 00 03 01 8c 02 7d | ac 4e d3 d6 00 00 18 73 |.<.....}|.N.....s|
|00002050| 00 00 18 7b 00 00 15 b8 | 00 00 00 00 00 04 00 01 |...{....|........|
|00002060| 00 01 00 00 01 00 00 00 | 02 e2 00 00 01 e2 00 00 |........|........|
|00002070| 00 7a 00 4b e0 68 2d 2c | 00 00 00 1c 00 7a 00 03 |.z.K.h-,|.....z..|
|00002080| 4d 50 53 52 00 01 00 22 | 42 4b 50 54 00 00 00 3a |MPSR..."|BKPT...:|
|00002090| 44 54 56 55 00 00 00 46 | 4d 57 42 42 00 00 00 52 |DTVU...F|MWBB...R|
|000020a0| 03 ef ff ff 00 00 01 62 | 00 00 00 00 03 ed ff ff |.......b|........|
|000020b0| 00 00 01 8e 00 00 00 00 | 3c 9c ff ff 00 00 00 00 |........|<.......|
|000020c0| 00 00 00 00 3f 7c ff ff | 00 00 00 0e 00 00 00 00 |....?|..|........|
|000020d0| 03 f0 ff ff 00 00 01 da | 00 00 00 00 00 00 00 00 |........|........|
|000020e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000020f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
+--------+-------------------------+-------------------------+--------+--------+