From c0a8334d98ace4de8cd8697b20f1dd5d71f9d9f4 Mon Sep 17 00:00:00 2001 From: Keith Lazuka Date: Fri, 25 Sep 2009 09:34:29 -0400 Subject: [PATCH] images.gif: added more tests --- extra/images/gif/gif-tests.factor | 51 ++++++++++++++++-- extra/images/testing/alpha.gif | Bin 0 -> 44 bytes extra/images/testing/astronaut_animation.gif | Bin 0 -> 10316 bytes .../{check-256-colors.gif => checkmark.gif} | Bin .../testing/{symbol-word.gif => circle.gif} | Bin 5 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 extra/images/testing/alpha.gif create mode 100644 extra/images/testing/astronaut_animation.gif rename extra/images/testing/{check-256-colors.gif => checkmark.gif} (100%) rename extra/images/testing/{symbol-word.gif => circle.gif} (100%) diff --git a/extra/images/gif/gif-tests.factor b/extra/images/gif/gif-tests.factor index 609f98c693..b62565ffbc 100644 --- a/extra/images/gif/gif-tests.factor +++ b/extra/images/gif/gif-tests.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors bitstreams compression.lzw-gif images.gif io io.encodings.binary io.files kernel math math.bitwise -math.parser namespaces prettyprint sequences tools.test ; +math.parser namespaces prettyprint sequences tools.test images.viewer ; QUALIFIED-WITH: bitstreams bs IN: images.gif.tests @@ -10,10 +10,10 @@ IN: images.gif.tests binary [ input-stream get load-gif ] with-file-reader ; : gif-example1 ( -- loading-gif ) - "resource:extra/images/testing/symbol-word.gif" path>gif ; + "resource:extra/images/testing/circle.gif" path>gif ; : gif-example2 ( -- loading-gif ) - "resource:extra/images/testing/check-256-colors.gif" path>gif ; + "resource:extra/images/testing/checkmark.gif" path>gif ; : gif-example3 ( -- loading-gif ) "resource:extra/images/testing/monochrome.gif" path>gif ; @@ -21,8 +21,21 @@ IN: images.gif.tests : gif-example4 ( -- loading-gif ) "resource:extra/images/testing/noise.gif" path>gif ; +: gif-example5 ( -- loading-gif ) + "resource:extra/images/testing/alpha.gif" path>gif ; + +: gif-example6 ( -- loading-gif ) + "resource:extra/images/testing/astronaut_animation.gif" path>gif ; + +: gif-all. ( -- ) + { + gif-example1 gif-example2 gif-example3 gif-example4 gif-example5 + gif-example6 + } + [ execute( -- gif ) loading-gif>image image. ] each ; + : declared-num-colors ( gif -- n ) flags>> 3 bits 1 + 2^ ; -: actual-num-colors ( gif -- n ) global-color-table>> length 3 /i ; +: actual-num-colors ( gif -- n ) global-color-table>> length ; [ 16 ] [ gif-example1 actual-num-colors ] unit-test [ 16 ] [ gif-example1 declared-num-colors ] unit-test @@ -49,4 +62,34 @@ IN: images.gif.tests } ] [ gif-example3 >index-stream ] unit-test +[ + B{ + 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 + 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 255 + 0 0 0 255 0 0 0 255 255 255 255 255 255 255 255 255 0 0 0 255 0 0 0 255 + 0 0 0 255 0 0 0 255 0 0 0 255 0 0 0 255 0 0 0 255 0 0 0 255 + 0 0 0 255 255 255 255 255 0 0 0 255 0 0 0 255 255 255 255 255 0 0 0 255 + 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 255 + } +] [ gif-example3 loading-gif>image bitmap>> ] unit-test +[ + BV{ + 0 1 + 1 0 + } +] [ gif-example5 >index-stream ] unit-test + +[ + B{ + 255 000 000 255 000 000 000 000 + 000 000 000 000 255 000 000 255 + } +] [ gif-example5 loading-gif>image bitmap>> ] unit-test + +[ 100 ] [ gif-example1 >index-stream length ] unit-test +[ 870 ] [ gif-example2 >index-stream length ] unit-test +[ 16384 ] [ gif-example4 >index-stream length ] unit-test + +! example6 is a GIF animation and the first frame contains 1768 pixels +[ 1768 ] [ gif-example6 >index-stream length ] unit-test diff --git a/extra/images/testing/alpha.gif b/extra/images/testing/alpha.gif new file mode 100644 index 0000000000000000000000000000000000000000..c4c38bdaf02a8625fbdbdde2796402d669449261 GIT binary patch literal 44 scmZ?wbhEHbWMW`qXkcXc&j137KUo+V7#JCJKpc<^0~50g6Dxx?0F_V$2mk;8 literal 0 HcmV?d00001 diff --git a/extra/images/testing/astronaut_animation.gif b/extra/images/testing/astronaut_animation.gif new file mode 100644 index 0000000000000000000000000000000000000000..8c768480fea417aa54f0a60ca54711bf28c2f8f2 GIT binary patch literal 10316 zcmY*jCpQlTRpKDN1 zP_(CKil=9Mi07`rzyp4M@sUA$W4Fe{#OzOr*|%?B1BoPIFmeL|+B`k0A|vznMds~K zZ8&hCN)lfzIZ!7_X)8X^R&^jhKfk`JxUR0Qvo5c#zV>Qc@tL-&%crYOojTQjrtQ+D zOJn_QcgFh1$H$*OxHCUL|N7~JH*enj_19mDpEvx8^mX;$!gc1mT2rjRz`q}Tg&@=c zP5|=Xllyy`P}ooTi9{Y*uWY}n=7&IIdcnfd~fx|^H#WV^Ii@{>2 z=cdV_`yCm~!Uq%z`ROzUjirolJ)B`rawxR2wz9Bzf-|xFGAB(X^P32+fS{2?e#3%$O?6l{$6!=`lKC+46SPUwJJ&@_fT^9?Xi0&!DpL3 z01P>h*uae@wO)2&fHK|Gv2C**=LsZ;_`UIsIP_vc;rAI^!2$q82CLxN<@gW4&RqxI zt_s)yF&L(-vYgW<5<{RwcdKJx+n<3U${K(xgsiApMDQ}})&-I1PTxfrd;S7D>(sAP z7Z)^~)5IY=*mhqF8Cz&SrrX!kjk46($pkfITM4;U-zi5 z%udVew7sQ}9z>#u?zt|vIA|MYW}66{A$#VtEHWH-?D$I?XSb%BCDpcqH~+j7dqbQT zPSf96F@waUPT`>N{J9|&%Ty6a*Q7Nu3nmT?k|$w_(m|Mh%u6U@1E9`W350cbhN#i3 zoOMZa!5sYb!ueK+W+-3@u_4upPg^*n1FYVZ)dQ?B2+l4^PoOfykZ|cRr+y_Jk5loA zkgI0UKQZ9BQH1QK@-R4h+;&XHu2!|3^&sjLb;jOOmwYOSDG08b3U`=?Z*Igt6llQU z>+>}@P_6uLT`1uTblldpcrGB8tGn;9uEwpLUJX31{AM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