[AD] modified version of quantize.c

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Attached below is modified version of quantize.c.  It fixes
portability problems, fixes mask for reading 16 bit bitmaps, also
there were some problems with array manipulations.  I have tested it a
little and have not found any problems, but if anyone has any real
application that needs to quantize truecolor bitmaps into 8 bit
palette, it would be interesting to test quantization with this
version.


begin 644 quantize.c.gz
M'XL("):K1C@"`W%U86YT:7IE+F,`M1MI4]M(]C/\BI[9VL$"`S+7)#$F11*8
MH8H<E3"[6QLHCRRU;1D=7DG&>&;RW_<=?4DVY*B,J=A2'Z_?>_WN[NQN"OWI
MTX<?U/NZ,-V[U]`BQ#4\].&;?YS^:_R[A'_7N[OTS#\*LOWI"[V&,YEF8\>U
M^M,_8G>CW__]&G_$[]>[U[_#Z_6NP#9W.@xxxxxxxxxx
M`$$NZ!_A_O`@];);GP^`837^A[TK?G!1&"#HI3G],Y_=E6M^Y@/T\QPS[>VT
MBM.XE)&8!HFL*BE&,I-%4,5Y)HI\5L69+-MBL!"OXW`<).*U+*IDQP7Q04I1
MR"!*Y4YU7XEA7H@PGRZ*>#2N1)S!>TK@:I.NQE($R2@xxxxxxxxxx<BADB,):%%'$I
MTH7(YQFL*<,`.D0%0W/`0EP`[%D6&1B`(?9ELA*EE"F`J/(<UDZGB;PG/%(I
MGFU[XCPNR@JF3V;P$P*,"B<:.-DL'<A"Y$,QC>]E4N(3`BX#F!_F"0!JT4)F
M7!0/AX!M5G%W:4`!^KCNWL'N_MY@.A5E/,KB81P&694L@$O1+`0T@9NS,LY&
M0`&T'K0./3&(JU),96$@O?_EA;<#;`HR0+S,"T)9)#%0,`>>T5N:PQOQCM$0
M0R1T1[R&=LLE)D9O+V"HV#!=<!^T$-@domain.hid(>&E=2>+A24KG0(&0`3LIQ@&
M8>4A'"4I3!"R/2B0*(4+;!FVPX\!0XC+(!R+'!8J`%@)TH1SJKR&I"'.,AHE
M8$F"[@(8DP83%*.%IA0$&O9N*AE;HHCE&'&&ECB+JSA(#"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