aebf321998-04-16Mirar (Pontus Hagland) #module Image.image { dnl-----------------------------------------------------------------------
8e781a1998-04-29Mirar (Pontus Hagland) #chapter testsuite
aebf321998-04-16Mirar (Pontus Hagland)  #test Image.PNM.decode, == object img1=Image.PNM.decode("P1\n5 5\n0 1 1 1 1\n1 0 1 1 1\n1 1 0 1 1\n1 1 1 0 1\n1 1 1 1 0"); object img2=Image.PNM.decode("P4\n5 5\nx¸Øèð"); if (img1!=img2) fail("differ\n"); ok(); #test MIME.decode_base64 if ("hejsan, hoppsan" != MIME.decode_base64("aGVqc2FuLCBob3Bwc2Fu\n")) fail("differ"); ok(); #test Image.GIF.decode, MIME.decode_base64, == object img1=Image.GIF.decode(MIME.decode_base64("R0lGODlhBQAFAIAAAAAAAP///ywAAAAABQAFAAACCAxwEWrY8BwoADs=")); object img2=Image.PNM.decode("P4\n5 5\nx\00èØèð"); if (img1!=img2) fail("differ\n"); ok(); dnl----------------------------------------------------------------------- #chapter create #test Image.image() no image object img=Image.image(); if (!img || img->xsize() || img->ysize()) fail("have size"); ok(); #test Image.image() image object img=Image.image(100,100); if (!img || img->xsize()!=100 || img->ysize()!=100) fail("wrong size"); if (img!=0) fail("wrong color"); ok(); #test Image.image() too big int x=1; while ((x<<1)>0) x=(x<<1)+1;
fa6e741998-04-17Mirar (Pontus Hagland)  if (!catch { Image.image(x,2); }) fail(x+"x2 permitted"); if (!catch { Image.image(x/32768,65537); }) fail((x/32768)+"x65537 permitted"); if (!catch { Image.image(x/(32768*3),65537); }) fail((x/(32768*3))+"x65537 permitted");
aebf321998-04-16Mirar (Pontus Hagland)  ok(); #test Image.image() color object img=Image.image(1000,1000,17,42,96); if (!img || img->xsize()!=1000 || img->ysize()!=1000) fail("wrong size"); if (img!=({17,42,96})) fail("wrong color"); ok(); dnl----------------------------------------------------------------------- #chapter testsuite II #test Image.image->test(), == object img=Image.image(10,10); img=img->test(); if (equal(img->max(),({0,0,0}))) fail("failed"); img->setpixel(2,2,0,255,0); if (img==img->invert()) fail("failed"); ok(); dnl----------------------------------------------------------------------- #chapter copy #test Image.image->copy object img=Image.image(100,100)->test(); if (img!=img->copy()) fail("differ"); if (img->copy(25,25,75,75)!=img->copy(25,25,75,75)) fail("subregion differ"); if (img->copy(25,25,75,75)==img) fail("subregion doesn't differ"); img->setpixel(2,2,0,255,0); if (img->copy()==img->invert()->copy()) fail("copy of other doesn't differ"); ok(); #test Image.image->clear object img=Image.image(100,100)->test(); if (img->clear()==img) fail("doesn't differ"); if (img->clear(0,0,0)!=0) fail("wrong color (black)"); if (img->clear(1,255,0)!=({1,255,0})) fail("wrong color (color)"); ok(); #test Image.image->clone object img=Image.image(100,100)->test(); if (img!=img->clone()) fail("differ"); img->setpixel(2,2,0,255,0); if (img->clone()==img->invert()->clone()) fail("clone of other doesn't differ"); ok(); dnl-----------------------------------------------------------------------
8e781a1998-04-29Mirar (Pontus Hagland) #chapter testsuite III
aebf321998-04-16Mirar (Pontus Hagland)  #test equal, copy_value array a=({0,0,0}); array b=copy_value(a); b[0]=17; b[1]=42; b[2]=128; if (!equal( ({0,0,0}), a)) fail("differ (1)"); if (!equal( ({17,42,128}), b)) fail("differ (2)"); ok(); #test Image.image->max() if (!equal( ({0,0,0}), Image.image(10,10,0,0,0)->max() )) fail("erranous (1)"); if (!equal( ({17,42,36}), Image.image(10,10,17,42,36)->max() )) fail("erranous (2)"); if (!equal( ({17,42,36}), Image.image(10,10,0,0,0) ->setpixel(5,5,17,42,36)->max() )) fail("erranous (3)"); if (!equal( ({17,42,36}), 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())) fail("erranous (4)");
acdcbc1998-04-19Mirar (Pontus Hagland)  if (!equal( ({17,42,36}), 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())) fail("erranous (5)");
aebf321998-04-16Mirar (Pontus Hagland)  ok(); dnl----------------------------------------------------------------------- #chapter plain #test setpixel, getpixel object img=Image.image(10,10,255,0,0); if (!equal(img->getpixel(5,5),({255,0,0}))) fail("getpixel erranous"); img->setpixel(5,5,1,2,3); if (!equal(img->getpixel(5,5),({1,2,3}))) fail("failed"); ok(); #test setpixel alpha object img=Image.image(10,10,255,0,0); img->setpixel(5,5,0,255,0,127); if (!equal(img->getpixel(5,5),({127,128,0}))) fail("failed"); ok(); #test Image.image->line structure object img=Image.image(100,100,0,0,0); foreach (({40,50,60}),int z) { img->line(50-z,0,50,50,255,255,255); img->line(50-z,100,50,50,255,255,255);
5d0a351998-04-19Mirar (Pontus Hagland)  img->line(100,50+z,50,50,255,255,255);
aebf321998-04-16Mirar (Pontus Hagland)  img->line(100,50-z,50,50,255,255,255); } object img1=Image.GIF.decode(MIME.decode_base64(
5d0a351998-04-19Mirar (Pontus Hagland)  "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"));
aebf321998-04-16Mirar (Pontus Hagland)  if (img!=img1) fail("differ"); ok();
acdcbc1998-04-19Mirar (Pontus Hagland) #test Image.image->line color
aebf321998-04-16Mirar (Pontus Hagland)  object img=Image.image(100,100,0,0,0); img->line(40,0,0,40); if (!equal( ({0,0,0}), img->max() )) fail("differ (reset)"); img->line(10,10,20,20,128,13,42); if (!equal( ({128,13,42}), img->max() )) fail("differ (direct)"); img->setcolor(200,19,99); img->line(30,20,20,30); if (!equal( ({200,19,99}), img->max() )) fail("differ (setcolor)"); ok();
5d0a351998-04-19Mirar (Pontus Hagland) #test Image.image->box structure object img=Image.image(100,100,0,0,0); foreach (({40,60,50}),int z) { 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); } object img1=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")); if (img!=img1) fail("differ"); ok(); #test Image.image->box color object img=Image.image(100,100,0,0,0); img->box(40,0,0,40); if (!equal( ({0,0,0}), img->max() )) fail("differ (reset)"); img->box(10,10,20,20,128,13,42); if (!equal( ({128,13,42}), img->max() )) fail("differ (direct)"); img->setcolor(200,19,99); img->box(30,20,20,30); if (!equal( ({200,19,99}), img->max() )) fail("differ (setcolor)"); ok(); dnl----------------------------------------------------- #chapter advanced drawing
acdcbc1998-04-19Mirar (Pontus Hagland) #test Image.image->polyfill 1 (right triangle 0.0, 0.2) 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}), ({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}), ({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="));
3139761998-04-30Mirar (Pontus Hagland)  if (!(img-img1<16)) fail("differ too much");
acdcbc1998-04-19Mirar (Pontus Hagland)  if (!equal(img->max(),({255,254,253}))) fail("wrong maxcolor"); ok(); #test Image.image->polyfill 2 (right triangle -0.2, -0.2) object img=Image.image(100,100,0,0,0); float x=-0.2,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}), ({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}), ({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( "R0lGODlhZABkANUAAAAAAAICAgUFBQcHBwoKChQUFBYWFh4eHiMjIyYmJS0tLTAwMDMyMigoKFFRUFlYWHp5eX9+fnJycYyLi56dnDIyMqOioaWlpMHBwMvLyszLytHQz9bV1Orp6Ojn5vTz8vz7+v/+/QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAZABkAAUG/0AAQDgcFo1GZDK5ZDKdz2dUKqVWq1csVrvddr1ecDg8JpPN53NarWa32284XD6f1+12fD6/5/P9f3+BgoKEhYVqAkmKiGQEWAMBjW0FFEkMEZNYBhMYWBUcD5KaWwUbGZchmaRGnB8hqFUVISGho6xJprCpqqyutLuywLWiuEO6wUMMwKuIv8OxUrPDxLeTAhQZGRkWSQ3b2w6FAQ8Y4ODcWN/o4BYNxsbw8fHz9PT29/f5ggIMDP7vjBD49w/BuAUECf4LKGWgQoUHWEUAFg3AMlodFCBqcAEEtWRPplHzIOGRRFoVL2bUxNEjxU8jS9KbmDLESlYtUcKkRdLkvf8IKW8aa1mRyaye+pKIM4JAo74GELAkkJk0aVWrVrFmzbqVK1evX7+GFSuWbNmyZ9GiVbt2bVu3buHGjTuXLl27d+/m1auXb9++fwEDFjx4cGHDhvlYs5b43oMkCxg2jmfAkxEGFybfm5AShGTNmgx8qJkZNKsJIJd5Nh36Vc0QpVkjQp2a1mrZgkTrvAwsNu48tGvb/vxbDQFz27oZWbctavHiz6FDlz59enXr1rFnz152QIUK3yUTAA8+AfczATi85A1MwvkzD9YrA+bB5/st6XfPp+X+Ppn4wtXnHxn5vdbfgGHEV5OACIaRXk0HNujFAykxKKEXASinTIQXbiEk2QH2ddihiCOOWKKJJqKYYoorssiiiy++GKOMMtJYY4034hYEADs="));
3139761998-04-30Mirar (Pontus Hagland)  if (!(img-img1<16)) fail("differ too much");
acdcbc1998-04-19Mirar (Pontus Hagland)  if (!equal(img->max(),({255,254,253}))) fail("wrong maxcolor"); ok();
5d0a351998-04-19Mirar (Pontus Hagland) #test Image.image->polyfill 3 (hollow stars)
acdcbc1998-04-19Mirar (Pontus Hagland)  object img=Image.image(100,100,0,0,0); int i; array a=({}),b=({}); foreach (({0,1,2,3,4}),i) { a+=({ 50+50*sin(i*2*3.1415926535/5+0.11), 50+50*cos(i*2*3.1415926535/5+0.11) }); a+=({ 50+19*sin((i+0.5)*2*3.1415926535/5+0.11), 50+19*cos((i+0.5)*2*3.1415926535/5+0.11) }); b+=({ 50+19*sin(i*2*3.1415926535/5+0.1), 50+19*cos(i*2*3.1415926535/5+0.1) }); b+=({ 50+0.5*5*sin((i+0.5)*2*3.1415926535/5+0.1), 50+0.5*5*cos((i+0.5)*2*3.1415926535/5+0.1) }); } img->setcolor(128,0,16); img->polyfill(a,b); a=({}),b=({}); foreach (({0,1,2,3,4,5,6}),i) { a+=({ 50+50*sin(i*2*3.1415926535/7+0.11), 50+50*cos(i*2*3.1415926535/7+0.11) }); a+=({ 50+19*sin((i+0.5)*2*3.1415926535/7+0.11), 50+19*cos((i+0.5)*2*3.1415926535/7+0.11) });
3139761998-04-30Mirar (Pontus Hagland)  b+=({ 50+0.9*50*sin(i*2*3.1415926535/7+0.11), 50+0.9*50*cos(i*2*3.1415926535/7+0.11) }); b+=({ 50+0.5*19*sin((i+0.5)*2*3.1415926535/7+0.11), 50+0.5*19*cos((i+0.5)*2*3.1415926535/7+0.11) });
acdcbc1998-04-19Mirar (Pontus Hagland)  } img->setcolor(255,128,0); img->polyfill(a,b); object img1=Image.GIF.decode(MIME.decode_base64(
3139761998-04-30Mirar (Pontus Hagland)  "R0lGODlhZABkAPcAAAAAAAEAAAIBAAQAAAIAAAMBAAUAAAQCAAUCAAMAAAcAAAgAAQYAAAcDAAkAAQsAAQwAAQsBAAoAAQkEAAoFAAsFAAwGAAgEAA0AAQ4AAQ8AARAAAhIAAhMAAhADABEAAhQAAhUAAhYAAhgAAxoAAxsAAw0GAA8HABEIABAIABEJABIJABMKAA4HABcAAhcIABUKABQKABYLABcLABkMABgMABoNABsNABwAAx0AAx4AAx8AAx0EASAABCEABCIABCQABCUABCYAAyQCAiYABCcABCgABSkABSsABSoABSwABS4ABS8ABTAABjEABjIABjAEBDMABjUABjcABjgABzcCBTYABjkABzoABzsABz0ABz4ABxwOAB0OAB4PAB0PAB8PACAQACEQACIRACMRACQSACcPACYTACcTACUSACgUACkUACkVACsWACoVACwWAC0WAC0XADEP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IhkBsAhkojk2+Q+/8ATgaBtTUDH90ApBiQtDVZSSwQCpUC24oAozAgv855SMAQiisgxUqQ8siZWMkQGVdg1UGQ5vBpaSUQjoMA+roChahpaMMQJLkinRIG5wGRia0A+xogyveJdSEQTcsCy64JeSwQvu8A+aQJiMEQj40A93oJiBMQDTkA7EBplqsQnXYJmB4QHLoJmBIQe2EhAAOw=="));
92cf601998-04-20Mirar (Pontus Hagland) 
acdcbc1998-04-19Mirar (Pontus Hagland) 
3139761998-04-30Mirar (Pontus Hagland)  if (!(img-img1<16)) fail("differ too much");
5d0a351998-04-19Mirar (Pontus Hagland) dnl known failure dnl if (!equal(img->max(),({255,128,16}))) dnl fail("wrong maxcolor ("+img->max()[0]+","+img->max()[1]+","+img->max()[2]+")");
acdcbc1998-04-19Mirar (Pontus Hagland)  ok();
5d0a351998-04-19Mirar (Pontus Hagland)  #test Image.image->polyfill 4 (star) int i; array a=({}); foreach (({0,1,2,3,4}),i) { a+=({ 50+50*sin(i*2*3.1415926535/5+0.11), 50+50*cos(i*2*3.1415926535/5+0.11) }); a+=({ 50+20*sin((i+0.5)*2*3.1415926535/5+0.11), 50+20*cos((i+0.5)*2*3.1415926535/5+0.11) }); } object img=Image.image(100,100,0,0,0); img->setcolor(128,0,16); img->polyfill(a); object img1=Image.GIF.decode(MIME.decode_base64( "R0lGODlhZABkAOYAAAAAAAIAAAEAAAQAAAUAAAYAAAMAAAgAAQkAAQoAAQsAAQwAAQ0AAQ4AAQ8AAQcAABAAAhEAAhIAAhMAAhUAAhQAAhYAAhcAAhgAAxkAAxoAAxsAAxwAAx0AAx4AAx8AAyAABCEABCIABCMABCQABCUABCYABCcABCgABSkABSoABSsABSwABS0ABS4ABS8ABTAABjEABjIABjMABjQABjUABjYABjcABjgABzkABzoABzsABzwABz0ABz4ABz8AB0AACEMACEIACEYACEcACEgACUkACUoACUsACUwACU0ACU4ACU8ACVAAClIAClEAClMAClUAClgAC1cAClkAC1YAClsAC1wAC10AC14AC18AC2AADG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5lAX6Z6IHDWClJyZ8caX1ChhBA2nFGdGWfFkGVfetSRhhdTIAFEDSl4IMEDkrxQ3RJa3QCXHnKgwUUVR/wwAwocROCo1ioBmNZaDE5F0IMMJmzgwLDJ1GAcpxfOMoAbrZmUsi2sgUbFy7YUMG1kPNBsCx6gfaCzpUIulgfJP4dCRGRfFD0LA0r6RITSs6Q1WKVQtyLBvVfpwUDVsEDRlxpcwxLdWE6EDQtMV9VgdisdnFkNBmu3ol1Mc9gadygj+ITF3a2AERMQfKuSQkwqBn6KGQjtQbDhpBi8zxiMnxLAUtUgEfkpJsPT1OWhrAzPkZyHEjMfbYROis3VVGE6KTzzkcPqoSAgJGywb0KEHTjWjgkDM+nuCQVzBQIAOw=="));
3139761998-04-30Mirar (Pontus Hagland)  if (!(img-img1<16)) fail("differ too much");
5d0a351998-04-19Mirar (Pontus Hagland)  if (!equal(img->max(),({128,0,16}))) fail("wrong maxcolor ("+img->max()[0]+","+img->max()[1]+","+img->max()[2]+")"); ok();
3139761998-04-30Mirar (Pontus Hagland)  dnl----------------------------------------------------- #chapter colortable #test colortable - standard object img=Image.image(200,200)->test(); img->tuned_box(50,50,150,150,({({0,0,0}),({255,0,0}),({0,255,0}),({0,0,255})}));
c742a51998-04-30Mirar (Pontus Hagland)  object c=Image.colortable(img,1000)->cubicles(16,16,16,4);
3139761998-04-30Mirar (Pontus Hagland)  if (sizeof(c)<200) fail("too few colors"); object img1=(c*img);
c742a51998-04-30Mirar (Pontus Hagland)  if (!(img-img1<50)) fail("differ too much ("+(img-img1)->max()[0]+","+(img-img1)->max()[1]+","+(img-img1)->max()[2]+","+")");
3139761998-04-30Mirar (Pontus Hagland)  ok(); #test colortable - floyd-steinberg object img=Image.image(200,200)->test(); img->tuned_box(50,50,150,150,({({0,0,0}),({255,0,0}),({0,255,0}),({0,0,255})}));
c742a51998-04-30Mirar (Pontus Hagland)  object c=Image.colortable(32,32,32)->floyd_steinberg();
3139761998-04-30Mirar (Pontus Hagland)  object img1=(c*img);
c742a51998-04-30Mirar (Pontus Hagland)  if (!(img-img1<50)) fail("differ too much ("+(img-img1)->max()[0]+","+(img-img1)->max()[1]+","+(img-img1)->max()[2]+","+")");
3139761998-04-30Mirar (Pontus Hagland)  ok(); #test colortable - ordered object img=Image.image(200,200)->test(); img->tuned_box(50,50,150,150,({({0,0,0}),({255,0,0}),({0,255,0}),({0,0,255})})); object c=Image.colortable(32,32,32)->ordered(); object img1=(c*img); if (!(img-img1<32)) fail("differ too much ("+(img-img1)->max()[0]+","+(img-img1)->max()[1]+","+(img-img1)->max()[2]+","+")"); ok(); dnl----------------------------------------------------- #chapter encoding/decoding #test Image.PNM.encode/decode object img=Image.image(100,100)->test(); object img1=Image.PNM.decode(Image.PNM.encode(img)); if (img!=img1) fail("differ"); ok(); #test Image.GIF.encode/decode object img=Image.image(100,100)->test();
c742a51998-04-30Mirar (Pontus Hagland)  object c=Image.colortable(img,250)->cubicles(10,10,10,1)->floyd_steinberg(); img=c*img;
3139761998-04-30Mirar (Pontus Hagland)  object img1=Image.GIF.decode(Image.GIF.encode(img));
c742a51998-04-30Mirar (Pontus Hagland)  if (img!=img1) fail("differ ("+(img-img1)->max()[0]+","+(img-img1)->max()[1]+","+(img-img1)->max()[2]+","+")"); ok(); #test Image.GIF.encode/decode colortable object img=Image.image(100,100)->test(); object c=Image.colortable(img,256)->cubicles(16,16,16,1); img=c*img; object img1=Image.GIF.decode(Image.GIF.encode(img,c)); if (img!=img1) fail("differ ("+(img-img1)->max()[0]+","+(img-img1)->max()[1]+","+(img-img1)->max()[2]+","+")");
3139761998-04-30Mirar (Pontus Hagland)  ok(); #test Image.GIF.encode/decode colortable w/ floyd-steinberg object img=Image.image(100,100)->test();
c742a51998-04-30Mirar (Pontus Hagland)  object c=Image.colortable(img,256)->floyd_steinberg()->cubicles(16,16,16); img=c*img;
3139761998-04-30Mirar (Pontus Hagland)  object img1=Image.GIF.decode(Image.GIF.encode(img,c)); if (!(img-img1<50)) fail("differ too much ("+(img-img1)->max()[0]+","+(img-img1)->max()[1]+","+(img-img1)->max()[2]+","+")"); ok();
fd77911999-01-23Mirar (Pontus Hagland) dnl----------------------------------------------------- #chapter Image.color #test Image.color foreach ( ({ ({ "black", ({ 0, 0, 0 }), ({ 0, 0, 0 }), 0 }), ({ "blue", ({ 0, 0, 255 }), ({ 170, 255, 255 }), 41 }), ({ "cyan", ({ 0, 255, 255 }), ({ 128, 255, 255 }), 168 }), ({ "green", ({ 0, 255, 0 }), ({ 85, 255, 255 }), 127 }), ({ "magenta", ({ 255, 0, 255 }), ({ 213, 255, 255 }), 128 }), ({ "red", ({ 255, 0, 0 }), ({ 0, 255, 255 }), 87 }), ({ "white", ({ 255, 255, 255 }), ({ 0, 0, 255 }), 255 }), ({ "yellow", ({ 255, 255, 0 }), ({ 43, 255, 255 }), 214 }) }), array i) { object c1=Image.color(i[0]); object c2=Image.color(@i[1]); object c3=Image.color.rgb(@i[1]); if (c1!=c2) fail("color "+i[0]+" (rgb="+i[1][0]+","+i[1][1]+","+i[1][2]+ ", hsv="+i[2][0]+","+i[2][1]+","+i[2][2]+") failed; " "by values != by name"); if (c1!=c3) fail("color "+i[0]+" (rgb="+i[1][0]+","+i[1][1]+","+i[1][2]+ ", hsv="+i[2][0]+","+i[2][1]+","+i[2][2]+") failed; " "by rgb() != by name|values"); if (c1->r!=i[1][0] || c1->g!=i[1][1] || c1->b!=i[1][2]) fail("color "+i[0]+" (rgb="+i[1][0]+","+i[1][1]+","+i[1][2]+ ", hsv="+i[2][0]+","+i[2][1]+","+i[2][2]+") failed; " "wrong ->r("+c1->r+"), ->g, ->b reported"); if (c1->rgb()[0]!=i[1][0] || c1->rgb()[1]!=i[1][1] || c1->rgb()[2]!=i[1][2]) fail("color "+i[0]+" (rgb="+i[1][0]+","+i[1][1]+","+i[1][2]+ ", hsv="+i[2][0]+","+i[2][1]+","+i[2][2]+") failed; " "wrong ->rgb() (" +c1->rgb()[0]+","+c1->rgb()[1]+","+c1->rgb()[2]+") reported"); if (c1->hsv()[0]!=i[2][0] || c1->hsv()[1]!=i[2][1] || c1->hsv()[2]!=i[2][2]) fail("color "+i[0]+" (rgb="+i[1][0]+","+i[1][1]+","+i[1][2]+ ", hsv="+i[2][0]+","+i[2][1]+","+i[2][2]+") failed; " "wrong ->hsv() (" +c1->hsv()[0]+","+c1->hsv()[1]+","+c1->hsv()[2]+") reported"); if (c1->greylevel()!=i[3]) fail("color "+i[0]+" (rgb="+i[1][0]+","+i[1][1]+","+i[1][2]+ ", hsv="+i[2][0]+","+i[2][1]+","+i[2][2]+") failed; " "wrong ->greylevel() ("+c1->greylevel()+", should be " +i[3]+") reported"); if (c1->grey()->r!=i[3]) fail("color "+i[0]+" (rgb="+i[1][0]+","+i[1][1]+","+i[1][2]+ ", hsv="+i[2][0]+","+i[2][1]+","+i[2][2]+") failed; " "wrong ->grey()->r ("+c1->grey()->r+", should be " +i[3]+") reported"); }; ok(); #test indices(Image.color) if (!arrayp(indices(Image.color))) fail("wrong type\n"); if (!stringp(indices(Image.color)[0])) fail("wrong type of elements\n"); if (sizeof(indices(Image.color))<8) fail("too few colors\n"); ok(); #test values(Image.color) if (!arrayp(values(Image.color))) fail("wrong type\n"); if (!objectp(values(Image.color)[0])) fail("wrong type of elements\n"); if (sizeof(indices(Image.color))!=sizeof(values(Image.color))) fail("not the same size of indices() and values()\n"); ok();