1169d92004-05-02Martin Nilsson START_MARKER
05bd782002-12-12Martin Nilsson  test_eq([[ Image.PNM.decode("P1\n5 5\n0 1 1 1 1\n1 0 1 1 1\n" "1 1 0 1 1\n1 1 1 0 1\n1 1 1 1 0") ]], Image.PNM.decode("P4\n5 5\nx¸Øèð") ) test_eq([[ Image.GIF.decode(MIME.decode_base64( "R0lGODlhBQAFAIAAAAAAAP///ywAAAAABQAFAAACCAxwEWrY8BwoADs=")) ]], Image.PNM.decode("P4\n5 5\nx\00èØèð") )
ab62bd2015-08-23Martin Nilsson dnl netpbm wikipedia examples test_do(add_constant("IMAGE",lambda(string in) { return decode_value(Gz.uncompress(String.hex2string(in))); })) test_eq(Image.PNM.decode(#{P1 # This is an example bitmap of the letter "J" 6 10 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 1 0 0 0 1 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #}), IMAGE("78dadb969d6a90fc9423e1010713071bdb86ff48808181e13f2aa0ae08b2389ccd0003ff89060072d39782")) test_eq(Image.PNM.decode(#{P2 # Shows the word "FEEP" (example from Netpbm man page on PGM) 24 7 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 3 0 0 7 7 7 7 0 0 11 11 11 11 0 0 15 15 15 15 0 0 3 0 0 0 0 0 7 0 0 0 0 0 11 0 0 0 0 0 15 0 0 15 0 0 3 3 3 0 0 0 7 7 7 0 0 0 11 11 11 0 0 0 15 15 15 15 0 0 3 0 0 0 0 0 7 0 0 0 0 0 11 0 0 0 0 0 15 0 0 0 0 0 3 0 0 0 0 0 7 7 7 7 0 0 11 11 11 11 0 0 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #}), IMAGE("78dadb969d6a90fc9423e101870807b31bc31706ea01632400112947021091dd480022f21f09c0cd413319ae1d0ee0dae100ae1dd91c64c720bb07d91c64c7d0c23dc8e183690e31e1c34003000052ea5e1c")) test_eq(Image.PNM.decode(#{P3 # The P3 means colors are in ASCII, then 3 columns and 2 rows, # then 255 for max color, then RGB triplets 3 2 255 255 0 0 0 255 0 0 0 255 255 255 0 255 255 255 0 0 0 #}), IMAGE("78dadb969d6a90fc9423e1c18b156c7cff191818c0f8ff7f3066600000dfef0de3")) test_eq(Image.PNM.decode(#{P3 # The same image with width 3 and height 2, # using 0 or 1 per color (red, green, blue) 3 2 1 1 0 0 0 1 0 0 0 1 1 1 0 1 1 1 0 0 0 #}), IMAGE("78dadb969d6a90fc9423e1c18b156c7cff191818c0f8ff7f3066600000dfef0de3")) test_eq(Image.PNM.decode("P3 3 2 1 1 0 0 0 1 0 0 0 1 1 1 0 1 1 1 0 0 0"), IMAGE("78dadb969d6a90fc9423e1c18b156c7cff191818c0f8ff7f3066600000dfef0de3"))
d417912015-08-23Martin Nilsson test_eval_error(Image.PNM.decode("P2 1 1 0 0"))
c32d1c2015-08-24Martin Nilsson test_eq(Image.PNM.decode("P4\n" "3 3\n" "\240@\240"), IMAGE("78dadb969d6a90fc9423e1c10b7d3671060686ffffff63250165b1116f"))
ab62bd2015-08-23Martin Nilsson test_do(add_constant("IMAGE"))
05bd782002-12-12Martin Nilsson test_true( objectp(Image.Image()) ) test_false( Image.Image()->xsize() ) test_false( Image.Image()->ysize() ) test_true( objectp(Image.Image(100,100)) ) test_eq( Image.Image(100,100)->xsize(), 100) test_eq( Image.Image(100,100)->ysize(), 100) test_false( Image.Image(100,100)!=0 )
1b093e2003-03-21Johan Sundström test_do([[ // http://bugs.roxen.com/3384 Image.Image(1,1)->scale(0.5)->scale(2.0); ]])
05bd782002-12-12Martin Nilsson define(test_too_big,[[ test_true( $1>0 ) test_eval_error([[ // This should work if you have $1*2*4 bytes of memory Image.Image($1,2) ]]) test_eval_error( Image.Image($1/32768,65537) ) test_eval_error( Image.Image($1/(32768*3),65537) ) ]]) test_too_big(0x7fffffff) test_too_big(0x7ffffffff) test_too_big(0x7fffffffff) test_too_big(0x7ffffffffff) test_true( objectp(Image.Image(1000,1000,17,42,96)) ) test_eq( Image.Image(1000,1000,17,42,96)->xsize(), 1000) test_eq( Image.Image(1000,1000,17,42,96)->ysize(), 1000) test_false( Image.Image(1000,1000,17,42,96)!=({17,42,96}) ) define(test_cx,[[ test_do( add_constant("cx", c1) ) $1 test_do( add_constant("cx", c2) ) $1 test_do( add_constant("cx", c3) ) $1 test_do( add_constant("cx") ) ]]) define(test_color,[[ test_do( add_constant("c1", Image.Color($1)) ) test_do( add_constant("c2", Image.Color($2, $3, $4)) ) test_do( add_constant("c3", Image.Color.rgb($2, $3, $4)) ) test_eq( c1, c2 ) test_eq( c2, c3 ) test_eq( c3, c1 ) test_cx([[ test_eq( c1->r, $2 ) ]]) test_cx([[ test_eq( c1->g, $3 ) ]]) test_cx([[ test_eq( c1->b, $4 ) ]]) test_cx([[ test_equal( c1->rgb(), ({ $2, $3, $4 }) ) ]]) test_cx([[ test_equal( cx->hsv(), ({ $5, $6, $7 }) ) ]]) test_cx([[ test_eq( cx->hex(), sprintf("#%02x%02x%02x", $2, $3, $4) ) ]]) test_cx([[ test_eq( cx->greylevel(), $8 ) ]]) test_cx([[ test_eq( cx->grey()->r, $8 ) ]]) test_cx([[ test_eq( sprintf("%t", cx->cmyk()[*])*"", "float"*4) ]]) test_cx([[ test_eq( sprintf("%t", cx->hsvf()[*])*"", "float"*3) ]]) test_cx([[ test_eq( sprintf("%t", cx->rgbf()[*])*"", "float"*3) ]]) test_cx([[ test_do( cx->light() ) ]]) test_cx([[ test_do( cx->dark() ) ]]) test_cx([[ test_do( cx->neon() ) ]]) test_cx([[ test_do( cx->dull() ) ]]) test_cx([[ test_do( cx->bright() ) ]]) test_cx([[ test_eq( cx->name(), $1) ]]) test_cx([[ test_eq( (string)cx, $1) ]]) test_cx([[ test_equal( (array)cx, ({ $2, $3, $4 }) ) ]]) test_do( add_constant("c1") ) test_do( add_constant("c2") ) test_do( add_constant("c3") ) ]]) test_color( "black", 0, 0, 0, 0, 0, 0, 0 ) test_color( "blue", 0, 0, 255, 170, 255, 255, 41 ) test_color( "cyan", 0, 255, 255, 127, 255, 255, 168 ) test_color( "green", 0, 255, 0, 85, 255, 255, 127 ) test_color( "magenta", 255, 0, 255, 212, 255, 255, 128 ) test_color( "red", 255, 0, 0, 0, 255, 255, 87 ) test_color( "white", 255, 255, 255, 0, 0, 255, 255 ) test_color( "yellow", 255, 255, 0, 42, 255, 255, 214 ) test_true( arrayp(indices(Image.Color)) ) test_true( stringp(indices(Image.Color)[0]) ) test_true( sizeof(indices(Image.Color))>8 ) test_true( arrayp(values(Image.Color)) ) test_true( objectp(values(Image.Color)[0]) ) test_eq( sizeof(indices(Image.Color)), sizeof(values(Image.Color)) )
0caad52011-04-08Martin Nilsson test_eq( Image.Color(0xffffff), Image.Color.white ) test_eq( (int)Image.Color(0xabcdef), 0xabcdef )
05bd782002-12-12Martin Nilsson  define(test_img,[[ test_do([[ object img = Image.Image(100,100)->test(42); img->setpixel(2,2,0,255,0); add_constant("img", img); ]]) $1 test_do( add_constant("img") ) ]]) test_img([[ test_false( equal(img->max(),({0,0,0})) ) ]]) test_img([[ test_true( objectp( img->setpixel(3,3,0,255,0) ) ) ]]) test_img([[ test_false( img==img->invert() ) ]]) test_img([[ test_eq( img->invert(), img->invert() ) ]]) test_img([[ test_eq( img->copy(), img ) ]]) test_img([[ test_eq( img->copy(25,25,75,75), img->copy(25,25,75,75) ) ]]) test_img([[ test_false( img==img->copy(25,25,75,75) ) ]]) test_img([[ test_false( img->copy()==img->invert()->copy() ) ]]) test_img([[ test_false( img==img->clear() ) ]]) test_img([[ test_eq( img->clear(0,0,0), 0 ) ]]) test_img([[ test_eq( img->clear(1,255,0), ({1,255,0}) ) ]]) test_img([[ test_eq( img, img->clone() ) ]]) test_img([[ test_fales( img->clone()==img->invert()->clone() ) ]]) test_do([[ object img = Image.Image(20,20); img->box(4,4,8,8,Image.Color.red); img->box(8,8,12,12,Image.Color.green); img->box(12,4,16,8,Image.Color.blue); img->setcolor(255,255,255); add_constant("img", img); ]]) test_equal( img->find_autocrop(), ({ 4, 4, 16, 12 }) ) test_equal( img->find_autocrop(5), ({ -1, -1, 21, 17 }) ) test_equal( img->find_autocrop(-2), ({ 6, 6, 14, 10 }) ) test_equal( img->find_autocrop(0,1,0,0,0), ({ 4, 0, 19, 19 }) ) test_equal( img->find_autocrop(0,0,1,0,0), ({ 0, 0, 16, 19 }) ) test_equal( img->find_autocrop(0,0,0,1,0), ({ 0, 4, 19, 19 }) ) test_equal( img->find_autocrop(0,0,0,0,1), ({ 0, 0, 19, 12 }) ) test_eq( img->autocrop(),[[ Image.GIF.decode(MIME.decode_base64( "R0lGODlhDQAJAJEAAAAAAP8AAAAA/wD/ACwAAAAADQAJAAECIkwcACD" "Sck5azkE5mb1yaYsNg7gJ\r\nHjCOw3mqI+u5K4y6ZwEAOw==")) ]]) test_eq( img->autocrop(0,1,0,0,0),[[ Image.GIF.decode(MIME.decode_base64( "R0lGODlhEAAUAJEAAAAAAP8AAAAA/wD/ACwAAAAAEAAUAAECOQR8l6r" "c/SCUc54QcFBCdKFk2XZ4\r\nHniNJHB6ocq1bzYMdYtCtj1YDW/zKY" "A9IYBoNCaVSmaz+YQ2CgA7")) ]]) test_eq( img->autocrop(0,0,1,0,0),[[ Image.GIF.decode(MIME.decode_base64( "R0lGODlhEQAUAJEAAAAAAP8AAAAA/wD/ACwAAAAAEQAUAAECOgR8l6" "rc/SCUc1YVQg5KCC80msYd\r\n3xdiZAmgn7h2LqwNg+2m030PFtS7" "/RpB3/BQPB6Vy2XT6YRGfwUAOw==")) ]]) test_eq( img->autocrop(0,0,0,1,0),[[ Image.GIF.decode(MIME.decode_base64( "R0lGODlhFAAQAJEAAAAAAP8AAAAA/wD/ACwAAAAAFAAQAAECMwQckX" "Eg8kRrQCl2IJT0XNVsUOd9\r\noUhW1zCwIpcebTvEKd3aJF7rFO/z" "BYVCYrF4RCJjBQA7")) ]]) test_eq( img->autocrop(0,0,0,0,1),[[ Image.GIF.decode(MIME.decode_base64( "R0lGODlhFAANAJEAAAAAAP8AAAAA/wD/ACwAAAAAFAANAAECNQR8l6" "rc/SCUc1ZrQQg7KCGAgsVx\r\n3hGG42Ryn7pC7QnAcdMOg25nyr4b" "+CbB3RBSFB5/RUsBADs=")) ]]) test_eq( img->autocrop(5),[[ Image.GIF.decode(MIME.decode_base64( "R0lGODlhFwATAKIAAAAAAP8AAAAA/wD/AP///wAAAAAAAAAAACwAAA" "AAFwATAAIDVkiku+0OOgBo\r\nrRdjPPf2H9CFYTiWJbdsQdAGmCDI" "gkqwrhvPs43nO54Pk9NVeL3KqTgYNJE15arkdA5Kp43ViZ2G\r\ntl" "eT9wPu3lKpYTqdXX/abnX8TUgAADs=")) ]]) test_eq( img->autocrop(5,0,0,0,1),[[ Image.GIF.decode(MIME.decode_base64( "R0lGODlhHgAXAKIAAAAAAP8AAAAA/wD/AP///wAAAAAAAAAAACwAAA" "AAHgAXAAIDbUiku+0Oxjgp\r\ntfdmrXnvHwiKIwEAJ4qq67qOrhvL" "KEzTt43jrg4EAWBgJRAUBS+QKxgcooxGZE25agaJUSnAZ3UC\r\nsl" "puczAgg5MdXrk8wPlc7LKbSou3ae+VfZ7m8dAaf39TfYM8eYaAF4mH" "EQkAOw==")) ]]) test_eq( img->autocrop(5,0,0,1,0),[[ Image.GIF.decode(MIME.decode_base64( "R0lGODlhHgAaAKIAAAAAAP8AAAAA/wD/AP///wAAAAAAAAAAACwAAA" "AAHgAaAAIDdEiku+0OxjgJ\r\nABdjvfemlOeJIwZGZZkCp6OqZbt4" "QVAHmyDowifTNltut/O1gMEh0XhCCjHEoum3CQYGA2y0Nz2q\r\nst" "mBSmb5hsUxaumMHpFh7LEaBmPN63IvHvbe8+9+TCCBeU2EbmRkiYqK" "jI2Nj5CQko0JADs=")) ]]) test_eq( img->autocrop(5,0,1,0,0),[[ Image.GIF.decode(MIME.decode_base64( "R0lGODlhGwAeAKIAAAAAAP8AAAAA/wD/AP///wAAAAAAAAAAACwAAA" "AAGwAeAAIDfEiku+0Oxjgp\r\ntfdmrXnvHwheAFCaJpqmqcayL2y6" "slzTts3iQBD4gZRAMBS0SKnfL2giEo0zpGn5Ez6hAB6VCbhi\r\ntc" "vBQOw9UnTj8cDGY6nHbCnsvZa1U/T4WaczR/p9UXuBOneEfg6HhXKK" "iAuNdiMjkpOTlZaWmJmZ\r\nHQkAOw==")) ]]) test_eq( img->autocrop(5,1,0,0,0),[[ Image.GIF.decode(MIME.decode_base64( "R0lGODlhGgAeAKIAAAAAAP8AAAAA/wD/AP///wAAAAAAAAAAACwAAA" "AAGgAeAAIDekiku+0Oxjgp\r\ntfdmrXnvH3gBAFmWJ4qi47q6L9DG" "cTzXNUutQdAHKIFAKNBFeD5fcDg0OpDJJdO5gCpLzGbplgwM\r\nBt" "9scburgcGD2m2FBqvLsXbaBn/J38dcjkrY78l5fzlrgiuEhYBPiHSB" "i3wiIpCRkZOUlJaXlwQJ\r\nADs=")) ]]) test_do( add_constant("img") ) test_equal( Image.Image(10,10,0,0,0)->max(), ({0,0,0}) ) test_equal( Image.Image(10,10,17,42,36)->max(), ({17,42,36}) ) test_equal( Image.Image(10,10,0,0,0)->setpixel(5,5,17,42,36)->max(), ({17,42,36}) ) test_equal( Image.Image(10,10,0,0,0) ->setpixel(2,2,1,2,3) ->setpixel(3,3,17,42,36) ->setpixel(4,4,3,2,1) ->max(), ({17,42,36}) ) test_equal( Image.Image(10,10,0,0,0) ->setpixel(2,2,17,2,3) ->setpixel(3,3,2,42,5) ->setpixel(4,4,3,2,36) ->max(), ({17,42,36}) ) test_any_equal([[ object img=Image.Image(10,10,255,0,0); return img->getpixel(5,5); ]], ({255,0,0}) ) test_any_equal([[ object img=Image.Image(10,10,255,0,0); img->setpixel(5,5,1,2,3); return img->getpixel(5,5); ]], ({1,2,3}) ) test_any_equal([[ object img=Image.Image(10,10,255,0,0); img->setpixel(5,5,0,255,0,127); return img->getpixel(5,5); ]], ({127,128,0}) ) test_any([[ object img=Image.Image(100,100,0,0,0); foreach (({40,50,60}),int z)
13670c2015-05-25Martin Nilsson  {
05bd782002-12-12Martin Nilsson  img->line(50-z,0,50,50,255,255,255); img->line(50-z,100,50,50,255,255,255); img->line(100,50+z,50,50,255,255,255); img->line(100,50-z,50,50,255,255,255); } return img; ]],[[ Image.GIF.decode(MIME.decode_base64( "R0lGODlhZABkAIAAAAAAAP///ywAAAAAZABkAAAC/wxwiGC7/l6UktZ6Mdatdr9toSiSZQmCjPihqPu+MdLST23Lsr7vGF7DrXw+YhEF3AiFx2NTFiwtnU5qMYpUVqvbrAT7/XG5Y3HYfD6TyWsw+vZms68qaTw3n/tazE/AvcCkpwcH95OkFkhIaGdYdwfIyDikePeIVzk5yacFdUmpOcfpIUiaiBnK5Wfp6YiaerT6SecKCrtX++o0mnnb+vrHyKvr+xgpKttbbDxLmGy77Hi86VoK28FnrfesTY3a7VwdjTc8HowJToZ9Ok6unLoemA6fOR+L3u5Fab/T8JzfaR89UPyKnYsnjFzBaP6IVWnoEGAjiKLcSXyYY6EihP8Xd2VkY8Cfxo7BKN4z2RHkCn4hI6Y8CS0LypcVW/ZbOZImCJsvSuq85hMJz5/wzrEYSrRonz85kwoFYtSpwagMqEr1xfRG06u4aGzliusrWFpjASIta1Ae2qnYrK51RjXr201u5c5FttTt3X561YqVmtVa0L2ezooxTDgM4sNVE2tZ/Njl25Ysh/zNF7SgzcsMP6qzzPkWxJEUQ4caHU4gWtQJVXM9+E7lPtOq6g38RxNhaJO0u7oeSFCn7mUc+07t1ft3zLTI23Fcfk0cZmXJg8cmTp02N5K5OEctN/3d33LVWXT3Rv0nbuM3a5XvmQv6r2+A47ME/35+zHmR8rdPj82eeM2ox45k/a1WoHwHrgWeLlYhwmCC31ni32cJWkYhYdM4yAqCEmboGDTdTBGiiPB1eNeGy1UIXHwrljjLNCxi9UYfMAZkiI034hhIAQA7")) ]]) test_do( add_constant("img", Image.Image(100,100,0,0,0)) ) test_do( img->line(40,0,0,40) ) test_equal( img->max(), ({ 0, 0, 0 }) ) test_do( img->line(10,10,20,20,128,13,42) ) test_equal( img->max(), ({ 128, 13, 42 }) ) test_do( img->setcolor(200,19,99) ) test_do( img->line(30,20,20,30) ) test_equal( img->max(), ({ 200, 19, 99 }) ) test_do( add_constant("img") ) test_any([[ object img=Image.Image(100,100,0,0,0); foreach (({40,60,50}),int z)
13670c2015-05-25Martin Nilsson  {
05bd782002-12-12Martin Nilsson  img->box(z,0,50,50,255,z,255); img->box(z,100,50,50,255,z,0); img->box(100,z,50,50,0,z,255); img->box(0,z,50,50,0,z,0); } return img; ]],[[ Image.GIF.decode(MIME.decode_base64( "R0lGODlhZABkALMAAAAAAAAyAAA8AAAoAP8oAP8yAAAo/wAy/wA8//88AP8o//8y//88/wAAAAAAAAAAACwAAAAAZABkAAME/xAAOWe1Fue8OVAKGIbhwjAniqKe17ouHMcznZEkbq7rats/IFA4nORypV6PVSw2nU4bErlb+qJRbDY7zVWtjO1WPKZ1SV9rubxmf86K9NLtpkfhcfC1XudL4XI9fX2DZoB6TISEijeHiIuLkBZ4gXuRkYSUiGGYmJmOep6efZqPo6NspaGoqGOqYK2tW69qsrJOtHO3t0O5gry8f2eVicHBHr6Wx8eToLDMzI3Dm9HRzdOm1tHJxdrB3Jzex+DizOTl38616Lfn7LLu76jx8p709ZH3+J/Yq/uY+v65CSiwDMGCs9TpYjZgQEOHDiFGjDiRIkWLFy9mJMbAgAGPH/8/hhQpkmTJkidRatS4kiVLly8HcESJkmbNmjdLxoy5kydPhzNx4hQ6dOjPn0eRUgxatGjTokqVRuXJ1KlTqyqlStWqserVq18NbN06dukmsGDRfiRLlq3Ms2nTgm3blqxXuXJr1q0r9W7evCIDBBA8eHBhw4YRJ068mDFjxwEOHJA8eXJly5YxZ868mTNnzgIEhBYtmnTp0qdRo1a9enXrAggQxJYtm3bt2rdx49a9e/du166BBw8+nLgA2L59J1eunLly48ahR48uGnnz5texY8dNnXp376itb98+njx38ODRGxdv3nz75unTxw/O3r17++fly9df/f59/77tt5/lgMf995+BtQ044H71HXggeQsumF6DDz7YnDYEEJChhhpqWEACCYAYYoghIrRIhx2i+CGJJJJoIiEppuhhiy2W+GIdMsq4Yo0u3uhGjinuyGMCPv4I5IxD2ljkGEcimeSSZTRJgJA8Qslkk1TWaOUWUmbZ4pZZdJmkkmAOIeaYZTpx5pNpmonlmES2CcSaQ8o555to2kkDnVXqGQOfWvrpAqBfCuoBoT0amgGiZCoKAKNxOjoBpJJaQGmlj+LJZqWXcqppnZh2KqmojpKqqKmGoiqoqn6yqqerdsIqp6xt0pqmrYtEAAA7")) ]]) test_do( add_constant("img", Image.Image(100,100,0,0,0)) ) test_do( img->box(40,0,0,40) ) test_equal( img->max(), ({ 0, 0, 0 }) )
234bec2004-05-03Martin Nilsson test_equal( img->min(), ({ 0, 0, 0 }) ) test_equal( img->sum(), ({ 0, 0, 0 }) ) test_equal( img->sumf(), ({ 0.0, 0.0, 0.0 }) ) test_equal( img->average(), ({ 0.0, 0.0, 0.0 }) )
05bd782002-12-12Martin Nilsson test_do( img->box(10,10,20,20,128,13,42) ) test_equal( img->max(), ({ 128, 13, 42 }) )
234bec2004-05-03Martin Nilsson test_equal( img->min(), ({ 0, 0, 0 }) ) test_equal( img->sum(), ({ 15488, 1573, 5082 }) ) test_equal( (array(int))img->sumf(), ({ 15488, 1573, 5082 }) ) test_equal( (array(int))img->average(), ({ 1, 0, 0}) )
05bd782002-12-12Martin Nilsson test_do( img->setcolor(200,19,99) ) test_do( img->box(30,20,20,30) ) test_equal( img->max(), ({ 200, 19, 99 }) )
234bec2004-05-03Martin Nilsson test_equal( img->min(), ({ 0, 0, 0 }) ) test_equal( img->sum(), ({ 39560, 3859, 17019 }) ) test_equal( (array(int))img->sumf(), ({ 39560, 3859, 17019 }) ) test_equal( (array(int))img->average(), ({ 3, 0, 1 }) )
05bd782002-12-12Martin Nilsson test_do( add_constant("img") ) test_define(test_polygone,[[ test_any_equal([[ object img=Image.Image(100,100,0,0,0); float x=0,y=0.2; img->setcolor(255,254,253); img->polygone(({10+x,15+y,15+x,10+y,15+x,15+y}), ({20+x,15+y,25+x,15+y,20+x,10+y}), ({10+x,20+y,15+x,20+y,15+x,25+y}), ({20+x,25+y,25+x,20+y,20+x,20+y}),
13670c2015-05-25Martin Nilsson 
05bd782002-12-12Martin Nilsson  ({30+2*10+x,15+y,30+2*15+x,10+y,30+2*15+x,15+y}), ({30+2*20+x,15+y,30+2*25+x,15+y,30+2*20+x,10+y}), ({30+2*10+x,20+y,30+2*15+x,20+y,30+2*15+x,25+y}), ({30+2*20+x,25+y,30+2*25+x,20+y,30+2*20+x,20+y}),
13670c2015-05-25Martin Nilsson 
05bd782002-12-12Martin Nilsson  ({10+x,30+2*15+y,15+x,30+2*10+y,15+x,30+2*15+y}), ({20+x,30+2*15+y,25+x,30+2*15+y,20+x,30+2*10+y}), ({10+x,30+2*20+y,15+x,30+2*20+y,15+x,30+2*25+y}), ({20+x,30+2*25+y,25+x,30+2*20+y,20+x,30+2*20+y})); object img1=Image.GIF.decode(MIME.decode_base64( "R0lGODlhZABkAMQAAAAAAAICAgUFBQoKChYWFigoKC0tLTAwMDIyMjMyMj8/P1lYWFFRUHJycXp5eYyLi6OioaWlpK2srLW0s8vLyszLytbV1Ojn5vTz8vn49/z7+v/+/QAAAAAAAAAAAAAAACwAAAAAZABkAAQF/yAAiONYmiaapivLuu8byzJd1zeO6/ve+z5gMDgkEo3HY1KpZDabTyhUOp1WrVZsNrvlcr3fb1gsJpfLZzRafWSw3Osd4bF7EOLtDCsDx6fmGBs7Gxh2fjgMGYIpG3yHAIAbG4s1k4SGjyaJkyyTjnGRlpQyopd3j5ucjJ59X6Glg6WmhwYICLYst7cGaAW6uro7wMAIBZmZx8jIysvLzc7O0GUOFBTVLNbWDmgKE9nZ1jvg4BMKhwISlp2TEgJrAw0XsrGiFw0DmeiqJuzuePDy1OGod8+Zvk7tMgHcR2qDPXzRAKBjkXAZwB0PI6bwZ4KjM4g1QGrUOJIkSZMnT+6mVKmSZcuWL2HClDlzZk2bNnHmzLmTJ0+fP38GFSqUaNGiR5EiVbp0aVOnTqFGjTqV6hdjKbBadRaBRdetywpoYKFBK9hDEUYB2PD1rB+xajeUdesnbVy2dOPAvTs3bxm7d/H6vapBIL9JfQdbARxYsOIpBxIkkMxi8uQDjx9n1qyZc+fOn0GDFj169CMI4LBlg2D6yAJR6yYtaE0kgAXDIyxZCECbyGuGa2X3rn377u7hvoELRx7EdtzjzIO87jQ7enMLLKBb91HdRPftO3inEA8efHnz5tGnT7+ePXv379/Hly+ffv369/HjPxQCADs=")); return $1; ]],[[$2]]) ]]) test_polygone(img-img1<16, 1) test_polygone(img->max(), ({255,254,253}) ) define(test_polyfill,[[ test_any_equal([[ object img=Image.Image(100,100,0,0,0); float x=0,y=0.2; img->setcolor(255,254,253); img->polygone(({10+x,15+y,15+x,10+y,15+x,15+y}), ({20+x,15+y,25+x,15+y,20+x,10+y}), ({10+x,20+y,15+x,20+y,15+x,25+y}), ({20+x,25+y,25+x,20+y,20+x,20+y}),
13670c2015-05-25Martin Nilsson 
05bd782002-12-12Martin Nilsson  ({30+2*10+x,15+y,30+2*15+x,10+y,30+2*15+x,15+y}), ({30+2*20+x,15+y,30+2*25+x,15+y,30+2*20+x,10+y}), ({30+2*10+x,20+y,30+2*15+x,20+y,30+2*15+x,25+y}), ({30+2*20+x,25+y,30+2*25+x,20+y,30+2*20+x,20+y}),
13670c2015-05-25Martin Nilsson 
05bd782002-12-12Martin Nilsson  ({10+x,30+2*15+y,15+x,30+2*10+y,15+x,30+2*15+y}), ({20+x,30+2*15+y,25+x,30+2*15+y,20+x,30+2*10+y}), ({10+x,30+2*20+y,15+x,30+2*20+y,15+x,30+2*25+y}), ({20+x,30+2*25+y,25+x,30+2*20+y,20+x,30+2*20+y})); object img1=Image.GIF.decode(MIME.decode_base64( "R0lGODlhZABkAMQAAAAAAAICAgUFBQoKChYWFigoKC0tLTAwMDIyMjMyMj8/P1lYWFFRUHJycXp5eYyLi6OioaWlpK2srLW0s8vLyszLytbV1Ojn5vTz8vn49/z7+v/+/QAAAAAAAAAAAAAAACwAAAAAZABkAAQF/yAAiONYmiaapivLuu8byzJd1zeO6/ve+z5gMDgkEo3HY1KpZDabTyhUOp1WrVZsNrvlcr3fb1gsJpfLZzRafWSw3Osd4bF7EOLtDCsDx6fmGBs7Gxh2fjgMGYIpG3yHAIAbG4s1k4SGjyaJkyyTjnGRlpQyopd3j5ucjJ59X6Glg6WmhwYICLYst7cGaAW6uro7wMAIBZmZx8jIysvLzc7O0GUOFBTVLNbWDmgKE9nZ1jvg4BMKhwISlp2TEgJrAw0XsrGiFw0DmeiqJuzuePDy1OGod8+Zvk7tMgHcR2qDPXzRAKBjkXAZwB0PI6bwZ4KjM4g1QGrUOJIkSZMnT+6mVKmSZcuWL2HClDlzZk2bNnHmzLmTJ0+fP38GFSqUaNGiR5EiVbp0aVOnTqFGjTqV6hdjKbBadRaBRdetywpoYKFBK9hDEUYB2PD1rB+xajeUdesnbVy2dOPAvTs3bxm7d/H6vapBIL9JfQdbARxYsOIpBxIkkMxi8uQDjx9n1qyZc+fOn0GDFj169CMI4LBlg2D6yAJR6yYtaE0kgAXDIyxZCECbyGuGa2X3rn377u7hvoELRx7EdtzjzIO87jQ7enMLLKBb91HdRPftO3inEA8efHnz5tGnT7+ePXv379/Hly+ffv369/HjPxQCADs=")); return $1; ]],[[$2]]) ]]) test_polyfill(img-img1<16, 1) test_polyfill(img->max(), ({255,254,253}) )
234bec2004-05-03Martin Nilsson // Image.Image operations test_do([[ add_constant("img", lambda(void|int x,void|int y) { return Image.Image(x||50,y||50,0,0,0,)->test(); }) ]]) test_do( img()->apply_curve( enumerate(256,-1,255) ) ) test_do( img()->apply_curve( "red", enumerate(256,-1,255) ) ) test_do( img()->apply_curve( "green", enumerate(256,-1,255) ) ) test_do( img()->apply_curve( "blue", enumerate(256,-1,255) ) ) test_do( img()->apply_curve( "value", enumerate(256,-1,255) ) ) test_do( img()->apply_curve( "saturation", enumerate(256,-1,255) ) ) test_do( img()->apply_curve( "hue", enumerate(256,-1,255) ) ) test_eval_error( img()->apply_curve( "bar", enumerate(256,-1,255) ) ) test_do([[ img()->apply_matrix( ({ ({-1,-1,-1}), ({-1,16,-1}), ({-1,-1,-1}) }) ) ]]) test_do([[ img()->apply_matrix( ({ ({1,1,1}), ({1,-8,1}), ({1,1,1}) }) ) ]]) test_do([[ img()->apply_matrix( ({ ({0,0,0}), ({1,-2,1}), ({0,0,0}) }) ) ]]) test_do([[ img()->apply_matrix( ({ ({2,1,0}), ({1,0,-1}), ({0,-1,-2}) }), 128, 128, 128, 3.0 ) ]]) // MISSING_TEST: apply_max // autocrop tests above // average tests above test_do( img()->bitscale(0.75) ) test_do( img()->bitscale(1.3, 0.6) ) test_do( img()->bitscale(47, 11) ) test_do( img()->bitscale(99, 0) ) test_do( img()->bitscale(0, 99) ) test_do( img()->blur(0) ) test_do( img()->blur(1) ) test_do( img()->blur(5) ) test_do( img(100,100)->box(40,10,10,80) ) test_do( img(100,100)->box(40,10,10,80,0,255,0) ) test_do( img(100,100)->box(40,10,10,80,255,0,0,75) )
5f59c02006-08-31Martin Nilsson test_do( img(10,10)->setcolor(255,17,48,80)->box(0,2,11,9) )
234bec2004-05-03Martin Nilsson  test_do( (string)img() ) test_do( (array)img() ) test_do( img()->change_color(255,255,255) ) test_do( img()->change_color(1,2,3,10,20,30) ) test_do( img(100,100)->circle(50,50,30,50) ) test_do( img(100,100)->circle(50,50,30,50,0,255,255) ) test_do( img(100,100)->circle(50,50,30,50,0,255,255,75) ) test_do( img()->clear() ) test_do( img()->clear(0,128,255) ) test_do( img()->clear(0,128,255,66) ) test_do( img()->clone() ) test_do( img()->clone(20,20) ) test_do( img()->clone(100,100) ) test_do( img()->clone(100,100,27,55,111) ) test_do( img()->clone(99,99,66,33,22,11) ) test_do( img()->color() ) test_do( img()->color(69) ) test_do( img()->color(128,128,255) ) test_do( img()->copy() ) test_do( img()->copy(5,5,45,45) ) test_do( img()->copy(-5,-5,55,55) ) test_do( img()->copy(-5,-5,55,55,255,0,0) ) test_do( img()->copy(-5,-5,55,55,255,0,0,99) ) test_do( Image.Image() ) test_do( Image.Image(100,100) ) test_do( Image.Image(100,100, Image.Color("red")) ) test_do( Image.Image(100,100, "red") ) test_do( Image.Image(100,100, "grey", 128) ) test_do( Image.Image(100,100, "rgb", 11,22,33) ) test_do( Image.Image(100,100, "cmyk", 10,20,30,40) ) test_do( Image.Image(100,100, "test") ) test_do( Image.Image(100,100, "gradients") ) test_do( Image.Image(100,100, "noise", ({0, ({0,0,0}), 0.8, ({255,255,255}) }) ) ) test_do( Image.Image(100,100, "turbulence", ({0, ({0,0,0}), 0.8, ({255,255,255}) }) ) ) test_do( Image.Image(100,100, "random") ) test_do( Image.Image(100,100, "randomgrey") ) test_do( Image.Image(100,100, "tuned_box", ({ Image.Color.black, Image.Color.black, Image.Color.white, Image.Color.white}) ) ) test_eval_error( Image.Image(100,100, "bacon") ) test_do( Image.Image(100,100, 255,255,0) ) dnl test_do( Image.Image(100,100, 255,255,0,40) )
f14ba42017-12-28Martin Nilsson test_do( Image.Image(Image.Image(100,100,"test")) )
234bec2004-05-03Martin Nilsson  test_do( img()->dct(100,100) ) test_do( img()->distancesq() ) test_do( img()->distancesq(0,255,255) )
f14ba42017-12-28Martin Nilsson // find_autocrop above
234bec2004-05-03Martin Nilsson  // MISSING TEST: find_max // MISSING TEST: find_min test_do( img()->gamma(0.8) ) test_do( img()->gamma(0.9, 0.8, 1.1) ) // MISSING TEST: get_pixel
1cb48d2004-05-13Martin Nilsson // MISSING TEST: gradients
234bec2004-05-03Martin Nilsson 
1cb48d2004-05-13Martin Nilsson test_do( img()->grey() ) test_do( img()->grey(0,0,255) )
234bec2004-05-03Martin Nilsson 
1cb48d2004-05-13Martin Nilsson test_do( img()->grey_blur(1) ) test_do( img()->grey_blur(5) ) test_do( img()->hsv_to_rgb() ) test_do( img()->invert() ) test_do( img(100,100)->line(50,10,10,50) ) test_do( img(100,100)->line(50,10,10,50,255,0,0) ) test_do( img(100,100)->line(50,10,10,50,255,0,0,50) ) test_do([[ Image.Image i=img(); array(Image.Image) a=i->orient4(); a[1]*=215; a[3]*=215; i->make_ascii(@a); ]])
41248e2005-08-14Martin Nilsson // MISSING COMPATIBILITY TEST: map_closest // MISSING COMPATIBILITY TEST: map_fast // MISSING COMPATIBILITY TEST: map_fs
1cb48d2004-05-13Martin Nilsson // MISSING TEST: match
234bec2004-05-03Martin Nilsson  // max tests above // min tests above
1cb48d2004-05-13Martin Nilsson  test_any([[ Image.Image i=img(); return i->mirrorx()->mirrorx() == i; ]], 1)
41248e2005-08-14Martin Nilsson 
1cb48d2004-05-13Martin Nilsson test_any([[ Image.Image i=img(); return i->mirrory()->mirrory() == i; ]], 1) test_do( img()->grey()->modify_by_intensity(1,0,0,0,({255,0,0}),({0,255,0})) ) test_do( img()->noise(({0,({255,0,0}),0.3,({0,255,0}),0.6,({0,0,255}),0.8, ({255,255,0})})) ) test_do( img()->noise(({0,({255,0,0}),0.3,({0,255,0}),0.6,({0,0,255}),0.8, ({255,255,0})}), 0.2,0.0,0.0,1.0) )
41248e2005-08-14Martin Nilsson test_do( img()->orient() ) test_eq( sizeof(img()->orient4()), 4 ) test_do( img()->outline() ) test_do( img()->outline(12, 34, 56) ) test_do( img()->outline(55, 55, 55, 78, 90, 123) ) test_do( img()->outline( ({({1,1,0}),({1,1,1}),({0,0,1})}) ) ) test_do( img()->outline( ({({1,1,0}),({1,1,1}),({0,0,1})}), 33, 44, 55 ) ) test_do( img()->outline( ({({1,1,0}),({1,1,1}),({0,0,1})}), 47, 11, 00, 17, 42, 242 ) ) test_do( img()->outline_mask() ) test_do( img()->outline_mask(99, 99, 112) ) test_do( img()->outline_mask( ({({1,1,0}),({1,1,1}),({0,0,1})}) ) ) test_do( img()->outline_mask( ({({1,1,0}),({1,1,1}),({0,0,1})}), 101, 202, 33 ) ) // MISSING TEST: paste // MISSING TEST: paste_alpha // MISSING TEST: paste_alpha_color // MISSING TEST: paste_mask test_do( img()->phaseh() ) test_do( img()->phasev() ) test_do( img()->phasevh() ) test_do( img()->phasehv() ) test_do( Image.Image(100,100)->setcolor(255,0,0,128)-> polyfill( ({20,20, 80,20, 80,80 }) ) ) test_true( img()->random() != img()->random() )
aff9242016-01-17Martin Nilsson test_eq( (string)Image.Image(4,4)->random(42), String.hex2string("aacb8f50fe20afc5db8d2f676a5e56bd8dc87ac09bc2805b34156d026685411a793213af0518233d7bf0439233d7a6fc") ) test_do( img()->random(Random.Deterministic(42)->random_string) )
41248e2005-08-14Martin Nilsson 
aff9242016-01-17Martin Nilsson test_do( img()->randomgrey() != img()->randomgrey() ) test_eq( (string)Image.Image(4,4)->randomgrey(42), String.hex2string("bdbdbd5656565e5e5e6a6a6a6767672f2f2f8d8d8ddbdbdbc5c5c5afafaf202020fefefe5050508f8f8fcbcbcbaaaaaa") ) test_do( img()->randomgrey(Random.Deterministic(42)->random_string) )
41248e2005-08-14Martin Nilsson  test_eq( img()->write_lsb_rgb("hello")->read_lsb_rgb(), "hello"+"\0"*933 ) test_eq( img()->write_lsb_grey("hello")->read_lsb_grey(), "hello"+"\0"*308 ) test_do( img()->rgb_to_hsv() ) test_do( img()->rotate(17) ) test_do( img()->rotate(33.333) ) test_do( img()->rotate(44, 250, 1, 2) )
1cb48d2004-05-13Martin Nilsson 
41248e2005-08-14Martin Nilsson test_do( img()->rotate_expand(18) ) test_do( img()->rotate_expand(34.333) ) test_do( img()->rotate_expand(45, 241, 2, 3) ) test_do( img()->rotate_ccw() ) test_do( img()->rotate_cw() ) test_do( img()->scale(0.5) ) test_do( img()->scale(3.7) ) test_do( img()->scale(2.1, 0.9) ) test_do( img()->scale(101, 99) ) test_do( img()->scale(0, 55) ) test_do( img()->scale(0, 33) ) test_do( img()->scale(55, 0) ) test_do( img()->scale(33, 0) ) // MISSING COMPATIBILITY TEST: select_colors test_do( img()->setcolor( 255, 0, 128 ) ) test_do( img()->setcolor( 128, 255, 0, 192 ) ) test_do( img()->setpixel( 37, 48 ) ) test_do( img()->setpixel( 50, 50 ) ) test_do( img()->setpixel( 11, 12, Image.Color.red ) ) test_do( img()->setpixel( 11, 12, 13, 14, 15 ) ) test_do( img()->setpixel( 22, 23, 24, 25, 26, 27 ) ) test_do( img()->skewx(10) ) test_do( img()->skewx(16.4) ) test_do( img()->skewx(13, 26, 36, 47) ) test_do( img()->skewx(22.8, 100, 75, 26) ) test_do( img()->skewy(10) ) test_do( img()->skewy(16.4) ) test_do( img()->skewy(13, 26, 36, 47) ) test_do( img()->skewy(22.8, 100, 75, 26) )
1cb48d2004-05-13Martin Nilsson 
234bec2004-05-03Martin Nilsson // sum tests above // sumf tests above
68fa9d2016-04-04Henrik Grubbström (Grubba) test_any([[ string i = (string)Image.Image(4,4)->test(42); string expected = String.hex2string("f15a00af68556c879b539aac904c946c70ad35a0cd35aebf5000fe4a77e100bafc24cbb2a0b4ff6393e32dc3b929ff67"); if (i == expected) return 0; // The test image is generated with doubles, and my be off by 1 // in a few places if the mantissa is small. if (sizeof(i) != sizeof(expected)) return String.string2hex(i); for (int j = 0; j < sizeof(i); j++) { if ((i[j] > expected[j] + 1) || (i[j] < expected[j] - 1)) { return String.string2hex(i); } } // All pixels are within the tolerance limits. return 0; ]], 0)
aff9242016-01-17Martin Nilsson test_do( img()->test(Random.Deterministic(42)->random) )
41248e2005-08-14Martin Nilsson  test_do( img()->threshold() ) test_do( img()->threshold(28) ) test_do( img()->threshold(128, 255, 111) ) test_do( img()->threshold(Image.Color.green) ) test_do( img()->tuned_box(10,10,40,40, ({({255,0,0}),({255,255,255}),({128,100,0}),({0,70,255})}) ) ) test_do( img()->tuned_box(10,10,40,40, ({({255,0,0,0}),({255,255,255,240}),({128,100,0,230}),({0,70,255,7})}) ) ) test_do( img()->turbulence( ({0, ({229,204,204}), 0.9,({229,20,20}), 0.9,Image.Color.black}) ) ) test_eq( img(77,88)->xsize(), 77 ) test_eq( img(77,88)->ysize(), 88 )
234bec2004-05-03Martin Nilsson test_do( add_constant("img") )
05bd782002-12-12Martin Nilsson test_true( objectp(Image.Font()) ) test_eq( Image.Font()->write("hej"), Image.PNM.decode(MIME.decode_base64("UDQKMTkgMTEK///gv/7gv//grzjglt7gth7gtv7gtv7gtx7g//7g//Hg")) ) test_eq( Image.Font()->write("h","o"), Image.PNM.decode(MIME.decode_base64("UDQKNyAyMwr+vr6ulra2trb+/v7+/s62tra2zv7+/g==")) )
3f1fac2006-07-26Martin Nilsson  dnl #### Colortable
05bd782002-12-12Martin Nilsson define(test_blackwhite,[[ test_equal_any($1,[[ (< Image.Color.white, Image.Color.black >) ]]) ]]) test_blackwhite([[ return (multiset)(array)Image.Colortable( ({Image.Color.white,Image.Color.black})) ]]) test_blackwhite([[ object img=Image.Image(100,100)->test(43); object c=Image.Colortable(({Image.Color.white,Image.Color.black})); img=c*img; return (multiset)(array)Image.Colortable(img); ]]) test_blackwhite([[ object img=Image.Image(100,100)->test(43); object c=Image.Colortable(({Image.Color.white,Image.Color.black})); c->floyd_steinberg(); img=c*img; return (multiset)(array)Image.Colortable(img); ]]) test_blackwhite([[ object img=Image.Image(100,100)->test(43); object c=Image.Colortable(({Image.Color.white,Image.Color.black})); c->ordered(); img=c*img; return (multiset)(array)Image.Colortable(img); ]]) define(test_coltab,[[ test_do([[ object img=Image.Image(200,200)->test(42); img->tuned_box(50,50,150,150, ({({0,0,0}),({255,0,0}),({0,255,0}),({0,0,255})})); add_constant("img", img); ]]) $1 test_do( add_constant("img") ) ]]) test_coltab([[ test_do([[ add_constant("c", Image.Colortable(img,1000)->cubicles(16,16,16,4) ) ]]) test_true( sizeof(c)>=200 ) test_true( img-(c*img)<50 ) test_do( add_constant("c") ) ]]) test_coltab([[ test_do([[ add_constant("c", Image.Colortable(32,32,32)->floyd_steinberg() ) ]]) test_true( img-(c*img)<50 ) test_do( add_constant("c") ) ]]) test_coltab([[ test_do([[ add_constant("c", Image.Colortable(32,32,32)->ordered()) ]]) test_true( img-(c*img)<32 ) test_do( add_constant("c") ) ]])
3f1fac2006-07-26Martin Nilsson test_true( Image.Colortable(Image.Image(10,10)->randomgrey())->greyp() ) test_false( Image.Colortable(Image.Image(10,10,255,0,0))->greyp() ) dnl #### Encodings
05bd782002-12-12Martin Nilsson 
5697552015-08-08Martin Nilsson define(test_image_any,[[
4402032016-12-15Henrik Grubbström (Grubba)  cond_resolv(Image.$1, [[ test_any([[ return Image.ANY.decode(Image.$1.encode(Image.Image(10,10)))->xsize(); ]],10) test_any([[ mapping m=Image.ANY._decode(Image.$1.encode(Image.Image(10,10))); if(!m->image || !m->type) return -1; if(!has_prefix(m->type, "image/")) return -2; return 1; ]], 1) ]])
5697552015-08-08Martin Nilsson ]]) ; Missing tests for XCF, PSD, TIM, XWD test_image_any(PNM) test_image_any(JPEG) test_image_any(PNG) test_image_any(GIF) test_image_any(ILBM) test_image_any(BMP) test_image_any(RAS) test_image_any(PVR) test_image_any(PCX)
05bd782002-12-12Martin Nilsson define(test_encoding,[[
d2f0382004-03-20Henrik Grubbström (Grubba)  cond( (master()->resolv("Image.$1")||([]))->encode,[[
05bd782002-12-12Martin Nilsson  test_any([[ object img=Image.Image(100,100)->test(40); $2 object img1=Image.$1.decode(Image.$1.encode(img$3)); return img==img1; ]],1) ]]) ]]) test_encoding(AVS,,) test_encoding(BMP,,) test_encoding(BMP,[[ img=Image.Colortable(img,256)*img; ]],[[,(["bpp":8])]]) test_encoding(BMP,[[ img=Image.Colortable(img,16)*img; ]],[[,(["bpp":4])]]) test_encoding(BMP,[[ img=Image.Colortable(img,2)->floyd_steinberg()*img; ]],[[,(["bpp":1])]]) define(test_bmp_rle,[[ test_any([[ object img=Image.Image(400,100,Image.Color.red); img->line(0,0,0,99,Image.Color.green); img->line(399,0,399,99,Image.Color.blue); object c=Image.Colortable(img,pow(2,$1)); img=c*img; return Image.BMP.decode(Image.BMP.encode(img,(["bpp":$1,"rle":1])))==img; ]],1) ]]) test_bmp_rle(8) test_bmp_rle(4) test_encoding(BMP,[[ img=img->scale(400,100); object c=Image.Colortable(img,256); img=c*img; ]],[[,(["bpp":8,"rle":1])]]) test_encoding(BMP,[[ img=img->scale(400,100); object c=Image.Colortable(img,16); img=c*img; ]],[[,(["bpp":4,"rle":1])]])
1cb48d2004-05-13Martin Nilsson test_do([[ Image.Image img=Image.Image(50,50)->test(); string s = Image.BMP.encode(img); return Image.BMP.decode(s, (["quality":50])); ]])
05bd782002-12-12Martin Nilsson 
f453212002-12-12Martin Nilsson test_encoding(GIF,[[ img = Image.Colortable(img,250)->cubicles(10,10,10,1)-> floyd_steinberg()*img; ]],) test_encoding(GIF,[[ object c=Image.Colortable(img,256)->cubicles(16,16,16,1); img=c*img; ]],[[,c]]) test_any([[ object img=Image.Image(100,100)->test(43); object c=Image.Colortable(img,256)->floyd_steinberg()->cubicles(16,16,16); img=c*img; object img1=Image.GIF.decode(Image.GIF.encode(img,c)); return img-img1<50; ]],1)
05bd782002-12-12Martin Nilsson test_any([[ object img=Image.Image(256,240)->test(43); img=Image.Colortable( ({"white","black","red","green"}) )*img; return Image.HRZ.decode(Image.HRZ.encode(img))==img; ]],1) test_encoding(ILBM,[[ img=Image.Colortable(img,16)*img; ]],)
f453212002-12-12Martin Nilsson 
d2f0382004-03-20Henrik Grubbström (Grubba) cond( (master()->resolv("Image.JPEG")||([]))->encode,[[
f453212002-12-12Martin Nilsson  test_any([[ object img=Image.Image(100,100)->test(43); object img1=Image.JPEG.decode(Image.JPEG.encode(img,(["quality":100])));
5697552015-08-08Martin Nilsson  return img-img1<20;
f453212002-12-12Martin Nilsson  ]],1) ]])
05bd782002-12-12Martin Nilsson test_encoding(PCX,,)
f453212002-12-12Martin Nilsson test_encoding(PNG,,)
05bd782002-12-12Martin Nilsson test_encoding(PNM,,)
f453212002-12-12Martin Nilsson dnl test_encoding(PVR,,) test_encoding(RAS,,)
05bd782002-12-12Martin Nilsson test_encoding(TGA,,)
f453212002-12-12Martin Nilsson dnl test_encoding(WBF,[[ dnl object c=Image.Colortable(({Image.Color.white,Image.Color.black})); dnl img=c*img; dnl ]],) dnl test_encoding(WBMP,[[ dnl object c=Image.Colortable(({Image.Color.white,Image.Color.black})); dnl img=c*img; dnl ]],)
05bd782002-12-12Martin Nilsson test_encoding(XBM,[[ object c=Image.Colortable(({Image.Color.white,Image.Color.black})); img=c*img; ]],)
b491e92012-02-11Marcus Comstedt cond_resolv( Image.PNG.decode_header, [[ test_equal( Image.PNG.decode_header(Image.PNG.encode(Image.Image(20,20))), (["bpp":8, "type":2, "xsize":20, "ysize":20 ]) ) ]]) cond_resolv( Image.PNG.encode, [[ test_true( Image.PNG.encode(Image.Image(5,5)) ) test_true( Image.PNG.encode(Image.Image(5,5), ([])) ) test_true( Image.PNG.encode(Image.Image(5,5), (["alpha":0])) ) test_eval_error( Image.PNG.encode(Image.Image(5,5), (["alpha":"x"])) ) test_eval_error( Image.PNG.encode(Image.Image(5,5), (["alpha":Image.Image(4,4)])) ) test_true( Image.PNG.encode(Image.Image(5,5), (["alpha":Image.Image(5,5)])) ) dnl FIXME: Test that alpha is actually encoded dnl FIXME: Test "palette" attribute test_eval_error( Image.PNG.encode(Image.Image(5,5), (["zlevel":"x"])) ) test_true( Image.PNG.encode(Image.Image(5,5), (["zlevel":0])) ) test_true( Image.PNG.encode(Image.Image(5,5), (["zlevel":9])) ) test_true( Image.PNG.encode(Image.Image(5,5), (["zstrategy":Gz.DEFAULT_STRATEGY])) ) test_true( Image.PNG.encode(Image.Image(5,5), (["zstrategy":Gz.FILTERED])) ) test_true( Image.PNG.encode(Image.Image(5,5), (["zstrategy":Gz.HUFFMAN_ONLY])) ) ]])
977c7f2014-07-04Henrik Grubbström (Grubba) cond_resolv( Image.PSD.decode, [[ test_true( arrayp(Image.decode_layers(Stdio.read_bytes("SRCDIR/corner2.psd"), ([ "crop_to_bounds":1 ]))) ) ]])
b491e92012-02-11Marcus Comstedt dnl ACK! cond_resolv does not nest. But if Gz.RLE or Gz.FIXED exists, it dnl means the Gz module is there, and in that case Image.PNG should be too...
d318912010-02-15Stephen R. van den Berg cond_resolv( Gz.RLE, [[
ad11dd2009-08-10Martin Nilsson  test_true( Image.PNG.encode(Image.Image(5,5), (["zstrategy":Gz.RLE])) ) ]])
00b3db2010-02-15Stephen R. van den Berg cond_resolv( Gz.FIXED, [[
ad11dd2009-08-10Martin Nilsson  test_true( Image.PNG.encode(Image.Image(5,5), (["zstrategy":Gz.FIXED])) ) ]])
d2f0382004-03-20Henrik Grubbström (Grubba) cond( (master()->resolv("Image.XFace")||([]))->encode,[[
05bd782002-12-12Martin Nilsson  test_any([[ object img=Image.Image(48,48)->test(43); object c=Image.Colortable(({Image.Color.white,Image.Color.black})); c->floyd_steinberg(); img=c*img; return Image.XFace.decode(Image.XFace.encode(img))==img; ]],1) ]])
f453212002-12-12Martin Nilsson test_encoding(XPM,[[
13670c2015-05-25Martin Nilsson  object c=Image.Colortable(16,16,16);
f453212002-12-12Martin Nilsson  img=c*img; ]],[[,(["colortable":c]) ]]) test_encoding(TIFF,,)
1169d92004-05-02Martin Nilsson END_MARKER