home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sources / misc / 4202 < prev    next >
SHell self-extracting ARchive  |  1992-12-16  |  57.7 KB

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: SHell self-extracting ARchive (archive/shar).

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert SHell self-extracting ARchive (archive/shar) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file ASCII text default
100% checkBytes Printable ASCII default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/329 Shell Archive Format default
100% detectItEasy Format: plain text[LF] default (weak)



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 4e 65 77 73 67 72 6f 75 | 70 73 3a 20 63 6f 6d 70 |Newsgrou|ps: comp|
|00000010| 2e 73 6f 75 72 63 65 73 | 2e 6d 69 73 63 0a 50 61 |.sources|.misc.Pa|
|00000020| 74 68 3a 20 73 70 61 72 | 6b 79 21 6b 65 6e 74 0a |th: spar|ky!kent.|
|00000030| 46 72 6f 6d 3a 20 6a 70 | 65 67 2d 69 6e 66 6f 40 |From: jp|eg-info@|
|00000040| 75 75 6e 65 74 2e 75 75 | 2e 6e 65 74 20 28 49 6e |uunet.uu|.net (In|
|00000050| 64 65 70 65 6e 64 65 6e | 74 20 4a 50 45 47 20 47 |dependen|t JPEG G|
|00000060| 72 6f 75 70 29 0a 53 75 | 62 6a 65 63 74 3a 20 20 |roup).Su|bject: |
|00000070| 76 33 34 69 30 36 32 3a | 20 20 6a 70 65 67 20 2d |v34i062:| jpeg -|
|00000080| 20 4a 50 45 47 20 69 6d | 61 67 65 20 63 6f 6d 70 | JPEG im|age comp|
|00000090| 72 65 73 73 69 6f 6e 2c | 20 50 61 72 74 30 38 2f |ression,| Part08/|
|000000a0| 31 38 0a 4d 65 73 73 61 | 67 65 2d 49 44 3a 20 3c |18.Messa|ge-ID: <|
|000000b0| 31 39 39 32 44 65 63 31 | 37 2e 30 34 31 38 32 34 |1992Dec1|7.041824|
|000000c0| 2e 32 33 36 32 33 40 73 | 70 61 72 6b 79 2e 69 6d |.23623@s|parky.im|
|000000d0| 64 2e 73 74 65 72 6c 69 | 6e 67 2e 63 6f 6d 3e 0a |d.sterli|ng.com>.|
|000000e0| 46 6f 6c 6c 6f 77 75 70 | 2d 54 6f 3a 20 63 6f 6d |Followup|-To: com|
|000000f0| 70 2e 73 6f 75 72 63 65 | 73 2e 64 0a 58 2d 4d 64 |p.source|s.d.X-Md|
|00000100| 34 2d 53 69 67 6e 61 74 | 75 72 65 3a 20 30 35 38 |4-Signat|ure: 058|
|00000110| 39 64 31 34 30 36 37 37 | 33 32 66 34 39 35 61 61 |9d140677|32f495aa|
|00000120| 61 35 31 39 37 64 34 61 | 66 61 35 66 36 0a 53 65 |a5197d4a|fa5f6.Se|
|00000130| 6e 64 65 72 3a 20 6b 65 | 6e 74 40 73 70 61 72 6b |nder: ke|nt@spark|
|00000140| 79 2e 69 6d 64 2e 73 74 | 65 72 6c 69 6e 67 2e 63 |y.imd.st|erling.c|
|00000150| 6f 6d 20 28 4b 65 6e 74 | 20 4c 61 6e 64 66 69 65 |om (Kent| Landfie|
|00000160| 6c 64 29 0a 4f 72 67 61 | 6e 69 7a 61 74 69 6f 6e |ld).Orga|nization|
|00000170| 3a 20 53 74 65 72 6c 69 | 6e 67 20 53 6f 66 74 77 |: Sterli|ng Softw|
|00000180| 61 72 65 0a 52 65 66 65 | 72 65 6e 63 65 73 3a 20 |are.Refe|rences: |
|00000190| 3c 63 73 6d 2d 76 33 34 | 69 30 35 35 3d 6a 70 65 |<csm-v34|i055=jpe|
|000001a0| 67 2e 32 32 30 34 32 34 | 40 73 70 61 72 6b 79 2e |g.220424|@sparky.|
|000001b0| 49 4d 44 2e 53 74 65 72 | 6c 69 6e 67 2e 43 4f 4d |IMD.Ster|ling.COM|
|000001c0| 3e 0a 44 61 74 65 3a 20 | 54 68 75 2c 20 31 37 20 |>.Date: |Thu, 17 |
|000001d0| 44 65 63 20 31 39 39 32 | 20 30 34 3a 31 38 3a 32 |Dec 1992| 04:18:2|
|000001e0| 34 20 47 4d 54 0a 41 70 | 70 72 6f 76 65 64 3a 20 |4 GMT.Ap|proved: |
|000001f0| 6b 65 6e 74 40 73 70 61 | 72 6b 79 2e 69 6d 64 2e |kent@spa|rky.imd.|
|00000200| 73 74 65 72 6c 69 6e 67 | 2e 63 6f 6d 0a 4c 69 6e |sterling|.com.Lin|
|00000210| 65 73 3a 20 31 34 37 34 | 0a 0a 53 75 62 6d 69 74 |es: 1474|..Submit|
|00000220| 74 65 64 2d 62 79 3a 20 | 6a 70 65 67 2d 69 6e 66 |ted-by: |jpeg-inf|
|00000230| 6f 40 75 75 6e 65 74 2e | 75 75 2e 6e 65 74 20 28 |o@uunet.|uu.net (|
|00000240| 49 6e 64 65 70 65 6e 64 | 65 6e 74 20 4a 50 45 47 |Independ|ent JPEG|
|00000250| 20 47 72 6f 75 70 29 0a | 50 6f 73 74 69 6e 67 2d | Group).|Posting-|
|00000260| 6e 75 6d 62 65 72 3a 20 | 56 6f 6c 75 6d 65 20 33 |number: |Volume 3|
|00000270| 34 2c 20 49 73 73 75 65 | 20 36 32 0a 41 72 63 68 |4, Issue| 62.Arch|
|00000280| 69 76 65 2d 6e 61 6d 65 | 3a 20 6a 70 65 67 2f 70 |ive-name|: jpeg/p|
|00000290| 61 72 74 30 38 0a 45 6e | 76 69 72 6f 6e 6d 65 6e |art08.En|vironmen|
|000002a0| 74 3a 20 55 4e 49 58 2c | 20 56 4d 53 2c 20 4d 53 |t: UNIX,| VMS, MS|
|000002b0| 2d 44 4f 53 2c 20 4d 61 | 63 2c 20 41 6d 69 67 61 |-DOS, Ma|c, Amiga|
|000002c0| 2c 20 41 74 61 72 69 2c | 20 43 72 61 79 0a 53 75 |, Atari,| Cray.Su|
|000002d0| 70 65 72 73 65 64 65 73 | 3a 20 6a 70 65 67 3a 20 |persedes|: jpeg: |
|000002e0| 56 6f 6c 75 6d 65 20 32 | 39 2c 20 49 73 73 75 65 |Volume 2|9, Issue|
|000002f0| 20 31 2d 31 38 0a 0a 23 | 21 20 2f 62 69 6e 2f 73 | 1-18..#|! /bin/s|
|00000300| 68 0a 23 20 54 68 69 73 | 20 69 73 20 61 20 73 68 |h.# This| is a sh|
|00000310| 65 6c 6c 20 61 72 63 68 | 69 76 65 2e 20 20 52 65 |ell arch|ive. Re|
|00000320| 6d 6f 76 65 20 61 6e 79 | 74 68 69 6e 67 20 62 65 |move any|thing be|
|00000330| 66 6f 72 65 20 74 68 69 | 73 20 6c 69 6e 65 2c 20 |fore thi|s line, |
|00000340| 74 68 65 6e 20 66 65 65 | 64 20 69 74 0a 23 20 69 |then fee|d it.# i|
|00000350| 6e 74 6f 20 61 20 73 68 | 65 6c 6c 20 76 69 61 20 |nto a sh|ell via |
|00000360| 22 73 68 20 66 69 6c 65 | 22 20 6f 72 20 73 69 6d |"sh file|" or sim|
|00000370| 69 6c 61 72 2e 20 20 54 | 6f 20 6f 76 65 72 77 72 |ilar. T|o overwr|
|00000380| 69 74 65 20 65 78 69 73 | 74 69 6e 67 20 66 69 6c |ite exis|ting fil|
|00000390| 65 73 2c 0a 23 20 74 79 | 70 65 20 22 73 68 20 66 |es,.# ty|pe "sh f|
|000003a0| 69 6c 65 20 2d 63 22 2e | 0a 23 20 43 6f 6e 74 65 |ile -c".|.# Conte|
|000003b0| 6e 74 73 3a 20 20 65 78 | 61 6d 70 6c 65 2e 63 20 |nts: ex|ample.c |
|000003c0| 6a 63 61 72 69 74 68 2e | 63 20 6a 63 70 69 70 65 |jcarith.|c jcpipe|
|000003d0| 2e 63 0a 23 20 57 72 61 | 70 70 65 64 20 62 79 20 |.c.# Wra|pped by |
|000003e0| 6b 65 6e 74 40 73 70 61 | 72 6b 79 20 6f 6e 20 57 |kent@spa|rky on W|
|000003f0| 65 64 20 44 65 63 20 31 | 36 20 32 30 3a 35 32 3a |ed Dec 1|6 20:52:|
|00000400| 32 37 20 31 39 39 32 0a | 50 41 54 48 3d 2f 62 69 |27 1992.|PATH=/bi|
|00000410| 6e 3a 2f 75 73 72 2f 62 | 69 6e 3a 2f 75 73 72 2f |n:/usr/b|in:/usr/|
|00000420| 75 63 62 3a 2f 75 73 72 | 2f 6c 6f 63 61 6c 2f 62 |ucb:/usr|/local/b|
|00000430| 69 6e 3a 2f 75 73 72 2f | 6c 62 69 6e 20 3b 20 65 |in:/usr/|lbin ; e|
|00000440| 78 70 6f 72 74 20 50 41 | 54 48 0a 65 63 68 6f 20 |xport PA|TH.echo |
|00000450| 49 66 20 74 68 69 73 20 | 61 72 63 68 69 76 65 20 |If this |archive |
|00000460| 69 73 20 63 6f 6d 70 6c | 65 74 65 2c 20 79 6f 75 |is compl|ete, you|
|00000470| 20 77 69 6c 6c 20 73 65 | 65 20 74 68 65 20 66 6f | will se|e the fo|
|00000480| 6c 6c 6f 77 69 6e 67 20 | 6d 65 73 73 61 67 65 3a |llowing |message:|
|00000490| 0a 65 63 68 6f 20 27 20 | 20 20 20 20 20 20 20 20 |.echo ' | |
|000004a0| 20 22 73 68 61 72 3a 20 | 45 6e 64 20 6f 66 20 61 | "shar: |End of a|
|000004b0| 72 63 68 69 76 65 20 38 | 20 28 6f 66 20 31 38 29 |rchive 8| (of 18)|
|000004c0| 2e 22 27 0a 69 66 20 74 | 65 73 74 20 2d 66 20 27 |."'.if t|est -f '|
|000004d0| 65 78 61 6d 70 6c 65 2e | 63 27 20 2d 61 20 22 24 |example.|c' -a "$|
|000004e0| 7b 31 7d 22 20 21 3d 20 | 22 2d 63 22 20 3b 20 74 |{1}" != |"-c" ; t|
|000004f0| 68 65 6e 20 0a 20 20 65 | 63 68 6f 20 73 68 61 72 |hen . e|cho shar|
|00000500| 3a 20 57 69 6c 6c 20 6e | 6f 74 20 63 6c 6f 62 62 |: Will n|ot clobb|
|00000510| 65 72 20 65 78 69 73 74 | 69 6e 67 20 66 69 6c 65 |er exist|ing file|
|00000520| 20 5c 22 27 65 78 61 6d | 70 6c 65 2e 63 27 5c 22 | \"'exam|ple.c'\"|
|00000530| 0a 65 6c 73 65 0a 20 20 | 65 63 68 6f 20 73 68 61 |.else. |echo sha|
|00000540| 72 3a 20 45 78 74 72 61 | 63 74 69 6e 67 20 5c 22 |r: Extra|cting \"|
|00000550| 27 65 78 61 6d 70 6c 65 | 2e 63 27 5c 22 20 5c 28 |'example|.c'\" \(|
|00000560| 32 36 38 37 39 20 63 68 | 61 72 61 63 74 65 72 73 |26879 ch|aracters|
|00000570| 5c 29 0a 20 20 73 65 64 | 20 22 73 2f 5e 58 2f 2f |\). sed| "s/^X//|
|00000580| 22 20 3e 27 65 78 61 6d | 70 6c 65 2e 63 27 20 3c |" >'exam|ple.c' <|
|00000590| 3c 27 45 4e 44 5f 4f 46 | 5f 46 49 4c 45 27 0a 58 |<'END_OF|_FILE'.X|
|000005a0| 2f 2a 0a 58 20 2a 20 65 | 78 61 6d 70 6c 65 2e 63 |/*.X * e|xample.c|
|000005b0| 0a 58 20 2a 0a 58 20 2a | 20 54 68 69 73 20 66 69 |.X *.X *| This fi|
|000005c0| 6c 65 20 69 73 20 6e 6f | 74 20 61 63 74 75 61 6c |le is no|t actual|
|000005d0| 6c 79 20 70 61 72 74 20 | 6f 66 20 74 68 65 20 4a |ly part |of the J|
|000005e0| 50 45 47 20 73 6f 66 74 | 77 61 72 65 2e 20 20 52 |PEG soft|ware. R|
|000005f0| 61 74 68 65 72 2c 20 69 | 74 20 70 72 6f 76 69 64 |ather, i|t provid|
|00000600| 65 73 0a 58 20 2a 20 61 | 20 73 6b 65 6c 65 74 6f |es.X * a| skeleto|
|00000610| 6e 20 74 68 61 74 20 6d | 61 79 20 62 65 20 75 73 |n that m|ay be us|
|00000620| 65 66 75 6c 20 66 6f 72 | 20 63 6f 6e 73 74 72 75 |eful for| constru|
|00000630| 63 74 69 6e 67 20 61 70 | 70 6c 69 63 61 74 69 6f |cting ap|plicatio|
|00000640| 6e 73 20 74 68 61 74 20 | 75 73 65 20 74 68 65 0a |ns that |use the.|
|00000650| 58 20 2a 20 4a 50 45 47 | 20 73 6f 66 74 77 61 72 |X * JPEG| softwar|
|00000660| 65 20 61 73 20 73 75 62 | 72 6f 75 74 69 6e 65 73 |e as sub|routines|
|00000670| 2e 20 20 54 68 69 73 20 | 63 6f 64 65 20 77 69 6c |. This |code wil|
|00000680| 6c 20 4e 4f 54 20 64 6f | 20 61 6e 79 74 68 69 6e |l NOT do| anythin|
|00000690| 67 20 75 73 65 66 75 6c | 20 61 73 20 69 73 2e 0a |g useful| as is..|
|000006a0| 58 20 2a 0a 58 20 2a 20 | 54 68 69 73 20 66 69 6c |X *.X * |This fil|
|000006b0| 65 20 69 6c 6c 75 73 74 | 72 61 74 65 73 20 68 6f |e illust|rates ho|
|000006c0| 77 20 74 6f 20 75 73 65 | 20 74 68 65 20 4a 50 45 |w to use| the JPE|
|000006d0| 47 20 63 6f 64 65 20 61 | 73 20 61 20 73 75 62 72 |G code a|s a subr|
|000006e0| 6f 75 74 69 6e 65 20 6c | 69 62 72 61 72 79 0a 58 |outine l|ibrary.X|
|000006f0| 20 2a 20 74 6f 20 72 65 | 61 64 20 6f 72 20 77 72 | * to re|ad or wr|
|00000700| 69 74 65 20 4a 50 45 47 | 20 69 6d 61 67 65 20 66 |ite JPEG| image f|
|00000710| 69 6c 65 73 2e 20 20 57 | 65 20 61 73 73 75 6d 65 |iles. W|e assume|
|00000720| 20 68 65 72 65 20 74 68 | 61 74 20 79 6f 75 20 61 | here th|at you a|
|00000730| 72 65 20 6e 6f 74 0a 58 | 20 2a 20 6d 65 72 65 6c |re not.X| * merel|
|00000740| 79 20 69 6e 74 65 72 65 | 73 74 65 64 20 69 6e 20 |y intere|sted in |
|00000750| 63 6f 6e 76 65 72 74 69 | 6e 67 20 74 68 65 20 69 |converti|ng the i|
|00000760| 6d 61 67 65 20 74 6f 20 | 79 65 74 20 61 6e 6f 74 |mage to |yet anot|
|00000770| 68 65 72 20 69 6d 61 67 | 65 20 66 69 6c 65 20 66 |her imag|e file f|
|00000780| 6f 72 6d 61 74 0a 58 20 | 2a 20 28 69 66 20 79 6f |ormat.X |* (if yo|
|00000790| 75 20 61 72 65 2c 20 79 | 6f 75 20 73 68 6f 75 6c |u are, y|ou shoul|
|000007a0| 64 20 62 65 20 61 64 64 | 69 6e 67 20 61 6e 6f 74 |d be add|ing anot|
|000007b0| 68 65 72 20 49 2f 4f 20 | 6d 6f 64 75 6c 65 20 74 |her I/O |module t|
|000007c0| 6f 20 63 6a 70 65 67 2f | 64 6a 70 65 67 2c 20 6e |o cjpeg/|djpeg, n|
|000007d0| 6f 74 0a 58 20 2a 20 63 | 6f 6e 73 74 72 75 63 74 |ot.X * c|onstruct|
|000007e0| 69 6e 67 20 61 20 6e 65 | 77 20 61 70 70 6c 69 63 |ing a ne|w applic|
|000007f0| 61 74 69 6f 6e 29 2e 20 | 20 49 6e 73 74 65 61 64 |ation). | Instead|
|00000800| 2c 20 77 65 20 73 68 6f | 77 20 68 6f 77 20 74 6f |, we sho|w how to|
|00000810| 20 70 61 73 73 20 74 68 | 65 0a 58 20 2a 20 64 65 | pass th|e.X * de|
|00000820| 63 6f 6d 70 72 65 73 73 | 65 64 20 69 6d 61 67 65 |compress|ed image|
|00000830| 20 64 61 74 61 20 69 6e | 74 6f 20 6f 72 20 6f 75 | data in|to or ou|
|00000840| 74 20 6f 66 20 72 6f 75 | 74 69 6e 65 73 20 74 68 |t of rou|tines th|
|00000850| 61 74 20 79 6f 75 20 70 | 72 6f 76 69 64 65 2e 20 |at you p|rovide. |
|00000860| 20 46 6f 72 0a 58 20 2a | 20 65 78 61 6d 70 6c 65 | For.X *| example|
|00000870| 2c 20 61 20 76 69 65 77 | 65 72 20 70 72 6f 67 72 |, a view|er progr|
|00000880| 61 6d 20 6d 69 67 68 74 | 20 75 73 65 20 74 68 65 |am might| use the|
|00000890| 20 4a 50 45 47 20 64 65 | 63 6f 6d 70 72 65 73 73 | JPEG de|compress|
|000008a0| 6f 72 20 74 6f 67 65 74 | 68 65 72 20 77 69 74 68 |or toget|her with|
|000008b0| 0a 58 20 2a 20 72 6f 75 | 74 69 6e 65 73 20 74 68 |.X * rou|tines th|
|000008c0| 61 74 20 77 72 69 74 65 | 20 74 68 65 20 64 65 63 |at write| the dec|
|000008d0| 6f 6d 70 72 65 73 73 65 | 64 20 69 6d 61 67 65 20 |ompresse|d image |
|000008e0| 64 69 72 65 63 74 6c 79 | 20 74 6f 20 61 20 64 69 |directly| to a di|
|000008f0| 73 70 6c 61 79 2e 0a 58 | 20 2a 0a 58 20 2a 20 57 |splay..X| *.X * W|
|00000900| 65 20 70 72 65 73 65 6e | 74 20 74 68 65 73 65 20 |e presen|t these |
|00000910| 72 6f 75 74 69 6e 65 73 | 20 69 6e 20 74 68 65 20 |routines| in the |
|00000920| 73 61 6d 65 20 63 6f 64 | 69 6e 67 20 73 74 79 6c |same cod|ing styl|
|00000930| 65 20 75 73 65 64 20 69 | 6e 20 74 68 65 20 4a 50 |e used i|n the JP|
|00000940| 45 47 20 63 6f 64 65 0a | 58 20 2a 20 28 41 4e 53 |EG code.|X * (ANS|
|00000950| 49 20 66 75 6e 63 74 69 | 6f 6e 20 64 65 66 69 6e |I functi|on defin|
|00000960| 69 74 69 6f 6e 73 2c 20 | 65 74 63 29 3b 20 62 75 |itions, |etc); bu|
|00000970| 74 20 79 6f 75 20 61 72 | 65 20 6f 66 20 63 6f 75 |t you ar|e of cou|
|00000980| 72 73 65 20 66 72 65 65 | 20 74 6f 20 63 6f 64 65 |rse free| to code|
|00000990| 20 79 6f 75 72 0a 58 20 | 2a 20 72 6f 75 74 69 6e | your.X |* routin|
|000009a0| 65 73 20 69 6e 20 61 20 | 64 69 66 66 65 72 65 6e |es in a |differen|
|000009b0| 74 20 73 74 79 6c 65 20 | 69 66 20 79 6f 75 20 70 |t style |if you p|
|000009c0| 72 65 66 65 72 2e 0a 58 | 20 2a 2f 0a 58 0a 58 2f |refer..X| */.X.X/|
|000009d0| 2a 0a 58 20 2a 20 49 6e | 63 6c 75 64 65 20 66 69 |*.X * In|clude fi|
|000009e0| 6c 65 20 66 6f 72 20 64 | 65 63 6c 61 72 69 6e 67 |le for d|eclaring|
|000009f0| 20 4a 50 45 47 20 64 61 | 74 61 20 73 74 72 75 63 | JPEG da|ta struc|
|00000a00| 74 75 72 65 73 2e 0a 58 | 20 2a 20 54 68 69 73 20 |tures..X| * This |
|00000a10| 66 69 6c 65 20 61 6c 73 | 6f 20 69 6e 63 6c 75 64 |file als|o includ|
|00000a20| 65 73 20 73 6f 6d 65 20 | 73 79 73 74 65 6d 20 68 |es some |system h|
|00000a30| 65 61 64 65 72 73 20 6c | 69 6b 65 20 3c 73 74 64 |eaders l|ike <std|
|00000a40| 69 6f 2e 68 3e 3b 0a 58 | 20 2a 20 69 66 20 79 6f |io.h>;.X| * if yo|
|00000a50| 75 20 70 72 65 66 65 72 | 2c 20 79 6f 75 20 63 61 |u prefer|, you ca|
|00000a60| 6e 20 69 6e 63 6c 75 64 | 65 20 22 6a 63 6f 6e 66 |n includ|e "jconf|
|00000a70| 69 67 2e 68 22 20 61 6e | 64 20 22 6a 70 65 67 64 |ig.h" an|d "jpegd|
|00000a80| 61 74 61 2e 68 22 20 69 | 6e 73 74 65 61 64 2e 0a |ata.h" i|nstead..|
|00000a90| 58 20 2a 2f 0a 58 0a 58 | 23 69 6e 63 6c 75 64 65 |X */.X.X|#include|
|00000aa0| 20 22 6a 69 6e 63 6c 75 | 64 65 2e 68 22 0a 58 0a | "jinclu|de.h".X.|
|00000ab0| 58 2f 2a 0a 58 20 2a 20 | 3c 73 65 74 6a 6d 70 2e |X/*.X * |<setjmp.|
|00000ac0| 68 3e 20 69 73 20 75 73 | 65 64 20 66 6f 72 20 74 |h> is us|ed for t|
|00000ad0| 68 65 20 6f 70 74 69 6f | 6e 61 6c 20 65 72 72 6f |he optio|nal erro|
|00000ae0| 72 20 72 65 63 6f 76 65 | 72 79 20 6d 65 63 68 61 |r recove|ry mecha|
|00000af0| 6e 69 73 6d 20 73 68 6f | 77 6e 20 69 6e 0a 58 20 |nism sho|wn in.X |
|00000b00| 2a 20 74 68 65 20 73 65 | 63 6f 6e 64 20 70 61 72 |* the se|cond par|
|00000b10| 74 20 6f 66 20 74 68 65 | 20 65 78 61 6d 70 6c 65 |t of the| example|
|00000b20| 2e 0a 58 20 2a 2f 0a 58 | 0a 58 23 69 6e 63 6c 75 |..X */.X|.X#inclu|
|00000b30| 64 65 20 3c 73 65 74 6a | 6d 70 2e 68 3e 0a 58 0a |de <setj|mp.h>.X.|
|00000b40| 58 0a 58 0a 58 2f 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |X.X.X/**|********|
|00000b50| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 20 4a 50 45 47 20 |********|** JPEG |
|00000b60| 43 4f 4d 50 52 45 53 53 | 49 4f 4e 20 53 41 4d 50 |COMPRESS|ION SAMP|
|00000b70| 4c 45 20 49 4e 54 45 52 | 46 41 43 45 20 2a 2a 2a |LE INTER|FACE ***|
|00000b80| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00000b90| 2f 0a 58 0a 58 2f 2a 20 | 54 68 69 73 20 68 61 6c |/.X.X/* |This hal|
|00000ba0| 66 20 6f 66 20 74 68 65 | 20 65 78 61 6d 70 6c 65 |f of the| example|
|00000bb0| 20 73 68 6f 77 73 20 68 | 6f 77 20 74 6f 20 66 65 | shows h|ow to fe|
|00000bc0| 65 64 20 64 61 74 61 20 | 69 6e 74 6f 20 74 68 65 |ed data |into the|
|00000bd0| 20 4a 50 45 47 20 63 6f | 6d 70 72 65 73 73 6f 72 | JPEG co|mpressor|
|00000be0| 2e 0a 58 20 2a 20 57 65 | 20 70 72 65 73 65 6e 74 |..X * We| present|
|00000bf0| 20 61 20 6d 69 6e 69 6d | 61 6c 20 76 65 72 73 69 | a minim|al versi|
|00000c00| 6f 6e 20 74 68 61 74 20 | 64 6f 65 73 20 6e 6f 74 |on that |does not|
|00000c10| 20 77 6f 72 72 79 20 61 | 62 6f 75 74 20 72 65 66 | worry a|bout ref|
|00000c20| 69 6e 65 6d 65 6e 74 73 | 20 73 75 63 68 0a 58 20 |inements| such.X |
|00000c30| 2a 20 61 73 20 65 72 72 | 6f 72 20 72 65 63 6f 76 |* as err|or recov|
|00000c40| 65 72 79 20 28 74 68 65 | 20 4a 50 45 47 20 63 6f |ery (the| JPEG co|
|00000c50| 64 65 20 77 69 6c 6c 20 | 6a 75 73 74 20 65 78 69 |de will |just exi|
|00000c60| 74 28 29 20 69 66 20 69 | 74 20 67 65 74 73 20 61 |t() if i|t gets a|
|00000c70| 6e 20 65 72 72 6f 72 29 | 2e 0a 58 20 2a 2f 0a 58 |n error)|..X */.X|
|00000c80| 0a 58 0a 58 2f 2a 0a 58 | 20 2a 20 54 6f 20 73 75 |.X.X/*.X| * To su|
|00000c90| 70 70 6c 79 20 74 68 65 | 20 69 6d 61 67 65 20 64 |pply the| image d|
|00000ca0| 61 74 61 20 66 6f 72 20 | 63 6f 6d 70 72 65 73 73 |ata for |compress|
|00000cb0| 69 6f 6e 2c 20 79 6f 75 | 20 6d 75 73 74 20 64 65 |ion, you| must de|
|00000cc0| 66 69 6e 65 20 74 68 72 | 65 65 20 72 6f 75 74 69 |fine thr|ee routi|
|00000cd0| 6e 65 73 0a 58 20 2a 20 | 69 6e 70 75 74 5f 69 6e |nes.X * |input_in|
|00000ce0| 69 74 2c 20 67 65 74 5f | 69 6e 70 75 74 5f 72 6f |it, get_|input_ro|
|00000cf0| 77 2c 20 61 6e 64 20 69 | 6e 70 75 74 5f 74 65 72 |w, and i|nput_ter|
|00000d00| 6d 2e 20 20 54 68 65 73 | 65 20 72 6f 75 74 69 6e |m. Thes|e routin|
|00000d10| 65 73 20 77 69 6c 6c 20 | 62 65 20 63 61 6c 6c 65 |es will |be calle|
|00000d20| 64 0a 58 20 2a 20 66 72 | 6f 6d 20 74 68 65 20 4a |d.X * fr|om the J|
|00000d30| 50 45 47 20 63 6f 6d 70 | 72 65 73 73 6f 72 20 76 |PEG comp|ressor v|
|00000d40| 69 61 20 66 75 6e 63 74 | 69 6f 6e 20 70 6f 69 6e |ia funct|ion poin|
|00000d50| 74 65 72 20 76 61 6c 75 | 65 73 20 74 68 61 74 20 |ter valu|es that |
|00000d60| 79 6f 75 20 73 74 6f 72 | 65 20 69 6e 20 74 68 65 |you stor|e in the|
|00000d70| 0a 58 20 2a 20 63 69 6e | 66 6f 20 64 61 74 61 20 |.X * cin|fo data |
|00000d80| 73 74 72 75 63 74 75 72 | 65 3b 20 68 65 6e 63 65 |structur|e; hence|
|00000d90| 20 74 68 65 79 20 6e 65 | 65 64 20 6e 6f 74 20 62 | they ne|ed not b|
|00000da0| 65 20 67 6c 6f 62 61 6c | 6c 79 20 76 69 73 69 62 |e global|ly visib|
|00000db0| 6c 65 20 61 6e 64 20 74 | 68 65 20 65 78 61 63 74 |le and t|he exact|
|00000dc0| 0a 58 20 2a 20 6e 61 6d | 65 73 20 64 6f 6e 27 74 |.X * nam|es don't|
|00000dd0| 20 6d 61 74 74 65 72 2e | 20 20 28 49 6e 20 66 61 | matter.| (In fa|
|00000de0| 63 74 2c 20 74 68 65 20 | 22 4d 45 54 48 4f 44 44 |ct, the |"METHODD|
|00000df0| 45 46 22 20 6d 61 63 72 | 6f 20 65 78 70 61 6e 64 |EF" macr|o expand|
|00000e00| 73 20 74 6f 20 22 73 74 | 61 74 69 63 22 20 69 66 |s to "st|atic" if|
|00000e10| 0a 58 20 2a 20 79 6f 75 | 20 75 73 65 20 74 68 65 |.X * you| use the|
|00000e20| 20 75 6e 6d 6f 64 69 66 | 69 65 64 20 4a 50 45 47 | unmodif|ied JPEG|
|00000e30| 20 69 6e 63 6c 75 64 65 | 20 66 69 6c 65 73 2e 29 | include| files.)|
|00000e40| 0a 58 20 2a 0a 58 20 2a | 20 54 68 65 20 69 6e 70 |.X *.X *| The inp|
|00000e50| 75 74 20 66 69 6c 65 20 | 72 65 61 64 69 6e 67 20 |ut file |reading |
|00000e60| 6d 6f 64 75 6c 65 73 20 | 28 6a 72 64 70 70 6d 2e |modules |(jrdppm.|
|00000e70| 63 2c 20 6a 72 64 67 69 | 66 2e 63 2c 20 6a 72 64 |c, jrdgi|f.c, jrd|
|00000e80| 74 61 72 67 61 2e 63 2c | 20 65 74 63 29 20 6d 61 |targa.c,| etc) ma|
|00000e90| 79 20 62 65 0a 58 20 2a | 20 75 73 65 66 75 6c 20 |y be.X *| useful |
|00000ea0| 65 78 61 6d 70 6c 65 73 | 20 6f 66 20 77 68 61 74 |examples| of what|
|00000eb0| 20 74 68 65 73 65 20 72 | 6f 75 74 69 6e 65 73 20 | these r|outines |
|00000ec0| 73 68 6f 75 6c 64 20 61 | 63 74 75 61 6c 6c 79 20 |should a|ctually |
|00000ed0| 64 6f 2c 20 61 6c 74 68 | 6f 75 67 68 20 65 61 63 |do, alth|ough eac|
|00000ee0| 68 20 6f 66 0a 58 20 2a | 20 74 68 65 6d 20 69 73 |h of.X *| them is|
|00000ef0| 20 65 6e 63 72 75 73 74 | 65 64 20 77 69 74 68 20 | encrust|ed with |
|00000f00| 61 20 6c 6f 74 20 6f 66 | 20 73 70 65 63 69 61 6c |a lot of| special|
|00000f10| 69 7a 65 64 20 63 6f 64 | 65 20 66 6f 72 20 69 74 |ized cod|e for it|
|00000f20| 73 20 6f 77 6e 20 66 69 | 6c 65 20 66 6f 72 6d 61 |s own fi|le forma|
|00000f30| 74 2e 0a 58 20 2a 2f 0a | 58 0a 58 0a 58 4d 45 54 |t..X */.|X.X.XMET|
|00000f40| 48 4f 44 44 45 46 20 76 | 6f 69 64 0a 58 69 6e 70 |HODDEF v|oid.Xinp|
|00000f50| 75 74 5f 69 6e 69 74 20 | 28 63 6f 6d 70 72 65 73 |ut_init |(compres|
|00000f60| 73 5f 69 6e 66 6f 5f 70 | 74 72 20 63 69 6e 66 6f |s_info_p|tr cinfo|
|00000f70| 29 0a 58 2f 2a 20 49 6e | 69 74 69 61 6c 69 7a 65 |).X/* In|itialize|
|00000f80| 20 66 6f 72 20 69 6e 70 | 75 74 3b 20 72 65 74 75 | for inp|ut; retu|
|00000f90| 72 6e 20 69 6d 61 67 65 | 20 73 69 7a 65 20 61 6e |rn image| size an|
|00000fa0| 64 20 63 6f 6d 70 6f 6e | 65 6e 74 20 64 61 74 61 |d compon|ent data|
|00000fb0| 2e 20 2a 2f 0a 58 7b 0a | 58 20 20 2f 2a 20 54 68 |. */.X{.|X /* Th|
|00000fc0| 69 73 20 72 6f 75 74 69 | 6e 65 20 6d 75 73 74 20 |is routi|ne must |
|00000fd0| 72 65 74 75 72 6e 20 66 | 69 76 65 20 70 69 65 63 |return f|ive piec|
|00000fe0| 65 73 20 6f 66 20 69 6e | 66 6f 72 6d 61 74 69 6f |es of in|formatio|
|00000ff0| 6e 20 61 62 6f 75 74 20 | 74 68 65 20 69 6e 63 6f |n about |the inco|
|00001000| 6d 69 6e 67 0a 58 20 20 | 20 2a 20 69 6d 61 67 65 |ming.X | * image|
|00001010| 2c 20 61 6e 64 20 6d 75 | 73 74 20 64 6f 20 61 6e |, and mu|st do an|
|00001020| 79 20 73 65 74 75 70 20 | 6e 65 65 64 65 64 20 66 |y setup |needed f|
|00001030| 6f 72 20 74 68 65 20 67 | 65 74 5f 69 6e 70 75 74 |or the g|et_input|
|00001040| 5f 72 6f 77 20 72 6f 75 | 74 69 6e 65 2e 0a 58 20 |_row rou|tine..X |
|00001050| 20 20 2a 20 54 68 65 20 | 69 6d 61 67 65 20 69 6e | * The |image in|
|00001060| 66 6f 72 6d 61 74 69 6f | 6e 20 69 73 20 72 65 74 |formatio|n is ret|
|00001070| 75 72 6e 65 64 20 69 6e | 20 66 69 65 6c 64 73 20 |urned in| fields |
|00001080| 6f 66 20 74 68 65 20 63 | 69 6e 66 6f 20 73 74 72 |of the c|info str|
|00001090| 75 63 74 2e 0a 58 20 20 | 20 2a 20 28 49 66 20 79 |uct..X | * (If y|
|000010a0| 6f 75 20 64 6f 6e 27 74 | 20 63 61 72 65 20 61 62 |ou don't| care ab|
|000010b0| 6f 75 74 20 6d 6f 64 75 | 6c 61 72 69 74 79 2c 20 |out modu|larity, |
|000010c0| 79 6f 75 20 63 6f 75 6c | 64 20 69 6e 69 74 69 61 |you coul|d initia|
|000010d0| 6c 69 7a 65 20 74 68 65 | 73 65 20 66 69 65 6c 64 |lize the|se field|
|000010e0| 73 0a 58 20 20 20 2a 20 | 69 6e 20 74 68 65 20 6d |s.X * |in the m|
|000010f0| 61 69 6e 20 4a 50 45 47 | 20 63 61 6c 6c 69 6e 67 |ain JPEG| calling|
|00001100| 20 72 6f 75 74 69 6e 65 | 2c 20 61 6e 64 20 6d 61 | routine|, and ma|
|00001110| 6b 65 20 74 68 69 73 20 | 72 6f 75 74 69 6e 65 20 |ke this |routine |
|00001120| 62 65 20 61 20 6e 6f 2d | 6f 70 2e 29 0a 58 20 20 |be a no-|op.).X |
|00001130| 20 2a 20 57 65 20 73 68 | 6f 77 20 73 6f 6d 65 20 | * We sh|ow some |
|00001140| 65 78 61 6d 70 6c 65 20 | 76 61 6c 75 65 73 20 68 |example |values h|
|00001150| 65 72 65 2e 0a 58 20 20 | 20 2a 2f 0a 58 20 20 63 |ere..X | */.X c|
|00001160| 69 6e 66 6f 2d 3e 69 6d | 61 67 65 5f 77 69 64 74 |info->im|age_widt|
|00001170| 68 20 3d 20 36 34 30 3b | 09 09 2f 2a 20 77 69 64 |h = 640;|../* wid|
|00001180| 74 68 20 69 6e 20 70 69 | 78 65 6c 73 20 2a 2f 0a |th in pi|xels */.|
|00001190| 58 20 20 63 69 6e 66 6f | 2d 3e 69 6d 61 67 65 5f |X cinfo|->image_|
|000011a0| 68 65 69 67 68 74 20 3d | 20 34 38 30 3b 09 09 2f |height =| 480;../|
|000011b0| 2a 20 68 65 69 67 68 74 | 20 69 6e 20 70 69 78 65 |* height| in pixe|
|000011c0| 6c 73 20 2a 2f 0a 58 20 | 20 2f 2a 20 4a 50 45 47 |ls */.X | /* JPEG|
|000011d0| 20 76 69 65 77 73 20 61 | 6e 20 69 6d 61 67 65 20 | views a|n image |
|000011e0| 61 73 20 62 65 69 6e 67 | 20 61 20 72 65 63 74 61 |as being| a recta|
|000011f0| 6e 67 75 6c 61 72 20 61 | 72 72 61 79 20 6f 66 20 |ngular a|rray of |
|00001200| 70 69 78 65 6c 73 2c 20 | 77 69 74 68 20 65 61 63 |pixels, |with eac|
|00001210| 68 0a 58 20 20 20 2a 20 | 70 69 78 65 6c 20 68 61 |h.X * |pixel ha|
|00001220| 76 69 6e 67 20 74 68 65 | 20 73 61 6d 65 20 6e 75 |ving the| same nu|
|00001230| 6d 62 65 72 20 6f 66 20 | 22 63 6f 6d 70 6f 6e 65 |mber of |"compone|
|00001240| 6e 74 22 20 76 61 6c 75 | 65 73 20 28 63 6f 6c 6f |nt" valu|es (colo|
|00001250| 72 20 63 68 61 6e 6e 65 | 6c 73 29 2e 0a 58 20 20 |r channe|ls)..X |
|00001260| 20 2a 20 59 6f 75 20 6d | 75 73 74 20 73 70 65 63 | * You m|ust spec|
|00001270| 69 66 79 20 68 6f 77 20 | 6d 61 6e 79 20 63 6f 6d |ify how |many com|
|00001280| 70 6f 6e 65 6e 74 73 20 | 74 68 65 72 65 20 61 72 |ponents |there ar|
|00001290| 65 20 61 6e 64 20 74 68 | 65 20 63 6f 6c 6f 72 73 |e and th|e colors|
|000012a0| 70 61 63 65 0a 58 20 20 | 20 2a 20 69 6e 74 65 72 |pace.X | * inter|
|000012b0| 70 72 65 74 61 74 69 6f | 6e 20 6f 66 20 74 68 65 |pretatio|n of the|
|000012c0| 20 63 6f 6d 70 6f 6e 65 | 6e 74 73 2e 20 20 4d 6f | compone|nts. Mo|
|000012d0| 73 74 20 61 70 70 6c 69 | 63 61 74 69 6f 6e 73 20 |st appli|cations |
|000012e0| 77 69 6c 6c 20 75 73 65 | 20 52 47 42 20 64 61 74 |will use| RGB dat|
|000012f0| 61 20 6f 72 0a 58 20 20 | 20 2a 20 67 72 61 79 73 |a or.X | * grays|
|00001300| 63 61 6c 65 20 64 61 74 | 61 2e 20 20 49 66 20 79 |cale dat|a. If y|
|00001310| 6f 75 20 77 61 6e 74 20 | 74 6f 20 75 73 65 20 73 |ou want |to use s|
|00001320| 6f 6d 65 74 68 69 6e 67 | 20 65 6c 73 65 2c 20 79 |omething| else, y|
|00001330| 6f 75 27 6c 6c 20 6e 65 | 65 64 20 74 6f 20 73 74 |ou'll ne|ed to st|
|00001340| 75 64 79 0a 58 20 20 20 | 2a 20 61 6e 64 20 70 65 |udy.X |* and pe|
|00001350| 72 68 61 70 73 20 6d 6f | 64 69 66 79 20 6a 63 64 |rhaps mo|dify jcd|
|00001360| 65 66 6c 74 73 2e 63 2c | 20 6a 63 63 6f 6c 6f 72 |eflts.c,| jccolor|
|00001370| 2e 63 2c 20 61 6e 64 20 | 6a 64 63 6f 6c 6f 72 2e |.c, and |jdcolor.|
|00001380| 63 2e 0a 58 20 20 20 2a | 2f 0a 58 20 20 63 69 6e |c..X *|/.X cin|
|00001390| 66 6f 2d 3e 69 6e 70 75 | 74 5f 63 6f 6d 70 6f 6e |fo->inpu|t_compon|
|000013a0| 65 6e 74 73 20 3d 20 33 | 3b 09 09 2f 2a 20 6f 72 |ents = 3|;../* or|
|000013b0| 20 31 20 66 6f 72 20 67 | 72 61 79 73 63 61 6c 65 | 1 for g|rayscale|
|000013c0| 20 2a 2f 0a 58 20 20 63 | 69 6e 66 6f 2d 3e 69 6e | */.X c|info->in|
|000013d0| 5f 63 6f 6c 6f 72 5f 73 | 70 61 63 65 20 3d 20 43 |_color_s|pace = C|
|000013e0| 53 5f 52 47 42 3b 09 2f | 2a 20 6f 72 20 43 53 5f |S_RGB;./|* or CS_|
|000013f0| 47 52 41 59 53 43 41 4c | 45 20 66 6f 72 20 67 72 |GRAYSCAL|E for gr|
|00001400| 61 79 73 63 61 6c 65 20 | 2a 2f 0a 58 20 20 63 69 |ayscale |*/.X ci|
|00001410| 6e 66 6f 2d 3e 64 61 74 | 61 5f 70 72 65 63 69 73 |nfo->dat|a_precis|
|00001420| 69 6f 6e 20 3d 20 38 3b | 09 09 2f 2a 20 62 69 74 |ion = 8;|../* bit|
|00001430| 73 20 70 65 72 20 70 69 | 78 65 6c 20 63 6f 6d 70 |s per pi|xel comp|
|00001440| 6f 6e 65 6e 74 20 76 61 | 6c 75 65 20 2a 2f 0a 58 |onent va|lue */.X|
|00001450| 20 20 2f 2a 20 49 6e 20 | 74 68 65 20 63 75 72 72 | /* In |the curr|
|00001460| 65 6e 74 20 4a 50 45 47 | 20 73 6f 66 74 77 61 72 |ent JPEG| softwar|
|00001470| 65 2c 20 64 61 74 61 5f | 70 72 65 63 69 73 69 6f |e, data_|precisio|
|00001480| 6e 20 6d 75 73 74 20 62 | 65 20 73 65 74 20 65 71 |n must b|e set eq|
|00001490| 75 61 6c 20 74 6f 0a 58 | 20 20 20 2a 20 42 49 54 |ual to.X| * BIT|
|000014a0| 53 5f 49 4e 5f 4a 53 41 | 4d 50 4c 45 2c 20 77 68 |S_IN_JSA|MPLE, wh|
|000014b0| 69 63 68 20 69 73 20 38 | 20 75 6e 6c 65 73 73 20 |ich is 8| unless |
|000014c0| 79 6f 75 20 74 77 69 64 | 64 6c 65 20 6a 63 6f 6e |you twid|dle jcon|
|000014d0| 66 69 67 2e 68 2e 20 20 | 46 75 74 75 72 65 0a 58 |fig.h. |Future.X|
|000014e0| 20 20 20 2a 20 76 65 72 | 73 69 6f 6e 73 20 6d 69 | * ver|sions mi|
|000014f0| 67 68 74 20 61 6c 6c 6f | 77 20 79 6f 75 20 74 6f |ght allo|w you to|
|00001500| 20 73 61 79 20 65 69 74 | 68 65 72 20 38 20 6f 72 | say eit|her 8 or|
|00001510| 20 31 32 20 69 66 20 63 | 6f 6d 70 69 6c 65 64 20 | 12 if c|ompiled |
|00001520| 77 69 74 68 0a 58 20 20 | 20 2a 20 31 32 2d 62 69 |with.X | * 12-bi|
|00001530| 74 20 4a 53 41 4d 50 4c | 45 73 2c 20 6f 72 20 75 |t JSAMPL|Es, or u|
|00001540| 70 20 74 6f 20 31 36 20 | 69 6e 20 6c 6f 73 73 6c |p to 16 |in lossl|
|00001550| 65 73 73 20 6d 6f 64 65 | 2e 20 20 49 6e 20 61 6e |ess mode|. In an|
|00001560| 79 20 63 61 73 65 2c 0a | 58 20 20 20 2a 20 69 74 |y case,.|X * it|
|00001570| 20 69 73 20 75 70 20 74 | 6f 20 79 6f 75 20 74 6f | is up t|o you to|
|00001580| 20 73 63 61 6c 65 20 69 | 6e 63 6f 6d 69 6e 67 20 | scale i|ncoming |
|00001590| 70 69 78 65 6c 20 76 61 | 6c 75 65 73 20 74 6f 20 |pixel va|lues to |
|000015a0| 74 68 65 20 72 61 6e 67 | 65 0a 58 20 20 20 2a 20 |the rang|e.X * |
|000015b0| 20 20 30 20 2e 2e 20 28 | 31 3c 3c 64 61 74 61 5f | 0 .. (|1<<data_|
|000015c0| 70 72 65 63 69 73 69 6f | 6e 29 2d 31 2e 0a 58 20 |precisio|n)-1..X |
|000015d0| 20 20 2a 20 49 66 20 79 | 6f 75 72 20 69 6d 61 67 | * If y|our imag|
|000015e0| 65 20 64 61 74 61 20 66 | 6f 72 6d 61 74 20 69 73 |e data f|ormat is|
|000015f0| 20 66 69 78 65 64 20 61 | 74 20 61 20 62 79 74 65 | fixed a|t a byte|
|00001600| 20 70 65 72 20 63 6f 6d | 70 6f 6e 65 6e 74 2c 0a | per com|ponent,.|
|00001610| 58 20 20 20 2a 20 74 68 | 65 6e 20 73 61 79 69 6e |X * th|en sayin|
|00001620| 67 20 22 38 22 20 69 73 | 20 70 72 6f 62 61 62 6c |g "8" is| probabl|
|00001630| 79 20 74 68 65 20 62 65 | 73 74 20 6c 6f 6e 67 2d |y the be|st long-|
|00001640| 74 65 72 6d 20 73 6f 6c | 75 74 69 6f 6e 2e 0a 58 |term sol|ution..X|
|00001650| 20 20 20 2a 2f 0a 58 7d | 0a 58 0a 58 0a 58 2f 2a | */.X}|.X.X.X/*|
|00001660| 0a 58 20 2a 20 54 68 69 | 73 20 66 75 6e 63 74 69 |.X * Thi|s functi|
|00001670| 6f 6e 20 69 73 20 63 61 | 6c 6c 65 64 20 72 65 70 |on is ca|lled rep|
|00001680| 65 61 74 65 64 6c 79 20 | 61 6e 64 20 6d 75 73 74 |eatedly |and must|
|00001690| 20 73 75 70 70 6c 79 20 | 74 68 65 20 6e 65 78 74 | supply |the next|
|000016a0| 20 72 6f 77 20 6f 66 20 | 70 69 78 65 6c 73 0a 58 | row of |pixels.X|
|000016b0| 20 2a 20 6f 6e 20 65 61 | 63 68 20 63 61 6c 6c 2e | * on ea|ch call.|
|000016c0| 20 20 54 68 65 20 72 6f | 77 73 20 4d 55 53 54 20 | The ro|ws MUST |
|000016d0| 62 65 20 72 65 74 75 72 | 6e 65 64 20 69 6e 20 74 |be retur|ned in t|
|000016e0| 6f 70 2d 74 6f 2d 62 6f | 74 74 6f 6d 20 6f 72 64 |op-to-bo|ttom ord|
|000016f0| 65 72 20 69 66 20 79 6f | 75 20 77 61 6e 74 0a 58 |er if yo|u want.X|
|00001700| 20 2a 20 79 6f 75 72 20 | 4a 50 45 47 20 66 69 6c | * your |JPEG fil|
|00001710| 65 73 20 74 6f 20 62 65 | 20 63 6f 6d 70 61 74 69 |es to be| compati|
|00001720| 62 6c 65 20 77 69 74 68 | 20 65 76 65 72 79 6f 6e |ble with| everyon|
|00001730| 65 20 65 6c 73 65 27 73 | 2e 20 20 28 49 66 20 79 |e else's|. (If y|
|00001740| 6f 75 20 63 61 6e 6e 6f | 74 0a 58 20 2a 20 72 65 |ou canno|t.X * re|
|00001750| 61 64 69 6c 79 20 72 65 | 61 64 20 79 6f 75 72 20 |adily re|ad your |
|00001760| 64 61 74 61 20 69 6e 20 | 74 68 61 74 20 6f 72 64 |data in |that ord|
|00001770| 65 72 2c 20 79 6f 75 27 | 6c 6c 20 6e 65 65 64 20 |er, you'|ll need |
|00001780| 61 6e 20 69 6e 74 65 72 | 6d 65 64 69 61 74 65 20 |an inter|mediate |
|00001790| 61 72 72 61 79 20 74 6f | 0a 58 20 2a 20 68 6f 6c |array to|.X * hol|
|000017a0| 64 20 74 68 65 20 69 6d | 61 67 65 2e 20 20 53 65 |d the im|age. Se|
|000017b0| 65 20 6a 72 64 74 61 72 | 67 61 2e 63 20 6f 72 20 |e jrdtar|ga.c or |
|000017c0| 6a 72 64 72 6c 65 2e 63 | 20 66 6f 72 20 65 78 61 |jrdrle.c| for exa|
|000017d0| 6d 70 6c 65 73 20 6f 66 | 20 68 61 6e 64 6c 69 6e |mples of| handlin|
|000017e0| 67 0a 58 20 2a 20 62 6f | 74 74 6f 6d 2d 74 6f 2d |g.X * bo|ttom-to-|
|000017f0| 74 6f 70 20 73 6f 75 72 | 63 65 20 64 61 74 61 20 |top sour|ce data |
|00001800| 75 73 69 6e 67 20 74 68 | 65 20 4a 50 45 47 20 63 |using th|e JPEG c|
|00001810| 6f 64 65 27 73 20 70 6f | 72 74 61 62 6c 65 20 6d |ode's po|rtable m|
|00001820| 65 63 68 61 6e 69 73 6d | 73 2e 29 0a 58 20 2a 20 |echanism|s.).X * |
|00001830| 54 68 65 20 64 61 74 61 | 20 69 73 20 74 6f 20 62 |The data| is to b|
|00001840| 65 20 72 65 74 75 72 6e | 65 64 20 69 6e 74 6f 20 |e return|ed into |
|00001850| 61 20 32 2d 44 20 61 72 | 72 61 79 20 6f 66 20 4a |a 2-D ar|ray of J|
|00001860| 53 41 4d 50 4c 45 73 2c | 20 69 6e 64 65 78 65 64 |SAMPLEs,| indexed|
|00001870| 20 61 73 0a 58 20 2a 09 | 09 4a 53 41 4d 50 4c 45 | as.X *.|.JSAMPLE|
|00001880| 20 70 69 78 65 6c 5f 72 | 6f 77 5b 63 6f 6d 70 6f | pixel_r|ow[compo|
|00001890| 6e 65 6e 74 5d 5b 63 6f | 6c 75 6d 6e 5d 0a 58 20 |nent][co|lumn].X |
|000018a0| 2a 20 77 68 65 72 65 20 | 63 6f 6d 70 6f 6e 65 6e |* where |componen|
|000018b0| 74 20 72 75 6e 73 20 66 | 72 6f 6d 20 30 20 74 6f |t runs f|rom 0 to|
|000018c0| 20 63 69 6e 66 6f 2d 3e | 69 6e 70 75 74 5f 63 6f | cinfo->|input_co|
|000018d0| 6d 70 6f 6e 65 6e 74 73 | 2d 31 2c 20 61 6e 64 20 |mponents|-1, and |
|000018e0| 63 6f 6c 75 6d 6e 20 72 | 75 6e 73 0a 58 20 2a 20 |column r|uns.X * |
|000018f0| 66 72 6f 6d 20 30 20 74 | 6f 20 63 69 6e 66 6f 2d |from 0 t|o cinfo-|
|00001900| 3e 69 6d 61 67 65 5f 77 | 69 64 74 68 2d 31 20 28 |>image_w|idth-1 (|
|00001910| 63 6f 6c 75 6d 6e 20 30 | 20 69 73 20 6c 65 66 74 |column 0| is left|
|00001920| 20 65 64 67 65 20 6f 66 | 20 69 6d 61 67 65 29 2e | edge of| image).|
|00001930| 20 20 4e 6f 74 65 20 74 | 68 61 74 0a 58 20 2a 20 | Note t|hat.X * |
|00001940| 74 68 69 73 20 69 73 20 | 61 63 74 75 61 6c 6c 79 |this is |actually|
|00001950| 20 61 6e 20 61 72 72 61 | 79 20 6f 66 20 70 6f 69 | an arra|y of poi|
|00001960| 6e 74 65 72 73 20 74 6f | 20 61 72 72 61 79 73 20 |nters to| arrays |
|00001970| 72 61 74 68 65 72 20 74 | 68 61 6e 20 61 20 74 72 |rather t|han a tr|
|00001980| 75 65 20 32 44 20 61 72 | 72 61 79 2c 0a 58 20 2a |ue 2D ar|ray,.X *|
|00001990| 20 73 69 6e 63 65 20 43 | 20 64 6f 65 73 20 6e 6f | since C| does no|
|000019a0| 74 20 73 75 70 70 6f 72 | 74 20 76 61 72 69 61 62 |t suppor|t variab|
|000019b0| 6c 65 2d 73 69 7a 65 20 | 6d 75 6c 74 69 64 69 6d |le-size |multidim|
|000019c0| 65 6e 73 69 6f 6e 61 6c | 20 61 72 72 61 79 73 2e |ensional| arrays.|
|000019d0| 0a 58 20 2a 20 4a 53 41 | 4d 50 4c 45 20 69 73 20 |.X * JSA|MPLE is |
|000019e0| 74 79 70 69 63 61 6c 6c | 79 20 74 79 70 65 64 65 |typicall|y typede|
|000019f0| 66 27 64 20 61 73 20 22 | 75 6e 73 69 67 6e 65 64 |f'd as "|unsigned|
|00001a00| 20 63 68 61 72 22 2e 0a | 58 20 2a 2f 0a 58 0a 58 | char"..|X */.X.X|
|00001a10| 0a 58 4d 45 54 48 4f 44 | 44 45 46 20 76 6f 69 64 |.XMETHOD|DEF void|
|00001a20| 0a 58 67 65 74 5f 69 6e | 70 75 74 5f 72 6f 77 20 |.Xget_in|put_row |
|00001a30| 28 63 6f 6d 70 72 65 73 | 73 5f 69 6e 66 6f 5f 70 |(compres|s_info_p|
|00001a40| 74 72 20 63 69 6e 66 6f | 2c 20 4a 53 41 4d 50 41 |tr cinfo|, JSAMPA|
|00001a50| 52 52 41 59 20 70 69 78 | 65 6c 5f 72 6f 77 29 0a |RRAY pix|el_row).|
|00001a60| 58 2f 2a 20 52 65 61 64 | 20 6e 65 78 74 20 72 6f |X/* Read| next ro|
|00001a70| 77 20 6f 66 20 70 69 78 | 65 6c 73 20 69 6e 74 6f |w of pix|els into|
|00001a80| 20 70 69 78 65 6c 5f 72 | 6f 77 5b 5d 5b 5d 20 2a | pixel_r|ow[][] *|
|00001a90| 2f 0a 58 7b 0a 58 20 20 | 2f 2a 20 54 68 69 73 20 |/.X{.X |/* This |
|00001aa0| 65 78 61 6d 70 6c 65 20 | 73 68 6f 77 73 20 68 6f |example |shows ho|
|00001ab0| 77 20 79 6f 75 20 6d 69 | 67 68 74 20 72 65 61 64 |w you mi|ght read|
|00001ac0| 20 52 47 42 20 64 61 74 | 61 20 28 33 20 63 6f 6d | RGB dat|a (3 com|
|00001ad0| 70 6f 6e 65 6e 74 73 29 | 0a 58 20 20 20 2a 20 66 |ponents)|.X * f|
|00001ae0| 72 6f 6d 20 61 6e 20 69 | 6e 70 75 74 20 66 69 6c |rom an i|nput fil|
|00001af0| 65 20 69 6e 20 77 68 69 | 63 68 20 74 68 65 20 64 |e in whi|ch the d|
|00001b00| 61 74 61 20 69 73 20 73 | 74 6f 72 65 64 20 33 20 |ata is s|tored 3 |
|00001b10| 62 79 74 65 73 20 70 65 | 72 20 70 69 78 65 6c 0a |bytes pe|r pixel.|
|00001b20| 58 20 20 20 2a 20 69 6e | 20 6c 65 66 74 2d 74 6f |X * in| left-to|
|00001b30| 2d 72 69 67 68 74 2c 20 | 74 6f 70 2d 74 6f 2d 62 |-right, |top-to-b|
|00001b40| 6f 74 74 6f 6d 20 6f 72 | 64 65 72 2e 0a 58 20 20 |ottom or|der..X |
|00001b50| 20 2a 2f 0a 58 20 20 72 | 65 67 69 73 74 65 72 20 | */.X r|egister |
|00001b60| 46 49 4c 45 20 2a 20 69 | 6e 66 69 6c 65 20 3d 20 |FILE * i|nfile = |
|00001b70| 63 69 6e 66 6f 2d 3e 69 | 6e 70 75 74 5f 66 69 6c |cinfo->i|nput_fil|
|00001b80| 65 3b 0a 58 20 20 72 65 | 67 69 73 74 65 72 20 4a |e;.X re|gister J|
|00001b90| 53 41 4d 50 52 4f 57 20 | 70 74 72 30 2c 20 70 74 |SAMPROW |ptr0, pt|
|00001ba0| 72 31 2c 20 70 74 72 32 | 3b 0a 58 20 20 72 65 67 |r1, ptr2|;.X reg|
|00001bb0| 69 73 74 65 72 20 6c 6f | 6e 67 20 63 6f 6c 3b 0a |ister lo|ng col;.|
|00001bc0| 58 20 20 0a 58 20 20 70 | 74 72 30 20 3d 20 70 69 |X .X p|tr0 = pi|
|00001bd0| 78 65 6c 5f 72 6f 77 5b | 30 5d 3b 0a 58 20 20 70 |xel_row[|0];.X p|
|00001be0| 74 72 31 20 3d 20 70 69 | 78 65 6c 5f 72 6f 77 5b |tr1 = pi|xel_row[|
|00001bf0| 31 5d 3b 0a 58 20 20 70 | 74 72 32 20 3d 20 70 69 |1];.X p|tr2 = pi|
|00001c00| 78 65 6c 5f 72 6f 77 5b | 32 5d 3b 0a 58 20 20 66 |xel_row[|2];.X f|
|00001c10| 6f 72 20 28 63 6f 6c 20 | 3d 20 30 3b 20 63 6f 6c |or (col |= 0; col|
|00001c20| 20 3c 20 63 69 6e 66 6f | 2d 3e 69 6d 61 67 65 5f | < cinfo|->image_|
|00001c30| 77 69 64 74 68 3b 20 63 | 6f 6c 2b 2b 29 20 7b 0a |width; c|ol++) {.|
|00001c40| 58 20 20 20 20 2a 70 74 | 72 30 2b 2b 20 3d 20 28 |X *pt|r0++ = (|
|00001c50| 4a 53 41 4d 50 4c 45 29 | 20 67 65 74 63 28 69 6e |JSAMPLE)| getc(in|
|00001c60| 66 69 6c 65 29 3b 20 2f | 2a 20 72 65 64 20 2a 2f |file); /|* red */|
|00001c70| 0a 58 20 20 20 20 2a 70 | 74 72 31 2b 2b 20 3d 20 |.X *p|tr1++ = |
|00001c80| 28 4a 53 41 4d 50 4c 45 | 29 20 67 65 74 63 28 69 |(JSAMPLE|) getc(i|
|00001c90| 6e 66 69 6c 65 29 3b 20 | 2f 2a 20 67 72 65 65 6e |nfile); |/* green|
|00001ca0| 20 2a 2f 0a 58 20 20 20 | 20 2a 70 74 72 32 2b 2b | */.X | *ptr2++|
|00001cb0| 20 3d 20 28 4a 53 41 4d | 50 4c 45 29 20 67 65 74 | = (JSAM|PLE) get|
|00001cc0| 63 28 69 6e 66 69 6c 65 | 29 3b 20 2f 2a 20 62 6c |c(infile|); /* bl|
|00001cd0| 75 65 20 2a 2f 0a 58 20 | 20 7d 0a 58 7d 0a 58 0a |ue */.X | }.X}.X.|
|00001ce0| 58 0a 58 4d 45 54 48 4f | 44 44 45 46 20 76 6f 69 |X.XMETHO|DDEF voi|
|00001cf0| 64 0a 58 69 6e 70 75 74 | 5f 74 65 72 6d 20 28 63 |d.Xinput|_term (c|
|00001d00| 6f 6d 70 72 65 73 73 5f | 69 6e 66 6f 5f 70 74 72 |ompress_|info_ptr|
|00001d10| 20 63 69 6e 66 6f 29 0a | 58 2f 2a 20 46 69 6e 69 | cinfo).|X/* Fini|
|00001d20| 73 68 20 75 70 20 61 74 | 20 74 68 65 20 65 6e 64 |sh up at| the end|
|00001d30| 20 6f 66 20 74 68 65 20 | 69 6e 70 75 74 20 2a 2f | of the |input */|
|00001d40| 0a 58 7b 0a 58 20 20 2f | 2a 20 54 68 69 73 20 74 |.X{.X /|* This t|
|00001d50| 65 72 6d 69 6e 61 74 69 | 6f 6e 20 72 6f 75 74 69 |erminati|on routi|
|00001d60| 6e 65 20 77 69 6c 6c 20 | 76 65 72 79 20 6f 66 74 |ne will |very oft|
|00001d70| 65 6e 20 68 61 76 65 20 | 6e 6f 20 77 6f 72 6b 20 |en have |no work |
|00001d80| 74 6f 20 64 6f 2c 20 2a | 2f 0a 58 20 20 2f 2a 20 |to do, *|/.X /* |
|00001d90| 62 75 74 20 79 6f 75 20 | 6d 75 73 74 20 70 72 6f |but you |must pro|
|00001da0| 76 69 64 65 20 69 74 20 | 61 6e 79 77 61 79 2e 20 |vide it |anyway. |
|00001db0| 2a 2f 0a 58 20 20 2f 2a | 20 4e 6f 74 65 20 74 68 |*/.X /*| Note th|
|00001dc0| 61 74 20 74 68 65 20 4a | 50 45 47 20 63 6f 64 65 |at the J|PEG code|
|00001dd0| 20 77 69 6c 6c 20 6f 6e | 6c 79 20 63 61 6c 6c 20 | will on|ly call |
|00001de0| 69 74 20 64 75 72 69 6e | 67 20 73 75 63 63 65 73 |it durin|g succes|
|00001df0| 73 66 75 6c 20 65 78 69 | 74 3b 20 2a 2f 0a 58 20 |sful exi|t; */.X |
|00001e00| 20 2f 2a 20 69 66 20 79 | 6f 75 20 77 61 6e 74 20 | /* if y|ou want |
|00001e10| 69 74 20 63 61 6c 6c 65 | 64 20 64 75 72 69 6e 67 |it calle|d during|
|00001e20| 20 65 72 72 6f 72 20 65 | 78 69 74 2c 20 79 6f 75 | error e|xit, you|
|00001e30| 20 67 6f 74 74 61 20 64 | 6f 20 74 68 61 74 20 79 | gotta d|o that y|
|00001e40| 6f 75 72 73 65 6c 66 2e | 20 2a 2f 0a 58 7d 0a 58 |ourself.| */.X}.X|
|00001e50| 0a 58 0a 58 2f 2a 0a 58 | 20 2a 20 54 68 61 74 27 |.X.X/*.X| * That'|
|00001e60| 73 20 69 74 20 66 6f 72 | 20 74 68 65 20 72 6f 75 |s it for| the rou|
|00001e70| 74 69 6e 65 73 20 74 68 | 61 74 20 64 65 61 6c 20 |tines th|at deal |
|00001e80| 77 69 74 68 20 72 65 61 | 64 69 6e 67 20 74 68 65 |with rea|ding the|
|00001e90| 20 69 6e 70 75 74 20 69 | 6d 61 67 65 20 64 61 74 | input i|mage dat|
|00001ea0| 61 2e 0a 58 20 2a 20 4e | 6f 77 20 77 65 20 68 61 |a..X * N|ow we ha|
|00001eb0| 76 65 20 6f 76 65 72 61 | 6c 6c 20 63 6f 6e 74 72 |ve overa|ll contr|
|00001ec0| 6f 6c 20 61 6e 64 20 70 | 61 72 61 6d 65 74 65 72 |ol and p|arameter|
|00001ed0| 20 73 65 6c 65 63 74 69 | 6f 6e 20 72 6f 75 74 69 | selecti|on routi|
|00001ee0| 6e 65 73 2e 0a 58 20 2a | 2f 0a 58 0a 58 0a 58 2f |nes..X *|/.X.X.X/|
|00001ef0| 2a 0a 58 20 2a 20 54 68 | 69 73 20 72 6f 75 74 69 |*.X * Th|is routi|
|00001f00| 6e 65 20 6d 75 73 74 20 | 64 65 74 65 72 6d 69 6e |ne must |determin|
|00001f10| 65 20 77 68 61 74 20 6f | 75 74 70 75 74 20 4a 50 |e what o|utput JP|
|00001f20| 45 47 20 66 69 6c 65 20 | 66 6f 72 6d 61 74 20 69 |EG file |format i|
|00001f30| 73 20 74 6f 20 62 65 20 | 77 72 69 74 74 65 6e 2c |s to be |written,|
|00001f40| 0a 58 20 2a 20 61 6e 64 | 20 6d 61 6b 65 20 61 6e |.X * and| make an|
|00001f50| 79 20 6f 74 68 65 72 20 | 63 6f 6d 70 72 65 73 73 |y other |compress|
|00001f60| 69 6f 6e 20 70 61 72 61 | 6d 65 74 65 72 20 63 68 |ion para|meter ch|
|00001f70| 61 6e 67 65 73 20 74 68 | 61 74 20 61 72 65 20 64 |anges th|at are d|
|00001f80| 65 73 69 72 61 62 6c 65 | 2e 0a 58 20 2a 20 54 68 |esirable|..X * Th|
|00001f90| 69 73 20 72 6f 75 74 69 | 6e 65 20 67 65 74 73 20 |is routi|ne gets |
|00001fa0| 63 6f 6e 74 72 6f 6c 20 | 61 66 74 65 72 20 74 68 |control |after th|
|00001fb0| 65 20 69 6e 70 75 74 20 | 66 69 6c 65 20 68 65 61 |e input |file hea|
|00001fc0| 64 65 72 20 68 61 73 20 | 62 65 65 6e 20 72 65 61 |der has |been rea|
|00001fd0| 64 0a 58 20 2a 20 28 69 | 2e 65 2e 2c 20 72 69 67 |d.X * (i|.e., rig|
|00001fe0| 68 74 20 61 66 74 65 72 | 20 69 6e 70 75 74 5f 69 |ht after| input_i|
|00001ff0| 6e 69 74 20 68 61 73 20 | 62 65 65 6e 20 63 61 6c |nit has |been cal|
|00002000| 6c 65 64 29 2e 20 20 59 | 6f 75 20 63 6f 75 6c 64 |led). Y|ou could|
|00002010| 20 63 6f 6d 62 69 6e 65 | 20 69 74 73 0a 58 20 2a | combine| its.X *|
|00002020| 20 66 75 6e 63 74 69 6f | 6e 73 20 69 6e 74 6f 20 | functio|ns into |
|00002030| 69 6e 70 75 74 5f 69 6e | 69 74 2c 20 6f 72 20 65 |input_in|it, or e|
|00002040| 76 65 6e 20 69 6e 74 6f | 20 74 68 65 20 6d 61 69 |ven into| the mai|
|00002050| 6e 20 63 6f 6e 74 72 6f | 6c 20 72 6f 75 74 69 6e |n contro|l routin|
|00002060| 65 2c 20 62 75 74 0a 58 | 20 2a 20 69 66 20 79 6f |e, but.X| * if yo|
|00002070| 75 20 68 61 76 65 20 73 | 65 76 65 72 61 6c 20 64 |u have s|everal d|
|00002080| 69 66 66 65 72 65 6e 74 | 20 69 6e 70 75 74 5f 69 |ifferent| input_i|
|00002090| 6e 69 74 20 72 6f 75 74 | 69 6e 65 73 2c 20 69 74 |nit rout|ines, it|
|000020a0| 27 73 20 61 20 64 65 66 | 69 6e 69 74 65 20 77 69 |'s a def|inite wi|
|000020b0| 6e 0a 58 20 2a 20 74 6f | 20 6b 65 65 70 20 74 68 |n.X * to| keep th|
|000020c0| 69 73 20 73 65 70 61 72 | 61 74 65 2e 20 20 59 6f |is separ|ate. Yo|
|000020d0| 75 20 4d 55 53 54 20 73 | 75 70 70 6c 79 20 74 68 |u MUST s|upply th|
|000020e0| 69 73 20 72 6f 75 74 69 | 6e 65 20 65 76 65 6e 20 |is routi|ne even |
|000020f0| 69 66 20 69 74 27 73 20 | 61 20 6e 6f 2d 6f 70 2e |if it's |a no-op.|
|00002100| 0a 58 20 2a 2f 0a 58 0a | 58 4d 45 54 48 4f 44 44 |.X */.X.|XMETHODD|
|00002110| 45 46 20 76 6f 69 64 0a | 58 63 5f 75 69 5f 6d 65 |EF void.|Xc_ui_me|
|00002120| 74 68 6f 64 5f 73 65 6c | 65 63 74 69 6f 6e 20 28 |thod_sel|ection (|
|00002130| 63 6f 6d 70 72 65 73 73 | 5f 69 6e 66 6f 5f 70 74 |compress|_info_pt|
|00002140| 72 20 63 69 6e 66 6f 29 | 0a 58 7b 0a 58 20 20 2f |r cinfo)|.X{.X /|
|00002150| 2a 20 49 66 20 74 68 65 | 20 69 6e 70 75 74 20 69 |* If the| input i|
|00002160| 73 20 67 72 61 79 20 73 | 63 61 6c 65 2c 20 67 65 |s gray s|cale, ge|
|00002170| 6e 65 72 61 74 65 20 61 | 20 6d 6f 6e 6f 63 68 72 |nerate a| monochr|
|00002180| 6f 6d 65 20 4a 50 45 47 | 20 66 69 6c 65 2e 20 2a |ome JPEG| file. *|
|00002190| 2f 0a 58 20 20 69 66 20 | 28 63 69 6e 66 6f 2d 3e |/.X if |(cinfo->|
|000021a0| 69 6e 5f 63 6f 6c 6f 72 | 5f 73 70 61 63 65 20 3d |in_color|_space =|
|000021b0| 3d 20 43 53 5f 47 52 41 | 59 53 43 41 4c 45 29 0a |= CS_GRA|YSCALE).|
|000021c0| 58 20 20 20 20 6a 5f 6d | 6f 6e 6f 63 68 72 6f 6d |X j_m|onochrom|
|000021d0| 65 5f 64 65 66 61 75 6c | 74 28 63 69 6e 66 6f 29 |e_defaul|t(cinfo)|
|000021e0| 3b 0a 58 20 20 2f 2a 20 | 46 6f 72 20 6e 6f 77 2c |;.X /* |For now,|
|000021f0| 20 61 6c 77 61 79 73 20 | 73 65 6c 65 63 74 20 4a | always |select J|
|00002200| 46 49 46 20 6f 75 74 70 | 75 74 20 66 6f 72 6d 61 |FIF outp|ut forma|
|00002210| 74 2e 20 2a 2f 0a 58 20 | 20 6a 73 65 6c 77 6a 66 |t. */.X | jselwjf|
|00002220| 69 66 28 63 69 6e 66 6f | 29 3b 0a 58 7d 0a 58 0a |if(cinfo|);.X}.X.|
|00002230| 58 0a 58 2f 2a 0a 58 20 | 2a 20 4f 4b 2c 20 68 65 |X.X/*.X |* OK, he|
|00002240| 72 65 20 69 73 20 74 68 | 65 20 6d 61 69 6e 20 66 |re is th|e main f|
|00002250| 75 6e 63 74 69 6f 6e 20 | 74 68 61 74 20 61 63 74 |unction |that act|
|00002260| 75 61 6c 6c 79 20 63 61 | 75 73 65 73 20 65 76 65 |ually ca|uses eve|
|00002270| 72 79 74 68 69 6e 67 20 | 74 6f 20 68 61 70 70 65 |rything |to happe|
|00002280| 6e 2e 0a 58 20 2a 20 57 | 65 20 61 73 73 75 6d 65 |n..X * W|e assume|
|00002290| 20 68 65 72 65 20 74 68 | 61 74 20 74 68 65 20 74 | here th|at the t|
|000022a0| 61 72 67 65 74 20 66 69 | 6c 65 6e 61 6d 65 20 69 |arget fi|lename i|
|000022b0| 73 20 73 75 70 70 6c 69 | 65 64 20 62 79 20 74 68 |s suppli|ed by th|
|000022c0| 65 20 63 61 6c 6c 65 72 | 20 6f 66 20 74 68 69 73 |e caller| of this|
|000022d0| 0a 58 20 2a 20 72 6f 75 | 74 69 6e 65 2c 20 61 6e |.X * rou|tine, an|
|000022e0| 64 20 74 68 61 74 20 61 | 6c 6c 20 4a 50 45 47 20 |d that a|ll JPEG |
|000022f0| 63 6f 6d 70 72 65 73 73 | 69 6f 6e 20 70 61 72 61 |compress|ion para|
|00002300| 6d 65 74 65 72 73 20 63 | 61 6e 20 62 65 20 64 65 |meters c|an be de|
|00002310| 66 61 75 6c 74 20 76 61 | 6c 75 65 73 2e 0a 58 20 |fault va|lues..X |
|00002320| 2a 2f 0a 58 0a 58 47 4c | 4f 42 41 4c 20 76 6f 69 |*/.X.XGL|OBAL voi|
|00002330| 64 0a 58 77 72 69 74 65 | 5f 4a 50 45 47 5f 66 69 |d.Xwrite|_JPEG_fi|
|00002340| 6c 65 20 28 63 68 61 72 | 20 2a 20 66 69 6c 65 6e |le (char| * filen|
|00002350| 61 6d 65 29 0a 58 7b 0a | 58 20 20 2f 2a 20 54 68 |ame).X{.|X /* Th|
|00002360| 65 73 65 20 74 68 72 65 | 65 20 73 74 72 75 63 74 |ese thre|e struct|
|00002370| 73 20 63 6f 6e 74 61 69 | 6e 20 4a 50 45 47 20 70 |s contai|n JPEG p|
|00002380| 61 72 61 6d 65 74 65 72 | 73 20 61 6e 64 20 77 6f |arameter|s and wo|
|00002390| 72 6b 69 6e 67 20 64 61 | 74 61 2e 0a 58 20 20 20 |rking da|ta..X |
|000023a0| 2a 20 54 68 65 79 20 6d | 75 73 74 20 73 75 72 76 |* They m|ust surv|
|000023b0| 69 76 65 20 66 6f 72 20 | 74 68 65 20 64 75 72 61 |ive for |the dura|
|000023c0| 74 69 6f 6e 20 6f 66 20 | 70 61 72 61 6d 65 74 65 |tion of |paramete|
|000023d0| 72 20 73 65 74 75 70 20 | 61 6e 64 20 6f 6e 65 0a |r setup |and one.|
|000023e0| 58 20 20 20 2a 20 63 61 | 6c 6c 20 74 6f 20 6a 70 |X * ca|ll to jp|
|000023f0| 65 67 5f 63 6f 6d 70 72 | 65 73 73 3b 20 74 79 70 |eg_compr|ess; typ|
|00002400| 69 63 61 6c 6c 79 2c 20 | 6d 61 6b 69 6e 67 20 74 |ically, |making t|
|00002410| 68 65 6d 20 6c 6f 63 61 | 6c 20 64 61 74 61 20 69 |hem loca|l data i|
|00002420| 6e 20 74 68 65 0a 58 20 | 20 20 2a 20 63 61 6c 6c |n the.X | * call|
|00002430| 69 6e 67 20 72 6f 75 74 | 69 6e 65 20 69 73 20 74 |ing rout|ine is t|
|00002440| 68 65 20 62 65 73 74 20 | 73 74 72 61 74 65 67 79 |he best |strategy|
|00002450| 2e 0a 58 20 20 20 2a 2f | 0a 58 20 20 73 74 72 75 |..X */|.X stru|
|00002460| 63 74 20 43 6f 6d 70 72 | 65 73 73 5f 69 6e 66 6f |ct Compr|ess_info|
|00002470| 5f 73 74 72 75 63 74 20 | 63 69 6e 66 6f 3b 0a 58 |_struct |cinfo;.X|
|00002480| 20 20 73 74 72 75 63 74 | 20 43 6f 6d 70 72 65 73 | struct| Compres|
|00002490| 73 5f 6d 65 74 68 6f 64 | 73 5f 73 74 72 75 63 74 |s_method|s_struct|
|000024a0| 20 63 5f 6d 65 74 68 6f | 64 73 3b 0a 58 20 20 73 | c_metho|ds;.X s|
|000024b0| 74 72 75 63 74 20 45 78 | 74 65 72 6e 61 6c 5f 6d |truct Ex|ternal_m|
|000024c0| 65 74 68 6f 64 73 5f 73 | 74 72 75 63 74 20 65 5f |ethods_s|truct e_|
|000024d0| 6d 65 74 68 6f 64 73 3b | 0a 58 0a 58 20 20 2f 2a |methods;|.X.X /*|
|000024e0| 20 49 6e 69 74 69 61 6c | 69 7a 65 20 74 68 65 20 | Initial|ize the |
|000024f0| 73 79 73 74 65 6d 2d 64 | 65 70 65 6e 64 65 6e 74 |system-d|ependent|
|00002500| 20 6d 65 74 68 6f 64 20 | 70 6f 69 6e 74 65 72 73 | method |pointers|
|00002510| 2e 20 2a 2f 0a 58 20 20 | 63 69 6e 66 6f 2e 6d 65 |. */.X |cinfo.me|
|00002520| 74 68 6f 64 73 20 3d 20 | 26 63 5f 6d 65 74 68 6f |thods = |&c_metho|
|00002530| 64 73 3b 09 2f 2a 20 6c | 69 6e 6b 73 20 74 6f 20 |ds;./* l|inks to |
|00002540| 6d 65 74 68 6f 64 20 73 | 74 72 75 63 74 73 20 2a |method s|tructs *|
|00002550| 2f 0a 58 20 20 63 69 6e | 66 6f 2e 65 6d 65 74 68 |/.X cin|fo.emeth|
|00002560| 6f 64 73 20 3d 20 26 65 | 5f 6d 65 74 68 6f 64 73 |ods = &e|_methods|
|00002570| 3b 0a 58 20 20 2f 2a 20 | 48 65 72 65 20 77 65 20 |;.X /* |Here we |
|00002580| 75 73 65 20 74 68 65 20 | 64 65 66 61 75 6c 74 20 |use the |default |
|00002590| 4a 50 45 47 20 65 72 72 | 6f 72 20 68 61 6e 64 6c |JPEG err|or handl|
|000025a0| 65 72 2c 20 77 68 69 63 | 68 20 77 69 6c 6c 20 6a |er, whic|h will j|
|000025b0| 75 73 74 20 70 72 69 6e | 74 0a 58 20 20 20 2a 20 |ust prin|t.X * |
|000025c0| 61 6e 20 65 72 72 6f 72 | 20 6d 65 73 73 61 67 65 |an error| message|
|000025d0| 20 6f 6e 20 73 74 64 65 | 72 72 20 61 6e 64 20 63 | on stde|rr and c|
|000025e0| 61 6c 6c 20 65 78 69 74 | 28 29 2e 20 20 53 65 65 |all exit|(). See|
|000025f0| 20 74 68 65 20 73 65 63 | 6f 6e 64 20 68 61 6c 66 | the sec|ond half|
|00002600| 20 6f 66 0a 58 20 20 20 | 2a 20 74 68 69 73 20 66 | of.X |* this f|
|00002610| 69 6c 65 20 66 6f 72 20 | 61 6e 20 65 78 61 6d 70 |ile for |an examp|
|00002620| 6c 65 20 6f 66 20 6d 6f | 72 65 20 67 72 61 63 65 |le of mo|re grace|
|00002630| 66 75 6c 20 65 72 72 6f | 72 20 72 65 63 6f 76 65 |ful erro|r recove|
|00002640| 72 79 2e 0a 58 20 20 20 | 2a 2f 0a 58 20 20 6a 73 |ry..X |*/.X js|
|00002650| 65 6c 65 72 72 6f 72 28 | 26 65 5f 6d 65 74 68 6f |elerror(|&e_metho|
|00002660| 64 73 29 3b 09 2f 2a 20 | 73 65 6c 65 63 74 20 73 |ds);./* |select s|
|00002670| 74 64 20 65 72 72 6f 72 | 2f 74 72 61 63 65 20 6d |td error|/trace m|
|00002680| 65 73 73 61 67 65 20 72 | 6f 75 74 69 6e 65 73 20 |essage r|outines |
|00002690| 2a 2f 0a 58 20 20 2f 2a | 20 48 65 72 65 20 77 65 |*/.X /*| Here we|
|000026a0| 20 75 73 65 20 74 68 65 | 20 73 74 61 6e 64 61 72 | use the| standar|
|000026b0| 64 20 6d 65 6d 6f 72 79 | 20 6d 61 6e 61 67 65 72 |d memory| manager|
|000026c0| 20 70 72 6f 76 69 64 65 | 64 20 77 69 74 68 20 74 | provide|d with t|
|000026d0| 68 65 20 4a 50 45 47 20 | 63 6f 64 65 2e 0a 58 20 |he JPEG |code..X |
|000026e0| 20 20 2a 20 49 6e 20 73 | 6f 6d 65 20 63 61 73 65 | * In s|ome case|
|000026f0| 73 20 79 6f 75 20 6d 69 | 67 68 74 20 77 61 6e 74 |s you mi|ght want|
|00002700| 20 74 6f 20 72 65 70 6c | 61 63 65 20 74 68 65 20 | to repl|ace the |
|00002710| 6d 65 6d 6f 72 79 20 6d | 61 6e 61 67 65 72 2c 20 |memory m|anager, |
|00002720| 6f 72 20 61 74 0a 58 20 | 20 20 2a 20 6c 65 61 73 |or at.X | * leas|
|00002730| 74 20 74 68 65 20 73 79 | 73 74 65 6d 2d 64 65 70 |t the sy|stem-dep|
|00002740| 65 6e 64 65 6e 74 20 70 | 61 72 74 20 6f 66 20 69 |endent p|art of i|
|00002750| 74 2c 20 77 69 74 68 20 | 79 6f 75 72 20 6f 77 6e |t, with |your own|
|00002760| 20 63 6f 64 65 2e 0a 58 | 20 20 20 2a 2f 0a 58 20 | code..X| */.X |
|00002770| 20 6a 73 65 6c 6d 65 6d | 6d 67 72 28 26 65 5f 6d | jselmem|mgr(&e_m|
|00002780| 65 74 68 6f 64 73 29 3b | 09 2f 2a 20 73 65 6c 65 |ethods);|./* sele|
|00002790| 63 74 20 73 74 64 20 6d | 65 6d 6f 72 79 20 61 6c |ct std m|emory al|
|000027a0| 6c 6f 63 61 74 69 6f 6e | 20 72 6f 75 74 69 6e 65 |location| routine|
|000027b0| 73 20 2a 2f 0a 58 20 20 | 2f 2a 20 49 66 20 74 68 |s */.X |/* If th|
|000027c0| 65 20 63 6f 6d 70 72 65 | 73 73 6f 72 20 72 65 71 |e compre|ssor req|
|000027d0| 75 69 72 65 73 20 66 75 | 6c 6c 2d 69 6d 61 67 65 |uires fu|ll-image|
|000027e0| 20 62 75 66 66 65 72 73 | 20 28 66 6f 72 20 65 6e | buffers| (for en|
|000027f0| 74 72 6f 70 79 2d 63 6f | 64 69 6e 67 0a 58 20 20 |tropy-co|ding.X |
|00002800| 20 2a 20 6f 70 74 69 6d | 69 7a 61 74 69 6f 6e 20 | * optim|ization |
|00002810| 6f 72 20 61 20 6e 6f 6e | 69 6e 74 65 72 6c 65 61 |or a non|interlea|
|00002820| 76 65 64 20 4a 50 45 47 | 20 66 69 6c 65 29 2c 20 |ved JPEG| file), |
|00002830| 69 74 20 77 69 6c 6c 20 | 63 72 65 61 74 65 20 74 |it will |create t|
|00002840| 65 6d 70 6f 72 61 72 79 | 0a 58 20 20 20 2a 20 66 |emporary|.X * f|
|00002850| 69 6c 65 73 20 66 6f 72 | 20 61 6e 79 74 68 69 6e |iles for| anythin|
|00002860| 67 20 74 68 61 74 20 64 | 6f 65 73 6e 27 74 20 66 |g that d|oesn't f|
|00002870| 69 74 20 77 69 74 68 69 | 6e 20 74 68 65 20 6d 61 |it withi|n the ma|
|00002880| 78 69 6d 75 6d 2d 6d 65 | 6d 6f 72 79 20 73 65 74 |ximum-me|mory set|
|00002890| 74 69 6e 67 2e 0a 58 20 | 20 20 2a 20 28 4e 6f 74 |ting..X | * (Not|
|000028a0| 65 20 74 68 61 74 20 74 | 65 6d 70 20 66 69 6c 65 |e that t|emp file|
|000028b0| 73 20 61 72 65 20 4e 4f | 54 20 6e 65 65 64 65 64 |s are NO|T needed|
|000028c0| 20 69 66 20 79 6f 75 20 | 75 73 65 20 74 68 65 20 | if you |use the |
|000028d0| 64 65 66 61 75 6c 74 20 | 70 61 72 61 6d 65 74 65 |default |paramete|
|000028e0| 72 73 2e 29 0a 58 20 20 | 20 2a 20 59 6f 75 20 63 |rs.).X | * You c|
|000028f0| 61 6e 20 63 68 61 6e 67 | 65 20 74 68 65 20 64 65 |an chang|e the de|
|00002900| 66 61 75 6c 74 20 6d 61 | 78 69 6d 75 6d 2d 6d 65 |fault ma|ximum-me|
|00002910| 6d 6f 72 79 20 73 65 74 | 74 69 6e 67 20 62 79 20 |mory set|ting by |
|00002920| 63 68 61 6e 67 69 6e 67 | 0a 58 20 20 20 2a 20 65 |changing|.X * e|
|00002930| 5f 6d 65 74 68 6f 64 73 | 2e 6d 61 78 5f 6d 65 6d |_methods|.max_mem|
|00002940| 6f 72 79 5f 74 6f 5f 75 | 73 65 20 61 66 74 65 72 |ory_to_u|se after|
|00002950| 20 6a 73 65 6c 6d 65 6d | 6d 67 72 20 72 65 74 75 | jselmem|mgr retu|
|00002960| 72 6e 73 2e 0a 58 20 20 | 20 2a 20 4f 6e 20 73 6f |rns..X | * On so|
|00002970| 6d 65 20 73 79 73 74 65 | 6d 73 20 79 6f 75 20 6d |me syste|ms you m|
|00002980| 61 79 20 61 6c 73 6f 20 | 6e 65 65 64 20 74 6f 20 |ay also |need to |
|00002990| 73 65 74 20 75 70 20 61 | 20 73 69 67 6e 61 6c 20 |set up a| signal |
|000029a0| 68 61 6e 64 6c 65 72 20 | 74 6f 0a 58 20 20 20 2a |handler |to.X *|
|000029b0| 20 65 6e 73 75 72 65 20 | 74 68 61 74 20 74 65 6d | ensure |that tem|
|000029c0| 70 6f 72 61 72 79 20 66 | 69 6c 65 73 20 61 72 65 |porary f|iles are|
|000029d0| 20 64 65 6c 65 74 65 64 | 20 69 66 20 74 68 65 20 | deleted| if the |
|000029e0| 70 72 6f 67 72 61 6d 20 | 69 73 20 69 6e 74 65 72 |program |is inter|
|000029f0| 72 75 70 74 65 64 2e 0a | 58 20 20 20 2a 20 28 54 |rupted..|X * (T|
|00002a00| 68 69 73 20 69 73 20 6d | 6f 73 74 20 69 6d 70 6f |his is m|ost impo|
|00002a10| 72 74 61 6e 74 20 69 66 | 20 79 6f 75 20 61 72 65 |rtant if| you are|
|00002a20| 20 6f 6e 20 4d 53 2d 44 | 4f 53 20 61 6e 64 20 75 | on MS-D|OS and u|
|00002a30| 73 65 20 74 68 65 20 6a | 6d 65 6d 64 6f 73 2e 63 |se the j|memdos.c|
|00002a40| 0a 58 20 20 20 2a 20 6d | 65 6d 6f 72 79 20 6d 61 |.X * m|emory ma|
|00002a50| 6e 61 67 65 72 20 62 61 | 63 6b 20 65 6e 64 3b 20 |nager ba|ck end; |
|00002a60| 69 74 20 77 69 6c 6c 20 | 74 72 79 20 74 6f 20 67 |it will |try to g|
|00002a70| 72 61 62 20 65 78 74 65 | 6e 64 65 64 20 6d 65 6d |rab exte|nded mem|
|00002a80| 6f 72 79 20 66 6f 72 0a | 58 20 20 20 2a 20 74 65 |ory for.|X * te|
|00002a90| 6d 70 20 66 69 6c 65 73 | 2c 20 61 6e 64 20 74 68 |mp files|, and th|
|00002aa0| 61 74 20 73 70 61 63 65 | 20 77 69 6c 6c 20 4e 4f |at space| will NO|
|00002ab0| 54 20 62 65 20 66 72 65 | 65 64 20 61 75 74 6f 6d |T be fre|ed autom|
|00002ac0| 61 74 69 63 61 6c 6c 79 | 2e 29 0a 58 20 20 20 2a |atically|.).X *|
|00002ad0| 20 53 65 65 20 6a 63 6d | 61 69 6e 2e 63 20 6f 72 | See jcm|ain.c or|
|00002ae0| 20 6a 64 6d 61 69 6e 2e | 63 20 66 6f 72 20 61 6e | jdmain.|c for an|
|00002af0| 20 65 78 61 6d 70 6c 65 | 20 73 69 67 6e 61 6c 20 | example| signal |
|00002b00| 68 61 6e 64 6c 65 72 2e | 0a 58 20 20 20 2a 2f 0a |handler.|.X */.|
|00002b10| 58 0a 58 20 20 2f 2a 20 | 48 65 72 65 2c 20 73 65 |X.X /* |Here, se|
|00002b20| 74 20 75 70 20 70 6f 69 | 6e 74 65 72 73 20 74 6f |t up poi|nters to|
|00002b30| 20 79 6f 75 72 20 6f 77 | 6e 20 72 6f 75 74 69 6e | your ow|n routin|
|00002b40| 65 73 20 66 6f 72 20 69 | 6e 70 75 74 20 64 61 74 |es for i|nput dat|
|00002b50| 61 20 68 61 6e 64 6c 69 | 6e 67 0a 58 20 20 20 2a |a handli|ng.X *|
|00002b60| 20 61 6e 64 20 70 6f 73 | 74 2d 69 6e 69 74 20 70 | and pos|t-init p|
|00002b70| 61 72 61 6d 65 74 65 72 | 20 73 65 6c 65 63 74 69 |arameter| selecti|
|00002b80| 6f 6e 2e 0a 58 20 20 20 | 2a 2f 0a 58 20 20 63 5f |on..X |*/.X c_|
|00002b90| 6d 65 74 68 6f 64 73 2e | 69 6e 70 75 74 5f 69 6e |methods.|input_in|
|00002ba0| 69 74 20 3d 20 69 6e 70 | 75 74 5f 69 6e 69 74 3b |it = inp|ut_init;|
|00002bb0| 0a 58 20 20 63 5f 6d 65 | 74 68 6f 64 73 2e 67 65 |.X c_me|thods.ge|
|00002bc0| 74 5f 69 6e 70 75 74 5f | 72 6f 77 20 3d 20 67 65 |t_input_|row = ge|
|00002bd0| 74 5f 69 6e 70 75 74 5f | 72 6f 77 3b 0a 58 20 20 |t_input_|row;.X |
|00002be0| 63 5f 6d 65 74 68 6f 64 | 73 2e 69 6e 70 75 74 5f |c_method|s.input_|
|00002bf0| 74 65 72 6d 20 3d 20 69 | 6e 70 75 74 5f 74 65 72 |term = i|nput_ter|
|00002c00| 6d 3b 0a 58 20 20 63 5f | 6d 65 74 68 6f 64 73 2e |m;.X c_|methods.|
|00002c10| 63 5f 75 69 5f 6d 65 74 | 68 6f 64 5f 73 65 6c 65 |c_ui_met|hod_sele|
|00002c20| 63 74 69 6f 6e 20 3d 20 | 63 5f 75 69 5f 6d 65 74 |ction = |c_ui_met|
|00002c30| 68 6f 64 5f 73 65 6c 65 | 63 74 69 6f 6e 3b 0a 58 |hod_sele|ction;.X|
|00002c40| 0a 58 20 20 2f 2a 20 53 | 65 74 20 75 70 20 64 65 |.X /* S|et up de|
|00002c50| 66 61 75 6c 74 20 4a 50 | 45 47 20 70 61 72 61 6d |fault JP|EG param|
|00002c60| 65 74 65 72 73 20 69 6e | 20 74 68 65 20 63 69 6e |eters in| the cin|
|00002c70| 66 6f 20 64 61 74 61 20 | 73 74 72 75 63 74 75 72 |fo data |structur|
|00002c80| 65 2e 20 2a 2f 0a 58 20 | 20 6a 5f 63 5f 64 65 66 |e. */.X | j_c_def|
|00002c90| 61 75 6c 74 73 28 26 63 | 69 6e 66 6f 2c 20 37 35 |aults(&c|info, 75|
|00002ca0| 2c 20 46 41 4c 53 45 29 | 3b 0a 58 20 20 2f 2a 20 |, FALSE)|;.X /* |
|00002cb0| 4e 6f 74 65 3a 20 37 35 | 20 69 73 20 74 68 65 20 |Note: 75| is the |
|00002cc0| 72 65 63 6f 6d 6d 65 6e | 64 65 64 20 64 65 66 61 |recommen|ded defa|
|00002cd0| 75 6c 74 20 71 75 61 6c | 69 74 79 20 6c 65 76 65 |ult qual|ity leve|
|00002ce0| 6c 3b 20 79 6f 75 20 6d | 61 79 20 69 6e 73 74 65 |l; you m|ay inste|
|00002cf0| 61 64 20 70 61 73 73 0a | 58 20 20 20 2a 20 61 20 |ad pass.|X * a |
|00002d00| 75 73 65 72 2d 73 70 65 | 63 69 66 69 65 64 20 71 |user-spe|cified q|
|00002d10| 75 61 6c 69 74 79 20 6c | 65 76 65 6c 2e 20 20 42 |uality l|evel. B|
|00002d20| 65 20 61 77 61 72 65 20 | 74 68 61 74 20 76 61 6c |e aware |that val|
|00002d30| 75 65 73 20 62 65 6c 6f | 77 20 32 35 20 77 69 6c |ues belo|w 25 wil|
|00002d40| 6c 20 63 61 75 73 65 0a | 58 20 20 20 2a 20 6e 6f |l cause.|X * no|
|00002d50| 6e 2d 62 61 73 65 6c 69 | 6e 65 20 4a 50 45 47 20 |n-baseli|ne JPEG |
|00002d60| 66 69 6c 65 73 20 74 6f | 20 62 65 20 63 72 65 61 |files to| be crea|
|00002d70| 74 65 64 20 28 61 6e 64 | 20 61 20 77 61 72 6e 69 |ted (and| a warni|
|00002d80| 6e 67 20 6d 65 73 73 61 | 67 65 20 74 6f 20 74 68 |ng messa|ge to th|
|00002d90| 61 74 0a 58 20 20 20 2a | 20 65 66 66 65 63 74 20 |at.X *| effect |
|00002da0| 74 6f 20 62 65 20 65 6d | 69 74 74 65 64 20 6f 6e |to be em|itted on|
|00002db0| 20 73 74 64 65 72 72 29 | 2e 20 20 54 68 69 73 20 | stderr)|. This |
|00002dc0| 77 6f 6e 27 74 20 62 6f | 74 68 65 72 20 6f 75 72 |won't bo|ther our|
|00002dd0| 20 64 65 63 6f 64 65 72 | 2c 20 62 75 74 20 73 6f | decoder|, but so|
|00002de0| 6d 65 0a 58 20 20 20 2a | 20 63 6f 6d 6d 65 72 63 |me.X *| commerc|
|00002df0| 69 61 6c 20 4a 50 45 47 | 20 69 6d 70 6c 65 6d 65 |ial JPEG| impleme|
|00002e00| 6e 74 61 74 69 6f 6e 73 | 20 6d 61 79 20 63 68 6f |ntations| may cho|
|00002e10| 6b 65 20 6f 6e 20 6e 6f | 6e 2d 62 61 73 65 6c 69 |ke on no|n-baseli|
|00002e20| 6e 65 20 4a 50 45 47 20 | 66 69 6c 65 73 2e 0a 58 |ne JPEG |files..X|
|00002e30| 20 20 20 2a 20 49 66 20 | 79 6f 75 20 77 61 6e 74 | * If |you want|
|00002e40| 20 74 6f 20 66 6f 72 63 | 65 20 62 61 73 65 6c 69 | to forc|e baseli|
|00002e50| 6e 65 20 63 6f 6d 70 61 | 74 69 62 69 6c 69 74 79 |ne compa|tibility|
|00002e60| 2c 20 70 61 73 73 20 54 | 52 55 45 20 69 6e 73 74 |, pass T|RUE inst|
|00002e70| 65 61 64 20 6f 66 20 46 | 41 4c 53 45 2e 0a 58 20 |ead of F|ALSE..X |
|00002e80| 20 20 2a 20 28 49 66 20 | 6e 6f 6e 2d 62 61 73 65 | * (If |non-base|
|00002e90| 6c 69 6e 65 20 66 69 6c | 65 73 20 61 72 65 20 66 |line fil|es are f|
|00002ea0| 69 6e 65 2c 20 62 75 74 | 20 79 6f 75 20 63 6f 75 |ine, but| you cou|
|00002eb0| 6c 64 20 64 6f 20 77 69 | 74 68 6f 75 74 20 74 68 |ld do wi|thout th|
|00002ec0| 61 74 20 77 61 72 6e 69 | 6e 67 0a 58 20 20 20 2a |at warni|ng.X *|
|00002ed0| 20 6d 65 73 73 61 67 65 | 2c 20 73 65 74 20 65 5f | message|, set e_|
|00002ee0| 6d 65 74 68 6f 64 73 2e | 74 72 61 63 65 5f 6c 65 |methods.|trace_le|
|00002ef0| 76 65 6c 20 74 6f 20 2d | 31 2e 29 0a 58 20 20 20 |vel to -|1.).X |
|00002f00| 2a 2f 0a 58 0a 58 20 20 | 2f 2a 20 41 74 20 74 68 |*/.X.X |/* At th|
|00002f10| 69 73 20 70 6f 69 6e 74 | 20 79 6f 75 20 63 61 6e |is point| you can|
|00002f20| 20 6d 6f 64 69 66 79 20 | 74 68 65 20 64 65 66 61 | modify |the defa|
|00002f30| 75 6c 74 20 70 61 72 61 | 6d 65 74 65 72 73 20 73 |ult para|meters s|
|00002f40| 65 74 20 62 79 20 6a 5f | 63 5f 64 65 66 61 75 6c |et by j_|c_defaul|
|00002f50| 74 73 0a 58 20 20 20 2a | 20 61 73 20 6e 65 65 64 |ts.X *| as need|
|00002f60| 65 64 2e 20 20 46 6f 72 | 20 61 20 6d 69 6e 69 6d |ed. For| a minim|
|00002f70| 61 6c 20 69 6d 70 6c 65 | 6d 65 6e 74 61 74 69 6f |al imple|mentatio|
|00002f80| 6e 2c 20 79 6f 75 20 73 | 68 6f 75 6c 64 6e 27 74 |n, you s|houldn't|
|00002f90| 20 6e 65 65 64 20 74 6f | 20 63 68 61 6e 67 65 0a | need to| change.|
|00002fa0| 58 20 20 20 2a 20 61 6e | 79 74 68 69 6e 67 2e 20 |X * an|ything. |
|00002fb0| 20 53 65 65 20 6a 63 6d | 61 69 6e 2e 63 20 66 6f | See jcm|ain.c fo|
|00002fc0| 72 20 73 6f 6d 65 20 65 | 78 61 6d 70 6c 65 73 20 |r some e|xamples |
|00002fd0| 6f 66 20 77 68 61 74 20 | 79 6f 75 20 6d 69 67 68 |of what |you migh|
|00002fe0| 74 20 63 68 61 6e 67 65 | 2e 0a 58 20 20 20 2a 2f |t change|..X */|
|00002ff0| 0a 58 0a 58 20 20 2f 2a | 20 53 65 6c 65 63 74 20 |.X.X /*| Select |
|00003000| 74 68 65 20 69 6e 70 75 | 74 20 61 6e 64 20 6f 75 |the inpu|t and ou|
|00003010| 74 70 75 74 20 66 69 6c | 65 73 2e 0a 58 20 20 20 |tput fil|es..X |
|00003020| 2a 20 4e 6f 74 65 20 74 | 68 61 74 20 63 69 6e 66 |* Note t|hat cinf|
|00003030| 6f 2e 69 6e 70 75 74 5f | 66 69 6c 65 20 69 73 20 |o.input_|file is |
|00003040| 6f 6e 6c 79 20 75 73 65 | 64 20 69 66 20 79 6f 75 |only use|d if you|
|00003050| 72 20 69 6e 70 75 74 20 | 72 65 61 64 69 6e 67 20 |r input |reading |
|00003060| 72 6f 75 74 69 6e 65 73 | 0a 58 20 20 20 2a 20 75 |routines|.X * u|
|00003070| 73 65 20 69 74 3b 20 6f | 74 68 65 72 77 69 73 65 |se it; o|therwise|
|00003080| 2c 20 79 6f 75 20 63 61 | 6e 20 6a 75 73 74 20 6d |, you ca|n just m|
|00003090| 61 6b 65 20 69 74 20 4e | 55 4c 4c 2e 0a 58 20 20 |ake it N|ULL..X |
|000030a0| 20 2a 20 56 45 52 59 20 | 49 4d 50 4f 52 54 41 4e | * VERY |IMPORTAN|
|000030b0| 54 3a 20 75 73 65 20 22 | 62 22 20 6f 70 74 69 6f |T: use "|b" optio|
|000030c0| 6e 20 74 6f 20 66 6f 70 | 65 6e 28 29 20 69 66 20 |n to fop|en() if |
|000030d0| 79 6f 75 20 61 72 65 20 | 6f 6e 20 61 20 6d 61 63 |you are |on a mac|
|000030e0| 68 69 6e 65 20 74 68 61 | 74 0a 58 20 20 20 2a 20 |hine tha|t.X * |
|000030f0| 72 65 71 75 69 72 65 73 | 20 69 74 20 69 6e 20 6f |requires| it in o|
|00003100| 72 64 65 72 20 74 6f 20 | 77 72 69 74 65 20 62 69 |rder to |write bi|
|00003110| 6e 61 72 79 20 66 69 6c | 65 73 2e 0a 58 20 20 20 |nary fil|es..X |
|00003120| 2a 2f 0a 58 0a 58 20 20 | 63 69 6e 66 6f 2e 69 6e |*/.X.X |cinfo.in|
|00003130| 70 75 74 5f 66 69 6c 65 | 20 3d 20 4e 55 4c 4c 3b |put_file| = NULL;|
|00003140| 09 2f 2a 20 69 66 20 6e | 6f 20 61 63 74 75 61 6c |./* if n|o actual|
|00003150| 20 69 6e 70 75 74 20 66 | 69 6c 65 20 69 6e 76 6f | input f|ile invo|
|00003160| 6c 76 65 64 20 2a 2f 0a | 58 0a 58 20 20 69 66 20 |lved */.|X.X if |
|00003170| 28 28 63 69 6e 66 6f 2e | 6f 75 74 70 75 74 5f 66 |((cinfo.|output_f|
|00003180| 69 6c 65 20 3d 20 66 6f | 70 65 6e 28 66 69 6c 65 |ile = fo|pen(file|
|00003190| 6e 61 6d 65 2c 20 22 77 | 62 22 29 29 20 3d 3d 20 |name, "w|b")) == |
|000031a0| 4e 55 4c 4c 29 20 7b 0a | 58 20 20 20 20 66 70 72 |NULL) {.|X fpr|
|000031b0| 69 6e 74 66 28 73 74 64 | 65 72 72 2c 20 22 63 61 |intf(std|err, "ca|
|000031c0| 6e 27 74 20 6f 70 65 6e | 20 25 73 5c 6e 22 2c 20 |n't open| %s\n", |
|000031d0| 66 69 6c 65 6e 61 6d 65 | 29 3b 0a 58 20 20 20 20 |filename|);.X |
|000031e0| 65 78 69 74 28 31 29 3b | 0a 58 20 20 7d 0a 58 0a |exit(1);|.X }.X.|
|000031f0| 58 20 20 2f 2a 20 48 65 | 72 65 20 77 65 20 67 6f |X /* He|re we go|
|00003200| 21 20 2a 2f 0a 58 20 20 | 6a 70 65 67 5f 63 6f 6d |! */.X |jpeg_com|
|00003210| 70 72 65 73 73 28 26 63 | 69 6e 66 6f 29 3b 0a 58 |press(&c|info);.X|
|00003220| 0a 58 20 20 2f 2a 20 54 | 68 61 74 27 73 20 69 74 |.X /* T|hat's it|
|00003230| 2c 20 73 6f 6e 2e 20 20 | 4e 6f 74 68 69 6e 27 20 |, son. |Nothin' |
|00003240| 65 6c 73 65 20 74 6f 20 | 64 6f 2c 20 65 78 63 65 |else to |do, exce|
|00003250| 70 74 20 63 6c 6f 73 65 | 20 66 69 6c 65 73 2e 20 |pt close| files. |
|00003260| 2a 2f 0a 58 20 20 2f 2a | 20 48 65 72 65 20 77 65 |*/.X /*| Here we|
|00003270| 20 61 73 73 75 6d 65 20 | 6f 6e 6c 79 20 74 68 65 | assume |only the|
|00003280| 20 6f 75 74 70 75 74 20 | 66 69 6c 65 20 6e 65 65 | output |file nee|
|00003290| 64 20 62 65 20 63 6c 6f | 73 65 64 2e 20 2a 2f 0a |d be clo|sed. */.|
|000032a0| 58 20 20 66 63 6c 6f 73 | 65 28 63 69 6e 66 6f 2e |X fclos|e(cinfo.|
|000032b0| 6f 75 74 70 75 74 5f 66 | 69 6c 65 29 3b 0a 58 0a |output_f|ile);.X.|
|000032c0| 58 20 20 2f 2a 20 4e 6f | 74 65 3a 20 69 66 20 79 |X /* No|te: if y|
|000032d0| 6f 75 20 77 61 6e 74 20 | 74 6f 20 63 6f 6d 70 72 |ou want |to compr|
|000032e0| 65 73 73 20 6d 6f 72 65 | 20 74 68 61 6e 20 6f 6e |ess more| than on|
|000032f0| 65 20 69 6d 61 67 65 2c | 20 77 65 20 72 65 63 6f |e image,| we reco|
|00003300| 6d 6d 65 6e 64 20 79 6f | 75 0a 58 20 20 20 2a 20 |mmend yo|u.X * |
|00003310| 72 65 70 65 61 74 20 74 | 68 69 73 20 77 68 6f 6c |repeat t|his whol|
|00003320| 65 20 72 6f 75 74 69 6e | 65 2e 20 20 59 6f 75 20 |e routin|e. You |
|00003330| 4d 55 53 54 20 72 65 70 | 65 61 74 20 74 68 65 20 |MUST rep|eat the |
|00003340| 6a 5f 63 5f 64 65 66 61 | 75 6c 74 73 28 29 2f 61 |j_c_defa|ults()/a|
|00003350| 6c 74 65 72 0a 58 20 20 | 20 2a 20 70 61 72 61 6d |lter.X | * param|
|00003360| 65 74 65 72 73 2f 6a 70 | 65 67 5f 63 6f 6d 70 72 |eters/jp|eg_compr|
|00003370| 65 73 73 28 29 20 73 65 | 71 75 65 6e 63 65 2c 20 |ess() se|quence, |
|00003380| 61 73 20 73 6f 6d 65 20 | 64 61 74 61 20 73 74 72 |as some |data str|
|00003390| 75 63 74 75 72 65 73 20 | 61 6c 6c 6f 63 61 74 65 |uctures |allocate|
|000033a0| 64 0a 58 20 20 20 2a 20 | 69 6e 20 6a 5f 63 5f 64 |d.X * |in j_c_d|
|000033b0| 65 66 61 75 6c 74 73 20 | 61 72 65 20 66 72 65 65 |efaults |are free|
|000033c0| 64 20 75 70 6f 6e 20 65 | 78 69 74 20 66 72 6f 6d |d upon e|xit from|
|000033d0| 20 6a 70 65 67 5f 63 6f | 6d 70 72 65 73 73 2e 0a | jpeg_co|mpress..|
|000033e0| 58 20 20 20 2a 2f 0a 58 | 7d 0a 58 0a 58 0a 58 0a |X */.X|}.X.X.X.|
|000033f0| 58 2f 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |X/******|********|
|00003400| 2a 2a 2a 2a 2a 2a 20 4a | 50 45 47 20 44 45 43 4f |****** J|PEG DECO|
|00003410| 4d 50 52 45 53 53 49 4f | 4e 20 53 41 4d 50 4c 45 |MPRESSIO|N SAMPLE|
|00003420| 20 49 4e 54 45 52 46 41 | 43 45 20 2a 2a 2a 2a 2a | INTERFA|CE *****|
|00003430| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2f 0a |********|******/.|
|00003440| 58 0a 58 2f 2a 20 54 68 | 69 73 20 68 61 6c 66 20 |X.X/* Th|is half |
|00003450| 6f 66 20 74 68 65 20 65 | 78 61 6d 70 6c 65 20 73 |of the e|xample s|
|00003460| 68 6f 77 73 20 68 6f 77 | 20 74 6f 20 72 65 61 64 |hows how| to read|
|00003470| 20 64 61 74 61 20 66 72 | 6f 6d 20 74 68 65 20 4a | data fr|om the J|
|00003480| 50 45 47 20 64 65 63 6f | 6d 70 72 65 73 73 6f 72 |PEG deco|mpressor|
|00003490| 2e 0a 58 20 2a 20 49 74 | 27 73 20 61 20 6c 69 74 |..X * It|'s a lit|
|000034a0| 74 6c 65 20 6d 6f 72 65 | 20 72 65 66 69 6e 65 64 |tle more| refined|
|000034b0| 20 74 68 61 6e 20 74 68 | 65 20 61 62 6f 76 65 20 | than th|e above |
|000034c0| 69 6e 20 74 68 61 74 20 | 77 65 20 73 68 6f 77 20 |in that |we show |
|000034d0| 68 6f 77 20 74 6f 20 64 | 6f 20 79 6f 75 72 0a 58 |how to d|o your.X|
|000034e0| 20 2a 20 6f 77 6e 20 65 | 72 72 6f 72 20 72 65 63 | * own e|rror rec|
|000034f0| 6f 76 65 72 79 2e 20 20 | 49 66 20 79 6f 75 20 64 |overy. |If you d|
|00003500| 6f 6e 27 74 20 63 61 72 | 65 20 61 62 6f 75 74 20 |on't car|e about |
|00003510| 74 68 61 74 2c 20 79 6f | 75 20 64 6f 6e 27 74 20 |that, yo|u don't |
|00003520| 6e 65 65 64 20 74 68 65 | 73 65 0a 58 20 2a 20 6e |need the|se.X * n|
|00003530| 65 78 74 20 74 77 6f 20 | 72 6f 75 74 69 6e 65 73 |ext two |routines|
|00003540| 2e 0a 58 20 2a 2f 0a 58 | 0a 58 0a 58 2f 2a 0a 58 |..X */.X|.X.X/*.X|
|00003550| 20 2a 20 54 68 65 73 65 | 20 72 6f 75 74 69 6e 65 | * These| routine|
|00003560| 73 20 72 65 70 6c 61 63 | 65 20 74 68 65 20 64 65 |s replac|e the de|
|00003570| 66 61 75 6c 74 20 74 72 | 61 63 65 2f 65 72 72 6f |fault tr|ace/erro|
|00003580| 72 20 72 6f 75 74 69 6e | 65 73 20 69 6e 63 6c 75 |r routin|es inclu|
|00003590| 64 65 64 20 77 69 74 68 | 20 74 68 65 0a 58 20 2a |ded with| the.X *|
|000035a0| 20 4a 50 45 47 20 63 6f | 64 65 2e 20 20 54 68 65 | JPEG co|de. The|
|000035b0| 20 65 78 61 6d 70 6c 65 | 20 74 72 61 63 65 5f 6d | example| trace_m|
|000035c0| 65 73 73 61 67 65 20 72 | 6f 75 74 69 6e 65 20 73 |essage r|outine s|
|000035d0| 68 6f 77 6e 20 68 65 72 | 65 20 69 73 20 61 63 74 |hown her|e is act|
|000035e0| 75 61 6c 6c 79 20 74 68 | 65 0a 58 20 2a 20 73 61 |ually th|e.X * sa|
|000035f0| 6d 65 20 61 73 20 74 68 | 65 20 73 74 61 6e 64 61 |me as th|e standa|
|00003600| 72 64 20 6f 6e 65 2c 20 | 62 75 74 20 79 6f 75 20 |rd one, |but you |
|00003610| 63 6f 75 6c 64 20 6d 6f | 64 69 66 79 20 69 74 20 |could mo|dify it |
|00003620| 69 66 20 79 6f 75 20 64 | 6f 6e 27 74 20 77 61 6e |if you d|on't wan|
|00003630| 74 20 6d 65 73 73 61 67 | 65 73 0a 58 20 2a 20 73 |t messag|es.X * s|
|00003640| 65 6e 74 20 74 6f 20 73 | 74 64 65 72 72 2e 20 20 |ent to s|tderr. |
|00003650| 54 68 65 20 65 78 61 6d | 70 6c 65 20 65 72 72 6f |The exam|ple erro|
|00003660| 72 5f 65 78 69 74 20 72 | 6f 75 74 69 6e 65 20 69 |r_exit r|outine i|
|00003670| 73 20 73 65 74 20 75 70 | 20 74 6f 20 72 65 74 75 |s set up| to retu|
|00003680| 72 6e 0a 58 20 2a 20 63 | 6f 6e 74 72 6f 6c 20 74 |rn.X * c|ontrol t|
|00003690| 6f 20 72 65 61 64 5f 4a | 50 45 47 5f 66 69 6c 65 |o read_J|PEG_file|
|000036a0| 28 29 20 72 61 74 68 65 | 72 20 74 68 61 6e 20 63 |() rathe|r than c|
|000036b0| 61 6c 6c 69 6e 67 20 65 | 78 69 74 28 29 2e 20 20 |alling e|xit(). |
|000036c0| 59 6f 75 20 63 61 6e 20 | 75 73 65 20 74 68 65 0a |You can |use the.|
|000036d0| 58 20 2a 20 73 61 6d 65 | 20 72 6f 75 74 69 6e 65 |X * same| routine|
|000036e0| 73 20 66 6f 72 20 62 6f | 74 68 20 63 6f 6d 70 72 |s for bo|th compr|
|000036f0| 65 73 73 69 6f 6e 20 61 | 6e 64 20 64 65 63 6f 6d |ession a|nd decom|
|00003700| 70 72 65 73 73 69 6f 6e | 20 65 72 72 6f 72 20 72 |pression| error r|
|00003710| 65 63 6f 76 65 72 79 2e | 0a 58 20 2a 2f 0a 58 0a |ecovery.|.X */.X.|
|00003720| 58 2f 2a 20 54 68 65 73 | 65 20 73 74 61 74 69 63 |X/* Thes|e static|
|00003730| 20 76 61 72 69 61 62 6c | 65 73 20 61 72 65 20 6e | variabl|es are n|
|00003740| 65 65 64 65 64 20 62 79 | 20 74 68 65 20 65 72 72 |eeded by| the err|
|00003750| 6f 72 20 72 6f 75 74 69 | 6e 65 73 2e 20 2a 2f 0a |or routi|nes. */.|
|00003760| 58 73 74 61 74 69 63 20 | 6a 6d 70 5f 62 75 66 20 |Xstatic |jmp_buf |
|00003770| 73 65 74 6a 6d 70 5f 62 | 75 66 66 65 72 3b 09 2f |setjmp_b|uffer;./|
|00003780| 2a 20 66 6f 72 20 72 65 | 74 75 72 6e 20 74 6f 20 |* for re|turn to |
|00003790| 63 61 6c 6c 65 72 20 2a | 2f 0a 58 73 74 61 74 69 |caller *|/.Xstati|
|000037a0| 63 20 65 78 74 65 72 6e | 61 6c 5f 6d 65 74 68 6f |c extern|al_metho|
|000037b0| 64 73 5f 70 74 72 20 65 | 6d 65 74 68 6f 64 73 3b |ds_ptr e|methods;|
|000037c0| 20 2f 2a 20 6e 65 65 64 | 65 64 20 66 6f 72 20 61 | /* need|ed for a|
|000037d0| 63 63 65 73 73 20 74 6f | 20 6d 65 73 73 61 67 65 |ccess to| message|
|000037e0| 5f 70 61 72 6d 20 2a 2f | 0a 58 0a 58 0a 58 2f 2a |_parm */|.X.X.X/*|
|000037f0| 20 54 68 69 73 20 72 6f | 75 74 69 6e 65 20 69 73 | This ro|utine is|
|00003800| 20 75 73 65 64 20 66 6f | 72 20 61 6e 79 20 61 6e | used fo|r any an|
|00003810| 64 20 61 6c 6c 20 74 72 | 61 63 65 2c 20 64 65 62 |d all tr|ace, deb|
|00003820| 75 67 2c 20 6f 72 20 65 | 72 72 6f 72 20 70 72 69 |ug, or e|rror pri|
|00003830| 6e 74 6f 75 74 73 0a 58 | 20 2a 20 66 72 6f 6d 20 |ntouts.X| * from |
|00003840| 74 68 65 20 4a 50 45 47 | 20 63 6f 64 65 2e 20 20 |the JPEG| code. |
|00003850| 54 68 65 20 70 61 72 61 | 6d 65 74 65 72 20 69 73 |The para|meter is|
|00003860| 20 61 20 70 72 69 6e 74 | 66 20 66 6f 72 6d 61 74 | a print|f format|
|00003870| 20 73 74 72 69 6e 67 3b | 20 75 70 20 74 6f 20 38 | string;| up to 8|
|00003880| 0a 58 20 2a 20 69 6e 74 | 65 67 65 72 20 64 61 74 |.X * int|eger dat|
|00003890| 61 20 76 61 6c 75 65 73 | 20 66 6f 72 20 74 68 65 |a values| for the|
|000038a0| 20 66 6f 72 6d 61 74 20 | 73 74 72 69 6e 67 20 68 | format |string h|
|000038b0| 61 76 65 20 62 65 65 6e | 20 73 74 6f 72 65 64 20 |ave been| stored |
|000038c0| 69 6e 20 74 68 65 0a 58 | 20 2a 20 6d 65 73 73 61 |in the.X| * messa|
|000038d0| 67 65 5f 70 61 72 6d 5b | 5d 20 66 69 65 6c 64 20 |ge_parm[|] field |
|000038e0| 6f 66 20 74 68 65 20 65 | 78 74 65 72 6e 61 6c 5f |of the e|xternal_|
|000038f0| 6d 65 74 68 6f 64 73 20 | 73 74 72 75 63 74 2e 0a |methods |struct..|
|00003900| 58 20 2a 2f 0a 58 0a 58 | 4d 45 54 48 4f 44 44 45 |X */.X.X|METHODDE|
|00003910| 46 20 76 6f 69 64 0a 58 | 74 72 61 63 65 5f 6d 65 |F void.X|trace_me|
|00003920| 73 73 61 67 65 20 28 63 | 6f 6e 73 74 20 63 68 61 |ssage (c|onst cha|
|00003930| 72 20 2a 6d 73 67 74 65 | 78 74 29 0a 58 7b 0a 58 |r *msgte|xt).X{.X|
|00003940| 20 20 66 70 72 69 6e 74 | 66 28 73 74 64 65 72 72 | fprint|f(stderr|
|00003950| 2c 20 6d 73 67 74 65 78 | 74 2c 0a 58 09 20 20 65 |, msgtex|t,.X. e|
|00003960| 6d 65 74 68 6f 64 73 2d | 3e 6d 65 73 73 61 67 65 |methods-|>message|
|00003970| 5f 70 61 72 6d 5b 30 5d | 2c 20 65 6d 65 74 68 6f |_parm[0]|, emetho|
|00003980| 64 73 2d 3e 6d 65 73 73 | 61 67 65 5f 70 61 72 6d |ds->mess|age_parm|
|00003990| 5b 31 5d 2c 0a 58 09 20 | 20 65 6d 65 74 68 6f 64 |[1],.X. | emethod|
|000039a0| 73 2d 3e 6d 65 73 73 61 | 67 65 5f 70 61 72 6d 5b |s->messa|ge_parm[|
|000039b0| 32 5d 2c 20 65 6d 65 74 | 68 6f 64 73 2d 3e 6d 65 |2], emet|hods->me|
|000039c0| 73 73 61 67 65 5f 70 61 | 72 6d 5b 33 5d 2c 0a 58 |ssage_pa|rm[3],.X|
|000039d0| 09 20 20 65 6d 65 74 68 | 6f 64 73 2d 3e 6d 65 73 |. emeth|ods->mes|
|000039e0| 73 61 67 65 5f 70 61 72 | 6d 5b 34 5d 2c 20 65 6d |sage_par|m[4], em|
|000039f0| 65 74 68 6f 64 73 2d 3e | 6d 65 73 73 61 67 65 5f |ethods->|message_|
|00003a00| 70 61 72 6d 5b 35 5d 2c | 0a 58 09 20 20 65 6d 65 |parm[5],|.X. eme|
|00003a10| 74 68 6f 64 73 2d 3e 6d | 65 73 73 61 67 65 5f 70 |thods->m|essage_p|
|00003a20| 61 72 6d 5b 36 5d 2c 20 | 65 6d 65 74 68 6f 64 73 |arm[6], |emethods|
|00003a30| 2d 3e 6d 65 73 73 61 67 | 65 5f 70 61 72 6d 5b 37 |->messag|e_parm[7|
|00003a40| 5d 29 3b 0a 58 20 20 66 | 70 72 69 6e 74 66 28 73 |]);.X f|printf(s|
|00003a50| 74 64 65 72 72 2c 20 22 | 5c 6e 22 29 3b 09 2f 2a |tderr, "|\n");./*|
|00003a60| 20 74 68 65 72 65 20 69 | 73 20 6e 6f 20 5c 6e 20 | there i|s no \n |
|00003a70| 69 6e 20 74 68 65 20 66 | 6f 72 6d 61 74 20 73 74 |in the f|ormat st|
|00003a80| 72 69 6e 67 21 20 2a 2f | 0a 58 7d 0a 58 0a 58 2f |ring! */|.X}.X.X/|
|00003a90| 2a 0a 58 20 2a 20 54 68 | 65 20 65 72 72 6f 72 5f |*.X * Th|e error_|
|00003aa0| 65 78 69 74 28 29 20 72 | 6f 75 74 69 6e 65 20 73 |exit() r|outine s|
|00003ab0| 68 6f 75 6c 64 20 6e 6f | 74 20 72 65 74 75 72 6e |hould no|t return|
|00003ac0| 20 74 6f 20 69 74 73 20 | 63 61 6c 6c 65 72 2e 20 | to its |caller. |
|00003ad0| 20 54 68 65 20 64 65 66 | 61 75 6c 74 0a 58 20 2a | The def|ault.X *|
|00003ae0| 20 72 6f 75 74 69 6e 65 | 20 63 61 6c 6c 73 20 65 | routine| calls e|
|00003af0| 78 69 74 28 29 2c 20 62 | 75 74 20 68 65 72 65 20 |xit(), b|ut here |
|00003b00| 77 65 20 61 73 73 75 6d | 65 20 74 68 61 74 20 77 |we assum|e that w|
|00003b10| 65 20 77 61 6e 74 20 74 | 6f 20 72 65 74 75 72 6e |e want t|o return|
|00003b20| 20 74 6f 0a 58 20 2a 20 | 72 65 61 64 5f 4a 50 45 | to.X * |read_JPE|
|00003b30| 47 5f 66 69 6c 65 2c 20 | 77 68 69 63 68 20 68 61 |G_file, |which ha|
|00003b40| 73 20 73 65 74 20 75 70 | 20 61 20 73 65 74 6a 6d |s set up| a setjm|
|00003b50| 70 20 63 6f 6e 74 65 78 | 74 20 66 6f 72 20 74 68 |p contex|t for th|
|00003b60| 65 20 70 75 72 70 6f 73 | 65 2e 0a 58 20 2a 20 59 |e purpos|e..X * Y|
|00003b70| 6f 75 20 73 68 6f 75 6c | 64 20 6d 61 6b 65 20 73 |ou shoul|d make s|
|00003b80| 75 72 65 20 74 68 61 74 | 20 74 68 65 20 66 72 65 |ure that| the fre|
|00003b90| 65 5f 61 6c 6c 20 6d 65 | 74 68 6f 64 20 69 73 20 |e_all me|thod is |
|00003ba0| 63 61 6c 6c 65 64 2c 20 | 65 69 74 68 65 72 20 77 |called, |either w|
|00003bb0| 69 74 68 69 6e 0a 58 20 | 2a 20 65 72 72 6f 72 5f |ithin.X |* error_|
|00003bc0| 65 78 69 74 20 6f 72 20 | 61 66 74 65 72 20 74 68 |exit or |after th|
|00003bd0| 65 20 72 65 74 75 72 6e | 20 74 6f 20 74 68 65 20 |e return| to the |
|00003be0| 6f 75 74 65 72 2d 6c 65 | 76 65 6c 20 72 6f 75 74 |outer-le|vel rout|
|00003bf0| 69 6e 65 2e 0a 58 20 2a | 2f 0a 58 0a 58 4d 45 54 |ine..X *|/.X.XMET|
|00003c00| 48 4f 44 44 45 46 20 76 | 6f 69 64 0a 58 65 72 72 |HODDEF v|oid.Xerr|
|00003c10| 6f 72 5f 65 78 69 74 20 | 28 63 6f 6e 73 74 20 63 |or_exit |(const c|
|00003c20| 68 61 72 20 2a 6d 73 67 | 74 65 78 74 29 0a 58 7b |har *msg|text).X{|
|00003c30| 0a 58 20 20 74 72 61 63 | 65 5f 6d 65 73 73 61 67 |.X trac|e_messag|
|00003c40| 65 28 6d 73 67 74 65 78 | 74 29 3b 09 2f 2a 20 72 |e(msgtex|t);./* r|
|00003c50| 65 70 6f 72 74 20 74 68 | 65 20 65 72 72 6f 72 20 |eport th|e error |
|00003c60| 6d 65 73 73 61 67 65 20 | 2a 2f 0a 58 20 20 28 2a |message |*/.X (*|
|00003c70| 65 6d 65 74 68 6f 64 73 | 2d 3e 66 72 65 65 5f 61 |emethods|->free_a|
|00003c80| 6c 6c 29 20 28 29 3b 09 | 2f 2a 20 63 6c 65 61 6e |ll) ();.|/* clean|
|00003c90| 20 75 70 20 6d 65 6d 6f | 72 79 20 61 6c 6c 6f 63 | up memo|ry alloc|
|00003ca0| 61 74 69 6f 6e 20 26 20 | 74 65 6d 70 20 66 69 6c |ation & |temp fil|
|00003cb0| 65 73 20 2a 2f 0a 58 20 | 20 6c 6f 6e 67 6a 6d 70 |es */.X | longjmp|
|00003cc0| 28 73 65 74 6a 6d 70 5f | 62 75 66 66 65 72 2c 20 |(setjmp_|buffer, |
|00003cd0| 31 29 3b 09 2f 2a 20 72 | 65 74 75 72 6e 20 63 6f |1);./* r|eturn co|
|00003ce0| 6e 74 72 6f 6c 20 74 6f | 20 6f 75 74 65 72 20 72 |ntrol to| outer r|
|00003cf0| 6f 75 74 69 6e 65 20 2a | 2f 0a 58 7d 0a 58 0a 58 |outine *|/.X}.X.X|
|00003d00| 0a 58 0a 58 2f 2a 0a 58 | 20 2a 20 54 6f 20 61 63 |.X.X/*.X| * To ac|
|00003d10| 63 65 70 74 20 74 68 65 | 20 69 6d 61 67 65 20 64 |cept the| image d|
|00003d20| 61 74 61 20 66 72 6f 6d | 20 64 65 63 6f 6d 70 72 |ata from| decompr|
|00003d30| 65 73 73 69 6f 6e 2c 20 | 79 6f 75 20 6d 75 73 74 |ession, |you must|
|00003d40| 20 64 65 66 69 6e 65 20 | 66 6f 75 72 20 72 6f 75 | define |four rou|
|00003d50| 74 69 6e 65 73 0a 58 20 | 2a 20 6f 75 74 70 75 74 |tines.X |* output|
|00003d60| 5f 69 6e 69 74 2c 20 70 | 75 74 5f 63 6f 6c 6f 72 |_init, p|ut_color|
|00003d70| 5f 6d 61 70 2c 20 70 75 | 74 5f 70 69 78 65 6c 5f |_map, pu|t_pixel_|
|00003d80| 72 6f 77 73 2c 20 61 6e | 64 20 6f 75 74 70 75 74 |rows, an|d output|
|00003d90| 5f 74 65 72 6d 2e 0a 58 | 20 2a 0a 58 20 2a 20 59 |_term..X| *.X * Y|
|00003da0| 6f 75 20 6d 75 73 74 20 | 75 6e 64 65 72 73 74 61 |ou must |understa|
|00003db0| 6e 64 20 74 68 65 20 64 | 69 73 74 69 6e 63 74 69 |nd the d|istincti|
|00003dc0| 6f 6e 20 62 65 74 77 65 | 65 6e 20 66 75 6c 6c 20 |on betwe|en full |
|00003dd0| 63 6f 6c 6f 72 20 6f 75 | 74 70 75 74 20 6d 6f 64 |color ou|tput mod|
|00003de0| 65 0a 58 20 2a 20 28 4e | 20 69 6e 64 65 70 65 6e |e.X * (N| indepen|
|00003df0| 64 65 6e 74 20 63 6f 6c | 6f 72 20 63 6f 6d 70 6f |dent col|or compo|
|00003e00| 6e 65 6e 74 73 29 20 61 | 6e 64 20 63 6f 6c 6f 72 |nents) a|nd color|
|00003e10| 6d 61 70 70 65 64 20 6f | 75 74 70 75 74 20 6d 6f |mapped o|utput mo|
|00003e20| 64 65 20 28 61 20 73 69 | 6e 67 6c 65 0a 58 20 2a |de (a si|ngle.X *|
|00003e30| 20 6f 75 74 70 75 74 20 | 63 6f 6d 70 6f 6e 65 6e | output |componen|
|00003e40| 74 20 72 65 70 72 65 73 | 65 6e 74 69 6e 67 20 61 |t repres|enting a|
|00003e50| 6e 20 69 6e 64 65 78 20 | 69 6e 74 6f 20 61 20 63 |n index |into a c|
|00003e60| 6f 6c 6f 72 20 6d 61 70 | 29 2e 20 20 59 6f 75 20 |olor map|). You |
|00003e70| 73 68 6f 75 6c 64 20 75 | 73 65 0a 58 20 2a 20 63 |should u|se.X * c|
|00003e80| 6f 6c 6f 72 6d 61 70 70 | 65 64 20 6d 6f 64 65 20 |olormapp|ed mode |
|00003e90| 74 6f 20 77 72 69 74 65 | 20 74 6f 20 61 20 63 6f |to write| to a co|
|00003ea0| 6c 6f 72 6d 61 70 70 65 | 64 20 64 69 73 70 6c 61 |lormappe|d displa|
|00003eb0| 79 20 73 63 72 65 65 6e | 20 6f 72 20 6f 75 74 70 |y screen| or outp|
|00003ec0| 75 74 20 66 69 6c 65 2e | 0a 58 20 2a 20 43 6f 6c |ut file.|.X * Col|
|00003ed0| 6f 72 6d 61 70 70 65 64 | 20 6d 6f 64 65 20 69 73 |ormapped| mode is|
|00003ee0| 20 61 6c 73 6f 20 75 73 | 65 66 75 6c 20 66 6f 72 | also us|eful for|
|00003ef0| 20 72 65 64 75 63 69 6e | 67 20 67 72 61 79 73 63 | reducin|g graysc|
|00003f00| 61 6c 65 20 6f 75 74 70 | 75 74 20 74 6f 20 61 20 |ale outp|ut to a |
|00003f10| 73 6d 61 6c 6c 0a 58 20 | 2a 20 6e 75 6d 62 65 72 |small.X |* number|
|00003f20| 20 6f 66 20 67 72 61 79 | 20 6c 65 76 65 6c 73 3a | of gray| levels:|
|00003f30| 20 77 68 65 6e 20 75 73 | 69 6e 67 20 74 68 65 20 | when us|ing the |
|00003f40| 31 2d 70 61 73 73 20 71 | 75 61 6e 74 69 7a 65 72 |1-pass q|uantizer|
|00003f50| 20 6f 6e 20 67 72 61 79 | 73 63 61 6c 65 20 64 61 | on gray|scale da|
|00003f60| 74 61 2c 0a 58 20 2a 20 | 74 68 65 20 63 6f 6c 6f |ta,.X * |the colo|
|00003f70| 72 6d 61 70 20 65 6e 74 | 72 69 65 73 20 77 69 6c |rmap ent|ries wil|
|00003f80| 6c 20 62 65 20 65 76 65 | 6e 6c 79 20 73 70 61 63 |l be eve|nly spac|
|00003f90| 65 64 20 66 72 6f 6d 20 | 30 20 74 6f 20 4d 41 58 |ed from |0 to MAX|
|00003fa0| 5f 4a 53 41 4d 50 4c 45 | 2c 20 73 6f 20 79 6f 75 |_JSAMPLE|, so you|
|00003fb0| 0a 58 20 2a 20 63 61 6e | 20 72 65 67 61 72 64 20 |.X * can| regard |
|00003fc0| 74 68 65 20 69 6e 64 65 | 78 65 73 20 61 72 65 20 |the inde|xes are |
|00003fd0| 64 69 72 65 63 74 6c 79 | 20 72 65 70 72 65 73 65 |directly| represe|
|00003fe0| 6e 74 69 6e 67 20 67 72 | 61 79 20 6c 65 76 65 6c |nting gr|ay level|
|00003ff0| 73 20 61 74 20 72 65 64 | 75 63 65 64 0a 58 20 2a |s at red|uced.X *|
|00004000| 20 70 72 65 63 69 73 69 | 6f 6e 2e 20 20 49 6e 20 | precisi|on. In |
|00004010| 61 6e 79 20 6f 74 68 65 | 72 20 63 61 73 65 2c 20 |any othe|r case, |
|00004020| 79 6f 75 20 73 68 6f 75 | 6c 64 20 6e 6f 74 20 64 |you shou|ld not d|
|00004030| 65 70 65 6e 64 20 6f 6e | 20 74 68 65 20 63 6f 6c |epend on| the col|
|00004040| 6f 72 6d 61 70 0a 58 20 | 2a 20 65 6e 74 72 69 65 |ormap.X |* entrie|
|00004050| 73 20 68 61 76 69 6e 67 | 20 61 6e 79 20 70 61 72 |s having| any par|
|00004060| 74 69 63 75 6c 61 72 20 | 6f 72 64 65 72 2e 0a 58 |ticular |order..X|
|00004070| 20 2a 20 54 6f 20 67 65 | 74 20 63 6f 6c 6f 72 6d | * To ge|t colorm|
|00004080| 61 70 70 65 64 20 6f 75 | 74 70 75 74 2c 20 73 65 |apped ou|tput, se|
|00004090| 74 20 63 69 6e 66 6f 2d | 3e 71 75 61 6e 74 69 7a |t cinfo-|>quantiz|
|000040a0| 65 5f 63 6f 6c 6f 72 73 | 20 74 6f 20 54 52 55 45 |e_colors| to TRUE|
|000040b0| 20 61 6e 64 20 73 65 74 | 0a 58 20 2a 20 63 69 6e | and set|.X * cin|
|000040c0| 66 6f 2d 3e 64 65 73 69 | 72 65 64 5f 6e 75 6d 62 |fo->desi|red_numb|
|000040d0| 65 72 5f 6f 66 5f 63 6f | 6c 6f 72 73 20 74 6f 20 |er_of_co|lors to |
|000040e0| 74 68 65 20 6d 61 78 69 | 6d 75 6d 20 6e 75 6d 62 |the maxi|mum numb|
|000040f0| 65 72 20 6f 66 20 65 6e | 74 72 69 65 73 20 69 6e |er of en|tries in|
|00004100| 20 74 68 65 0a 58 20 2a | 20 63 6f 6c 6f 72 6d 61 | the.X *| colorma|
|00004110| 70 2e 20 20 54 68 69 73 | 20 63 61 6e 20 62 65 20 |p. This| can be |
|00004120| 64 6f 6e 65 20 65 69 74 | 68 65 72 20 69 6e 20 79 |done eit|her in y|
|00004130| 6f 75 72 20 6d 61 69 6e | 20 72 6f 75 74 69 6e 65 |our main| routine|
|00004140| 20 6f 72 20 69 6e 0a 58 | 20 2a 20 64 5f 75 69 5f | or in.X| * d_ui_|
|00004150| 6d 65 74 68 6f 64 5f 73 | 65 6c 65 63 74 69 6f 6e |method_s|election|
|00004160| 2e 20 20 46 6f 72 20 67 | 72 61 79 73 63 61 6c 65 |. For g|rayscale|
|00004170| 20 71 75 61 6e 74 69 7a | 61 74 69 6f 6e 2c 20 61 | quantiz|ation, a|
|00004180| 6c 73 6f 20 73 65 74 0a | 58 20 2a 20 63 69 6e 66 |lso set.|X * cinf|
|00004190| 6f 2d 3e 74 77 6f 5f 70 | 61 73 73 5f 71 75 61 6e |o->two_p|ass_quan|
|000041a0| 74 69 7a 65 20 74 6f 20 | 46 41 4c 53 45 20 74 6f |tize to |FALSE to|
|000041b0| 20 65 6e 73 75 72 65 20 | 74 68 65 20 31 2d 70 61 | ensure |the 1-pa|
|000041c0| 73 73 20 71 75 61 6e 74 | 69 7a 65 72 20 69 73 20 |ss quant|izer is |
|000041d0| 75 73 65 64 0a 58 20 2a | 20 28 70 72 65 73 65 6e |used.X *| (presen|
|000041e0| 74 6c 79 20 74 68 69 73 | 20 69 73 20 74 68 65 20 |tly this| is the |
|000041f0| 64 65 66 61 75 6c 74 2c | 20 62 75 74 20 69 74 20 |default,| but it |
|00004200| 6d 61 79 20 6e 6f 74 20 | 62 65 20 73 6f 20 69 6e |may not |be so in|
|00004210| 20 74 68 65 20 66 75 74 | 75 72 65 29 2e 0a 58 20 | the fut|ure)..X |
|00004220| 2a 0a 58 20 2a 20 54 68 | 65 20 6f 75 74 70 75 74 |*.X * Th|e output|
|00004230| 20 66 69 6c 65 20 77 72 | 69 74 69 6e 67 20 6d 6f | file wr|iting mo|
|00004240| 64 75 6c 65 73 20 28 6a | 77 72 70 70 6d 2e 63 2c |dules (j|wrppm.c,|
|00004250| 20 6a 77 72 67 69 66 2e | 63 2c 20 6a 77 72 74 61 | jwrgif.|c, jwrta|
|00004260| 72 67 61 2e 63 2c 20 65 | 74 63 29 20 6d 61 79 20 |rga.c, e|tc) may |
|00004270| 62 65 0a 58 20 2a 20 75 | 73 65 66 75 6c 20 65 78 |be.X * u|seful ex|
|00004280| 61 6d 70 6c 65 73 20 6f | 66 20 77 68 61 74 20 74 |amples o|f what t|
|00004290| 68 65 73 65 20 72 6f 75 | 74 69 6e 65 73 20 73 68 |hese rou|tines sh|
|000042a0| 6f 75 6c 64 20 61 63 74 | 75 61 6c 6c 79 20 64 6f |ould act|ually do|
|000042b0| 2c 20 61 6c 74 68 6f 75 | 67 68 20 65 61 63 68 20 |, althou|gh each |
|000042c0| 6f 66 0a 58 20 2a 20 74 | 68 65 6d 20 69 73 20 65 |of.X * t|hem is e|
|000042d0| 6e 63 72 75 73 74 65 64 | 20 77 69 74 68 20 61 20 |ncrusted| with a |
|000042e0| 6c 6f 74 20 6f 66 20 73 | 70 65 63 69 61 6c 69 7a |lot of s|pecializ|
|000042f0| 65 64 20 63 6f 64 65 20 | 66 6f 72 20 69 74 73 20 |ed code |for its |
|00004300| 6f 77 6e 20 66 69 6c 65 | 20 66 6f 72 6d 61 74 2e |own file| format.|
|00004310| 0a 58 20 2a 2f 0a 58 0a | 58 0a 58 4d 45 54 48 4f |.X */.X.|X.XMETHO|
|00004320| 44 44 45 46 20 76 6f 69 | 64 0a 58 6f 75 74 70 75 |DDEF voi|d.Xoutpu|
|00004330| 74 5f 69 6e 69 74 20 28 | 64 65 63 6f 6d 70 72 65 |t_init (|decompre|
|00004340| 73 73 5f 69 6e 66 6f 5f | 70 74 72 20 63 69 6e 66 |ss_info_|ptr cinf|
|00004350| 6f 29 0a 58 2f 2a 20 54 | 68 69 73 20 72 6f 75 74 |o).X/* T|his rout|
|00004360| 69 6e 65 20 73 68 6f 75 | 6c 64 20 64 6f 20 61 6e |ine shou|ld do an|
|00004370| 79 20 73 65 74 75 70 20 | 72 65 71 75 69 72 65 64 |y setup |required|
|00004380| 20 2a 2f 0a 58 7b 0a 58 | 20 20 2f 2a 20 54 68 69 | */.X{.X| /* Thi|
|00004390| 73 20 72 6f 75 74 69 6e | 65 20 63 61 6e 20 69 6e |s routin|e can in|
|000043a0| 69 74 69 61 6c 69 7a 65 | 20 66 6f 72 20 6f 75 74 |itialize| for out|
|000043b0| 70 75 74 20 62 61 73 65 | 64 20 6f 6e 20 74 68 65 |put base|d on the|
|000043c0| 20 64 61 74 61 20 70 61 | 73 73 65 64 20 69 6e 20 | data pa|ssed in |
|000043d0| 63 69 6e 66 6f 2e 0a 58 | 20 20 20 2a 20 55 73 65 |cinfo..X| * Use|
|000043e0| 66 75 6c 20 66 69 65 6c | 64 73 20 69 6e 63 6c 75 |ful fiel|ds inclu|
|000043f0| 64 65 3a 0a 58 20 20 20 | 2a 09 69 6d 61 67 65 5f |de:.X |*.image_|
|00004400| 77 69 64 74 68 2c 20 69 | 6d 61 67 65 5f 68 65 69 |width, i|mage_hei|
|00004410| 67 68 74 09 50 72 65 74 | 74 79 20 6f 62 76 69 6f |ght.Pret|ty obvio|
|00004420| 75 73 2c 20 49 20 68 6f | 70 65 2e 0a 58 20 20 20 |us, I ho|pe..X |
|00004430| 2a 09 64 61 74 61 5f 70 | 72 65 63 69 73 69 6f 6e |*.data_p|recision|
|00004440| 09 09 09 62 69 74 73 20 | 70 65 72 20 70 69 78 65 |...bits |per pixe|
|00004450| 6c 20 76 61 6c 75 65 3b | 20 74 79 70 69 63 61 6c |l value;| typical|
|00004460| 6c 79 20 38 2e 0a 58 20 | 20 20 2a 09 6f 75 74 5f |ly 8..X | *.out_|
|00004470| 63 6f 6c 6f 72 5f 73 70 | 61 63 65 09 09 09 6f 75 |color_sp|ace...ou|
|00004480| 74 70 75 74 20 63 6f 6c | 6f 72 73 70 61 63 65 20 |tput col|orspace |
|00004490| 70 72 65 76 69 6f 75 73 | 6c 79 20 72 65 71 75 65 |previous|ly reque|
|000044a0| 73 74 65 64 0a 58 20 20 | 20 2a 09 63 6f 6c 6f 72 |sted.X | *.color|
|000044b0| 5f 6f 75 74 5f 63 6f 6d | 70 73 09 09 09 6e 75 6d |_out_com|ps...num|
|000044c0| 62 65 72 20 6f 66 20 63 | 6f 6c 6f 72 20 63 6f 6d |ber of c|olor com|
|000044d0| 70 6f 6e 65 6e 74 73 20 | 69 6e 20 73 61 6d 65 0a |ponents |in same.|
|000044e0| 58 20 20 20 2a 09 66 69 | 6e 61 6c 5f 6f 75 74 5f |X *.fi|nal_out_|
|000044f0| 63 6f 6d 70 73 09 09 09 | 6e 75 6d 62 65 72 20 6f |comps...|number o|
|00004500| 66 20 63 6f 6d 70 6f 6e | 65 6e 74 73 20 61 63 74 |f compon|ents act|
|00004510| 75 61 6c 6c 79 20 6f 75 | 74 70 75 74 0a 58 20 20 |ually ou|tput.X |
|00004520| 20 2a 20 66 69 6e 61 6c | 5f 6f 75 74 5f 63 6f 6d | * final|_out_com|
|00004530| 70 73 20 69 73 20 31 20 | 69 66 20 71 75 61 6e 74 |ps is 1 |if quant|
|00004540| 69 7a 65 5f 63 6f 6c 6f | 72 73 20 69 73 20 74 72 |ize_colo|rs is tr|
|00004550| 75 65 2c 20 65 6c 73 65 | 20 69 74 20 69 73 20 65 |ue, else| it is e|
|00004560| 71 75 61 6c 20 74 6f 0a | 58 20 20 20 2a 20 63 6f |qual to.|X * co|
|00004570| 6c 6f 72 5f 6f 75 74 5f | 63 6f 6d 70 73 2e 0a 58 |lor_out_|comps..X|
|00004580| 20 20 20 2a 0a 58 20 20 | 20 2a 20 49 66 20 79 6f | *.X | * If yo|
|00004590| 75 20 68 61 76 65 20 72 | 65 71 75 65 73 74 65 64 |u have r|equested|
|000045a0| 20 63 6f 6c 6f 72 20 71 | 75 61 6e 74 69 7a 61 74 | color q|uantizat|
|000045b0| 69 6f 6e 2c 20 74 68 65 | 20 63 6f 6c 6f 72 6d 61 |ion, the| colorma|
|000045c0| 70 20 69 73 20 4e 4f 54 | 20 79 65 74 20 73 65 74 |p is NOT| yet set|
|000045d0| 2e 0a 58 20 20 20 2a 20 | 59 6f 75 20 6d 61 79 20 |..X * |You may |
|000045e0| 77 69 73 68 20 74 6f 20 | 64 65 66 65 72 20 6f 75 |wish to |defer ou|
|000045f0| 74 70 75 74 20 69 6e 69 | 74 69 61 6c 69 7a 61 74 |tput ini|tializat|
|00004600| 69 6f 6e 20 75 6e 74 69 | 6c 20 70 75 74 5f 63 6f |ion unti|l put_co|
|00004610| 6c 6f 72 5f 6d 61 70 20 | 69 73 20 63 61 6c 6c 65 |lor_map |is calle|
|00004620| 64 2e 0a 58 20 20 20 2a | 2f 0a 58 7d 0a 58 0a 58 |d..X *|/.X}.X.X|
|00004630| 0a 58 2f 2a 0a 58 20 2a | 20 54 68 69 73 20 72 6f |.X/*.X *| This ro|
|00004640| 75 74 69 6e 65 20 69 73 | 20 63 61 6c 6c 65 64 20 |utine is| called |
|00004650| 69 66 20 61 6e 64 20 6f | 6e 6c 79 20 69 66 20 79 |if and o|nly if y|
|00004660| 6f 75 20 68 61 76 65 20 | 73 65 74 20 63 69 6e 66 |ou have |set cinf|
|00004670| 6f 2d 3e 71 75 61 6e 74 | 69 7a 65 5f 63 6f 6c 6f |o->quant|ize_colo|
|00004680| 72 73 0a 58 20 2a 20 74 | 6f 20 54 52 55 45 2e 20 |rs.X * t|o TRUE. |
|00004690| 20 49 74 20 69 73 20 67 | 69 76 65 6e 20 74 68 65 | It is g|iven the|
|000046a0| 20 73 65 6c 65 63 74 65 | 64 20 63 6f 6c 6f 72 6d | selecte|d colorm|
|000046b0| 61 70 20 61 6e 64 20 63 | 61 6e 20 63 6f 6d 70 6c |ap and c|an compl|
|000046c0| 65 74 65 20 61 6e 79 20 | 72 65 71 75 69 72 65 64 |ete any |required|
|000046d0| 0a 58 20 2a 20 69 6e 69 | 74 69 61 6c 69 7a 61 74 |.X * ini|tializat|
|000046e0| 69 6f 6e 2e 20 20 54 68 | 69 73 20 63 61 6c 6c 20 |ion. Th|is call |
|000046f0| 77 69 6c 6c 20 6f 63 63 | 75 72 20 61 66 74 65 72 |will occ|ur after|
|00004700| 20 6f 75 74 70 75 74 5f | 69 6e 69 74 20 61 6e 64 | output_|init and|
|00004710| 20 62 65 66 6f 72 65 20 | 61 6e 79 0a 58 20 2a 20 | before |any.X * |
|00004720| 63 61 6c 6c 73 20 74 6f | 20 70 75 74 5f 70 69 78 |calls to| put_pix|
|00004730| 65 6c 5f 72 6f 77 73 2e | 20 20 4e 6f 74 65 20 74 |el_rows.| Note t|
|00004740| 68 61 74 20 74 68 65 20 | 63 6f 6c 6f 72 6d 61 70 |hat the |colormap|
|00004750| 20 70 6f 69 6e 74 65 72 | 20 69 73 20 61 6c 73 6f | pointer| is also|
|00004760| 20 70 6c 61 63 65 64 0a | 58 20 2a 20 69 6e 20 61 | placed.|X * in a|
|00004770| 20 63 69 6e 66 6f 20 66 | 69 65 6c 64 2c 20 77 68 | cinfo f|ield, wh|
|00004780| 65 6e 63 65 20 69 74 20 | 63 61 6e 20 62 65 20 75 |ence it |can be u|
|00004790| 73 65 64 20 62 79 20 70 | 75 74 5f 70 69 78 65 6c |sed by p|ut_pixel|
|000047a0| 5f 72 6f 77 73 20 6f 72 | 20 6f 75 74 70 75 74 5f |_rows or| output_|
|000047b0| 74 65 72 6d 2e 0a 58 20 | 2a 20 6e 75 6d 5f 63 6f |term..X |* num_co|
|000047c0| 6c 6f 72 73 20 77 69 6c | 6c 20 62 65 20 6c 65 73 |lors wil|l be les|
|000047d0| 73 20 74 68 61 6e 20 6f | 72 20 65 71 75 61 6c 20 |s than o|r equal |
|000047e0| 74 6f 20 64 65 73 69 72 | 65 64 5f 6e 75 6d 62 65 |to desir|ed_numbe|
|000047f0| 72 5f 6f 66 5f 63 6f 6c | 6f 72 73 2e 0a 58 20 2a |r_of_col|ors..X *|
|00004800| 0a 58 20 2a 20 54 68 65 | 20 63 6f 6c 6f 72 6d 61 |.X * The| colorma|
|00004810| 70 20 64 61 74 61 20 69 | 73 20 73 75 70 70 6c 69 |p data i|s suppli|
|00004820| 65 64 20 61 73 20 61 20 | 32 2d 44 20 61 72 72 61 |ed as a |2-D arra|
|00004830| 79 20 6f 66 20 4a 53 41 | 4d 50 4c 45 73 2c 20 69 |y of JSA|MPLEs, i|
|00004840| 6e 64 65 78 65 64 20 61 | 73 0a 58 20 2a 09 09 4a |ndexed a|s.X *..J|
|00004850| 53 41 4d 50 4c 45 20 63 | 6f 6c 6f 72 6d 61 70 5b |SAMPLE c|olormap[|
|00004860| 63 6f 6d 70 6f 6e 65 6e | 74 5d 5b 69 6e 64 65 78 |componen|t][index|
|00004870| 76 61 6c 75 65 5d 0a 58 | 20 2a 20 77 68 65 72 65 |value].X| * where|
|00004880| 20 63 6f 6d 70 6f 6e 65 | 6e 74 20 72 75 6e 73 20 | compone|nt runs |
|00004890| 66 72 6f 6d 20 30 20 74 | 6f 20 63 69 6e 66 6f 2d |from 0 t|o cinfo-|
|000048a0| 3e 63 6f 6c 6f 72 5f 6f | 75 74 5f 63 6f 6d 70 73 |>color_o|ut_comps|
|000048b0| 2d 31 2c 20 61 6e 64 20 | 69 6e 64 65 78 76 61 6c |-1, and |indexval|
|000048c0| 75 65 0a 58 20 2a 20 72 | 75 6e 73 20 66 72 6f 6d |ue.X * r|uns from|
|000048d0| 20 30 20 74 6f 20 6e 75 | 6d 5f 63 6f 6c 6f 72 73 | 0 to nu|m_colors|
|000048e0| 2d 31 2e 20 20 4e 6f 74 | 65 20 74 68 61 74 20 74 |-1. Not|e that t|
|000048f0| 68 69 73 20 69 73 20 61 | 63 74 75 61 6c 6c 79 20 |his is a|ctually |
|00004900| 61 6e 20 61 72 72 61 79 | 20 6f 66 0a 58 20 2a 20 |an array| of.X * |
|00004910| 70 6f 69 6e 74 65 72 73 | 20 74 6f 20 61 72 72 61 |pointers| to arra|
|00004920| 79 73 20 72 61 74 68 65 | 72 20 74 68 61 6e 20 61 |ys rathe|r than a|
|00004930| 20 74 72 75 65 20 32 44 | 20 61 72 72 61 79 2c 20 | true 2D| array, |
|00004940| 73 69 6e 63 65 20 43 20 | 64 6f 65 73 20 6e 6f 74 |since C |does not|
|00004950| 20 73 75 70 70 6f 72 74 | 0a 58 20 2a 20 76 61 72 | support|.X * var|
|00004960| 69 61 62 6c 65 2d 73 69 | 7a 65 20 6d 75 6c 74 69 |iable-si|ze multi|
|00004970| 64 69 6d 65 6e 73 69 6f | 6e 61 6c 20 61 72 72 61 |dimensio|nal arra|
|00004980| 79 73 2e 0a 58 20 2a 20 | 4a 53 41 4d 50 4c 45 20 |ys..X * |JSAMPLE |
|00004990| 69 73 20 74 79 70 69 63 | 61 6c 6c 79 20 74 79 70 |is typic|ally typ|
|000049a0| 65 64 65 66 27 64 20 61 | 73 20 22 75 6e 73 69 67 |edef'd a|s "unsig|
|000049b0| 6e 65 64 20 63 68 61 72 | 22 2e 20 20 49 66 20 79 |ned char|". If y|
|000049c0| 6f 75 20 77 61 6e 74 20 | 79 6f 75 72 20 63 6f 64 |ou want |your cod|
|000049d0| 65 0a 58 20 2a 20 74 6f | 20 62 65 20 61 73 20 70 |e.X * to| be as p|
|000049e0| 6f 72 74 61 62 6c 65 20 | 61 73 20 74 68 65 20 4a |ortable |as the J|
|000049f0| 50 45 47 20 63 6f 64 65 | 20 70 72 6f 70 65 72 2c |PEG code| proper,|
|00004a00| 20 79 6f 75 20 73 68 6f | 75 6c 64 20 61 6c 77 61 | you sho|uld alwa|
|00004a10| 79 73 20 61 63 63 65 73 | 73 20 4a 53 41 4d 50 4c |ys acces|s JSAMPL|
|00004a20| 45 0a 58 20 2a 20 76 61 | 6c 75 65 73 20 77 69 74 |E.X * va|lues wit|
|00004a30| 68 20 74 68 65 20 47 45 | 54 4a 53 41 4d 50 4c 45 |h the GE|TJSAMPLE|
|00004a40| 28 29 20 6d 61 63 72 6f | 2c 20 77 68 69 63 68 20 |() macro|, which |
|00004a50| 77 69 6c 6c 20 64 6f 20 | 74 68 65 20 72 69 67 68 |will do |the righ|
|00004a60| 74 20 74 68 69 6e 67 20 | 69 66 20 74 68 65 0a 58 |t thing |if the.X|
|00004a70| 20 2a 20 6d 61 63 68 69 | 6e 65 20 68 61 73 20 6f | * machi|ne has o|
|00004a80| 6e 6c 79 20 73 69 67 6e | 65 64 20 63 68 61 72 73 |nly sign|ed chars|
|00004a90| 2e 0a 58 20 2a 2f 0a 58 | 0a 58 4d 45 54 48 4f 44 |..X */.X|.XMETHOD|
|00004aa0| 44 45 46 20 76 6f 69 64 | 0a 58 70 75 74 5f 63 6f |DEF void|.Xput_co|
|00004ab0| 6c 6f 72 5f 6d 61 70 20 | 28 64 65 63 6f 6d 70 72 |lor_map |(decompr|
|00004ac0| 65 73 73 5f 69 6e 66 6f | 5f 70 74 72 20 63 69 6e |ess_info|_ptr cin|
|00004ad0| 66 6f 2c 20 69 6e 74 20 | 6e 75 6d 5f 63 6f 6c 6f |fo, int |num_colo|
|00004ae0| 72 73 2c 20 4a 53 41 4d | 50 41 52 52 41 59 20 63 |rs, JSAM|PARRAY c|
|00004af0| 6f 6c 6f 72 6d 61 70 29 | 0a 58 2f 2a 20 57 72 69 |olormap)|.X/* Wri|
|00004b00| 74 65 20 74 68 65 20 63 | 6f 6c 6f 72 20 6d 61 70 |te the c|olor map|
|00004b10| 20 2a 2f 0a 58 7b 0a 58 | 20 20 2f 2a 20 59 6f 75 | */.X{.X| /* You|
|00004b20| 20 6e 65 65 64 20 6e 6f | 74 20 70 72 6f 76 69 64 | need no|t provid|
|00004b30| 65 20 74 68 69 73 20 72 | 6f 75 74 69 6e 65 20 69 |e this r|outine i|
|00004b40| 66 20 79 6f 75 20 61 6c | 77 61 79 73 20 73 65 74 |f you al|ways set|
|00004b50| 20 63 69 6e 66 6f 2d 3e | 71 75 61 6e 74 69 7a 65 | cinfo->|quantize|
|00004b60| 5f 63 6f 6c 6f 72 73 0a | 58 20 20 20 2a 20 46 41 |_colors.|X * FA|
|00004b70| 4c 53 45 3b 20 62 75 74 | 20 61 20 73 61 66 65 72 |LSE; but| a safer|
|00004b80| 20 70 72 61 63 74 69 63 | 65 20 69 73 20 74 6f 20 | practic|e is to |
|00004b90| 70 72 6f 76 69 64 65 20 | 69 74 20 61 6e 64 20 68 |provide |it and h|
|00004ba0| 61 76 65 20 69 74 20 6a | 75 73 74 20 70 72 69 6e |ave it j|ust prin|
|00004bb0| 74 20 61 6e 0a 58 20 20 | 20 2a 20 65 72 72 6f 72 |t an.X | * error|
|00004bc0| 20 6d 65 73 73 61 67 65 | 2c 20 6c 69 6b 65 20 74 | message|, like t|
|00004bd0| 68 69 73 3a 0a 58 20 20 | 20 2a 2f 0a 58 20 20 66 |his:.X | */.X f|
|00004be0| 70 72 69 6e 74 66 28 73 | 74 64 65 72 72 2c 20 22 |printf(s|tderr, "|
|00004bf0| 70 75 74 5f 63 6f 6c 6f | 72 5f 6d 61 70 20 63 61 |put_colo|r_map ca|
|00004c00| 6c 6c 65 64 3a 20 74 68 | 65 72 65 27 73 20 61 20 |lled: th|ere's a |
|00004c10| 62 75 67 20 68 65 72 65 | 20 73 6f 6d 65 77 68 65 |bug here| somewhe|
|00004c20| 72 65 21 5c 6e 22 29 3b | 0a 58 7d 0a 58 0a 58 0a |re!\n");|.X}.X.X.|
|00004c30| 58 2f 2a 0a 58 20 2a 20 | 54 68 69 73 20 66 75 6e |X/*.X * |This fun|
|00004c40| 63 74 69 6f 6e 20 69 73 | 20 63 61 6c 6c 65 64 20 |ction is| called |
|00004c50| 72 65 70 65 61 74 65 64 | 6c 79 2c 20 77 69 74 68 |repeated|ly, with|
|00004c60| 20 61 20 66 65 77 20 6d | 6f 72 65 20 72 6f 77 73 | a few m|ore rows|
|00004c70| 20 6f 66 20 70 69 78 65 | 6c 73 20 73 75 70 70 6c | of pixe|ls suppl|
|00004c80| 69 65 64 0a 58 20 2a 20 | 6f 6e 20 65 61 63 68 20 |ied.X * |on each |
|00004c90| 63 61 6c 6c 2e 20 20 57 | 69 74 68 20 74 68 65 20 |call. W|ith the |
|00004ca0| 63 75 72 72 65 6e 74 20 | 4a 50 45 47 20 63 6f 64 |current |JPEG cod|
|00004cb0| 65 2c 20 73 6f 6d 65 20 | 6d 75 6c 74 69 70 6c 65 |e, some |multiple|
|00004cc0| 20 6f 66 20 38 20 72 6f | 77 73 20 77 69 6c 6c 20 | of 8 ro|ws will |
|00004cd0| 62 65 0a 58 20 2a 20 70 | 61 73 73 65 64 20 6f 6e |be.X * p|assed on|
|00004ce0| 20 65 61 63 68 20 63 61 | 6c 6c 20 65 78 63 65 70 | each ca|ll excep|
|00004cf0| 74 20 74 68 65 20 6c 61 | 73 74 2c 20 62 75 74 20 |t the la|st, but |
|00004d00| 69 74 20 69 73 20 65 78 | 74 72 65 6d 65 6c 79 20 |it is ex|tremely |
|00004d10| 62 61 64 20 66 6f 72 6d | 20 74 6f 20 64 65 70 65 |bad form| to depe|
|00004d20| 6e 64 0a 58 20 2a 20 6f | 6e 20 74 68 69 73 2e 20 |nd.X * o|n this. |
|00004d30| 20 59 6f 75 20 43 41 4e | 20 61 73 73 75 6d 65 20 | You CAN| assume |
|00004d40| 6e 75 6d 5f 72 6f 77 73 | 20 3e 20 30 2e 0a 58 20 |num_rows| > 0..X |
|00004d50| 2a 20 54 68 65 20 64 61 | 74 61 20 69 73 20 73 75 |* The da|ta is su|
|00004d60| 70 70 6c 69 65 64 20 69 | 6e 20 74 6f 70 2d 74 6f |pplied i|n top-to|
|00004d70| 2d 62 6f 74 74 6f 6d 20 | 72 6f 77 20 6f 72 64 65 |-bottom |row orde|
|00004d80| 72 20 28 74 68 65 20 73 | 74 61 6e 64 61 72 64 20 |r (the s|tandard |
|00004d90| 6f 72 64 65 72 20 77 69 | 74 68 69 6e 0a 58 20 2a |order wi|thin.X *|
|00004da0| 20 61 20 4a 50 45 47 20 | 66 69 6c 65 29 2e 20 20 | a JPEG |file). |
|00004db0| 49 66 20 79 6f 75 20 63 | 61 6e 6e 6f 74 20 72 65 |If you c|annot re|
|00004dc0| 61 64 69 6c 79 20 75 73 | 65 20 74 68 65 20 64 61 |adily us|e the da|
|00004dd0| 74 61 20 69 6e 20 74 68 | 61 74 20 6f 72 64 65 72 |ta in th|at order|
|00004de0| 2c 20 79 6f 75 27 6c 6c | 0a 58 20 2a 20 6e 65 65 |, you'll|.X * nee|
|00004df0| 64 20 61 6e 20 69 6e 74 | 65 72 6d 65 64 69 61 74 |d an int|ermediat|
|00004e00| 65 20 61 72 72 61 79 20 | 74 6f 20 68 6f 6c 64 20 |e array |to hold |
|00004e10| 74 68 65 20 69 6d 61 67 | 65 2e 20 20 53 65 65 20 |the imag|e. See |
|00004e20| 6a 77 72 72 6c 65 2e 63 | 20 66 6f 72 20 61 6e 20 |jwrrle.c| for an |
|00004e30| 65 78 61 6d 70 6c 65 0a | 58 20 2a 20 6f 66 20 6f |example.|X * of o|
|00004e40| 75 74 70 75 74 74 69 6e | 67 20 64 61 74 61 20 69 |utputtin|g data i|
|00004e50| 6e 20 62 6f 74 74 6f 6d | 2d 74 6f 2d 74 6f 70 20 |n bottom|-to-top |
|00004e60| 6f 72 64 65 72 2e 0a 58 | 20 2a 0a 58 20 2a 20 54 |order..X| *.X * T|
|00004e70| 68 65 20 64 61 74 61 20 | 69 73 20 73 75 70 70 6c |he data |is suppl|
|00004e80| 69 65 64 20 61 73 20 61 | 20 33 2d 44 20 61 72 72 |ied as a| 3-D arr|
|00004e90| 61 79 20 6f 66 20 4a 53 | 41 4d 50 4c 45 73 2c 20 |ay of JS|AMPLEs, |
|00004ea0| 69 6e 64 65 78 65 64 20 | 61 73 0a 58 20 2a 09 09 |indexed |as.X *..|
|00004eb0| 4a 53 41 4d 50 4c 45 20 | 70 69 78 65 6c 5f 64 61 |JSAMPLE |pixel_da|
|00004ec0| 74 61 5b 63 6f 6d 70 6f | 6e 65 6e 74 5d 5b 72 6f |ta[compo|nent][ro|
|00004ed0| 77 5d 5b 63 6f 6c 75 6d | 6e 5d 0a 58 20 2a 20 77 |w][colum|n].X * w|
|00004ee0| 68 65 72 65 20 63 6f 6d | 70 6f 6e 65 6e 74 20 72 |here com|ponent r|
|00004ef0| 75 6e 73 20 66 72 6f 6d | 20 30 20 74 6f 20 63 69 |uns from| 0 to ci|
|00004f00| 6e 66 6f 2d 3e 66 69 6e | 61 6c 5f 6f 75 74 5f 63 |nfo->fin|al_out_c|
|00004f10| 6f 6d 70 73 2d 31 2c 20 | 72 6f 77 20 72 75 6e 73 |omps-1, |row runs|
|00004f20| 20 66 72 6f 6d 20 30 20 | 74 6f 0a 58 20 2a 20 6e | from 0 |to.X * n|
|00004f30| 75 6d 5f 72 6f 77 73 2d | 31 2c 20 61 6e 64 20 63 |um_rows-|1, and c|
|00004f40| 6f 6c 75 6d 6e 20 72 75 | 6e 73 20 66 72 6f 6d 20 |olumn ru|ns from |
|00004f50| 30 20 74 6f 20 63 69 6e | 66 6f 2d 3e 69 6d 61 67 |0 to cin|fo->imag|
|00004f60| 65 5f 77 69 64 74 68 2d | 31 20 28 63 6f 6c 75 6d |e_width-|1 (colum|
|00004f70| 6e 20 30 20 69 73 0a 58 | 20 2a 20 6c 65 66 74 20 |n 0 is.X| * left |
|00004f80| 65 64 67 65 20 6f 66 20 | 69 6d 61 67 65 29 2e 20 |edge of |image). |
|00004f90| 20 4e 6f 74 65 20 74 68 | 61 74 20 74 68 69 73 20 | Note th|at this |
|00004fa0| 69 73 20 61 63 74 75 61 | 6c 6c 79 20 61 6e 20 61 |is actua|lly an a|
|00004fb0| 72 72 61 79 20 6f 66 20 | 70 6f 69 6e 74 65 72 73 |rray of |pointers|
|00004fc0| 20 74 6f 0a 58 20 2a 20 | 70 6f 69 6e 74 65 72 73 | to.X * |pointers|
|00004fd0| 20 74 6f 20 61 72 72 61 | 79 73 20 72 61 74 68 65 | to arra|ys rathe|
|00004fe0| 72 20 74 68 61 6e 20 61 | 20 74 72 75 65 20 33 44 |r than a| true 3D|
|00004ff0| 20 61 72 72 61 79 2c 20 | 73 69 6e 63 65 20 43 20 | array, |since C |
|00005000| 64 6f 65 73 20 6e 6f 74 | 20 73 75 70 70 6f 72 74 |does not| support|
|00005010| 0a 58 20 2a 20 76 61 72 | 69 61 62 6c 65 2d 73 69 |.X * var|iable-si|
|00005020| 7a 65 20 6d 75 6c 74 69 | 64 69 6d 65 6e 73 69 6f |ze multi|dimensio|
|00005030| 6e 61 6c 20 61 72 72 61 | 79 73 2e 0a 58 20 2a 20 |nal arra|ys..X * |
|00005040| 4a 53 41 4d 50 4c 45 20 | 69 73 20 74 79 70 69 63 |JSAMPLE |is typic|
|00005050| 61 6c 6c 79 20 74 79 70 | 65 64 65 66 27 64 20 61 |ally typ|edef'd a|
|00005060| 73 20 22 75 6e 73 69 67 | 6e 65 64 20 63 68 61 72 |s "unsig|ned char|
|00005070| 22 2e 20 20 49 66 20 79 | 6f 75 20 77 61 6e 74 20 |". If y|ou want |
|00005080| 79 6f 75 72 20 63 6f 64 | 65 0a 58 20 2a 20 74 6f |your cod|e.X * to|
|00005090| 20 62 65 20 61 73 20 70 | 6f 72 74 61 62 6c 65 20 | be as p|ortable |
|000050a0| 61 73 20 74 68 65 20 4a | 50 45 47 20 63 6f 64 65 |as the J|PEG code|
|000050b0| 20 70 72 6f 70 65 72 2c | 20 79 6f 75 20 73 68 6f | proper,| you sho|
|000050c0| 75 6c 64 20 61 6c 77 61 | 79 73 20 61 63 63 65 73 |uld alwa|ys acces|
|000050d0| 73 20 4a 53 41 4d 50 4c | 45 0a 58 20 2a 20 76 61 |s JSAMPL|E.X * va|
|000050e0| 6c 75 65 73 20 77 69 74 | 68 20 74 68 65 20 47 45 |lues wit|h the GE|
|000050f0| 54 4a 53 41 4d 50 4c 45 | 28 29 20 6d 61 63 72 6f |TJSAMPLE|() macro|
|00005100| 2c 20 77 68 69 63 68 20 | 77 69 6c 6c 20 64 6f 20 |, which |will do |
|00005110| 74 68 65 20 72 69 67 68 | 74 20 74 68 69 6e 67 20 |the righ|t thing |
|00005120| 69 66 20 74 68 65 0a 58 | 20 2a 20 6d 61 63 68 69 |if the.X| * machi|
|00005130| 6e 65 20 68 61 73 20 6f | 6e 6c 79 20 73 69 67 6e |ne has o|nly sign|
|00005140| 65 64 20 63 68 61 72 73 | 2e 0a 58 20 2a 0a 58 20 |ed chars|..X *.X |
|00005150| 2a 20 49 66 20 71 75 61 | 6e 74 69 7a 65 5f 63 6f |* If qua|ntize_co|
|00005160| 6c 6f 72 73 20 69 73 20 | 74 72 75 65 2c 20 74 68 |lors is |true, th|
|00005170| 65 6e 20 74 68 65 72 65 | 20 69 73 20 6f 6e 6c 79 |en there| is only|
|00005180| 20 6f 6e 65 20 63 6f 6d | 70 6f 6e 65 6e 74 2c 20 | one com|ponent, |
|00005190| 61 6e 64 20 69 74 73 20 | 76 61 6c 75 65 73 0a 58 |and its |values.X|
|000051a0| 20 2a 20 61 72 65 20 69 | 6e 64 65 78 65 73 20 69 | * are i|ndexes i|
|000051b0| 6e 74 6f 20 74 68 65 20 | 70 72 65 76 69 6f 75 73 |nto the |previous|
|000051c0| 6c 79 20 73 75 70 70 6c | 69 65 64 20 63 6f 6c 6f |ly suppl|ied colo|
|000051d0| 72 6d 61 70 2e 20 20 4f | 74 68 65 72 77 69 73 65 |rmap. O|therwise|
|000051e0| 20 74 68 65 20 76 61 6c | 75 65 73 0a 58 20 2a 20 | the val|ues.X * |
|000051f0| 61 72 65 20 61 63 74 75 | 61 6c 20 64 61 74 61 20 |are actu|al data |
|00005200| 69 6e 20 79 6f 75 72 20 | 73 65 6c 65 63 74 65 64 |in your |selected|
|00005210| 20 6f 75 74 70 75 74 20 | 63 6f 6c 6f 72 73 70 61 | output |colorspa|
|00005220| 63 65 2e 0a 58 20 2a 2f | 0a 58 0a 58 0a 58 4d 45 |ce..X */|.X.X.XME|
|00005230| 54 48 4f 44 44 45 46 20 | 76 6f 69 64 0a 58 70 75 |THODDEF |void.Xpu|
|00005240| 74 5f 70 69 78 65 6c 5f | 72 6f 77 73 20 28 64 65 |t_pixel_|rows (de|
|00005250| 63 6f 6d 70 72 65 73 73 | 5f 69 6e 66 6f 5f 70 74 |compress|_info_pt|
|00005260| 72 20 63 69 6e 66 6f 2c | 20 69 6e 74 20 6e 75 6d |r cinfo,| int num|
|00005270| 5f 72 6f 77 73 2c 20 4a | 53 41 4d 50 49 4d 41 47 |_rows, J|SAMPIMAG|
|00005280| 45 20 70 69 78 65 6c 5f | 64 61 74 61 29 0a 58 2f |E pixel_|data).X/|
|00005290| 2a 20 57 72 69 74 65 20 | 73 6f 6d 65 20 72 6f 77 |* Write |some row|
|000052a0| 73 20 6f 66 20 6f 75 74 | 70 75 74 20 64 61 74 61 |s of out|put data|
|000052b0| 20 2a 2f 0a 58 7b 0a 58 | 20 20 2f 2a 20 54 68 69 | */.X{.X| /* Thi|
|000052c0| 73 20 65 78 61 6d 70 6c | 65 20 73 68 6f 77 73 20 |s exampl|e shows |
|000052d0| 68 6f 77 20 79 6f 75 20 | 6d 69 67 68 74 20 77 72 |how you |might wr|
|000052e0| 69 74 65 20 66 75 6c 6c | 2d 63 6f 6c 6f 72 20 52 |ite full|-color R|
|000052f0| 47 42 20 64 61 74 61 20 | 28 33 20 63 6f 6d 70 6f |GB data |(3 compo|
|00005300| 6e 65 6e 74 73 29 0a 58 | 20 20 20 2a 20 74 6f 20 |nents).X| * to |
|00005310| 61 6e 20 6f 75 74 70 75 | 74 20 66 69 6c 65 20 69 |an outpu|t file i|
|00005320| 6e 20 77 68 69 63 68 20 | 74 68 65 20 64 61 74 61 |n which |the data|
|00005330| 20 69 73 20 73 74 6f 72 | 65 64 20 33 20 62 79 74 | is stor|ed 3 byt|
|00005340| 65 73 20 70 65 72 20 70 | 69 78 65 6c 2e 0a 58 20 |es per p|ixel..X |
|00005350| 20 20 2a 2f 0a 58 20 20 | 72 65 67 69 73 74 65 72 | */.X |register|
|00005360| 20 46 49 4c 45 20 2a 20 | 6f 75 74 66 69 6c 65 20 | FILE * |outfile |
|00005370| 3d 20 63 69 6e 66 6f 2d | 3e 6f 75 74 70 75 74 5f |= cinfo-|>output_|
|00005380| 66 69 6c 65 3b 0a 58 20 | 20 72 65 67 69 73 74 65 |file;.X | registe|
|00005390| 72 20 4a 53 41 4d 50 52 | 4f 57 20 70 74 72 30 2c |r JSAMPR|OW ptr0,|
|000053a0| 20 70 74 72 31 2c 20 70 | 74 72 32 3b 0a 58 20 20 | ptr1, p|tr2;.X |
|000053b0| 72 65 67 69 73 74 65 72 | 20 6c 6f 6e 67 20 63 6f |register| long co|
|000053c0| 6c 3b 0a 58 20 20 72 65 | 67 69 73 74 65 72 20 69 |l;.X re|gister i|
|000053d0| 6e 74 20 72 6f 77 3b 0a | 58 20 20 0a 58 20 20 66 |nt row;.|X .X f|
|000053e0| 6f 72 20 28 72 6f 77 20 | 3d 20 30 3b 20 72 6f 77 |or (row |= 0; row|
|000053f0| 20 3c 20 6e 75 6d 5f 72 | 6f 77 73 3b 20 72 6f 77 | < num_r|ows; row|
|00005400| 2b 2b 29 20 7b 0a 58 20 | 20 20 20 70 74 72 30 20 |++) {.X | ptr0 |
|00005410| 3d 20 70 69 78 65 6c 5f | 64 61 74 61 5b 30 5d 5b |= pixel_|data[0][|
|00005420| 72 6f 77 5d 3b 0a 58 20 | 20 20 20 70 74 72 31 20 |row];.X | ptr1 |
|00005430| 3d 20 70 69 78 65 6c 5f | 64 61 74 61 5b 31 5d 5b |= pixel_|data[1][|
|00005440| 72 6f 77 5d 3b 0a 58 20 | 20 20 20 70 74 72 32 20 |row];.X | ptr2 |
|00005450| 3d 20 70 69 78 65 6c 5f | 64 61 74 61 5b 32 5d 5b |= pixel_|data[2][|
|00005460| 72 6f 77 5d 3b 0a 58 20 | 20 20 20 66 6f 72 20 28 |row];.X | for (|
|00005470| 63 6f 6c 20 3d 20 30 3b | 20 63 6f 6c 20 3c 20 63 |col = 0;| col < c|
|00005480| 69 6e 66 6f 2d 3e 69 6d | 61 67 65 5f 77 69 64 74 |info->im|age_widt|
|00005490| 68 3b 20 63 6f 6c 2b 2b | 29 20 7b 0a 58 20 20 20 |h; col++|) {.X |
|000054a0| 20 20 20 70 75 74 63 28 | 47 45 54 4a 53 41 4d 50 | putc(|GETJSAMP|
|000054b0| 4c 45 28 2a 70 74 72 30 | 29 2c 20 6f 75 74 66 69 |LE(*ptr0|), outfi|
|000054c0| 6c 65 29 3b 09 2f 2a 20 | 72 65 64 20 2a 2f 0a 58 |le);./* |red */.X|
|000054d0| 20 20 20 20 20 20 70 74 | 72 30 2b 2b 3b 0a 58 20 | pt|r0++;.X |
|000054e0| 20 20 20 20 20 70 75 74 | 63 28 47 45 54 4a 53 41 | put|c(GETJSA|
|000054f0| 4d 50 4c 45 28 2a 70 74 | 72 31 29 2c 20 6f 75 74 |MPLE(*pt|r1), out|
|00005500| 66 69 6c 65 29 3b 09 2f | 2a 20 67 72 65 65 6e 20 |file);./|* green |
|00005510| 2a 2f 0a 58 20 20 20 20 | 20 20 70 74 72 31 2b 2b |*/.X | ptr1++|
|00005520| 3b 0a 58 20 20 20 20 20 | 20 70 75 74 63 28 47 45 |;.X | putc(GE|
|00005530| 54 4a 53 41 4d 50 4c 45 | 28 2a 70 74 72 32 29 2c |TJSAMPLE|(*ptr2),|
|00005540| 20 6f 75 74 66 69 6c 65 | 29 3b 09 2f 2a 20 62 6c | outfile|);./* bl|
|00005550| 75 65 20 2a 2f 0a 58 20 | 20 20 20 20 20 70 74 72 |ue */.X | ptr|
|00005560| 32 2b 2b 3b 0a 58 20 20 | 20 20 7d 0a 58 20 20 7d |2++;.X | }.X }|
|00005570| 0a 58 7d 0a 58 0a 58 0a | 58 4d 45 54 48 4f 44 44 |.X}.X.X.|XMETHODD|
|00005580| 45 46 20 76 6f 69 64 0a | 58 6f 75 74 70 75 74 5f |EF void.|Xoutput_|
|00005590| 74 65 72 6d 20 28 64 65 | 63 6f 6d 70 72 65 73 73 |term (de|compress|
|000055a0| 5f 69 6e 66 6f 5f 70 74 | 72 20 63 69 6e 66 6f 29 |_info_pt|r cinfo)|
|000055b0| 0a 58 2f 2a 20 46 69 6e | 69 73 68 20 75 70 20 61 |.X/* Fin|ish up a|
|000055c0| 74 20 74 68 65 20 65 6e | 64 20 6f 66 20 74 68 65 |t the en|d of the|
|000055d0| 20 6f 75 74 70 75 74 20 | 2a 2f 0a 58 7b 0a 58 20 | output |*/.X{.X |
|000055e0| 20 2f 2a 20 54 68 69 73 | 20 74 65 72 6d 69 6e 61 | /* This| termina|
|000055f0| 74 69 6f 6e 20 72 6f 75 | 74 69 6e 65 20 6d 61 79 |tion rou|tine may|
|00005600| 20 6e 6f 74 20 6e 65 65 | 64 20 74 6f 20 64 6f 20 | not nee|d to do |
|00005610| 61 6e 79 74 68 69 6e 67 | 2e 20 2a 2f 0a 58 20 20 |anything|. */.X |
|00005620| 2f 2a 20 4e 6f 74 65 20 | 74 68 61 74 20 74 68 65 |/* Note |that the|
|00005630| 20 4a 50 45 47 20 63 6f | 64 65 20 77 69 6c 6c 20 | JPEG co|de will |
|00005640| 6f 6e 6c 79 20 63 61 6c | 6c 20 69 74 20 64 75 72 |only cal|l it dur|
|00005650| 69 6e 67 20 73 75 63 63 | 65 73 73 66 75 6c 20 65 |ing succ|essful e|
|00005660| 78 69 74 3b 20 2a 2f 0a | 58 20 20 2f 2a 20 69 66 |xit; */.|X /* if|
|00005670| 20 79 6f 75 20 77 61 6e | 74 20 69 74 20 63 61 6c | you wan|t it cal|
|00005680| 6c 65 64 20 64 75 72 69 | 6e 67 20 65 72 72 6f 72 |led duri|ng error|
|00005690| 20 65 78 69 74 2c 20 79 | 6f 75 20 67 6f 74 74 61 | exit, y|ou gotta|
|000056a0| 20 64 6f 20 74 68 61 74 | 20 79 6f 75 72 73 65 6c | do that| yoursel|
|000056b0| 66 2e 20 2a 2f 0a 58 7d | 0a 58 0a 58 0a 58 2f 2a |f. */.X}|.X.X.X/*|
|000056c0| 0a 58 20 2a 20 54 68 61 | 74 27 73 20 69 74 20 66 |.X * Tha|t's it f|
|000056d0| 6f 72 20 74 68 65 20 72 | 6f 75 74 69 6e 65 73 20 |or the r|outines |
|000056e0| 74 68 61 74 20 64 65 61 | 6c 20 77 69 74 68 20 77 |that dea|l with w|
|000056f0| 72 69 74 69 6e 67 20 74 | 68 65 20 6f 75 74 70 75 |riting t|he outpu|
|00005700| 74 20 69 6d 61 67 65 2e | 0a 58 20 2a 20 4e 6f 77 |t image.|.X * Now|
|00005710| 20 77 65 20 68 61 76 65 | 20 6f 76 65 72 61 6c 6c | we have| overall|
|00005720| 20 63 6f 6e 74 72 6f 6c | 20 61 6e 64 20 70 61 72 | control| and par|
|00005730| 61 6d 65 74 65 72 20 73 | 65 6c 65 63 74 69 6f 6e |ameter s|election|
|00005740| 20 72 6f 75 74 69 6e 65 | 73 2e 0a 58 20 2a 2f 0a | routine|s..X */.|
|00005750| 58 0a 58 0a 58 2f 2a 0a | 58 20 2a 20 54 68 69 73 |X.X.X/*.|X * This|
|00005760| 20 72 6f 75 74 69 6e 65 | 20 67 65 74 73 20 63 6f | routine| gets co|
|00005770| 6e 74 72 6f 6c 20 61 66 | 74 65 72 20 74 68 65 20 |ntrol af|ter the |
|00005780| 4a 50 45 47 20 66 69 6c | 65 20 68 65 61 64 65 72 |JPEG fil|e header|
|00005790| 20 68 61 73 20 62 65 65 | 6e 20 72 65 61 64 3b 0a | has bee|n read;.|
|000057a0| 58 20 2a 20 61 74 20 74 | 68 69 73 20 70 6f 69 6e |X * at t|his poin|
|000057b0| 74 20 74 68 65 20 69 6d | 61 67 65 20 73 69 7a 65 |t the im|age size|
|000057c0| 20 61 6e 64 20 63 6f 6c | 6f 72 73 70 61 63 65 20 | and col|orspace |
|000057d0| 61 72 65 20 6b 6e 6f 77 | 6e 2e 0a 58 20 2a 20 54 |are know|n..X * T|
|000057e0| 68 65 20 72 6f 75 74 69 | 6e 65 20 6d 75 73 74 20 |he routi|ne must |
|000057f0| 64 65 74 65 72 6d 69 6e | 65 20 77 68 61 74 20 6f |determin|e what o|
|00005800| 75 74 70 75 74 20 72 6f | 75 74 69 6e 65 73 20 61 |utput ro|utines a|
|00005810| 72 65 20 74 6f 20 62 65 | 20 75 73 65 64 2c 20 61 |re to be| used, a|
|00005820| 6e 64 20 6d 61 6b 65 0a | 58 20 2a 20 61 6e 79 20 |nd make.|X * any |
|00005830| 64 65 63 6f 6d 70 72 65 | 73 73 69 6f 6e 20 70 61 |decompre|ssion pa|
|00005840| 72 61 6d 65 74 65 72 20 | 63 68 61 6e 67 65 73 20 |rameter |changes |
|00005850| 74 68 61 74 20 61 72 65 | 20 64 65 73 69 72 61 62 |that are| desirab|
|00005860| 6c 65 2e 20 20 46 6f 72 | 20 65 78 61 6d 70 6c 65 |le. For| example|
|00005870| 2c 0a 58 20 2a 20 69 66 | 20 69 74 20 69 73 20 66 |,.X * if| it is f|
|00005880| 6f 75 6e 64 20 74 68 61 | 74 20 74 68 65 20 4a 50 |ound tha|t the JP|
|00005890| 45 47 20 66 69 6c 65 20 | 69 73 20 67 72 61 79 73 |EG file |is grays|
|000058a0| 63 61 6c 65 2c 20 79 6f | 75 20 6d 69 67 68 74 20 |cale, yo|u might |
|000058b0| 77 61 6e 74 20 74 6f 20 | 64 6f 0a 58 20 2a 20 74 |want to |do.X * t|
|000058c0| 68 69 6e 67 73 20 64 69 | 66 66 65 72 65 6e 74 6c |hings di|fferentl|
|000058d0| 79 20 74 68 61 6e 20 69 | 66 20 69 74 20 69 73 20 |y than i|f it is |
|000058e0| 63 6f 6c 6f 72 2e 20 20 | 59 6f 75 20 63 61 6e 20 |color. |You can |
|000058f0| 61 6c 73 6f 20 64 65 6c | 61 79 20 73 65 74 74 69 |also del|ay setti|
|00005900| 6e 67 0a 58 20 2a 20 71 | 75 61 6e 74 69 7a 65 5f |ng.X * q|uantize_|
|00005910| 63 6f 6c 6f 72 73 20 61 | 6e 64 20 61 73 73 6f 63 |colors a|nd assoc|
|00005920| 69 61 74 65 64 20 6f 70 | 74 69 6f 6e 73 20 75 6e |iated op|tions un|
|00005930| 74 69 6c 20 74 68 69 73 | 20 70 6f 69 6e 74 2e 20 |til this| point. |
|00005940| 0a 58 20 2a 0a 58 20 2a | 20 6a 5f 64 5f 64 65 66 |.X *.X *| j_d_def|
|00005950| 61 75 6c 74 73 20 69 6e | 69 74 69 61 6c 69 7a 65 |aults in|itialize|
|00005960| 73 20 6f 75 74 5f 63 6f | 6c 6f 72 5f 73 70 61 63 |s out_co|lor_spac|
|00005970| 65 20 74 6f 20 43 53 5f | 52 47 42 2e 20 20 49 66 |e to CS_|RGB. If|
|00005980| 20 79 6f 75 20 77 61 6e | 74 20 67 72 61 79 73 63 | you wan|t graysc|
|00005990| 61 6c 65 0a 58 20 2a 20 | 6f 75 74 70 75 74 20 79 |ale.X * |output y|
|000059a0| 6f 75 20 73 68 6f 75 6c | 64 20 73 65 74 20 6f 75 |ou shoul|d set ou|
|000059b0| 74 5f 63 6f 6c 6f 72 5f | 73 70 61 63 65 20 74 6f |t_color_|space to|
|000059c0| 20 43 53 5f 47 52 41 59 | 53 43 41 4c 45 2e 20 20 | CS_GRAY|SCALE. |
|000059d0| 4e 6f 74 65 20 74 68 61 | 74 20 79 6f 75 20 63 61 |Note tha|t you ca|
|000059e0| 6e 0a 58 20 2a 20 66 6f | 72 63 65 20 67 72 61 79 |n.X * fo|rce gray|
|000059f0| 73 63 61 6c 65 20 6f 75 | 74 70 75 74 20 66 72 6f |scale ou|tput fro|
|00005a00| 6d 20 61 20 63 6f 6c 6f | 72 20 4a 50 45 47 20 66 |m a colo|r JPEG f|
|00005a10| 69 6c 65 20 28 74 68 6f | 75 67 68 20 6e 6f 74 20 |ile (tho|ugh not |
|00005a20| 76 69 63 65 20 76 65 72 | 73 61 29 2e 0a 58 20 2a |vice ver|sa)..X *|
|00005a30| 2f 0a 58 0a 58 4d 45 54 | 48 4f 44 44 45 46 20 76 |/.X.XMET|HODDEF v|
|00005a40| 6f 69 64 0a 58 64 5f 75 | 69 5f 6d 65 74 68 6f 64 |oid.Xd_u|i_method|
|00005a50| 5f 73 65 6c 65 63 74 69 | 6f 6e 20 28 64 65 63 6f |_selecti|on (deco|
|00005a60| 6d 70 72 65 73 73 5f 69 | 6e 66 6f 5f 70 74 72 20 |mpress_i|nfo_ptr |
|00005a70| 63 69 6e 66 6f 29 0a 58 | 7b 0a 58 20 20 2f 2a 20 |cinfo).X|{.X /* |
|00005a80| 69 66 20 67 72 61 79 73 | 63 61 6c 65 20 69 6e 70 |if grays|cale inp|
|00005a90| 75 74 2c 20 66 6f 72 63 | 65 20 67 72 61 79 73 63 |ut, forc|e graysc|
|00005aa0| 61 6c 65 20 6f 75 74 70 | 75 74 3b 20 2a 2f 0a 58 |ale outp|ut; */.X|
|00005ab0| 20 20 2f 2a 20 65 6c 73 | 65 20 6c 65 61 76 65 20 | /* els|e leave |
|00005ac0| 74 68 65 20 6f 75 74 70 | 75 74 20 63 6f 6c 6f 72 |the outp|ut color|
|00005ad0| 73 70 61 63 65 20 61 73 | 20 73 65 74 20 62 79 20 |space as| set by |
|00005ae0| 6d 61 69 6e 20 72 6f 75 | 74 69 6e 65 2e 20 2a 2f |main rou|tine. */|
|00005af0| 0a 58 20 20 69 66 20 28 | 63 69 6e 66 6f 2d 3e 6a |.X if (|cinfo->j|
|00005b00| 70 65 67 5f 63 6f 6c 6f | 72 5f 73 70 61 63 65 20 |peg_colo|r_space |
|00005b10| 3d 3d 20 43 53 5f 47 52 | 41 59 53 43 41 4c 45 29 |== CS_GR|AYSCALE)|
|00005b20| 0a 58 20 20 20 20 63 69 | 6e 66 6f 2d 3e 6f 75 74 |.X ci|nfo->out|
|00005b30| 5f 63 6f 6c 6f 72 5f 73 | 70 61 63 65 20 3d 20 43 |_color_s|pace = C|
|00005b40| 53 5f 47 52 41 59 53 43 | 41 4c 45 3b 0a 58 0a 58 |S_GRAYSC|ALE;.X.X|
|00005b50| 20 20 2f 2a 20 73 65 6c | 65 63 74 20 6f 75 74 70 | /* sel|ect outp|
|00005b60| 75 74 20 72 6f 75 74 69 | 6e 65 73 20 2a 2f 0a 58 |ut routi|nes */.X|
|00005b70| 20 20 63 69 6e 66 6f 2d | 3e 6d 65 74 68 6f 64 73 | cinfo-|>methods|
|00005b80| 2d 3e 6f 75 74 70 75 74 | 5f 69 6e 69 74 20 3d 20 |->output|_init = |
|00005b90| 6f 75 74 70 75 74 5f 69 | 6e 69 74 3b 0a 58 20 20 |output_i|nit;.X |
|00005ba0| 63 69 6e 66 6f 2d 3e 6d | 65 74 68 6f 64 73 2d 3e |cinfo->m|ethods->|
|00005bb0| 70 75 74 5f 63 6f 6c 6f | 72 5f 6d 61 70 20 3d 20 |put_colo|r_map = |
|00005bc0| 70 75 74 5f 63 6f 6c 6f | 72 5f 6d 61 70 3b 0a 58 |put_colo|r_map;.X|
|00005bd0| 20 20 63 69 6e 66 6f 2d | 3e 6d 65 74 68 6f 64 73 | cinfo-|>methods|
|00005be0| 2d 3e 70 75 74 5f 70 69 | 78 65 6c 5f 72 6f 77 73 |->put_pi|xel_rows|
|00005bf0| 20 3d 20 70 75 74 5f 70 | 69 78 65 6c 5f 72 6f 77 | = put_p|ixel_row|
|00005c00| 73 3b 0a 58 20 20 63 69 | 6e 66 6f 2d 3e 6d 65 74 |s;.X ci|nfo->met|
|00005c10| 68 6f 64 73 2d 3e 6f 75 | 74 70 75 74 5f 74 65 72 |hods->ou|tput_ter|
|00005c20| 6d 20 3d 20 6f 75 74 70 | 75 74 5f 74 65 72 6d 3b |m = outp|ut_term;|
|00005c30| 0a 58 7d 0a 58 0a 58 0a | 58 2f 2a 0a 58 20 2a 20 |.X}.X.X.|X/*.X * |
|00005c40| 4f 4b 2c 20 68 65 72 65 | 20 69 73 20 74 68 65 20 |OK, here| is the |
|00005c50| 6d 61 69 6e 20 66 75 6e | 63 74 69 6f 6e 20 74 68 |main fun|ction th|
|00005c60| 61 74 20 61 63 74 75 61 | 6c 6c 79 20 63 61 75 73 |at actua|lly caus|
|00005c70| 65 73 20 65 76 65 72 79 | 74 68 69 6e 67 20 74 6f |es every|thing to|
|00005c80| 20 68 61 70 70 65 6e 2e | 0a 58 20 2a 20 57 65 20 | happen.|.X * We |
|00005c90| 61 73 73 75 6d 65 20 68 | 65 72 65 20 74 68 61 74 |assume h|ere that|
|00005ca0| 20 74 68 65 20 4a 50 45 | 47 20 66 69 6c 65 6e 61 | the JPE|G filena|
|00005cb0| 6d 65 20 69 73 20 73 75 | 70 70 6c 69 65 64 20 62 |me is su|pplied b|
|00005cc0| 79 20 74 68 65 20 63 61 | 6c 6c 65 72 20 6f 66 20 |y the ca|ller of |
|00005cd0| 74 68 69 73 0a 58 20 2a | 20 72 6f 75 74 69 6e 65 |this.X *| routine|
|00005ce0| 2c 20 61 6e 64 20 74 68 | 61 74 20 61 6c 6c 20 64 |, and th|at all d|
|00005cf0| 65 63 6f 6d 70 72 65 73 | 73 69 6f 6e 20 70 61 72 |ecompres|sion par|
|00005d00| 61 6d 65 74 65 72 73 20 | 63 61 6e 20 62 65 20 64 |ameters |can be d|
|00005d10| 65 66 61 75 6c 74 20 76 | 61 6c 75 65 73 2e 0a 58 |efault v|alues..X|
|00005d20| 20 2a 20 54 68 65 20 72 | 6f 75 74 69 6e 65 20 72 | * The r|outine r|
|00005d30| 65 74 75 72 6e 73 20 31 | 20 69 66 20 73 75 63 63 |eturns 1| if succ|
|00005d40| 65 73 73 66 75 6c 2c 20 | 30 20 69 66 20 6e 6f 74 |essful, |0 if not|
|00005d50| 2e 0a 58 20 2a 2f 0a 58 | 0a 58 47 4c 4f 42 41 4c |..X */.X|.XGLOBAL|
|00005d60| 20 69 6e 74 0a 58 72 65 | 61 64 5f 4a 50 45 47 5f | int.Xre|ad_JPEG_|
|00005d70| 66 69 6c 65 20 28 63 68 | 61 72 20 2a 20 66 69 6c |file (ch|ar * fil|
|00005d80| 65 6e 61 6d 65 29 0a 58 | 7b 0a 58 20 20 2f 2a 20 |ename).X|{.X /* |
|00005d90| 54 68 65 73 65 20 74 68 | 72 65 65 20 73 74 72 75 |These th|ree stru|
|00005da0| 63 74 73 20 63 6f 6e 74 | 61 69 6e 20 4a 50 45 47 |cts cont|ain JPEG|
|00005db0| 20 70 61 72 61 6d 65 74 | 65 72 73 20 61 6e 64 20 | paramet|ers and |
|00005dc0| 77 6f 72 6b 69 6e 67 20 | 64 61 74 61 2e 0a 58 20 |working |data..X |
|00005dd0| 20 20 2a 20 54 68 65 79 | 20 6d 75 73 74 20 73 75 | * They| must su|
|00005de0| 72 76 69 76 65 20 66 6f | 72 20 74 68 65 20 64 75 |rvive fo|r the du|
|00005df0| 72 61 74 69 6f 6e 20 6f | 66 20 70 61 72 61 6d 65 |ration o|f parame|
|00005e00| 74 65 72 20 73 65 74 75 | 70 20 61 6e 64 20 6f 6e |ter setu|p and on|
|00005e10| 65 0a 58 20 20 20 2a 20 | 63 61 6c 6c 20 74 6f 20 |e.X * |call to |
|00005e20| 6a 70 65 67 5f 64 65 63 | 6f 6d 70 72 65 73 73 3b |jpeg_dec|ompress;|
|00005e30| 20 74 79 70 69 63 61 6c | 6c 79 2c 20 6d 61 6b 69 | typical|ly, maki|
|00005e40| 6e 67 20 74 68 65 6d 20 | 6c 6f 63 61 6c 20 64 61 |ng them |local da|
|00005e50| 74 61 20 69 6e 20 74 68 | 65 0a 58 20 20 20 2a 20 |ta in th|e.X * |
|00005e60| 63 61 6c 6c 69 6e 67 20 | 72 6f 75 74 69 6e 65 20 |calling |routine |
|00005e70| 69 73 20 74 68 65 20 62 | 65 73 74 20 73 74 72 61 |is the b|est stra|
|00005e80| 74 65 67 79 2e 0a 58 20 | 20 20 2a 2f 0a 58 20 20 |tegy..X | */.X |
|00005e90| 73 74 72 75 63 74 20 44 | 65 63 6f 6d 70 72 65 73 |struct D|ecompres|
|00005ea0| 73 5f 69 6e 66 6f 5f 73 | 74 72 75 63 74 20 63 69 |s_info_s|truct ci|
|00005eb0| 6e 66 6f 3b 0a 58 20 20 | 73 74 72 75 63 74 20 44 |nfo;.X |struct D|
|00005ec0| 65 63 6f 6d 70 72 65 73 | 73 5f 6d 65 74 68 6f 64 |ecompres|s_method|
|00005ed0| 73 5f 73 74 72 75 63 74 | 20 64 63 5f 6d 65 74 68 |s_struct| dc_meth|
|00005ee0| 6f 64 73 3b 0a 58 20 20 | 73 74 72 75 63 74 20 45 |ods;.X |struct E|
|00005ef0| 78 74 65 72 6e 61 6c 5f | 6d 65 74 68 6f 64 73 5f |xternal_|methods_|
|00005f00| 73 74 72 75 63 74 20 65 | 5f 6d 65 74 68 6f 64 73 |struct e|_methods|
|00005f10| 3b 0a 58 0a 58 20 20 2f | 2a 20 53 65 6c 65 63 74 |;.X.X /|* Select|
|00005f20| 20 74 68 65 20 69 6e 70 | 75 74 20 61 6e 64 20 6f | the inp|ut and o|
|00005f30| 75 74 70 75 74 20 66 69 | 6c 65 73 2e 0a 58 20 20 |utput fi|les..X |
|00005f40| 20 2a 20 49 6e 20 74 68 | 69 73 20 65 78 61 6d 70 | * In th|is examp|
|00005f50| 6c 65 20 77 65 20 77 61 | 6e 74 20 74 6f 20 6f 70 |le we wa|nt to op|
|00005f60| 65 6e 20 74 68 65 20 69 | 6e 70 75 74 20 66 69 6c |en the i|nput fil|
|00005f70| 65 20 62 65 66 6f 72 65 | 20 64 6f 69 6e 67 20 61 |e before| doing a|
|00005f80| 6e 79 74 68 69 6e 67 20 | 65 6c 73 65 2c 0a 58 20 |nything |else,.X |
|00005f90| 20 20 2a 20 73 6f 20 74 | 68 61 74 20 74 68 65 20 | * so t|hat the |
|00005fa0| 73 65 74 6a 6d 70 28 29 | 20 65 72 72 6f 72 20 72 |setjmp()| error r|
|00005fb0| 65 63 6f 76 65 72 79 20 | 62 65 6c 6f 77 20 63 61 |ecovery |below ca|
|00005fc0| 6e 20 61 73 73 75 6d 65 | 20 74 68 65 20 66 69 6c |n assume| the fil|
|00005fd0| 65 20 69 73 20 6f 70 65 | 6e 2e 0a 58 20 20 20 2a |e is ope|n..X *|
|00005fe0| 20 4e 6f 74 65 20 74 68 | 61 74 20 63 69 6e 66 6f | Note th|at cinfo|
|00005ff0| 2e 6f 75 74 70 75 74 5f | 66 69 6c 65 20 69 73 20 |.output_|file is |
|00006000| 6f 6e 6c 79 20 75 73 65 | 64 20 69 66 20 79 6f 75 |only use|d if you|
|00006010| 72 20 6f 75 74 70 75 74 | 20 68 61 6e 64 6c 69 6e |r output| handlin|
|00006020| 67 20 72 6f 75 74 69 6e | 65 73 0a 58 20 20 20 2a |g routin|es.X *|
|00006030| 20 75 73 65 20 69 74 3b | 20 6f 74 68 65 72 77 69 | use it;| otherwi|
|00006040| 73 65 2c 20 79 6f 75 20 | 63 61 6e 20 6a 75 73 74 |se, you |can just|
|00006050| 20 6d 61 6b 65 20 69 74 | 20 4e 55 4c 4c 2e 0a 58 | make it| NULL..X|
|00006060| 20 20 20 2a 20 56 45 52 | 59 20 49 4d 50 4f 52 54 | * VER|Y IMPORT|
|00006070| 41 4e 54 3a 20 75 73 65 | 20 22 62 22 20 6f 70 74 |ANT: use| "b" opt|
|00006080| 69 6f 6e 20 74 6f 20 66 | 6f 70 65 6e 28 29 20 69 |ion to f|open() i|
|00006090| 66 20 79 6f 75 20 61 72 | 65 20 6f 6e 20 61 20 6d |f you ar|e on a m|
|000060a0| 61 63 68 69 6e 65 20 74 | 68 61 74 0a 58 20 20 20 |achine t|hat.X |
|000060b0| 2a 20 72 65 71 75 69 72 | 65 73 20 69 74 20 69 6e |* requir|es it in|
|000060c0| 20 6f 72 64 65 72 20 74 | 6f 20 72 65 61 64 20 62 | order t|o read b|
|000060d0| 69 6e 61 72 79 20 66 69 | 6c 65 73 2e 0a 58 20 20 |inary fi|les..X |
|000060e0| 20 2a 2f 0a 58 0a 58 20 | 20 69 66 20 28 28 63 69 | */.X.X | if ((ci|
|000060f0| 6e 66 6f 2e 69 6e 70 75 | 74 5f 66 69 6c 65 20 3d |nfo.inpu|t_file =|
|00006100| 20 66 6f 70 65 6e 28 66 | 69 6c 65 6e 61 6d 65 2c | fopen(f|ilename,|
|00006110| 20 22 72 62 22 29 29 20 | 3d 3d 20 4e 55 4c 4c 29 | "rb")) |== NULL)|
|00006120| 20 7b 0a 58 20 20 20 20 | 66 70 72 69 6e 74 66 28 | {.X |fprintf(|
|00006130| 73 74 64 65 72 72 2c 20 | 22 63 61 6e 27 74 20 6f |stderr, |"can't o|
|00006140| 70 65 6e 20 25 73 5c 6e | 22 2c 20 66 69 6c 65 6e |pen %s\n|", filen|
|00006150| 61 6d 65 29 3b 0a 58 20 | 20 20 20 72 65 74 75 72 |ame);.X | retur|
|00006160| 6e 20 30 3b 0a 58 20 20 | 7d 0a 58 0a 58 20 20 63 |n 0;.X |}.X.X c|
|00006170| 69 6e 66 6f 2e 6f 75 74 | 70 75 74 5f 66 69 6c 65 |info.out|put_file|
|00006180| 20 3d 20 4e 55 4c 4c 3b | 09 2f 2a 20 69 66 20 6e | = NULL;|./* if n|
|00006190| 6f 20 61 63 74 75 61 6c | 20 6f 75 74 70 75 74 20 |o actual| output |
|000061a0| 66 69 6c 65 20 69 6e 76 | 6f 6c 76 65 64 20 2a 2f |file inv|olved */|
|000061b0| 0a 58 0a 58 20 20 2f 2a | 20 49 6e 69 74 69 61 6c |.X.X /*| Initial|
|000061c0| 69 7a 65 20 74 68 65 20 | 73 79 73 74 65 6d 2d 64 |ize the |system-d|
|000061d0| 65 70 65 6e 64 65 6e 74 | 20 6d 65 74 68 6f 64 20 |ependent| method |
|000061e0| 70 6f 69 6e 74 65 72 73 | 2e 20 2a 2f 0a 58 20 20 |pointers|. */.X |
|000061f0| 63 69 6e 66 6f 2e 6d 65 | 74 68 6f 64 73 20 3d 20 |cinfo.me|thods = |
|00006200| 26 64 63 5f 6d 65 74 68 | 6f 64 73 3b 09 2f 2a 20 |&dc_meth|ods;./* |
|00006210| 6c 69 6e 6b 73 20 74 6f | 20 6d 65 74 68 6f 64 20 |links to| method |
|00006220| 73 74 72 75 63 74 73 20 | 2a 2f 0a 58 20 20 63 69 |structs |*/.X ci|
|00006230| 6e 66 6f 2e 65 6d 65 74 | 68 6f 64 73 20 3d 20 26 |nfo.emet|hods = &|
|00006240| 65 5f 6d 65 74 68 6f 64 | 73 3b 0a 58 20 20 2f 2a |e_method|s;.X /*|
|00006250| 20 48 65 72 65 20 77 65 | 20 73 75 70 70 6c 79 20 | Here we| supply |
|00006260| 6f 75 72 20 6f 77 6e 20 | 65 72 72 6f 72 20 68 61 |our own |error ha|
|00006270| 6e 64 6c 65 72 3b 20 63 | 6f 6d 70 61 72 65 20 74 |ndler; c|ompare t|
|00006280| 6f 20 75 73 65 20 6f 66 | 20 73 74 61 6e 64 61 72 |o use of| standar|
|00006290| 64 20 65 72 72 6f 72 0a | 58 20 20 20 2a 20 68 61 |d error.|X * ha|
|000062a0| 6e 64 6c 65 72 20 69 6e | 20 74 68 65 20 70 72 65 |ndler in| the pre|
|000062b0| 76 69 6f 75 73 20 77 72 | 69 74 65 5f 4a 50 45 47 |vious wr|ite_JPEG|
|000062c0| 5f 66 69 6c 65 20 65 78 | 61 6d 70 6c 65 2e 0a 58 |_file ex|ample..X|
|000062d0| 20 20 20 2a 2f 0a 58 20 | 20 65 6d 65 74 68 6f 64 | */.X | emethod|
|000062e0| 73 20 3d 20 26 65 5f 6d | 65 74 68 6f 64 73 3b 09 |s = &e_m|ethods;.|
|000062f0| 2f 2a 20 73 61 76 65 20 | 73 74 72 75 63 74 20 61 |/* save |struct a|
|00006300| 64 64 72 20 66 6f 72 20 | 70 6f 73 73 69 62 6c 65 |ddr for |possible|
|00006310| 20 61 63 63 65 73 73 20 | 2a 2f 0a 58 20 20 65 5f | access |*/.X e_|
|00006320| 6d 65 74 68 6f 64 73 2e | 65 72 72 6f 72 5f 65 78 |methods.|error_ex|
|00006330| 69 74 20 3d 20 65 72 72 | 6f 72 5f 65 78 69 74 3b |it = err|or_exit;|
|00006340| 20 2f 2a 20 73 75 70 70 | 6c 79 20 65 72 72 6f 72 | /* supp|ly error|
|00006350| 2d 65 78 69 74 20 72 6f | 75 74 69 6e 65 20 2a 2f |-exit ro|utine */|
|00006360| 0a 58 20 20 65 5f 6d 65 | 74 68 6f 64 73 2e 74 72 |.X e_me|thods.tr|
|00006370| 61 63 65 5f 6d 65 73 73 | 61 67 65 20 3d 20 74 72 |ace_mess|age = tr|
|00006380| 61 63 65 5f 6d 65 73 73 | 61 67 65 3b 20 2f 2a 20 |ace_mess|age; /* |
|00006390| 73 75 70 70 6c 79 20 74 | 72 61 63 65 2d 6d 65 73 |supply t|race-mes|
|000063a0| 73 61 67 65 20 72 6f 75 | 74 69 6e 65 20 2a 2f 0a |sage rou|tine */.|
|000063b0| 58 20 20 65 5f 6d 65 74 | 68 6f 64 73 2e 74 72 61 |X e_met|hods.tra|
|000063c0| 63 65 5f 6c 65 76 65 6c | 20 3d 20 30 3b 09 2f 2a |ce_level| = 0;./*|
|000063d0| 20 64 65 66 61 75 6c 74 | 20 3d 20 6e 6f 20 74 72 | default| = no tr|
|000063e0| 61 63 69 6e 67 20 2a 2f | 0a 58 20 20 65 5f 6d 65 |acing */|.X e_me|
|000063f0| 74 68 6f 64 73 2e 6e 75 | 6d 5f 77 61 72 6e 69 6e |thods.nu|m_warnin|
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.