bitmap_image.hpp 242 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002
  1. /*
  2. *****************************************************************************
  3. * *
  4. * Platform Independent *
  5. * Bitmap Image Reader Writer Library *
  6. * *
  7. * Author: Arash Partow - 2002 *
  8. * URL: http://partow.net/programming/bitmap/index.html *
  9. * *
  10. * Note: This library only supports 24-bits per pixel bitmap format files. *
  11. * *
  12. * Copyright notice: *
  13. * Free use of the Platform Independent Bitmap Image Reader Writer Library *
  14. * is permitted under the guidelines and in accordance with the most current *
  15. * version of the MIT License. *
  16. * http://www.opensource.org/licenses/MIT *
  17. * *
  18. *****************************************************************************
  19. */
  20. #ifndef INCLUDE_BITMAP_IMAGE_HPP
  21. #define INCLUDE_BITMAP_IMAGE_HPP
  22. #include <algorithm>
  23. #include <cmath>
  24. #include <cstdlib>
  25. #include <cstring>
  26. #include <fstream>
  27. #include <iostream>
  28. #include <iterator>
  29. #include <limits>
  30. #include <string>
  31. #include <vector>
  32. class bitmap_image
  33. {
  34. public:
  35. enum channel_mode {
  36. rgb_mode = 0,
  37. bgr_mode = 1
  38. };
  39. enum color_plane {
  40. blue_plane = 0,
  41. green_plane = 1,
  42. red_plane = 2
  43. };
  44. struct rgb_t
  45. {
  46. unsigned char red;
  47. unsigned char green;
  48. unsigned char blue;
  49. };
  50. bitmap_image()
  51. : file_name_(""),
  52. width_ (0),
  53. height_ (0),
  54. row_increment_ (0),
  55. bytes_per_pixel_(3),
  56. channel_mode_(bgr_mode)
  57. {}
  58. bitmap_image(const std::string& filename)
  59. : file_name_(filename),
  60. width_ (0),
  61. height_ (0),
  62. row_increment_ (0),
  63. bytes_per_pixel_(0),
  64. channel_mode_(bgr_mode)
  65. {
  66. load_bitmap();
  67. }
  68. bitmap_image(const unsigned int width, const unsigned int height)
  69. : file_name_(""),
  70. width_ (width ),
  71. height_(height),
  72. row_increment_ (0),
  73. bytes_per_pixel_(3),
  74. channel_mode_(bgr_mode)
  75. {
  76. create_bitmap();
  77. }
  78. bitmap_image(const bitmap_image& image)
  79. : file_name_(image.file_name_),
  80. width_ (image.width_ ),
  81. height_ (image.height_ ),
  82. row_increment_ (0),
  83. bytes_per_pixel_(3),
  84. channel_mode_(bgr_mode)
  85. {
  86. create_bitmap();
  87. data_ = image.data_;
  88. }
  89. bitmap_image& operator=(const bitmap_image& image)
  90. {
  91. if (this != &image)
  92. {
  93. file_name_ = image.file_name_;
  94. bytes_per_pixel_ = image.bytes_per_pixel_;
  95. width_ = image.width_;
  96. height_ = image.height_;
  97. row_increment_ = 0;
  98. channel_mode_ = image.channel_mode_;
  99. create_bitmap();
  100. data_ = image.data_;
  101. }
  102. return *this;
  103. }
  104. inline bool operator!()
  105. {
  106. return (data_.size() == 0) ||
  107. (width_ == 0) ||
  108. (height_ == 0) ||
  109. (row_increment_ == 0);
  110. }
  111. inline void clear(const unsigned char v = 0x00)
  112. {
  113. std::fill(data_.begin(), data_.end(), v);
  114. }
  115. inline unsigned char red_channel(const unsigned int x, const unsigned int y) const
  116. {
  117. return data_[(y * row_increment_) + (x * bytes_per_pixel_ + 2)];
  118. }
  119. inline unsigned char green_channel(const unsigned int x, const unsigned int y) const
  120. {
  121. return data_[(y * row_increment_) + (x * bytes_per_pixel_ + 1)];
  122. }
  123. inline unsigned char blue_channel (const unsigned int x, const unsigned int y) const
  124. {
  125. return data_[(y * row_increment_) + (x * bytes_per_pixel_ + 0)];
  126. }
  127. inline void red_channel(const unsigned int x, const unsigned int y, const unsigned char value)
  128. {
  129. data_[(y * row_increment_) + (x * bytes_per_pixel_ + 2)] = value;
  130. }
  131. inline void green_channel(const unsigned int x, const unsigned int y, const unsigned char value)
  132. {
  133. data_[(y * row_increment_) + (x * bytes_per_pixel_ + 1)] = value;
  134. }
  135. inline void blue_channel (const unsigned int x, const unsigned int y, const unsigned char value)
  136. {
  137. data_[(y * row_increment_) + (x * bytes_per_pixel_ + 0)] = value;
  138. }
  139. inline unsigned char* row(unsigned int row_index) const
  140. {
  141. return const_cast<unsigned char*>(&data_[(row_index * row_increment_)]);
  142. }
  143. inline void get_pixel(const unsigned int x, const unsigned int y,
  144. unsigned char& red,
  145. unsigned char& green,
  146. unsigned char& blue) const
  147. {
  148. const unsigned int y_offset = y * row_increment_;
  149. const unsigned int x_offset = x * bytes_per_pixel_;
  150. const unsigned int offset = y_offset + x_offset;
  151. blue = data_[offset + 0];
  152. green = data_[offset + 1];
  153. red = data_[offset + 2];
  154. }
  155. template <typename RGB>
  156. inline void get_pixel(const unsigned int x, const unsigned int y, RGB& colour) const
  157. {
  158. get_pixel(x, y, colour.red, colour.green, colour.blue);
  159. }
  160. inline rgb_t get_pixel(const unsigned int x, const unsigned int y) const
  161. {
  162. rgb_t colour;
  163. get_pixel(x, y, colour.red, colour.green, colour.blue);
  164. return colour;
  165. }
  166. inline void set_pixel(const unsigned int x, const unsigned int y,
  167. const unsigned char red,
  168. const unsigned char green,
  169. const unsigned char blue)
  170. {
  171. const unsigned int y_offset = y * row_increment_;
  172. const unsigned int x_offset = x * bytes_per_pixel_;
  173. const unsigned int offset = y_offset + x_offset;
  174. data_[offset + 0] = blue;
  175. data_[offset + 1] = green;
  176. data_[offset + 2] = red;
  177. }
  178. template <typename RGB>
  179. inline void set_pixel(const unsigned int x, const unsigned int y, const RGB& colour)
  180. {
  181. set_pixel(x, y, colour.red, colour.green, colour.blue);
  182. }
  183. inline bool copy_from(const bitmap_image& image)
  184. {
  185. if (
  186. (image.height_ != height_) ||
  187. (image.width_ != width_ )
  188. )
  189. {
  190. return false;
  191. }
  192. data_ = image.data_;
  193. return true;
  194. }
  195. inline bool copy_from(const bitmap_image& source_image,
  196. const unsigned int& x_offset,
  197. const unsigned int& y_offset)
  198. {
  199. if ((x_offset + source_image.width_ ) > width_ ) { return false; }
  200. if ((y_offset + source_image.height_) > height_) { return false; }
  201. for (unsigned int y = 0; y < source_image.height_; ++y)
  202. {
  203. unsigned char* itr1 = row(y + y_offset) + x_offset * bytes_per_pixel_;
  204. const unsigned char* itr2 = source_image.row(y);
  205. const unsigned char* itr2_end = itr2 + source_image.width_ * bytes_per_pixel_;
  206. std::copy(itr2, itr2_end, itr1);
  207. }
  208. return true;
  209. }
  210. inline bool region(const unsigned int& x ,
  211. const unsigned int& y ,
  212. const unsigned int& width ,
  213. const unsigned int& height,
  214. bitmap_image& dest_image ) const
  215. {
  216. if ((x + width ) > width_ ) { return false; }
  217. if ((y + height) > height_) { return false; }
  218. if (
  219. (dest_image.width_ < width_ ) ||
  220. (dest_image.height_ < height_)
  221. )
  222. {
  223. dest_image.setwidth_height(width,height);
  224. }
  225. for (unsigned int r = 0; r < height; ++r)
  226. {
  227. unsigned char* itr1 = row(r + y) + x * bytes_per_pixel_;
  228. unsigned char* itr1_end = itr1 + (width * bytes_per_pixel_);
  229. unsigned char* itr2 = dest_image.row(r);
  230. std::copy(itr1, itr1_end, itr2);
  231. }
  232. return true;
  233. }
  234. inline bool roi_from_center(const unsigned int& cx ,
  235. const unsigned int& cy ,
  236. const unsigned int& width ,
  237. const unsigned int& height,
  238. bitmap_image& dest_image ) const
  239. {
  240. return region(cx - (width / 2), cy - (height / 2),
  241. width, height,
  242. dest_image);
  243. }
  244. inline bool set_region(const unsigned int& x ,
  245. const unsigned int& y ,
  246. const unsigned int& width ,
  247. const unsigned int& height,
  248. const unsigned char& value )
  249. {
  250. if ((x + width ) > width_ ) { return false; }
  251. if ((y + height) > height_) { return false; }
  252. for (unsigned int r = 0; r < height; ++r)
  253. {
  254. unsigned char* itr = row(r + y) + x * bytes_per_pixel_;
  255. unsigned char* itr_end = itr + (width * bytes_per_pixel_);
  256. std::fill(itr, itr_end, value);
  257. }
  258. return true;
  259. }
  260. inline bool set_region(const unsigned int& x ,
  261. const unsigned int& y ,
  262. const unsigned int& width ,
  263. const unsigned int& height,
  264. const color_plane color ,
  265. const unsigned char& value )
  266. {
  267. if ((x + width ) > width_ ) { return false; }
  268. if ((y + height) > height_) { return false; }
  269. const unsigned int color_plane_offset = offset(color);
  270. for (unsigned int r = 0; r < height; ++r)
  271. {
  272. unsigned char* itr = row(r + y) + x * bytes_per_pixel_ + color_plane_offset;
  273. unsigned char* itr_end = itr + (width * bytes_per_pixel_);
  274. while (itr != itr_end)
  275. {
  276. *itr = value;
  277. itr += bytes_per_pixel_;
  278. }
  279. }
  280. return true;
  281. }
  282. inline bool set_region(const unsigned int& x ,
  283. const unsigned int& y ,
  284. const unsigned int& width ,
  285. const unsigned int& height,
  286. const unsigned char& red ,
  287. const unsigned char& green ,
  288. const unsigned char& blue )
  289. {
  290. if ((x + width ) > width_ ) { return false; }
  291. if ((y + height) > height_) { return false; }
  292. for (unsigned int r = 0; r < height; ++r)
  293. {
  294. unsigned char* itr = row(r + y) + x * bytes_per_pixel_;
  295. unsigned char* itr_end = itr + (width * bytes_per_pixel_);
  296. while (itr != itr_end)
  297. {
  298. *(itr++) = blue;
  299. *(itr++) = green;
  300. *(itr++) = red;
  301. }
  302. }
  303. return true;
  304. }
  305. void reflective_image(bitmap_image& image, const bool include_diagnols = false)
  306. {
  307. image.setwidth_height(3 * width_, 3 * height_, true);
  308. image.copy_from(*this, width_, height_);
  309. vertical_flip();
  310. image.copy_from(*this, width_, 0);
  311. image.copy_from(*this, width_, 2 * height_);
  312. vertical_flip();
  313. horizontal_flip();
  314. image.copy_from(*this, 0, height_);
  315. image.copy_from(*this, 2 * width_, height_);
  316. horizontal_flip();
  317. if (include_diagnols)
  318. {
  319. bitmap_image tile = *this;
  320. tile.vertical_flip();
  321. tile.horizontal_flip();
  322. image.copy_from(tile, 0, 0);
  323. image.copy_from(tile, 2 * width_, 0);
  324. image.copy_from(tile, 2 * width_, 2 * height_);
  325. image.copy_from(tile, 0 , 2 * height_);
  326. }
  327. }
  328. inline unsigned int width() const
  329. {
  330. return width_;
  331. }
  332. inline unsigned int height() const
  333. {
  334. return height_;
  335. }
  336. inline unsigned int bytes_per_pixel() const
  337. {
  338. return bytes_per_pixel_;
  339. }
  340. inline unsigned int pixel_count() const
  341. {
  342. return width_ * height_;
  343. }
  344. inline void setwidth_height(const unsigned int width,
  345. const unsigned int height,
  346. const bool clear = false)
  347. {
  348. data_.clear();
  349. width_ = width;
  350. height_ = height;
  351. create_bitmap();
  352. if (clear)
  353. {
  354. std::fill(data_.begin(), data_.end(), static_cast<unsigned char>(0x00));
  355. }
  356. }
  357. void save_image(const std::string& file_name) const
  358. {
  359. std::ofstream stream(file_name.c_str(),std::ios::binary);
  360. if (!stream)
  361. {
  362. std::cerr << "bitmap_image::save_image(): Error - Could not open file "
  363. << file_name << " for writing!" << std::endl;
  364. return;
  365. }
  366. bitmap_information_header bih;
  367. bih.width = width_;
  368. bih.height = height_;
  369. bih.bit_count = static_cast<unsigned short>(bytes_per_pixel_ << 3);
  370. bih.clr_important = 0;
  371. bih.clr_used = 0;
  372. bih.compression = 0;
  373. bih.planes = 1;
  374. bih.size = bih.struct_size();
  375. bih.x_pels_per_meter = 0;
  376. bih.y_pels_per_meter = 0;
  377. bih.size_image = (((bih.width * bytes_per_pixel_) + 3) & 0x0000FFFC) * bih.height;
  378. bitmap_file_header bfh;
  379. bfh.type = 19778;
  380. bfh.size = bfh.struct_size() + bih.struct_size() + bih.size_image;
  381. bfh.reserved1 = 0;
  382. bfh.reserved2 = 0;
  383. bfh.off_bits = bih.struct_size() + bfh.struct_size();
  384. write_bfh(stream,bfh);
  385. write_bih(stream,bih);
  386. unsigned int padding = (4 - ((3 * width_) % 4)) % 4;
  387. char padding_data[4] = { 0x00, 0x00, 0x00, 0x00 };
  388. for (unsigned int i = 0; i < height_; ++i)
  389. {
  390. const unsigned char* data_ptr = &data_[(row_increment_ * (height_ - i - 1))];
  391. stream.write(reinterpret_cast<const char*>(data_ptr), sizeof(unsigned char) * bytes_per_pixel_ * width_);
  392. stream.write(padding_data,padding);
  393. }
  394. stream.close();
  395. }
  396. inline void set_all_ith_bits_low(const unsigned int bitr_index)
  397. {
  398. unsigned char mask = static_cast<unsigned char>(~(1 << bitr_index));
  399. for (unsigned char* itr = data(); itr != end(); ++itr)
  400. {
  401. *itr &= mask;
  402. }
  403. }
  404. inline void set_all_ith_bits_high(const unsigned int bitr_index)
  405. {
  406. unsigned char mask = static_cast<unsigned char>(1 << bitr_index);
  407. for (unsigned char* itr = data(); itr != end(); ++itr)
  408. {
  409. *itr |= mask;
  410. }
  411. }
  412. inline void set_all_ith_channels(const unsigned int& channel, const unsigned char& value)
  413. {
  414. for (unsigned char* itr = (data() + channel); itr < end(); itr += bytes_per_pixel_)
  415. {
  416. *itr = value;
  417. }
  418. }
  419. inline void set_channel(const color_plane color,const unsigned char& value)
  420. {
  421. for (unsigned char* itr = (data() + offset(color)); itr < end(); itr += bytes_per_pixel_)
  422. {
  423. *itr = value;
  424. }
  425. }
  426. inline void ror_channel(const color_plane color, const unsigned int& ror)
  427. {
  428. for (unsigned char* itr = (data() + offset(color)); itr < end(); itr += bytes_per_pixel_)
  429. {
  430. *itr = static_cast<unsigned char>(((*itr) >> ror) | ((*itr) << (8 - ror)));
  431. }
  432. }
  433. inline void set_all_channels(const unsigned char& value)
  434. {
  435. for (unsigned char* itr = data(); itr < end(); )
  436. {
  437. *(itr++) = value;
  438. }
  439. }
  440. inline void set_all_channels(const unsigned char& r_value,
  441. const unsigned char& g_value,
  442. const unsigned char& b_value)
  443. {
  444. for (unsigned char* itr = (data() + 0); itr < end(); itr += bytes_per_pixel_)
  445. {
  446. *(itr + 0) = b_value;
  447. *(itr + 1) = g_value;
  448. *(itr + 2) = r_value;
  449. }
  450. }
  451. inline void invert_color_planes()
  452. {
  453. for (unsigned char* itr = data(); itr < end(); *itr = ~(*itr), ++itr);
  454. }
  455. inline void add_to_color_plane(const color_plane color, const unsigned char& value)
  456. {
  457. for (unsigned char* itr = (data() + offset(color)); itr < end(); itr += bytes_per_pixel_)
  458. {
  459. (*itr) += value;
  460. }
  461. }
  462. inline void convert_to_grayscale()
  463. {
  464. double r_scaler = 0.299;
  465. double g_scaler = 0.587;
  466. double b_scaler = 0.114;
  467. if (rgb_mode == channel_mode_)
  468. {
  469. std::swap(r_scaler, b_scaler);
  470. }
  471. for (unsigned char* itr = data(); itr < end(); )
  472. {
  473. unsigned char gray_value = static_cast<unsigned char>
  474. (
  475. (r_scaler * (*(itr + 2))) +
  476. (g_scaler * (*(itr + 1))) +
  477. (b_scaler * (*(itr + 0)))
  478. );
  479. *(itr++) = gray_value;
  480. *(itr++) = gray_value;
  481. *(itr++) = gray_value;
  482. }
  483. }
  484. inline const unsigned char* data() const
  485. {
  486. return data_.data();
  487. }
  488. inline unsigned char* data()
  489. {
  490. return const_cast<unsigned char*>(data_.data());
  491. }
  492. inline void bgr_to_rgb()
  493. {
  494. if ((bgr_mode == channel_mode_) && (3 == bytes_per_pixel_))
  495. {
  496. reverse_channels();
  497. channel_mode_ = rgb_mode;
  498. }
  499. }
  500. inline void rgb_to_bgr()
  501. {
  502. if ((rgb_mode == channel_mode_) && (3 == bytes_per_pixel_))
  503. {
  504. reverse_channels();
  505. channel_mode_ = bgr_mode;
  506. }
  507. }
  508. inline void reverse()
  509. {
  510. unsigned char* itr1 = data();
  511. unsigned char* itr2 = end() - bytes_per_pixel_;
  512. while (itr1 < itr2)
  513. {
  514. for (std::size_t i = 0; i < bytes_per_pixel_; ++i)
  515. {
  516. unsigned char* citr1 = itr1 + i;
  517. unsigned char* citr2 = itr2 + i;
  518. std::swap(*citr1,*citr2);
  519. }
  520. itr1 += bytes_per_pixel_;
  521. itr2 -= bytes_per_pixel_;
  522. }
  523. }
  524. inline void horizontal_flip()
  525. {
  526. for (unsigned int y = 0; y < height_; ++y)
  527. {
  528. unsigned char* itr1 = row(y);
  529. unsigned char* itr2 = itr1 + row_increment_ - bytes_per_pixel_;
  530. while (itr1 < itr2)
  531. {
  532. for (unsigned int i = 0; i < bytes_per_pixel_; ++i)
  533. {
  534. unsigned char* p1 = (itr1 + i);
  535. unsigned char* p2 = (itr2 + i);
  536. std::swap(*p1,*p2);
  537. }
  538. itr1 += bytes_per_pixel_;
  539. itr2 -= bytes_per_pixel_;
  540. }
  541. }
  542. }
  543. inline void vertical_flip()
  544. {
  545. for (unsigned int y = 0; y < (height_ / 2); ++y)
  546. {
  547. unsigned char* itr1 = row(y);
  548. unsigned char* itr2 = row(height_ - y - 1);
  549. for (std::size_t x = 0; x < row_increment_; ++x)
  550. {
  551. std::swap(*(itr1 + x),*(itr2 + x));
  552. }
  553. }
  554. }
  555. inline void export_color_plane(const color_plane color, unsigned char* image)
  556. {
  557. for (unsigned char* itr = (data() + offset(color)); itr < end(); ++image, itr += bytes_per_pixel_)
  558. {
  559. (*image) = (*itr);
  560. }
  561. }
  562. inline void export_color_plane(const color_plane color, bitmap_image& image)
  563. {
  564. if (
  565. (width_ != image.width_ ) ||
  566. (height_ != image.height_)
  567. )
  568. {
  569. image.setwidth_height(width_,height_);
  570. }
  571. image.clear();
  572. unsigned char* itr1 = (data() + offset(color));
  573. unsigned char* itr1_end = end();
  574. unsigned char* itr2 = (image.data() + offset(color));
  575. while (itr1 < itr1_end)
  576. {
  577. (*itr2) = (*itr1);
  578. itr1 += bytes_per_pixel_;
  579. itr2 += bytes_per_pixel_;
  580. }
  581. }
  582. inline void export_response_image(const color_plane color, double* response_image)
  583. {
  584. double* resp_itr = response_image;
  585. for (unsigned char* itr = (data() + offset(color)); itr < end(); ++response_image, itr += bytes_per_pixel_)
  586. {
  587. *(resp_itr++) = (1.0 * (*itr)) / 256.0;
  588. }
  589. }
  590. inline void export_gray_scale_response_image(double* response_image) const
  591. {
  592. double* resp_itr = response_image;
  593. for (const unsigned char* itr = data(); itr < end(); itr += bytes_per_pixel_)
  594. {
  595. unsigned char gray_value = static_cast<unsigned char>
  596. (
  597. (0.299 * (*(itr + 2))) +
  598. (0.587 * (*(itr + 1))) +
  599. (0.114 * (*(itr + 0)))
  600. );
  601. *(resp_itr++) = (1.0 * gray_value) / 256.0;
  602. }
  603. }
  604. inline void export_rgb(double* red, double* green, double* blue) const
  605. {
  606. if (bgr_mode != channel_mode_)
  607. return;
  608. for (const unsigned char* itr = data(); itr < end(); ++red, ++green, ++blue)
  609. {
  610. (*blue ) = (1.0 * (*(itr++))) / 256.0;
  611. (*green) = (1.0 * (*(itr++))) / 256.0;
  612. (*red ) = (1.0 * (*(itr++))) / 256.0;
  613. }
  614. }
  615. inline void export_rgb(float* red, float* green, float* blue) const
  616. {
  617. if (bgr_mode != channel_mode_)
  618. return;
  619. for (const unsigned char* itr = data(); itr < end(); ++red, ++green, ++blue)
  620. {
  621. (*blue ) = (1.0f * (*(itr++))) / 256.0f;
  622. (*green) = (1.0f * (*(itr++))) / 256.0f;
  623. (*red ) = (1.0f * (*(itr++))) / 256.0f;
  624. }
  625. }
  626. inline void export_rgb(unsigned char* red, unsigned char* green, unsigned char* blue) const
  627. {
  628. if (bgr_mode != channel_mode_)
  629. return;
  630. for (const unsigned char* itr = data(); itr < end(); ++red, ++green, ++blue)
  631. {
  632. (*blue ) = *(itr++);
  633. (*green) = *(itr++);
  634. (*red ) = *(itr++);
  635. }
  636. }
  637. inline void export_ycbcr(double* y, double* cb, double* cr) const
  638. {
  639. if (bgr_mode != channel_mode_)
  640. return;
  641. for (const unsigned char* itr = data(); itr < end(); ++y, ++cb, ++cr)
  642. {
  643. const double blue = (1.0 * (*(itr++)));
  644. const double green = (1.0 * (*(itr++)));
  645. const double red = (1.0 * (*(itr++)));
  646. ( *y) = clamp<double>( 16.0 + (1.0/256.0) * ( 65.738 * red + 129.057 * green + 25.064 * blue),1.0,254);
  647. (*cb) = clamp<double>(128.0 + (1.0/256.0) * (- 37.945 * red - 74.494 * green + 112.439 * blue),1.0,254);
  648. (*cr) = clamp<double>(128.0 + (1.0/256.0) * ( 112.439 * red - 94.154 * green - 18.285 * blue),1.0,254);
  649. }
  650. }
  651. inline void export_rgb_normal(double* red, double* green, double* blue) const
  652. {
  653. if (bgr_mode != channel_mode_)
  654. return;
  655. for (const unsigned char* itr = data(); itr < end(); ++red, ++green, ++blue)
  656. {
  657. (*blue ) = (1.0 * (*(itr++)));
  658. (*green) = (1.0 * (*(itr++)));
  659. (*red ) = (1.0 * (*(itr++)));
  660. }
  661. }
  662. inline void export_rgb_normal(float* red, float* green, float* blue) const
  663. {
  664. if (bgr_mode != channel_mode_)
  665. return;
  666. for (const unsigned char* itr = data(); itr < end(); ++red, ++green, ++blue)
  667. {
  668. (*blue ) = (1.0f * (*(itr++)));
  669. (*green) = (1.0f * (*(itr++)));
  670. (*red ) = (1.0f * (*(itr++)));
  671. }
  672. }
  673. inline void import_rgb(double* red, double* green, double* blue)
  674. {
  675. if (bgr_mode != channel_mode_)
  676. return;
  677. for (unsigned char* itr = data(); itr < end(); ++red, ++green, ++blue)
  678. {
  679. *(itr++) = static_cast<unsigned char>(256.0 * (*blue ));
  680. *(itr++) = static_cast<unsigned char>(256.0 * (*green));
  681. *(itr++) = static_cast<unsigned char>(256.0 * (*red ));
  682. }
  683. }
  684. inline void import_rgb(float* red, float* green, float* blue)
  685. {
  686. if (bgr_mode != channel_mode_)
  687. return;
  688. for (unsigned char* itr = data(); itr < end(); ++red, ++green, ++blue)
  689. {
  690. *(itr++) = static_cast<unsigned char>(256.0f * (*blue ));
  691. *(itr++) = static_cast<unsigned char>(256.0f * (*green));
  692. *(itr++) = static_cast<unsigned char>(256.0f * (*red ));
  693. }
  694. }
  695. inline void import_rgb(unsigned char* red, unsigned char* green, unsigned char* blue)
  696. {
  697. if (bgr_mode != channel_mode_)
  698. return;
  699. for (unsigned char* itr = data(); itr < end(); ++red, ++green, ++blue)
  700. {
  701. *(itr++) = (*blue );
  702. *(itr++) = (*green);
  703. *(itr++) = (*red );
  704. }
  705. }
  706. inline void import_ycbcr(double* y, double* cb, double* cr)
  707. {
  708. if (bgr_mode != channel_mode_)
  709. return;
  710. for (unsigned char* itr = data(); itr < end(); ++y, ++cb, ++cr)
  711. {
  712. double y_ = (*y);
  713. double cb_ = (*cb);
  714. double cr_ = (*cr);
  715. *(itr++) = static_cast<unsigned char>(clamp((298.082 * y_ + 516.412 * cb_ ) / 256.0 - 276.836,0.0,255.0));
  716. *(itr++) = static_cast<unsigned char>(clamp((298.082 * y_ - 100.291 * cb_ - 208.120 * cr_ ) / 256.0 + 135.576,0.0,255.0));
  717. *(itr++) = static_cast<unsigned char>(clamp((298.082 * y_ + 408.583 * cr_ ) / 256.0 - 222.921,0.0,255.0));
  718. }
  719. }
  720. inline void import_gray_scale_clamped(double* gray)
  721. {
  722. if (bgr_mode != channel_mode_)
  723. return;
  724. for (unsigned char* itr = data(); itr < end(); ++gray)
  725. {
  726. unsigned char c = static_cast<unsigned char>(clamp<double>(256.0 * (*gray),0.0,255.0));
  727. *(itr + 0) = c;
  728. *(itr + 1) = c;
  729. *(itr + 2) = c;
  730. itr += 3;
  731. }
  732. }
  733. inline void import_rgb_clamped(double* red, double* green, double* blue)
  734. {
  735. if (bgr_mode != channel_mode_)
  736. return;
  737. for (unsigned char* itr = data(); itr < end(); ++red, ++green, ++blue)
  738. {
  739. *(itr++) = static_cast<unsigned char>(clamp<double>(256.0 * (*blue ),0.0,255.0));
  740. *(itr++) = static_cast<unsigned char>(clamp<double>(256.0 * (*green),0.0,255.0));
  741. *(itr++) = static_cast<unsigned char>(clamp<double>(256.0 * (*red ),0.0,255.0));
  742. }
  743. }
  744. inline void import_rgb_clamped(float* red, float* green, float* blue)
  745. {
  746. if (bgr_mode != channel_mode_)
  747. return;
  748. for (unsigned char* itr = data(); itr < end(); ++red, ++green, ++blue)
  749. {
  750. *(itr++) = static_cast<unsigned char>(clamp<double>(256.0f * (*blue ),0.0,255.0));
  751. *(itr++) = static_cast<unsigned char>(clamp<double>(256.0f * (*green),0.0,255.0));
  752. *(itr++) = static_cast<unsigned char>(clamp<double>(256.0f * (*red ),0.0,255.0));
  753. }
  754. }
  755. inline void import_rgb_normal(double* red, double* green, double* blue)
  756. {
  757. if (bgr_mode != channel_mode_)
  758. return;
  759. for (unsigned char* itr = data(); itr < end(); ++red, ++green, ++blue)
  760. {
  761. *(itr++) = static_cast<unsigned char>(*blue );
  762. *(itr++) = static_cast<unsigned char>(*green);
  763. *(itr++) = static_cast<unsigned char>(*red );
  764. }
  765. }
  766. inline void import_rgb_normal(float* red, float* green, float* blue)
  767. {
  768. if (bgr_mode != channel_mode_)
  769. return;
  770. for (unsigned char* itr = data(); itr < end(); ++red, ++green, ++blue)
  771. {
  772. *(itr++) = static_cast<unsigned char>(*blue );
  773. *(itr++) = static_cast<unsigned char>(*green);
  774. *(itr++) = static_cast<unsigned char>(*red );
  775. }
  776. }
  777. inline void subsample(bitmap_image& dest) const
  778. {
  779. /*
  780. Half sub-sample of original image.
  781. */
  782. unsigned int w = 0;
  783. unsigned int h = 0;
  784. bool odd_width = false;
  785. bool odd_height = false;
  786. if (0 == (width_ % 2))
  787. w = width_ / 2;
  788. else
  789. {
  790. w = 1 + (width_ / 2);
  791. odd_width = true;
  792. }
  793. if (0 == (height_ % 2))
  794. h = height_ / 2;
  795. else
  796. {
  797. h = 1 + (height_ / 2);
  798. odd_height = true;
  799. }
  800. unsigned int horizontal_upper = (odd_width) ? (w - 1) : w;
  801. unsigned int vertical_upper = (odd_height) ? (h - 1) : h;
  802. dest.setwidth_height(w,h);
  803. dest.clear();
  804. unsigned char* s_itr[3];
  805. const unsigned char* itr1[3];
  806. const unsigned char* itr2[3];
  807. s_itr[0] = dest.data() + 0;
  808. s_itr[1] = dest.data() + 1;
  809. s_itr[2] = dest.data() + 2;
  810. itr1[0] = data() + 0;
  811. itr1[1] = data() + 1;
  812. itr1[2] = data() + 2;
  813. itr2[0] = data() + row_increment_ + 0;
  814. itr2[1] = data() + row_increment_ + 1;
  815. itr2[2] = data() + row_increment_ + 2;
  816. unsigned int total = 0;
  817. for (unsigned int j = 0; j < vertical_upper; ++j)
  818. {
  819. for (unsigned int i = 0; i < horizontal_upper; ++i)
  820. {
  821. for (unsigned int k = 0; k < bytes_per_pixel_; s_itr[k] += bytes_per_pixel_, ++k)
  822. {
  823. total = 0;
  824. total += *(itr1[k]);
  825. total += *(itr1[k]);
  826. total += *(itr2[k]);
  827. total += *(itr2[k]);
  828. itr1[k] += bytes_per_pixel_;
  829. itr1[k] += bytes_per_pixel_;
  830. itr2[k] += bytes_per_pixel_;
  831. itr2[k] += bytes_per_pixel_;
  832. *(s_itr[k]) = static_cast<unsigned char>(total >> 2);
  833. }
  834. }
  835. if (odd_width)
  836. {
  837. for (unsigned int k = 0; k < bytes_per_pixel_; s_itr[k] += bytes_per_pixel_, ++k)
  838. {
  839. total = 0;
  840. total += *(itr1[k]);
  841. total += *(itr2[k]);
  842. itr1[k] += bytes_per_pixel_;
  843. itr2[k] += bytes_per_pixel_;
  844. *(s_itr[k]) = static_cast<unsigned char>(total >> 1);
  845. }
  846. }
  847. for (unsigned int k = 0; k < bytes_per_pixel_; ++k)
  848. {
  849. itr1[k] += row_increment_;
  850. }
  851. if (j != (vertical_upper - 1))
  852. {
  853. for (unsigned int k = 0; k < bytes_per_pixel_; ++k)
  854. {
  855. itr2[k] += row_increment_;
  856. }
  857. }
  858. }
  859. if (odd_height)
  860. {
  861. for (unsigned int i = 0; i < horizontal_upper; ++i)
  862. {
  863. for (unsigned int k = 0; k < bytes_per_pixel_; s_itr[k] += bytes_per_pixel_, ++k)
  864. {
  865. total = 0;
  866. total += *(itr1[k]);
  867. total += *(itr2[k]);
  868. itr1[k] += bytes_per_pixel_;
  869. itr2[k] += bytes_per_pixel_;
  870. *(s_itr[k]) = static_cast<unsigned char>(total >> 1);
  871. }
  872. }
  873. if (odd_width)
  874. {
  875. for (unsigned int k = 0; k < bytes_per_pixel_; ++k)
  876. {
  877. (*(s_itr[k])) = *(itr1[k]);
  878. }
  879. }
  880. }
  881. }
  882. inline void upsample(bitmap_image& dest) const
  883. {
  884. /*
  885. 2x up-sample of original image.
  886. */
  887. dest.setwidth_height(2 * width_ ,2 * height_);
  888. dest.clear();
  889. const unsigned char* s_itr[3];
  890. unsigned char* itr1[3];
  891. unsigned char* itr2[3];
  892. s_itr[0] = data() + 0;
  893. s_itr[1] = data() + 1;
  894. s_itr[2] = data() + 2;
  895. itr1[0] = dest.data() + 0;
  896. itr1[1] = dest.data() + 1;
  897. itr1[2] = dest.data() + 2;
  898. itr2[0] = dest.data() + dest.row_increment_ + 0;
  899. itr2[1] = dest.data() + dest.row_increment_ + 1;
  900. itr2[2] = dest.data() + dest.row_increment_ + 2;
  901. for (unsigned int j = 0; j < height_; ++j)
  902. {
  903. for (unsigned int i = 0; i < width_; ++i)
  904. {
  905. for (unsigned int k = 0; k < bytes_per_pixel_; s_itr[k] += bytes_per_pixel_, ++k)
  906. {
  907. *(itr1[k]) = *(s_itr[k]); itr1[k] += bytes_per_pixel_;
  908. *(itr1[k]) = *(s_itr[k]); itr1[k] += bytes_per_pixel_;
  909. *(itr2[k]) = *(s_itr[k]); itr2[k] += bytes_per_pixel_;
  910. *(itr2[k]) = *(s_itr[k]); itr2[k] += bytes_per_pixel_;
  911. }
  912. }
  913. for (unsigned int k = 0; k < bytes_per_pixel_; ++k)
  914. {
  915. itr1[k] += dest.row_increment_;
  916. itr2[k] += dest.row_increment_;
  917. }
  918. }
  919. }
  920. inline void alpha_blend(const double& alpha, const bitmap_image& image)
  921. {
  922. if (
  923. (image.width_ != width_ ) ||
  924. (image.height_ != height_)
  925. )
  926. {
  927. return;
  928. }
  929. if ((alpha < 0.0) || (alpha > 1.0))
  930. {
  931. return;
  932. }
  933. unsigned char* itr1 = data();
  934. const unsigned char* itr1_end = end();
  935. const unsigned char* itr2 = image.data();
  936. double alpha_compliment = 1.0 - alpha;
  937. while (itr1 != itr1_end)
  938. {
  939. *(itr1) = static_cast<unsigned char>((alpha * (*itr2)) + (alpha_compliment * (*itr1)));
  940. ++itr1;
  941. ++itr2;
  942. }
  943. }
  944. inline double psnr(const bitmap_image& image)
  945. {
  946. if (
  947. (image.width_ != width_ ) ||
  948. (image.height_ != height_)
  949. )
  950. {
  951. return 0.0;
  952. }
  953. const unsigned char* itr1 = data();
  954. const unsigned char* itr2 = image.data();
  955. double mse = 0.0;
  956. while (itr1 != end())
  957. {
  958. const double v = (static_cast<double>(*itr1) - static_cast<double>(*itr2));
  959. mse += v * v;
  960. ++itr1;
  961. ++itr2;
  962. }
  963. if (mse <= 0.0000001)
  964. {
  965. return 1000000.0;
  966. }
  967. else
  968. {
  969. mse /= (3.0 * width_ * height_);
  970. return 20.0 * std::log10(255.0 / std::sqrt(mse));
  971. }
  972. }
  973. inline double psnr(const unsigned int& x,
  974. const unsigned int& y,
  975. const bitmap_image& image)
  976. {
  977. if ((x + image.width() ) > width_ ) { return 0.0; }
  978. if ((y + image.height()) > height_) { return 0.0; }
  979. double mse = 0.0;
  980. const unsigned int height = image.height();
  981. const unsigned int width = image.width();
  982. for (unsigned int r = 0; r < height; ++r)
  983. {
  984. const unsigned char* itr1 = row(r + y) + x * bytes_per_pixel_;
  985. const unsigned char* itr1_end = itr1 + (width * bytes_per_pixel_);
  986. const unsigned char* itr2 = image.row(r);
  987. while (itr1 != itr1_end)
  988. {
  989. double v = (static_cast<double>(*itr1) - static_cast<double>(*itr2));
  990. mse += v * v;
  991. ++itr1;
  992. ++itr2;
  993. }
  994. }
  995. if (mse <= 0.0000001)
  996. {
  997. return 1000000.0;
  998. }
  999. else
  1000. {
  1001. mse /= (3.0 * image.width() * image.height());
  1002. return 20.0 * std::log10(255.0 / std::sqrt(mse));
  1003. }
  1004. }
  1005. inline void histogram(const color_plane color, double hist[256]) const
  1006. {
  1007. std::fill(hist, hist + 256, 0.0);
  1008. for (const unsigned char* itr = (data() + offset(color)); itr < end(); itr += bytes_per_pixel_)
  1009. {
  1010. ++hist[(*itr)];
  1011. }
  1012. }
  1013. inline void histogram_normalized(const color_plane color, double hist[256]) const
  1014. {
  1015. histogram(color,hist);
  1016. double* h_itr = hist;
  1017. const double* h_end = hist + 256;
  1018. const double pixel_count = static_cast<double>(width_ * height_);
  1019. while (h_end != h_itr)
  1020. {
  1021. *(h_itr++) /= pixel_count;
  1022. }
  1023. }
  1024. inline unsigned int offset(const color_plane color) const
  1025. {
  1026. switch (channel_mode_)
  1027. {
  1028. case rgb_mode : {
  1029. switch (color)
  1030. {
  1031. case red_plane : return 0;
  1032. case green_plane : return 1;
  1033. case blue_plane : return 2;
  1034. default : return std::numeric_limits<unsigned int>::max();
  1035. }
  1036. }
  1037. case bgr_mode : {
  1038. switch (color)
  1039. {
  1040. case red_plane : return 2;
  1041. case green_plane : return 1;
  1042. case blue_plane : return 0;
  1043. default : return std::numeric_limits<unsigned int>::max();
  1044. }
  1045. }
  1046. default : return std::numeric_limits<unsigned int>::max();
  1047. }
  1048. }
  1049. inline void incremental()
  1050. {
  1051. unsigned char current_color = 0;
  1052. for (unsigned char* itr = data(); itr < end();)
  1053. {
  1054. (*itr++) = (current_color);
  1055. (*itr++) = (current_color);
  1056. (*itr++) = (current_color);
  1057. ++current_color;
  1058. }
  1059. }
  1060. inline void reverse_channels()
  1061. {
  1062. if (3 != bytes_per_pixel_)
  1063. return;
  1064. for (unsigned char* itr = data(); itr < end(); itr += bytes_per_pixel_)
  1065. {
  1066. std::swap(*(itr + 0),*(itr + 2));
  1067. }
  1068. }
  1069. private:
  1070. inline const unsigned char* end() const
  1071. {
  1072. return data_.data() + data_.size();
  1073. }
  1074. inline unsigned char* end()
  1075. {
  1076. return const_cast<unsigned char*>(data() + data_.size());
  1077. }
  1078. struct bitmap_file_header
  1079. {
  1080. unsigned short type;
  1081. unsigned int size;
  1082. unsigned short reserved1;
  1083. unsigned short reserved2;
  1084. unsigned int off_bits;
  1085. unsigned int struct_size() const
  1086. {
  1087. return sizeof(type ) +
  1088. sizeof(size ) +
  1089. sizeof(reserved1) +
  1090. sizeof(reserved2) +
  1091. sizeof(off_bits ) ;
  1092. }
  1093. void clear()
  1094. {
  1095. std::memset(this, 0x00, sizeof(bitmap_file_header));
  1096. }
  1097. };
  1098. struct bitmap_information_header
  1099. {
  1100. unsigned int size;
  1101. unsigned int width;
  1102. unsigned int height;
  1103. unsigned short planes;
  1104. unsigned short bit_count;
  1105. unsigned int compression;
  1106. unsigned int size_image;
  1107. unsigned int x_pels_per_meter;
  1108. unsigned int y_pels_per_meter;
  1109. unsigned int clr_used;
  1110. unsigned int clr_important;
  1111. unsigned int struct_size() const
  1112. {
  1113. return sizeof(size ) +
  1114. sizeof(width ) +
  1115. sizeof(height ) +
  1116. sizeof(planes ) +
  1117. sizeof(bit_count ) +
  1118. sizeof(compression ) +
  1119. sizeof(size_image ) +
  1120. sizeof(x_pels_per_meter) +
  1121. sizeof(y_pels_per_meter) +
  1122. sizeof(clr_used ) +
  1123. sizeof(clr_important ) ;
  1124. }
  1125. void clear()
  1126. {
  1127. std::memset(this, 0x00, sizeof(bitmap_information_header));
  1128. }
  1129. };
  1130. inline bool big_endian() const
  1131. {
  1132. unsigned int v = 0x01;
  1133. return (1 != reinterpret_cast<char*>(&v)[0]);
  1134. }
  1135. inline unsigned short flip(const unsigned short& v) const
  1136. {
  1137. return ((v >> 8) | (v << 8));
  1138. }
  1139. inline unsigned int flip(const unsigned int& v) const
  1140. {
  1141. return (
  1142. ((v & 0xFF000000) >> 0x18) |
  1143. ((v & 0x000000FF) << 0x18) |
  1144. ((v & 0x00FF0000) >> 0x08) |
  1145. ((v & 0x0000FF00) << 0x08)
  1146. );
  1147. }
  1148. template <typename T>
  1149. inline void read_from_stream(std::ifstream& stream,T& t)
  1150. {
  1151. stream.read(reinterpret_cast<char*>(&t),sizeof(T));
  1152. }
  1153. template <typename T>
  1154. inline void write_to_stream(std::ofstream& stream,const T& t) const
  1155. {
  1156. stream.write(reinterpret_cast<const char*>(&t),sizeof(T));
  1157. }
  1158. inline void read_bfh(std::ifstream& stream, bitmap_file_header& bfh)
  1159. {
  1160. read_from_stream(stream,bfh.type );
  1161. read_from_stream(stream,bfh.size );
  1162. read_from_stream(stream,bfh.reserved1);
  1163. read_from_stream(stream,bfh.reserved2);
  1164. read_from_stream(stream,bfh.off_bits );
  1165. if (big_endian())
  1166. {
  1167. bfh.type = flip(bfh.type );
  1168. bfh.size = flip(bfh.size );
  1169. bfh.reserved1 = flip(bfh.reserved1);
  1170. bfh.reserved2 = flip(bfh.reserved2);
  1171. bfh.off_bits = flip(bfh.off_bits );
  1172. }
  1173. }
  1174. inline void write_bfh(std::ofstream& stream, const bitmap_file_header& bfh) const
  1175. {
  1176. if (big_endian())
  1177. {
  1178. write_to_stream(stream,flip(bfh.type ));
  1179. write_to_stream(stream,flip(bfh.size ));
  1180. write_to_stream(stream,flip(bfh.reserved1));
  1181. write_to_stream(stream,flip(bfh.reserved2));
  1182. write_to_stream(stream,flip(bfh.off_bits ));
  1183. }
  1184. else
  1185. {
  1186. write_to_stream(stream,bfh.type );
  1187. write_to_stream(stream,bfh.size );
  1188. write_to_stream(stream,bfh.reserved1);
  1189. write_to_stream(stream,bfh.reserved2);
  1190. write_to_stream(stream,bfh.off_bits );
  1191. }
  1192. }
  1193. inline void read_bih(std::ifstream& stream,bitmap_information_header& bih)
  1194. {
  1195. read_from_stream(stream,bih.size );
  1196. read_from_stream(stream,bih.width );
  1197. read_from_stream(stream,bih.height );
  1198. read_from_stream(stream,bih.planes );
  1199. read_from_stream(stream,bih.bit_count );
  1200. read_from_stream(stream,bih.compression );
  1201. read_from_stream(stream,bih.size_image );
  1202. read_from_stream(stream,bih.x_pels_per_meter);
  1203. read_from_stream(stream,bih.y_pels_per_meter);
  1204. read_from_stream(stream,bih.clr_used );
  1205. read_from_stream(stream,bih.clr_important );
  1206. if (big_endian())
  1207. {
  1208. bih.size = flip(bih.size );
  1209. bih.width = flip(bih.width );
  1210. bih.height = flip(bih.height );
  1211. bih.planes = flip(bih.planes );
  1212. bih.bit_count = flip(bih.bit_count );
  1213. bih.compression = flip(bih.compression );
  1214. bih.size_image = flip(bih.size_image );
  1215. bih.x_pels_per_meter = flip(bih.x_pels_per_meter);
  1216. bih.y_pels_per_meter = flip(bih.y_pels_per_meter);
  1217. bih.clr_used = flip(bih.clr_used );
  1218. bih.clr_important = flip(bih.clr_important );
  1219. }
  1220. }
  1221. inline void write_bih(std::ofstream& stream, const bitmap_information_header& bih) const
  1222. {
  1223. if (big_endian())
  1224. {
  1225. write_to_stream(stream,flip(bih.size ));
  1226. write_to_stream(stream,flip(bih.width ));
  1227. write_to_stream(stream,flip(bih.height ));
  1228. write_to_stream(stream,flip(bih.planes ));
  1229. write_to_stream(stream,flip(bih.bit_count ));
  1230. write_to_stream(stream,flip(bih.compression ));
  1231. write_to_stream(stream,flip(bih.size_image ));
  1232. write_to_stream(stream,flip(bih.x_pels_per_meter));
  1233. write_to_stream(stream,flip(bih.y_pels_per_meter));
  1234. write_to_stream(stream,flip(bih.clr_used ));
  1235. write_to_stream(stream,flip(bih.clr_important ));
  1236. }
  1237. else
  1238. {
  1239. write_to_stream(stream,bih.size );
  1240. write_to_stream(stream,bih.width );
  1241. write_to_stream(stream,bih.height );
  1242. write_to_stream(stream,bih.planes );
  1243. write_to_stream(stream,bih.bit_count );
  1244. write_to_stream(stream,bih.compression );
  1245. write_to_stream(stream,bih.size_image );
  1246. write_to_stream(stream,bih.x_pels_per_meter);
  1247. write_to_stream(stream,bih.y_pels_per_meter);
  1248. write_to_stream(stream,bih.clr_used );
  1249. write_to_stream(stream,bih.clr_important );
  1250. }
  1251. }
  1252. inline std::size_t file_size(const std::string& file_name) const
  1253. {
  1254. std::ifstream file(file_name.c_str(),std::ios::in | std::ios::binary);
  1255. if (!file) return 0;
  1256. file.seekg (0, std::ios::end);
  1257. return static_cast<std::size_t>(file.tellg());
  1258. }
  1259. void create_bitmap()
  1260. {
  1261. row_increment_ = width_ * bytes_per_pixel_;
  1262. data_.resize(height_ * row_increment_);
  1263. }
  1264. void load_bitmap()
  1265. {
  1266. std::ifstream stream(file_name_.c_str(),std::ios::binary);
  1267. if (!stream)
  1268. {
  1269. std::cerr << "bitmap_image::load_bitmap() ERROR: bitmap_image - "
  1270. << "file " << file_name_ << " not found!" << std::endl;
  1271. return;
  1272. }
  1273. width_ = 0;
  1274. height_ = 0;
  1275. bitmap_file_header bfh;
  1276. bitmap_information_header bih;
  1277. bfh.clear();
  1278. bih.clear();
  1279. read_bfh(stream,bfh);
  1280. read_bih(stream,bih);
  1281. if (bfh.type != 19778)
  1282. {
  1283. std::cerr << "bitmap_image::load_bitmap() ERROR: bitmap_image - "
  1284. << "Invalid type value " << bfh.type << " expected 19778." << std::endl;
  1285. bfh.clear();
  1286. bih.clear();
  1287. stream.close();
  1288. return;
  1289. }
  1290. if (bih.bit_count != 24)
  1291. {
  1292. std::cerr << "bitmap_image::load_bitmap() ERROR: bitmap_image - "
  1293. << "Invalid bit depth " << bih.bit_count << " expected 24." << std::endl;
  1294. bfh.clear();
  1295. bih.clear();
  1296. stream.close();
  1297. return;
  1298. }
  1299. if (bih.size != bih.struct_size())
  1300. {
  1301. std::cerr << "bitmap_image::load_bitmap() ERROR: bitmap_image - "
  1302. << "Invalid BIH size " << bih.size
  1303. << " expected " << bih.struct_size() << std::endl;
  1304. bfh.clear();
  1305. bih.clear();
  1306. stream.close();
  1307. return;
  1308. }
  1309. width_ = bih.width;
  1310. height_ = bih.height;
  1311. bytes_per_pixel_ = bih.bit_count >> 3;
  1312. unsigned int padding = (4 - ((3 * width_) % 4)) % 4;
  1313. char padding_data[4] = { 0x00, 0x00, 0x00, 0x00 };
  1314. std::size_t bitmap_file_size = file_size(file_name_);
  1315. std::size_t bitmap_logical_size = (height_ * width_ * bytes_per_pixel_) +
  1316. (height_ * padding) +
  1317. bih.struct_size() +
  1318. bfh.struct_size() ;
  1319. if (bitmap_file_size != bitmap_logical_size)
  1320. {
  1321. std::cerr << "bitmap_image::load_bitmap() ERROR: bitmap_image - "
  1322. << "Mismatch between logical and physical sizes of bitmap. "
  1323. << "Logical: " << bitmap_logical_size << " "
  1324. << "Physical: " << bitmap_file_size << std::endl;
  1325. bfh.clear();
  1326. bih.clear();
  1327. stream.close();
  1328. return;
  1329. }
  1330. create_bitmap();
  1331. for (unsigned int i = 0; i < height_; ++i)
  1332. {
  1333. unsigned char* data_ptr = row(height_ - i - 1); // read in inverted row order
  1334. stream.read(reinterpret_cast<char*>(data_ptr), sizeof(char) * bytes_per_pixel_ * width_);
  1335. stream.read(padding_data,padding);
  1336. }
  1337. }
  1338. template <typename T>
  1339. inline T clamp(const T& v, const T& lower_range, const T& upper_range) const
  1340. {
  1341. if (v < lower_range)
  1342. return lower_range;
  1343. else if (v > upper_range)
  1344. return upper_range;
  1345. else
  1346. return v;
  1347. }
  1348. std::string file_name_;
  1349. unsigned int width_;
  1350. unsigned int height_;
  1351. unsigned int row_increment_;
  1352. unsigned int bytes_per_pixel_;
  1353. channel_mode channel_mode_;
  1354. std::vector<unsigned char> data_;
  1355. };
  1356. typedef bitmap_image::rgb_t rgb_t;
  1357. inline bool operator==(const rgb_t& c0, const rgb_t& c1)
  1358. {
  1359. return (c0.red == c1 .red) &&
  1360. (c0.green == c1.green) &&
  1361. (c0.blue == c1 .blue) ;
  1362. }
  1363. inline bool operator!=(const rgb_t& c0, const rgb_t& c1)
  1364. {
  1365. return (c0.red != c1 .red) ||
  1366. (c0.green != c1.green) ||
  1367. (c0.blue != c1 .blue) ;
  1368. }
  1369. inline std::size_t hamming_distance(const rgb_t& c0, const rgb_t& c1)
  1370. {
  1371. std::size_t result = 0;
  1372. if (c0.red != c1 .red) ++result;
  1373. if (c0.green != c1.green) ++result;
  1374. if (c0.blue != c1 .blue) ++result;
  1375. return result;
  1376. }
  1377. inline rgb_t make_colour(const unsigned int& red, const unsigned int& green, const unsigned int& blue)
  1378. {
  1379. rgb_t result;
  1380. result.red = static_cast<unsigned char>(red );
  1381. result.green = static_cast<unsigned char>(green);
  1382. result.blue = static_cast<unsigned char>(blue );
  1383. return result;
  1384. }
  1385. template <typename OutputIterator>
  1386. inline void generate_colours(const std::size_t& steps, const rgb_t c0, const rgb_t& c1, OutputIterator out)
  1387. {
  1388. double dr = ((double)c1.red - (double)c0.red ) / steps;
  1389. double dg = ((double)c1.green - (double)c0.green ) / steps;
  1390. double db = ((double)c1.blue - (double)c0.blue ) / steps;
  1391. for (std::size_t i = 0; i < steps; ++i)
  1392. {
  1393. rgb_t c;
  1394. c.red = static_cast<unsigned char>(c0.red + (i * dr));
  1395. c.green = static_cast<unsigned char>(c0.green + (i * dg));
  1396. c.blue = static_cast<unsigned char>(c0.blue + (i * db));
  1397. *(out++) = c;
  1398. }
  1399. }
  1400. template <typename ResponseImage, typename Palette>
  1401. inline std::size_t convert_rsp_to_image(const ResponseImage& resp_image, const Palette& palette, bitmap_image& image)
  1402. {
  1403. if (
  1404. (resp_image.width () > image.width ()) ||
  1405. (resp_image.height() > image.height())
  1406. )
  1407. return 0;
  1408. for (std::size_t y = 0; y < resp_image.height(); ++y)
  1409. {
  1410. for (std::size_t x = 0; x < resp_image.width(); ++x)
  1411. {
  1412. const double v = resp_image(x,y);
  1413. unsigned int index = static_cast<unsigned int>((v < 0) ? 0 : v > (palette.size()) ? (palette.size() - 1) : v);
  1414. image.set_pixel(x,y,palette[index]);
  1415. }
  1416. }
  1417. return (resp_image.width() * resp_image.height());
  1418. }
  1419. inline void rgb_to_ycbcr(const unsigned int& length, double* red, double* green, double* blue,
  1420. double* y, double* cb, double* cr)
  1421. {
  1422. unsigned int i = 0;
  1423. while (i < length)
  1424. {
  1425. ( *y) = 16.0 + ( 65.481 * (*red) + 128.553 * (*green) + 24.966 * (*blue));
  1426. (*cb) = 128.0 + ( -37.797 * (*red) + -74.203 * (*green) + 112.000 * (*blue));
  1427. (*cr) = 128.0 + ( 112.000 * (*red) + -93.786 * (*green) - 18.214 * (*blue));
  1428. ++i;
  1429. ++red; ++green; ++blue;
  1430. ++y; ++cb; ++cr;
  1431. }
  1432. }
  1433. inline void ycbcr_to_rgb(const unsigned int& length, double* y, double* cb, double* cr,
  1434. double* red, double* green, double* blue)
  1435. {
  1436. unsigned int i = 0;
  1437. while (i < length)
  1438. {
  1439. double y_ = (*y) - 16.0;
  1440. double cb_ = (*cb) - 128.0;
  1441. double cr_ = (*cr) - 128.0;
  1442. (*red) = 0.000456621 * y_ + 0.00625893 * cr_;
  1443. (*green) = 0.000456621 * y_ - 0.00153632 * cb_ - 0.00318811 * cr_;
  1444. (*blue) = 0.000456621 * y_ + 0.00791071 * cb_;
  1445. ++i;
  1446. ++red; ++green; ++blue;
  1447. ++y; ++cb; ++cr;
  1448. }
  1449. }
  1450. inline void subsample(const unsigned int& width,
  1451. const unsigned int& height,
  1452. const double* source,
  1453. unsigned int& w,
  1454. unsigned int& h,
  1455. double*& dest)
  1456. {
  1457. /* Single channel. */
  1458. w = 0;
  1459. h = 0;
  1460. bool odd_width = false;
  1461. bool odd_height = false;
  1462. if (0 == (width % 2))
  1463. w = width / 2;
  1464. else
  1465. {
  1466. w = 1 + (width / 2);
  1467. odd_width = true;
  1468. }
  1469. if (0 == (height % 2))
  1470. h = height / 2;
  1471. else
  1472. {
  1473. h = 1 + (height / 2);
  1474. odd_height = true;
  1475. }
  1476. unsigned int horizontal_upper = (odd_width) ? w - 1 : w;
  1477. unsigned int vertical_upper = (odd_height) ? h - 1 : h;
  1478. dest = new double[w * h];
  1479. double* s_itr = dest;
  1480. const double* itr1 = source;
  1481. const double* itr2 = source + width;
  1482. for (unsigned int j = 0; j < vertical_upper; ++j)
  1483. {
  1484. for (unsigned int i = 0; i < horizontal_upper; ++i, ++s_itr)
  1485. {
  1486. (*s_itr) = *(itr1++);
  1487. (*s_itr) += *(itr1++);
  1488. (*s_itr) += *(itr2++);
  1489. (*s_itr) += *(itr2++);
  1490. (*s_itr) /= 4.0;
  1491. }
  1492. if (odd_width)
  1493. {
  1494. (*(s_itr++)) = ((*itr1++) + (*itr2++)) / 2.0;
  1495. }
  1496. itr1 += width;
  1497. if (j != (vertical_upper -1))
  1498. {
  1499. itr2 += width;
  1500. }
  1501. }
  1502. if (odd_height)
  1503. {
  1504. for (unsigned int i = 0; i < horizontal_upper; ++i, ++s_itr)
  1505. {
  1506. (*s_itr) += (*(itr1++));
  1507. (*s_itr) += (*(itr1++));
  1508. (*s_itr) /= 2.0;
  1509. }
  1510. if (odd_width)
  1511. {
  1512. (*(s_itr++)) = (*itr1);
  1513. }
  1514. }
  1515. }
  1516. inline void upsample(const unsigned int& width,
  1517. const unsigned int& height,
  1518. const double* source,
  1519. unsigned int& w,
  1520. unsigned int& h,
  1521. double*& dest)
  1522. {
  1523. /* Single channel. */
  1524. w = 2 * width;
  1525. h = 2 * height;
  1526. dest = new double[w * h];
  1527. const double* s_itr = source;
  1528. double* itr1 = dest;
  1529. double* itr2 = dest + w;
  1530. for (unsigned int j = 0; j < height; ++j)
  1531. {
  1532. for (unsigned int i = 0; i < width; ++i, ++s_itr)
  1533. {
  1534. *(itr1++) = (*s_itr);
  1535. *(itr1++) = (*s_itr);
  1536. *(itr2++) = (*s_itr);
  1537. *(itr2++) = (*s_itr);
  1538. }
  1539. itr1 += w;
  1540. itr2 += w;
  1541. }
  1542. }
  1543. inline void checkered_pattern(const unsigned int x_width,
  1544. const unsigned int y_width,
  1545. const unsigned char value,
  1546. const bitmap_image::color_plane color,
  1547. bitmap_image& image)
  1548. {
  1549. if (
  1550. (x_width >= image.width ()) ||
  1551. (y_width >= image.height())
  1552. )
  1553. {
  1554. return;
  1555. }
  1556. bool setter_x = false;
  1557. bool setter_y = true;
  1558. const unsigned int color_plane_offset = image.offset(color);
  1559. const unsigned int height = image.height();
  1560. const unsigned int width = image.width();
  1561. for (unsigned int y = 0; y < height; ++y)
  1562. {
  1563. if (0 == (y % y_width))
  1564. {
  1565. setter_y = !setter_y;
  1566. }
  1567. unsigned char* row = image.row(y) + color_plane_offset;
  1568. for (unsigned int x = 0; x < width; ++x, row += image.bytes_per_pixel())
  1569. {
  1570. if (0 == (x % x_width))
  1571. {
  1572. setter_x = !setter_x;
  1573. }
  1574. if (setter_x ^ setter_y)
  1575. {
  1576. *row = value;
  1577. }
  1578. }
  1579. }
  1580. }
  1581. inline void checkered_pattern(const unsigned int x_width,
  1582. const unsigned int y_width,
  1583. const unsigned char red,
  1584. const unsigned char green,
  1585. const unsigned char blue,
  1586. bitmap_image& image)
  1587. {
  1588. if (
  1589. (x_width >= image.width ()) ||
  1590. (y_width >= image.height())
  1591. )
  1592. {
  1593. return;
  1594. }
  1595. bool setter_x = false;
  1596. bool setter_y = true;
  1597. const unsigned int height = image.height();
  1598. const unsigned int width = image.width();
  1599. for (unsigned int y = 0; y < height; ++y)
  1600. {
  1601. if (0 == (y % y_width))
  1602. {
  1603. setter_y = !setter_y;
  1604. }
  1605. unsigned char* row = image.row(y);
  1606. for (unsigned int x = 0; x < width; ++x, row += image.bytes_per_pixel())
  1607. {
  1608. if (0 == (x % x_width))
  1609. {
  1610. setter_x = !setter_x;
  1611. }
  1612. if (setter_x ^ setter_y)
  1613. {
  1614. *(row + 0) = blue;
  1615. *(row + 1) = green;
  1616. *(row + 2) = red;
  1617. }
  1618. }
  1619. }
  1620. }
  1621. inline void plasma(bitmap_image& image,
  1622. const double& x, const double& y,
  1623. const double& width, const double& height,
  1624. const double& c1, const double& c2,
  1625. const double& c3, const double& c4,
  1626. const double& roughness = 3.0,
  1627. const rgb_t colormap[] = 0)
  1628. {
  1629. // Note: c1,c2,c3,c4 -> [0.0,1.0]
  1630. const double half_width = ( width / 2.0);
  1631. const double half_height = (height / 2.0);
  1632. if ((width >= 1.0) || (height >= 1.0))
  1633. {
  1634. const double corner1 = (c1 + c2) / 2.0;
  1635. const double corner2 = (c2 + c3) / 2.0;
  1636. const double corner3 = (c3 + c4) / 2.0;
  1637. const double corner4 = (c4 + c1) / 2.0;
  1638. double center = (c1 + c2 + c3 + c4) / 4.0 +
  1639. ((1.0 * ::rand() /(1.0 * RAND_MAX)) - 0.5) * // should use a better rng
  1640. ((1.0 * half_width + half_height) / (image.width() + image.height()) * roughness);
  1641. center = std::min<double>(std::max<double>(0.0,center),1.0);
  1642. plasma(image, x, y, half_width, half_height, c1, corner1, center, corner4,roughness,colormap);
  1643. plasma(image, x + half_width, y, half_width, half_height, corner1, c2, corner2, center,roughness,colormap);
  1644. plasma(image, x + half_width, y + half_height, half_width, half_height, center, corner2, c3, corner3,roughness,colormap);
  1645. plasma(image, x, y + half_height, half_width, half_height, corner4, center, corner3, c4,roughness,colormap);
  1646. }
  1647. else
  1648. {
  1649. rgb_t color = colormap[static_cast<unsigned int>(1000.0 * ((c1 + c2 + c3 + c4) / 4.0)) % 1000];
  1650. image.set_pixel(static_cast<unsigned int>(x),static_cast<unsigned int>(y),color);
  1651. }
  1652. }
  1653. inline void plasma(bitmap_image& image,
  1654. const double& c1, const double& c2,
  1655. const double& c3, const double& c4,
  1656. const double& roughness = 3.0,
  1657. const rgb_t colormap[] = 0)
  1658. {
  1659. plasma
  1660. (
  1661. image, 0, 0, image.width(), image.height(),
  1662. c1, c2, c3, c4,
  1663. roughness, colormap
  1664. );
  1665. }
  1666. inline double psnr_region(const unsigned int& x, const unsigned int& y,
  1667. const unsigned int& width, const unsigned int& height,
  1668. const bitmap_image& image1, const bitmap_image& image2)
  1669. {
  1670. if (
  1671. (image1.width() != image2.width ()) ||
  1672. (image1.height() != image2.height())
  1673. )
  1674. {
  1675. return 0.0;
  1676. }
  1677. if ((x + width ) > image1.width() ) { return 0.0; }
  1678. if ((y + height) > image1.height()) { return 0.0; }
  1679. double mse = 0.0;
  1680. for (unsigned int r = 0; r < height; ++r)
  1681. {
  1682. const unsigned char* itr1 = image1.row(r + y) + x * image1.bytes_per_pixel();
  1683. const unsigned char* itr1_end = itr1 + (width * image1.bytes_per_pixel());
  1684. const unsigned char* itr2 = image2.row(r + y) + x * image2.bytes_per_pixel();
  1685. while (itr1 != itr1_end)
  1686. {
  1687. double v = (static_cast<double>(*itr1) - static_cast<double>(*itr2));
  1688. mse += v * v;
  1689. ++itr1;
  1690. ++itr2;
  1691. }
  1692. }
  1693. if (mse <= 0.0000001)
  1694. {
  1695. return 1000000.0;
  1696. }
  1697. else
  1698. {
  1699. mse /= (3.0 * width * height);
  1700. return 20.0 * std::log10(255.0 / std::sqrt(mse));
  1701. }
  1702. }
  1703. inline void hierarchical_psnr_r(const double& x, const double& y,
  1704. const double& width, const double& height,
  1705. const bitmap_image& image1,
  1706. bitmap_image& image2,
  1707. const double& threshold,
  1708. const rgb_t colormap[])
  1709. {
  1710. if ((width <= 4.0) || (height <= 4.0))
  1711. {
  1712. const double psnr = psnr_region
  1713. (
  1714. static_cast<unsigned int>(x),
  1715. static_cast<unsigned int>(y),
  1716. static_cast<unsigned int>(width),
  1717. static_cast<unsigned int>(height),
  1718. image1, image2
  1719. );
  1720. if (psnr < threshold)
  1721. {
  1722. rgb_t c = colormap[static_cast<unsigned int>(1000.0 * (1.0 - (psnr / threshold)))];
  1723. image2.set_region
  1724. (
  1725. static_cast<unsigned int>(x),
  1726. static_cast<unsigned int>(y),
  1727. static_cast<unsigned int>(width + 1),
  1728. static_cast<unsigned int>(height + 1),
  1729. c.red, c.green, c.blue
  1730. );
  1731. }
  1732. }
  1733. else
  1734. {
  1735. const double half_width = ( width / 2.0);
  1736. const double half_height = (height / 2.0);
  1737. hierarchical_psnr_r(x , y , half_width, half_height, image1, image2, threshold, colormap);
  1738. hierarchical_psnr_r(x + half_width, y , half_width, half_height, image1, image2, threshold, colormap);
  1739. hierarchical_psnr_r(x + half_width, y + half_height, half_width, half_height, image1, image2, threshold, colormap);
  1740. hierarchical_psnr_r(x , y + half_height, half_width, half_height, image1, image2, threshold, colormap);
  1741. }
  1742. }
  1743. inline void hierarchical_psnr(bitmap_image& image1, bitmap_image& image2, const double threshold, const rgb_t colormap[])
  1744. {
  1745. if (
  1746. (image1.width() != image2.width ()) ||
  1747. (image1.height() != image2.height())
  1748. )
  1749. {
  1750. return;
  1751. }
  1752. const double psnr = psnr_region
  1753. (
  1754. 0, 0, image1.width(), image1.height(),
  1755. image1, image2
  1756. );
  1757. if (psnr < threshold)
  1758. {
  1759. hierarchical_psnr_r
  1760. (
  1761. 0, 0, image1.width(), image1.height(),
  1762. image1, image2,
  1763. threshold,
  1764. colormap
  1765. );
  1766. }
  1767. }
  1768. class image_drawer
  1769. {
  1770. public:
  1771. image_drawer(bitmap_image& image)
  1772. : image_(image),
  1773. pen_width_(1),
  1774. pen_color_red_ (0),
  1775. pen_color_green_(0),
  1776. pen_color_blue_ (0)
  1777. {}
  1778. void rectangle(int x1, int y1, int x2, int y2)
  1779. {
  1780. line_segment(x1, y1, x2, y1);
  1781. line_segment(x2, y1, x2, y2);
  1782. line_segment(x2, y2, x1, y2);
  1783. line_segment(x1, y2, x1, y1);
  1784. }
  1785. void triangle(int x1, int y1, int x2, int y2,int x3, int y3)
  1786. {
  1787. line_segment(x1, y1, x2, y2);
  1788. line_segment(x2, y2, x3, y3);
  1789. line_segment(x3, y3, x1, y1);
  1790. }
  1791. void quadix(int x1, int y1, int x2, int y2,int x3, int y3, int x4, int y4)
  1792. {
  1793. line_segment(x1, y1, x2, y2);
  1794. line_segment(x2, y2, x3, y3);
  1795. line_segment(x3, y3, x4, y4);
  1796. line_segment(x4, y4, x1, y1);
  1797. }
  1798. void line_segment(int x1, int y1, int x2, int y2)
  1799. {
  1800. int steep = 0;
  1801. int sx = ((x2 - x1) > 0) ? 1 : -1;
  1802. int sy = ((y2 - y1) > 0) ? 1 : -1;
  1803. int dx = abs(x2 - x1);
  1804. int dy = abs(y2 - y1);
  1805. if (dy > dx)
  1806. {
  1807. std::swap(x1,y1);
  1808. std::swap(dx,dy);
  1809. std::swap(sx,sy);
  1810. steep = 1;
  1811. }
  1812. int e = 2 * dy - dx;
  1813. for (int i = 0; i < dx; ++i)
  1814. {
  1815. if (steep)
  1816. plot_pen_pixel(y1,x1);
  1817. else
  1818. plot_pen_pixel(x1,y1);
  1819. while (e >= 0)
  1820. {
  1821. y1 += sy;
  1822. e -= (dx << 1);
  1823. }
  1824. x1 += sx;
  1825. e += (dy << 1);
  1826. }
  1827. plot_pen_pixel(x2,y2);
  1828. }
  1829. void horiztonal_line_segment(int x1, int x2, int y)
  1830. {
  1831. if (x1 > x2)
  1832. {
  1833. std::swap(x1,x2);
  1834. }
  1835. for (int i = 0; i < (x2 - x1); ++i)
  1836. {
  1837. plot_pen_pixel(x1 + i,y);
  1838. }
  1839. }
  1840. void vertical_line_segment(int y1, int y2, int x)
  1841. {
  1842. if (y1 > y2)
  1843. {
  1844. std::swap(y1,y2);
  1845. }
  1846. for (int i = 0; i < (y2 - y1); ++i)
  1847. {
  1848. plot_pen_pixel(x, y1 + i);
  1849. }
  1850. }
  1851. void ellipse(int centerx, int centery, int a, int b)
  1852. {
  1853. int t1 = a * a;
  1854. int t2 = t1 << 1;
  1855. int t3 = t2 << 1;
  1856. int t4 = b * b;
  1857. int t5 = t4 << 1;
  1858. int t6 = t5 << 1;
  1859. int t7 = a * t5;
  1860. int t8 = t7 << 1;
  1861. int t9 = 0;
  1862. int d1 = t2 - t7 + (t4 >> 1);
  1863. int d2 = (t1 >> 1) - t8 + t5;
  1864. int x = a;
  1865. int y = 0;
  1866. int negative_tx = centerx - x;
  1867. int positive_tx = centerx + x;
  1868. int negative_ty = centery - y;
  1869. int positive_ty = centery + y;
  1870. while (d2 < 0)
  1871. {
  1872. plot_pen_pixel(positive_tx, positive_ty);
  1873. plot_pen_pixel(positive_tx, negative_ty);
  1874. plot_pen_pixel(negative_tx, positive_ty);
  1875. plot_pen_pixel(negative_tx, negative_ty);
  1876. ++y;
  1877. t9 = t9 + t3;
  1878. if (d1 < 0)
  1879. {
  1880. d1 = d1 + t9 + t2;
  1881. d2 = d2 + t9;
  1882. }
  1883. else
  1884. {
  1885. x--;
  1886. t8 = t8 - t6;
  1887. d1 = d1 + (t9 + t2 - t8);
  1888. d2 = d2 + (t9 + t5 - t8);
  1889. negative_tx = centerx - x;
  1890. positive_tx = centerx + x;
  1891. }
  1892. negative_ty = centery - y;
  1893. positive_ty = centery + y;
  1894. }
  1895. do
  1896. {
  1897. plot_pen_pixel(positive_tx, positive_ty);
  1898. plot_pen_pixel(positive_tx, negative_ty);
  1899. plot_pen_pixel(negative_tx, positive_ty);
  1900. plot_pen_pixel(negative_tx, negative_ty);
  1901. x--;
  1902. t8 = t8 - t6;
  1903. if (d2 < 0)
  1904. {
  1905. ++y;
  1906. t9 = t9 + t3;
  1907. d2 = d2 + (t9 + t5 - t8);
  1908. negative_ty = centery - y;
  1909. positive_ty = centery + y;
  1910. }
  1911. else
  1912. d2 = d2 + (t5 - t8);
  1913. negative_tx = centerx - x;
  1914. positive_tx = centerx + x;
  1915. }
  1916. while (x >= 0);
  1917. }
  1918. void circle(int centerx, int centery, int radius)
  1919. {
  1920. int x = 0;
  1921. int d = (1 - radius) << 1;
  1922. while (radius >= 0)
  1923. {
  1924. plot_pen_pixel(centerx + x, centery + radius);
  1925. plot_pen_pixel(centerx + x, centery - radius);
  1926. plot_pen_pixel(centerx - x, centery + radius);
  1927. plot_pen_pixel(centerx - x, centery - radius);
  1928. if ((d + radius) > 0)
  1929. d -= ((--radius) << 1) - 1;
  1930. if (x > d)
  1931. d += ((++x) << 1) + 1;
  1932. }
  1933. }
  1934. void plot_pen_pixel(int x, int y)
  1935. {
  1936. switch (pen_width_)
  1937. {
  1938. case 1 : plot_pixel(x,y);
  1939. break;
  1940. case 2 : {
  1941. plot_pixel(x , y );
  1942. plot_pixel(x + 1, y );
  1943. plot_pixel(x + 1, y + 1);
  1944. plot_pixel(x , y + 1);
  1945. }
  1946. break;
  1947. case 3 : {
  1948. plot_pixel(x , y - 1);
  1949. plot_pixel(x - 1, y - 1);
  1950. plot_pixel(x + 1, y - 1);
  1951. plot_pixel(x , y );
  1952. plot_pixel(x - 1, y );
  1953. plot_pixel(x + 1, y );
  1954. plot_pixel(x , y + 1);
  1955. plot_pixel(x - 1, y + 1);
  1956. plot_pixel(x + 1, y + 1);
  1957. }
  1958. break;
  1959. default : plot_pixel(x,y);
  1960. break;
  1961. }
  1962. }
  1963. void plot_pixel(int x, int y)
  1964. {
  1965. if (
  1966. (x < 0) ||
  1967. (y < 0) ||
  1968. (x >= static_cast<int>(image_.width ())) ||
  1969. (y >= static_cast<int>(image_.height()))
  1970. )
  1971. return;
  1972. image_.set_pixel(x,y,pen_color_red_,pen_color_green_,pen_color_blue_);
  1973. }
  1974. void pen_width(const unsigned int& width)
  1975. {
  1976. if ((width > 0) && (width < 4))
  1977. {
  1978. pen_width_ = width;
  1979. }
  1980. }
  1981. void pen_color(const unsigned char& red,
  1982. const unsigned char& green,
  1983. const unsigned char& blue)
  1984. {
  1985. pen_color_red_ = red;
  1986. pen_color_green_ = green;
  1987. pen_color_blue_ = blue;
  1988. }
  1989. template <typename RGB>
  1990. void pen_color(const RGB colour)
  1991. {
  1992. pen_color_red_ = colour.red;
  1993. pen_color_green_ = colour.green;
  1994. pen_color_blue_ = colour.blue;
  1995. }
  1996. private:
  1997. image_drawer(const image_drawer& id);
  1998. image_drawer& operator =(const image_drawer& id);
  1999. bitmap_image& image_;
  2000. unsigned int pen_width_;
  2001. unsigned char pen_color_red_;
  2002. unsigned char pen_color_green_;
  2003. unsigned char pen_color_blue_;
  2004. };
  2005. class cartesian_canvas
  2006. {
  2007. public:
  2008. cartesian_canvas(const double x_length, const double y_length)
  2009. : width_div2_ (0.0),
  2010. height_div2_(0.0),
  2011. min_x_ (0.0),
  2012. min_y_ (0.0),
  2013. max_x_ (0.0),
  2014. max_y_ (0.0),
  2015. draw_ (image_)
  2016. {
  2017. setup_canvas(x_length,y_length);
  2018. }
  2019. inline bool operator!()
  2020. {
  2021. return !image_;
  2022. }
  2023. void rectangle(double x1, double y1, double x2, double y2)
  2024. {
  2025. line_segment(x1, y1, x2, y1);
  2026. line_segment(x2, y1, x2, y2);
  2027. line_segment(x2, y2, x1, y2);
  2028. line_segment(x1, y2, x1, y1);
  2029. }
  2030. void triangle(double x1, double y1, double x2, double y2, double x3, double y3)
  2031. {
  2032. line_segment(x1, y1, x2, y2);
  2033. line_segment(x2, y2, x3, y3);
  2034. line_segment(x3, y3, x1, y1);
  2035. }
  2036. void quadix(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
  2037. {
  2038. line_segment(x1, y1, x2, y2);
  2039. line_segment(x2, y2, x3, y3);
  2040. line_segment(x3, y3, x4, y4);
  2041. line_segment(x4, y4, x1, y1);
  2042. }
  2043. void line_segment(double x1, double y1, double x2, double y2)
  2044. {
  2045. if (clip(x1, y1, x2, y2))
  2046. {
  2047. const int sc_x1 = static_cast<int>(cart_to_screen_x(x1));
  2048. const int sc_x2 = static_cast<int>(cart_to_screen_x(x2));
  2049. const int sc_y1 = static_cast<int>(cart_to_screen_y(y1));
  2050. const int sc_y2 = static_cast<int>(cart_to_screen_y(y2));
  2051. draw_.line_segment(sc_x1, sc_y1, sc_x2, sc_y2);
  2052. }
  2053. }
  2054. void horiztonal_line_segment(double x1, double x2, double y)
  2055. {
  2056. x1 = clamp_x(x1);
  2057. x2 = clamp_x(x2);
  2058. y = clamp_y( y);
  2059. const int sc_x1 = static_cast<int>(cart_to_screen_x(x1));
  2060. const int sc_x2 = static_cast<int>(cart_to_screen_x(x2));
  2061. const int sc_y = static_cast<int>(cart_to_screen_y(y ));
  2062. draw_.horiztonal_line_segment(sc_x1, sc_x2, sc_y);
  2063. }
  2064. void vertical_line_segment(double y1, double y2, double x)
  2065. {
  2066. y1 = clamp_y(y1);
  2067. y2 = clamp_y(y2);
  2068. x = clamp_x( x);
  2069. const int sc_y1 = static_cast<int>(cart_to_screen_y(y1));
  2070. const int sc_y2 = static_cast<int>(cart_to_screen_y(y2));
  2071. const int sc_x = static_cast<int>(cart_to_screen_x(x ));
  2072. draw_.vertical_line_segment(sc_y1, sc_y2, sc_x);
  2073. }
  2074. void ellipse(double centerx, double centery, double a, double b)
  2075. {
  2076. const int sc_cx = static_cast<int>(cart_to_screen_x(centerx));
  2077. const int sc_cy = static_cast<int>(cart_to_screen_y(centery));
  2078. draw_.ellipse(sc_cx, sc_cy, static_cast<int>(a), static_cast<int>(b));
  2079. }
  2080. void circle(double centerx, double centery, double radius)
  2081. {
  2082. const int sc_cx = static_cast<int>(cart_to_screen_x(centerx));
  2083. const int sc_cy = static_cast<int>(cart_to_screen_y(centery));
  2084. draw_.circle(sc_cx, sc_cy, static_cast<int>(radius));
  2085. }
  2086. void fill_rectangle(double x1, double y1, double x2, double y2)
  2087. {
  2088. if (y1 > y2)
  2089. std::swap(y1, y2);
  2090. for (double y = y1; y <= y2; y += 0.5)
  2091. {
  2092. line_segment(x1, y, x2, y);
  2093. }
  2094. }
  2095. void fill_triangle(double x1, double y1, double x2, double y2, double x3, double y3)
  2096. {
  2097. typedef std::pair<double,double> point_t;
  2098. std::vector<point_t> p;
  2099. p.push_back(std::make_pair(x1,y1));
  2100. p.push_back(std::make_pair(x2,y2));
  2101. p.push_back(std::make_pair(x3,y3));
  2102. if (p[0].second > p[1].second)
  2103. std::swap(p[0],p[1]);
  2104. if (p[0].second > p[2].second)
  2105. std::swap(p[0],p[2]);
  2106. if (p[1].second > p[2].second)
  2107. std::swap(p[1],p[2]);
  2108. class draw_modes
  2109. {
  2110. private:
  2111. cartesian_canvas& canvas;
  2112. // Needed for incompetent and broken msvc compiler versions
  2113. #ifdef _MSC_VER
  2114. #pragma warning(push)
  2115. #pragma warning(disable: 4822)
  2116. #endif
  2117. draw_modes& operator=(const draw_modes&);
  2118. #ifdef _MSC_VER
  2119. #pragma warning(pop)
  2120. #endif
  2121. public:
  2122. draw_modes(cartesian_canvas& c)
  2123. : canvas(c)
  2124. {}
  2125. void bottom(const point_t& p0, const point_t& p1, const point_t& p2)
  2126. {
  2127. const double m0 = (p1.first - p0.first) / (2.0 * (p1.second - p0.second));
  2128. const double m1 = (p2.first - p0.first) / (2.0 * (p2.second - p0.second));
  2129. double x0 = p0.first;
  2130. double x1 = p0.first;
  2131. for (double y = p0.second; y <= p1.second; y += 0.5)
  2132. {
  2133. canvas.horiztonal_line_segment(x0, x1, y);
  2134. x0 += m0;
  2135. x1 += m1;
  2136. }
  2137. }
  2138. void top(const point_t& p0, const point_t& p1, const point_t& p2)
  2139. {
  2140. const double m0 = (p2.first - p0.first) / (2.0 * (p2.second - p0.second));
  2141. const double m1 = (p2.first - p1.first) / (2.0 * (p2.second - p1.second));
  2142. double x0 = p2.first;
  2143. double x1 = p2.first;
  2144. for (double y = p2.second; y >= p0.second; y -= 0.5)
  2145. {
  2146. canvas.horiztonal_line_segment(x0, x1, y);
  2147. x0 -= m0;
  2148. x1 -= m1;
  2149. }
  2150. }
  2151. };
  2152. draw_modes dm(*this);
  2153. const double eps = 0.00001;
  2154. if (std::abs(p[1].second - p[2].second) < eps)
  2155. dm.bottom(p[0], p[1], p[2]);
  2156. else if (std::abs(p[0].second - p[1].second) < eps)
  2157. dm.top(p[0], p[1], p[2]);
  2158. else
  2159. {
  2160. point_t p3;
  2161. p3.first = (p[0].first + ((p[1].second - p[0].second) / (p[2].second - p[0].second)) * (p[2].first - p[0].first));
  2162. p3.second = p[1].second;
  2163. dm.bottom(p[0], p[1], p3 );
  2164. dm.top (p[1], p3 , p[2]);
  2165. }
  2166. }
  2167. void fill_quadix(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
  2168. {
  2169. fill_triangle(x1, y1, x2, y2, x3, y3);
  2170. fill_triangle(x1, y1, x3, y3, x4, y4);
  2171. }
  2172. void fill_circle(double cx, double cy, double radius)
  2173. {
  2174. const double delta = 1.0;
  2175. double x = radius;
  2176. double y = 0.0;
  2177. double dx = delta - (2.0 * delta * radius);
  2178. double dy = 0.0;
  2179. double dr = 0.0;
  2180. while (x >= y)
  2181. {
  2182. for (double i = cx - x; i <= cx + x; i += delta)
  2183. {
  2184. horiztonal_line_segment(cx - x, cx + x, cy + y);
  2185. horiztonal_line_segment(cx - x, cx + x, cy - y);
  2186. }
  2187. for (double i = cx - y; i <= cx + y; i += delta)
  2188. {
  2189. horiztonal_line_segment(cx - y, cx + y, cy + x);
  2190. horiztonal_line_segment(cx - y, cx + y, cy - x);
  2191. }
  2192. y += delta;
  2193. dr += dy;
  2194. dy += 2.0 * delta;
  2195. if ((2.0 * delta * dr + dx) > 0)
  2196. {
  2197. x -= delta;
  2198. dr += dx;
  2199. dx += 2.0 * delta;
  2200. }
  2201. }
  2202. }
  2203. void plot_pen_pixel(double x, double y)
  2204. {
  2205. if ((x < min_x_) || (x > max_x_)) return;
  2206. if ((y < min_y_) || (y > max_y_)) return;
  2207. const int sc_x = static_cast<int>(cart_to_screen_x(x));
  2208. const int sc_y = static_cast<int>(cart_to_screen_y(y));
  2209. draw_.plot_pen_pixel(sc_x, sc_y);
  2210. }
  2211. void plot_pixel(double x, double y)
  2212. {
  2213. if ((x < min_x_) || (x > max_x_)) return;
  2214. if ((y < min_y_) || (y > max_y_)) return;
  2215. const int sc_x = static_cast<int>(cart_to_screen_x(x));
  2216. const int sc_y = static_cast<int>(cart_to_screen_y(y));
  2217. draw_.plot_pixel(sc_x, sc_y);
  2218. }
  2219. void pen_width(const unsigned int& width)
  2220. {
  2221. draw_.pen_width(width);
  2222. }
  2223. void pen_color(const unsigned char& red,
  2224. const unsigned char& green,
  2225. const unsigned char& blue)
  2226. {
  2227. draw_.pen_color(red,green,blue);
  2228. }
  2229. template <typename RGB>
  2230. void pen_color(const RGB colour)
  2231. {
  2232. draw_.pen_color(colour);
  2233. }
  2234. const bitmap_image& image() const
  2235. {
  2236. return image_;
  2237. }
  2238. bitmap_image& image()
  2239. {
  2240. return image_;
  2241. }
  2242. void set_widthheight(const double x_length, const double y_length)
  2243. {
  2244. setup_canvas(x_length, y_length);
  2245. }
  2246. double min_x() const { return min_x_; }
  2247. double min_y() const { return min_y_; }
  2248. double max_x() const { return max_x_; }
  2249. double max_y() const { return max_y_; }
  2250. private:
  2251. void setup_canvas(const double x_length, const double y_length)
  2252. {
  2253. if ((x_length < 2.0) || (y_length < 2.0))
  2254. return;
  2255. width_div2_ = x_length / 2.0;
  2256. height_div2_ = y_length / 2.0;
  2257. min_x_ = -width_div2_ ;
  2258. min_y_ = -height_div2_;
  2259. max_x_ = width_div2_ ;
  2260. max_y_ = height_div2_;
  2261. image_.setwidth_height(static_cast<unsigned int>(x_length) + 1, static_cast<unsigned int>(y_length) + 1);
  2262. image_.clear(0xFF);
  2263. }
  2264. double clamp_x(const double& x)
  2265. {
  2266. if (x < min_x_) return min_x_;
  2267. else if (x > max_x_) return max_x_;
  2268. else return x;
  2269. }
  2270. double clamp_y(const double& y)
  2271. {
  2272. if (y < min_y_) return min_y_;
  2273. else if (y > max_y_) return max_y_;
  2274. else return y;
  2275. }
  2276. double cart_to_screen_x(const double& x)
  2277. {
  2278. return x + width_div2_;
  2279. }
  2280. double cart_to_screen_y(const double& y)
  2281. {
  2282. return height_div2_ - y;
  2283. }
  2284. enum clip_code
  2285. {
  2286. e_clip_bottom = 1,
  2287. e_clip_top = 2,
  2288. e_clip_left = 4,
  2289. e_clip_right = 8
  2290. };
  2291. int out_code(
  2292. const double& x, const double& y,
  2293. const double& x1, const double& y1,
  2294. const double& x2, const double& y2
  2295. )
  2296. {
  2297. int result = 0;
  2298. if (y < y1) result |= e_clip_bottom;
  2299. else if (y > y2) result |= e_clip_top;
  2300. if (x < x1) result |= e_clip_left;
  2301. else if (x > x2) result |= e_clip_right;
  2302. return result;
  2303. }
  2304. bool clip(double& x1, double& y1, double& x2, double& y2)
  2305. {
  2306. bool result = false;
  2307. double x = 0.0;
  2308. double y = 0.0;
  2309. int outcode0 = out_code(x1, y1, min_x_, min_y_, max_x_, max_y_);
  2310. int outcode1 = out_code(x2, y2, min_x_, min_y_, max_x_, max_y_);
  2311. int outcodeout = 0;
  2312. while ((outcode0 != 0) || (outcode1 != 0))
  2313. {
  2314. if ((outcode0 & outcode1) != 0)
  2315. return result;
  2316. else
  2317. {
  2318. if (outcode0 != 0)
  2319. outcodeout = outcode0;
  2320. else
  2321. outcodeout = outcode1;
  2322. double dx = (x2 - x1);
  2323. double dy = (y2 - y1);
  2324. if ((outcodeout & e_clip_bottom) == e_clip_bottom)
  2325. {
  2326. x = x1 + dx * (min_y_ - y1) / dy;
  2327. y = min_y_;
  2328. }
  2329. else if ((outcodeout & e_clip_top) == e_clip_top)
  2330. {
  2331. x = x1 + dx * (max_y_ - y1) / dy;
  2332. y = max_y_;
  2333. }
  2334. else if ((outcodeout & e_clip_right) == e_clip_right)
  2335. {
  2336. y = y1 + dy * (max_x_ - x1) / dx;
  2337. x = max_x_;
  2338. }
  2339. else if ((outcodeout & e_clip_left) == e_clip_left)
  2340. {
  2341. y = y1 + dy * (min_x_ - x1) / dx;
  2342. x = min_x_;
  2343. }
  2344. if (outcodeout == outcode0)
  2345. {
  2346. x1 = x;
  2347. y1 = y;
  2348. outcode0 = out_code(x1, y1, min_x_, min_y_, max_x_, max_y_);
  2349. }
  2350. else
  2351. {
  2352. x2 = x;
  2353. y2 = y;
  2354. outcode1 = out_code(x2, y2, min_x_, min_y_, max_x_, max_y_);
  2355. }
  2356. }
  2357. }
  2358. return true;
  2359. }
  2360. cartesian_canvas(const cartesian_canvas&);
  2361. cartesian_canvas operator=(const cartesian_canvas&);
  2362. double width_div2_;
  2363. double height_div2_;
  2364. double min_x_;
  2365. double min_y_;
  2366. double max_x_;
  2367. double max_y_;
  2368. bitmap_image image_;
  2369. image_drawer draw_;
  2370. };
  2371. inline rgb_t convert_wave_length_nm_to_rgb(const double wave_length_nm)
  2372. {
  2373. // Credits: Dan Bruton http://www.physics.sfasu.edu/astro/color.html
  2374. double red = 0.0;
  2375. double green = 0.0;
  2376. double blue = 0.0;
  2377. if ((380.0 <= wave_length_nm) && (wave_length_nm <= 439.0))
  2378. {
  2379. red = -(wave_length_nm - 440.0) / (440.0 - 380.0);
  2380. green = 0.0;
  2381. blue = 1.0;
  2382. }
  2383. else if ((440.0 <= wave_length_nm) && (wave_length_nm <= 489.0))
  2384. {
  2385. red = 0.0;
  2386. green = (wave_length_nm - 440.0) / (490.0 - 440.0);
  2387. blue = 1.0;
  2388. }
  2389. else if ((490.0 <= wave_length_nm) && (wave_length_nm <= 509.0))
  2390. {
  2391. red = 0.0;
  2392. green = 1.0;
  2393. blue = -(wave_length_nm - 510.0) / (510.0 - 490.0);
  2394. }
  2395. else if ((510.0 <= wave_length_nm) && (wave_length_nm <= 579.0))
  2396. {
  2397. red = (wave_length_nm - 510.0) / (580.0 - 510.0);
  2398. green = 1.0;
  2399. blue = 0.0;
  2400. }
  2401. else if ((580.0 <= wave_length_nm) && (wave_length_nm <= 644.0))
  2402. {
  2403. red = 1.0;
  2404. green = -(wave_length_nm - 645.0) / (645.0 - 580.0);
  2405. blue = 0.0;
  2406. }
  2407. else if ((645.0 <= wave_length_nm) && (wave_length_nm <= 780.0))
  2408. {
  2409. red = 1.0;
  2410. green = 0.0;
  2411. blue = 0.0;
  2412. }
  2413. double factor = 0.0;
  2414. if ((380.0 <= wave_length_nm) && (wave_length_nm <= 419.0))
  2415. factor = 0.3 + 0.7 * (wave_length_nm - 380.0) / (420.0 - 380.0);
  2416. else if ((420.0 <= wave_length_nm) && (wave_length_nm <= 700.0))
  2417. factor = 1.0;
  2418. else if ((701.0 <= wave_length_nm) && (wave_length_nm <= 780.0))
  2419. factor = 0.3 + 0.7 * (780.0 - wave_length_nm) / (780.0 - 700.0);
  2420. else
  2421. factor = 0.0;
  2422. rgb_t result;
  2423. const double gamma = 0.8;
  2424. const double intensity_max = 255.0;
  2425. #define round(d) std::floor(d + 0.5)
  2426. result.red = static_cast<unsigned char>((red == 0.0) ? red : round(intensity_max * std::pow(red * factor, gamma)));
  2427. result.green = static_cast<unsigned char>((green == 0.0) ? green : round(intensity_max * std::pow(green * factor, gamma)));
  2428. result.blue = static_cast<unsigned char>((blue == 0.0) ? blue : round(intensity_max * std::pow(blue * factor, gamma)));
  2429. #undef round
  2430. return result;
  2431. }
  2432. inline double weighted_distance(const unsigned char r0, const unsigned char g0, const unsigned char b0,
  2433. const unsigned char r1, const unsigned char g1, const unsigned char b1)
  2434. {
  2435. const double diff_r = /*0.30 */ (r0 - r1);
  2436. const double diff_g = /*0.59 */ (g0 - g1);
  2437. const double diff_b = /*0.11 */ (b0 - b1);
  2438. return std::sqrt((diff_r * diff_r) + (diff_g * diff_g) + (diff_b * diff_b));
  2439. }
  2440. inline double weighted_distance(const rgb_t c0, const rgb_t c1)
  2441. {
  2442. return weighted_distance(c0.red, c0.green, c0.blue,
  2443. c1.red, c1.green, c1.blue);
  2444. }
  2445. template <typename Iterator>
  2446. inline rgb_t find_nearest_color(const rgb_t& c, const Iterator begin, const Iterator end)
  2447. {
  2448. if (0 == std::distance(begin,end))
  2449. return c;
  2450. double min_d = std::numeric_limits<double>::max();
  2451. rgb_t result = *begin;
  2452. for (Iterator itr = begin; itr != end; ++itr)
  2453. {
  2454. if (c == (*itr))
  2455. {
  2456. return (*itr);
  2457. }
  2458. double curr_d = weighted_distance(c,*itr);
  2459. if (curr_d < min_d)
  2460. {
  2461. min_d = curr_d;
  2462. result = *itr;
  2463. }
  2464. }
  2465. return result;
  2466. }
  2467. template <template <typename,typename> class Sequence,
  2468. typename Allocator>
  2469. inline rgb_t find_nearest_color(const rgb_t& c, const Sequence<rgb_t,Allocator>& seq)
  2470. {
  2471. return find_nearest_color(c, seq.begin(),seq.end());
  2472. }
  2473. template <std::size_t N>
  2474. inline rgb_t find_nearest_color(const rgb_t& c, const rgb_t (&colors)[N])
  2475. {
  2476. return find_nearest_color(c, colors, colors + N);
  2477. }
  2478. inline double find_nearest_wave_length(const rgb_t& c, const double increment = 0.001)
  2479. {
  2480. const double max_wave_length = 800.0; //800nm
  2481. double min_wave_length = 0.0;
  2482. double min_d = std::numeric_limits<double>::max();
  2483. for (double i = 0.0; i < max_wave_length; i += increment)
  2484. {
  2485. const rgb_t curr_rgb = convert_wave_length_nm_to_rgb(i);
  2486. if (c == curr_rgb)
  2487. {
  2488. return i;
  2489. }
  2490. const double curr_d = weighted_distance(c, curr_rgb);
  2491. if (curr_d <= min_d)
  2492. {
  2493. min_wave_length = i;
  2494. min_d = curr_d;
  2495. }
  2496. }
  2497. return min_wave_length;
  2498. }
  2499. template <typename T>
  2500. class response_image
  2501. {
  2502. public:
  2503. response_image(const std::size_t& width, const std::size_t& height, const T null = T(0))
  2504. : width_ (width ),
  2505. height_(height),
  2506. null_ (null )
  2507. {
  2508. data_.resize(width_ * height_);
  2509. }
  2510. std::size_t width () const { return width_; }
  2511. std::size_t height() const { return height_; }
  2512. void set_all(const T& t)
  2513. {
  2514. std::fill_n(data_.begin(), data_.size(), t);
  2515. }
  2516. const T& operator()(const std::size_t& x, const std::size_t& y) const
  2517. {
  2518. if (y >= height_) return null_;
  2519. if (x >= width_ ) return null_;
  2520. return data_[width_ * y + x];
  2521. }
  2522. T& operator()(const std::size_t& x, const std::size_t& y)
  2523. {
  2524. if (y >= height_) return null_;
  2525. if (x >= width_ ) return null_;
  2526. return data_[width_ * y + x];
  2527. }
  2528. bool valid(const std::size_t& x, const std::size_t& y)
  2529. {
  2530. return ((x < width_ ) || (y < height_));
  2531. }
  2532. void inc_all(const T& v)
  2533. {
  2534. for (std::size_t i = 0; i < data_.size(); ++i)
  2535. {
  2536. data_[i] += v;
  2537. }
  2538. }
  2539. void mul_all(const T& v)
  2540. {
  2541. for (std::size_t i = 0; i < data_.size(); ++i)
  2542. {
  2543. data_[i] *= v;
  2544. }
  2545. }
  2546. T* row (const std::size_t& row_index)
  2547. {
  2548. if (row_index < height_)
  2549. return &data_[width_ * row_index];
  2550. else
  2551. return reinterpret_cast<T*>(0);
  2552. }
  2553. const T* row (const std::size_t& row_index) const
  2554. {
  2555. if (row_index < height_)
  2556. return data_[width_ * row_index];
  2557. else
  2558. return reinterpret_cast<T*>(0);
  2559. }
  2560. private:
  2561. std::size_t width_;
  2562. std::size_t height_;
  2563. std::vector<T> data_;
  2564. T null_;
  2565. };
  2566. inline void sobel_operator(const bitmap_image& src_image,
  2567. bitmap_image& dst_image,
  2568. const double threshold = 0.0)
  2569. {
  2570. typedef double T;
  2571. response_image<T> im0(src_image.width(), src_image.height(), 0.0);
  2572. response_image<T> im1(src_image.width(), src_image.height(), 0.0);
  2573. src_image.export_gray_scale_response_image(&im0(0,0));
  2574. for (std::size_t y = 1; y < im0.height() - 1; ++y)
  2575. {
  2576. const T* itr0 = im0.row(y - 1);
  2577. const T* itr1 = im0.row(y );
  2578. const T* itr2 = im0.row(y + 1);
  2579. T* out = im1.row(y ) + 1;
  2580. for (std::size_t x = 1; x < im0.width() - 1; ++x)
  2581. {
  2582. const T c0 = *(itr0 + x - 1); const T c1 = *(itr0 + x); const T c2 = *(itr0 + x + 1);
  2583. const T c3 = *(itr1 + x - 1); /*const T c4 = *(itr1 + x);*/ const T c5 = *(itr1 + x + 1);
  2584. const T c6 = *(itr2 + x - 1); const T c7 = *(itr2 + x); const T c8 = *(itr2 + x + 1);
  2585. const T gx = (2.0 * (c5 - c3)) + (c2 - c0) + (c8 - c6);
  2586. const T gy = (2.0 * (c1 - c7)) + (c0 - c6) + (c2 - c8);
  2587. *(out++) = std::sqrt((gx * gx) + (gy * gy));
  2588. }
  2589. }
  2590. if (threshold > 0.0)
  2591. {
  2592. const T* end = im1.row(0) + (im1.width() * im1.height());
  2593. for (T* itr = im1.row(0); itr != end; ++itr)
  2594. {
  2595. T& v = *itr;
  2596. if (v <= threshold) v = 0;
  2597. }
  2598. }
  2599. dst_image.setwidth_height
  2600. (
  2601. static_cast<unsigned int>(im1.width()),
  2602. static_cast<unsigned int>(im1.height())
  2603. );
  2604. dst_image.import_gray_scale_clamped(&im1(0,0));
  2605. }
  2606. enum palette_name
  2607. {
  2608. e_red, e_scarlet, e_vermilion, e_tangelo, e_orange,
  2609. e_gamboge, e_amber, e_gold, e_yellow, e_apple_green,
  2610. e_lime_green, e_spring_bud, e_chartreuse_green, e_pistachio, e_harlequin,
  2611. e_sap_green, e_green, e_emerald_green, e_malachite_green, e_sea_green,
  2612. e_spring_green, e_aquamarine, e_turquoise, e_opal, e_cyan,
  2613. e_arctic_blue, e_cerulean, e_cornflower_blue, e_azure, e_cobalt_blue,
  2614. e_sapphire_blue, e_phthalo_blue, e_blue, e_persian_blue, e_indigo,
  2615. e_blue_violet, e_violet, e_purple, e_mulberry, e_heliotrope,
  2616. e_magenta, e_orchid, e_fuchsia, e_cerise, e_rose,
  2617. e_raspberry, e_crimson, e_amaranth, e_white, e_black
  2618. };
  2619. const rgb_t palette_colormap[] = {
  2620. {255, 0, 0}, {255, 31, 0}, {255, 63, 0}, {255, 95, 0}, {255, 127, 0},
  2621. {255, 159, 0}, {255, 191, 0}, {255, 223, 0}, {255, 255, 0}, {223, 255, 0},
  2622. {191, 255, 0}, {159, 255, 0}, {127, 255, 0}, { 95, 255, 0}, { 63, 255, 0},
  2623. { 31, 255, 0}, { 0, 255, 0}, { 0, 255, 31}, { 0, 255, 63}, { 0, 255, 95},
  2624. { 0, 255, 127}, { 0, 255, 159}, { 0, 255, 191}, { 0, 255, 223}, { 0, 255, 255},
  2625. { 0, 223, 255}, { 0, 191, 255}, { 0, 159, 255}, { 0, 127, 255}, { 0, 95, 255},
  2626. { 0, 63, 255}, { 0, 31, 255}, { 0, 0, 255}, { 31, 0, 255}, { 63, 0, 255},
  2627. { 95, 0, 255}, {127, 0, 255}, {159, 0, 255}, {191, 0, 255}, {223, 0, 255},
  2628. {255, 0, 255}, {255, 0, 223}, {255, 0, 191}, {255, 0, 159}, {255, 0, 127},
  2629. {255, 0, 95}, {255, 0, 63}, {255, 0, 31}, {255, 255, 255}, { 0, 0, 0}
  2630. };
  2631. const rgb_t autumn_colormap[1000] = {
  2632. {255, 0, 0}, {255, 0, 0}, {255, 1, 0}, {255, 1, 0}, {255, 1, 0},
  2633. {255, 1, 0}, {255, 2, 0}, {255, 2, 0}, {255, 2, 0}, {255, 2, 0},
  2634. {255, 3, 0}, {255, 3, 0}, {255, 3, 0}, {255, 3, 0}, {255, 4, 0},
  2635. {255, 4, 0}, {255, 4, 0}, {255, 4, 0}, {255, 5, 0}, {255, 5, 0},
  2636. {255, 5, 0}, {255, 5, 0}, {255, 6, 0}, {255, 6, 0}, {255, 6, 0},
  2637. {255, 6, 0}, {255, 7, 0}, {255, 7, 0}, {255, 7, 0}, {255, 7, 0},
  2638. {255, 8, 0}, {255, 8, 0}, {255, 8, 0}, {255, 8, 0}, {255, 9, 0},
  2639. {255, 9, 0}, {255, 9, 0}, {255, 9, 0}, {255, 10, 0}, {255, 10, 0},
  2640. {255, 10, 0}, {255, 10, 0}, {255, 11, 0}, {255, 11, 0}, {255, 11, 0},
  2641. {255, 11, 0}, {255, 12, 0}, {255, 12, 0}, {255, 12, 0}, {255, 13, 0},
  2642. {255, 13, 0}, {255, 13, 0}, {255, 13, 0}, {255, 14, 0}, {255, 14, 0},
  2643. {255, 14, 0}, {255, 14, 0}, {255, 15, 0}, {255, 15, 0}, {255, 15, 0},
  2644. {255, 15, 0}, {255, 16, 0}, {255, 16, 0}, {255, 16, 0}, {255, 16, 0},
  2645. {255, 17, 0}, {255, 17, 0}, {255, 17, 0}, {255, 17, 0}, {255, 18, 0},
  2646. {255, 18, 0}, {255, 18, 0}, {255, 18, 0}, {255, 19, 0}, {255, 19, 0},
  2647. {255, 19, 0}, {255, 19, 0}, {255, 20, 0}, {255, 20, 0}, {255, 20, 0},
  2648. {255, 20, 0}, {255, 21, 0}, {255, 21, 0}, {255, 21, 0}, {255, 21, 0},
  2649. {255, 22, 0}, {255, 22, 0}, {255, 22, 0}, {255, 22, 0}, {255, 23, 0},
  2650. {255, 23, 0}, {255, 23, 0}, {255, 23, 0}, {255, 24, 0}, {255, 24, 0},
  2651. {255, 24, 0}, {255, 25, 0}, {255, 25, 0}, {255, 25, 0}, {255, 25, 0},
  2652. {255, 26, 0}, {255, 26, 0}, {255, 26, 0}, {255, 26, 0}, {255, 27, 0},
  2653. {255, 27, 0}, {255, 27, 0}, {255, 27, 0}, {255, 28, 0}, {255, 28, 0},
  2654. {255, 28, 0}, {255, 28, 0}, {255, 29, 0}, {255, 29, 0}, {255, 29, 0},
  2655. {255, 29, 0}, {255, 30, 0}, {255, 30, 0}, {255, 30, 0}, {255, 30, 0},
  2656. {255, 31, 0}, {255, 31, 0}, {255, 31, 0}, {255, 31, 0}, {255, 32, 0},
  2657. {255, 32, 0}, {255, 32, 0}, {255, 32, 0}, {255, 33, 0}, {255, 33, 0},
  2658. {255, 33, 0}, {255, 33, 0}, {255, 34, 0}, {255, 34, 0}, {255, 34, 0},
  2659. {255, 34, 0}, {255, 35, 0}, {255, 35, 0}, {255, 35, 0}, {255, 35, 0},
  2660. {255, 36, 0}, {255, 36, 0}, {255, 36, 0}, {255, 37, 0}, {255, 37, 0},
  2661. {255, 37, 0}, {255, 37, 0}, {255, 38, 0}, {255, 38, 0}, {255, 38, 0},
  2662. {255, 38, 0}, {255, 39, 0}, {255, 39, 0}, {255, 39, 0}, {255, 39, 0},
  2663. {255, 40, 0}, {255, 40, 0}, {255, 40, 0}, {255, 40, 0}, {255, 41, 0},
  2664. {255, 41, 0}, {255, 41, 0}, {255, 41, 0}, {255, 42, 0}, {255, 42, 0},
  2665. {255, 42, 0}, {255, 42, 0}, {255, 43, 0}, {255, 43, 0}, {255, 43, 0},
  2666. {255, 43, 0}, {255, 44, 0}, {255, 44, 0}, {255, 44, 0}, {255, 44, 0},
  2667. {255, 45, 0}, {255, 45, 0}, {255, 45, 0}, {255, 45, 0}, {255, 46, 0},
  2668. {255, 46, 0}, {255, 46, 0}, {255, 46, 0}, {255, 47, 0}, {255, 47, 0},
  2669. {255, 47, 0}, {255, 47, 0}, {255, 48, 0}, {255, 48, 0}, {255, 48, 0},
  2670. {255, 48, 0}, {255, 49, 0}, {255, 49, 0}, {255, 49, 0}, {255, 50, 0},
  2671. {255, 50, 0}, {255, 50, 0}, {255, 50, 0}, {255, 51, 0}, {255, 51, 0},
  2672. {255, 51, 0}, {255, 51, 0}, {255, 52, 0}, {255, 52, 0}, {255, 52, 0},
  2673. {255, 52, 0}, {255, 53, 0}, {255, 53, 0}, {255, 53, 0}, {255, 53, 0},
  2674. {255, 54, 0}, {255, 54, 0}, {255, 54, 0}, {255, 54, 0}, {255, 55, 0},
  2675. {255, 55, 0}, {255, 55, 0}, {255, 55, 0}, {255, 56, 0}, {255, 56, 0},
  2676. {255, 56, 0}, {255, 56, 0}, {255, 57, 0}, {255, 57, 0}, {255, 57, 0},
  2677. {255, 57, 0}, {255, 58, 0}, {255, 58, 0}, {255, 58, 0}, {255, 58, 0},
  2678. {255, 59, 0}, {255, 59, 0}, {255, 59, 0}, {255, 59, 0}, {255, 60, 0},
  2679. {255, 60, 0}, {255, 60, 0}, {255, 60, 0}, {255, 61, 0}, {255, 61, 0},
  2680. {255, 61, 0}, {255, 62, 0}, {255, 62, 0}, {255, 62, 0}, {255, 62, 0},
  2681. {255, 63, 0}, {255, 63, 0}, {255, 63, 0}, {255, 63, 0}, {255, 64, 0},
  2682. {255, 64, 0}, {255, 64, 0}, {255, 64, 0}, {255, 65, 0}, {255, 65, 0},
  2683. {255, 65, 0}, {255, 65, 0}, {255, 66, 0}, {255, 66, 0}, {255, 66, 0},
  2684. {255, 66, 0}, {255, 67, 0}, {255, 67, 0}, {255, 67, 0}, {255, 67, 0},
  2685. {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 69, 0},
  2686. {255, 69, 0}, {255, 69, 0}, {255, 69, 0}, {255, 70, 0}, {255, 70, 0},
  2687. {255, 70, 0}, {255, 70, 0}, {255, 71, 0}, {255, 71, 0}, {255, 71, 0},
  2688. {255, 71, 0}, {255, 72, 0}, {255, 72, 0}, {255, 72, 0}, {255, 72, 0},
  2689. {255, 73, 0}, {255, 73, 0}, {255, 73, 0}, {255, 74, 0}, {255, 74, 0},
  2690. {255, 74, 0}, {255, 74, 0}, {255, 75, 0}, {255, 75, 0}, {255, 75, 0},
  2691. {255, 75, 0}, {255, 76, 0}, {255, 76, 0}, {255, 76, 0}, {255, 76, 0},
  2692. {255, 77, 0}, {255, 77, 0}, {255, 77, 0}, {255, 77, 0}, {255, 78, 0},
  2693. {255, 78, 0}, {255, 78, 0}, {255, 78, 0}, {255, 79, 0}, {255, 79, 0},
  2694. {255, 79, 0}, {255, 79, 0}, {255, 80, 0}, {255, 80, 0}, {255, 80, 0},
  2695. {255, 80, 0}, {255, 81, 0}, {255, 81, 0}, {255, 81, 0}, {255, 81, 0},
  2696. {255, 82, 0}, {255, 82, 0}, {255, 82, 0}, {255, 82, 0}, {255, 83, 0},
  2697. {255, 83, 0}, {255, 83, 0}, {255, 83, 0}, {255, 84, 0}, {255, 84, 0},
  2698. {255, 84, 0}, {255, 84, 0}, {255, 85, 0}, {255, 85, 0}, {255, 85, 0},
  2699. {255, 86, 0}, {255, 86, 0}, {255, 86, 0}, {255, 86, 0}, {255, 87, 0},
  2700. {255, 87, 0}, {255, 87, 0}, {255, 87, 0}, {255, 88, 0}, {255, 88, 0},
  2701. {255, 88, 0}, {255, 88, 0}, {255, 89, 0}, {255, 89, 0}, {255, 89, 0},
  2702. {255, 89, 0}, {255, 90, 0}, {255, 90, 0}, {255, 90, 0}, {255, 90, 0},
  2703. {255, 91, 0}, {255, 91, 0}, {255, 91, 0}, {255, 91, 0}, {255, 92, 0},
  2704. {255, 92, 0}, {255, 92, 0}, {255, 92, 0}, {255, 93, 0}, {255, 93, 0},
  2705. {255, 93, 0}, {255, 93, 0}, {255, 94, 0}, {255, 94, 0}, {255, 94, 0},
  2706. {255, 94, 0}, {255, 95, 0}, {255, 95, 0}, {255, 95, 0}, {255, 95, 0},
  2707. {255, 96, 0}, {255, 96, 0}, {255, 96, 0}, {255, 96, 0}, {255, 97, 0},
  2708. {255, 97, 0}, {255, 97, 0}, {255, 98, 0}, {255, 98, 0}, {255, 98, 0},
  2709. {255, 98, 0}, {255, 99, 0}, {255, 99, 0}, {255, 99, 0}, {255, 99, 0},
  2710. {255, 100, 0}, {255, 100, 0}, {255, 100, 0}, {255, 100, 0}, {255, 101, 0},
  2711. {255, 101, 0}, {255, 101, 0}, {255, 101, 0}, {255, 102, 0}, {255, 102, 0},
  2712. {255, 102, 0}, {255, 102, 0}, {255, 103, 0}, {255, 103, 0}, {255, 103, 0},
  2713. {255, 103, 0}, {255, 104, 0}, {255, 104, 0}, {255, 104, 0}, {255, 104, 0},
  2714. {255, 105, 0}, {255, 105, 0}, {255, 105, 0}, {255, 105, 0}, {255, 106, 0},
  2715. {255, 106, 0}, {255, 106, 0}, {255, 106, 0}, {255, 107, 0}, {255, 107, 0},
  2716. {255, 107, 0}, {255, 107, 0}, {255, 108, 0}, {255, 108, 0}, {255, 108, 0},
  2717. {255, 108, 0}, {255, 109, 0}, {255, 109, 0}, {255, 109, 0}, {255, 110, 0},
  2718. {255, 110, 0}, {255, 110, 0}, {255, 110, 0}, {255, 111, 0}, {255, 111, 0},
  2719. {255, 111, 0}, {255, 111, 0}, {255, 112, 0}, {255, 112, 0}, {255, 112, 0},
  2720. {255, 112, 0}, {255, 113, 0}, {255, 113, 0}, {255, 113, 0}, {255, 113, 0},
  2721. {255, 114, 0}, {255, 114, 0}, {255, 114, 0}, {255, 114, 0}, {255, 115, 0},
  2722. {255, 115, 0}, {255, 115, 0}, {255, 115, 0}, {255, 116, 0}, {255, 116, 0},
  2723. {255, 116, 0}, {255, 116, 0}, {255, 117, 0}, {255, 117, 0}, {255, 117, 0},
  2724. {255, 117, 0}, {255, 118, 0}, {255, 118, 0}, {255, 118, 0}, {255, 118, 0},
  2725. {255, 119, 0}, {255, 119, 0}, {255, 119, 0}, {255, 119, 0}, {255, 120, 0},
  2726. {255, 120, 0}, {255, 120, 0}, {255, 120, 0}, {255, 121, 0}, {255, 121, 0},
  2727. {255, 121, 0}, {255, 122, 0}, {255, 122, 0}, {255, 122, 0}, {255, 122, 0},
  2728. {255, 123, 0}, {255, 123, 0}, {255, 123, 0}, {255, 123, 0}, {255, 124, 0},
  2729. {255, 124, 0}, {255, 124, 0}, {255, 124, 0}, {255, 125, 0}, {255, 125, 0},
  2730. {255, 125, 0}, {255, 125, 0}, {255, 126, 0}, {255, 126, 0}, {255, 126, 0},
  2731. {255, 126, 0}, {255, 127, 0}, {255, 127, 0}, {255, 127, 0}, {255, 127, 0},
  2732. {255, 128, 0}, {255, 128, 0}, {255, 128, 0}, {255, 128, 0}, {255, 129, 0},
  2733. {255, 129, 0}, {255, 129, 0}, {255, 129, 0}, {255, 130, 0}, {255, 130, 0},
  2734. {255, 130, 0}, {255, 130, 0}, {255, 131, 0}, {255, 131, 0}, {255, 131, 0},
  2735. {255, 131, 0}, {255, 132, 0}, {255, 132, 0}, {255, 132, 0}, {255, 132, 0},
  2736. {255, 133, 0}, {255, 133, 0}, {255, 133, 0}, {255, 133, 0}, {255, 134, 0},
  2737. {255, 134, 0}, {255, 134, 0}, {255, 135, 0}, {255, 135, 0}, {255, 135, 0},
  2738. {255, 135, 0}, {255, 136, 0}, {255, 136, 0}, {255, 136, 0}, {255, 136, 0},
  2739. {255, 137, 0}, {255, 137, 0}, {255, 137, 0}, {255, 137, 0}, {255, 138, 0},
  2740. {255, 138, 0}, {255, 138, 0}, {255, 138, 0}, {255, 139, 0}, {255, 139, 0},
  2741. {255, 139, 0}, {255, 139, 0}, {255, 140, 0}, {255, 140, 0}, {255, 140, 0},
  2742. {255, 140, 0}, {255, 141, 0}, {255, 141, 0}, {255, 141, 0}, {255, 141, 0},
  2743. {255, 142, 0}, {255, 142, 0}, {255, 142, 0}, {255, 142, 0}, {255, 143, 0},
  2744. {255, 143, 0}, {255, 143, 0}, {255, 143, 0}, {255, 144, 0}, {255, 144, 0},
  2745. {255, 144, 0}, {255, 144, 0}, {255, 145, 0}, {255, 145, 0}, {255, 145, 0},
  2746. {255, 145, 0}, {255, 146, 0}, {255, 146, 0}, {255, 146, 0}, {255, 147, 0},
  2747. {255, 147, 0}, {255, 147, 0}, {255, 147, 0}, {255, 148, 0}, {255, 148, 0},
  2748. {255, 148, 0}, {255, 148, 0}, {255, 149, 0}, {255, 149, 0}, {255, 149, 0},
  2749. {255, 149, 0}, {255, 150, 0}, {255, 150, 0}, {255, 150, 0}, {255, 150, 0},
  2750. {255, 151, 0}, {255, 151, 0}, {255, 151, 0}, {255, 151, 0}, {255, 152, 0},
  2751. {255, 152, 0}, {255, 152, 0}, {255, 152, 0}, {255, 153, 0}, {255, 153, 0},
  2752. {255, 153, 0}, {255, 153, 0}, {255, 154, 0}, {255, 154, 0}, {255, 154, 0},
  2753. {255, 154, 0}, {255, 155, 0}, {255, 155, 0}, {255, 155, 0}, {255, 155, 0},
  2754. {255, 156, 0}, {255, 156, 0}, {255, 156, 0}, {255, 156, 0}, {255, 157, 0},
  2755. {255, 157, 0}, {255, 157, 0}, {255, 157, 0}, {255, 158, 0}, {255, 158, 0},
  2756. {255, 158, 0}, {255, 159, 0}, {255, 159, 0}, {255, 159, 0}, {255, 159, 0},
  2757. {255, 160, 0}, {255, 160, 0}, {255, 160, 0}, {255, 160, 0}, {255, 161, 0},
  2758. {255, 161, 0}, {255, 161, 0}, {255, 161, 0}, {255, 162, 0}, {255, 162, 0},
  2759. {255, 162, 0}, {255, 162, 0}, {255, 163, 0}, {255, 163, 0}, {255, 163, 0},
  2760. {255, 163, 0}, {255, 164, 0}, {255, 164, 0}, {255, 164, 0}, {255, 164, 0},
  2761. {255, 165, 0}, {255, 165, 0}, {255, 165, 0}, {255, 165, 0}, {255, 166, 0},
  2762. {255, 166, 0}, {255, 166, 0}, {255, 166, 0}, {255, 167, 0}, {255, 167, 0},
  2763. {255, 167, 0}, {255, 167, 0}, {255, 168, 0}, {255, 168, 0}, {255, 168, 0},
  2764. {255, 168, 0}, {255, 169, 0}, {255, 169, 0}, {255, 169, 0}, {255, 169, 0},
  2765. {255, 170, 0}, {255, 170, 0}, {255, 170, 0}, {255, 171, 0}, {255, 171, 0},
  2766. {255, 171, 0}, {255, 171, 0}, {255, 172, 0}, {255, 172, 0}, {255, 172, 0},
  2767. {255, 172, 0}, {255, 173, 0}, {255, 173, 0}, {255, 173, 0}, {255, 173, 0},
  2768. {255, 174, 0}, {255, 174, 0}, {255, 174, 0}, {255, 174, 0}, {255, 175, 0},
  2769. {255, 175, 0}, {255, 175, 0}, {255, 175, 0}, {255, 176, 0}, {255, 176, 0},
  2770. {255, 176, 0}, {255, 176, 0}, {255, 177, 0}, {255, 177, 0}, {255, 177, 0},
  2771. {255, 177, 0}, {255, 178, 0}, {255, 178, 0}, {255, 178, 0}, {255, 178, 0},
  2772. {255, 179, 0}, {255, 179, 0}, {255, 179, 0}, {255, 179, 0}, {255, 180, 0},
  2773. {255, 180, 0}, {255, 180, 0}, {255, 180, 0}, {255, 181, 0}, {255, 181, 0},
  2774. {255, 181, 0}, {255, 181, 0}, {255, 182, 0}, {255, 182, 0}, {255, 182, 0},
  2775. {255, 183, 0}, {255, 183, 0}, {255, 183, 0}, {255, 183, 0}, {255, 184, 0},
  2776. {255, 184, 0}, {255, 184, 0}, {255, 184, 0}, {255, 185, 0}, {255, 185, 0},
  2777. {255, 185, 0}, {255, 185, 0}, {255, 186, 0}, {255, 186, 0}, {255, 186, 0},
  2778. {255, 186, 0}, {255, 187, 0}, {255, 187, 0}, {255, 187, 0}, {255, 187, 0},
  2779. {255, 188, 0}, {255, 188, 0}, {255, 188, 0}, {255, 188, 0}, {255, 189, 0},
  2780. {255, 189, 0}, {255, 189, 0}, {255, 189, 0}, {255, 190, 0}, {255, 190, 0},
  2781. {255, 190, 0}, {255, 190, 0}, {255, 191, 0}, {255, 191, 0}, {255, 191, 0},
  2782. {255, 191, 0}, {255, 192, 0}, {255, 192, 0}, {255, 192, 0}, {255, 192, 0},
  2783. {255, 193, 0}, {255, 193, 0}, {255, 193, 0}, {255, 193, 0}, {255, 194, 0},
  2784. {255, 194, 0}, {255, 194, 0}, {255, 195, 0}, {255, 195, 0}, {255, 195, 0},
  2785. {255, 195, 0}, {255, 196, 0}, {255, 196, 0}, {255, 196, 0}, {255, 196, 0},
  2786. {255, 197, 0}, {255, 197, 0}, {255, 197, 0}, {255, 197, 0}, {255, 198, 0},
  2787. {255, 198, 0}, {255, 198, 0}, {255, 198, 0}, {255, 199, 0}, {255, 199, 0},
  2788. {255, 199, 0}, {255, 199, 0}, {255, 200, 0}, {255, 200, 0}, {255, 200, 0},
  2789. {255, 200, 0}, {255, 201, 0}, {255, 201, 0}, {255, 201, 0}, {255, 201, 0},
  2790. {255, 202, 0}, {255, 202, 0}, {255, 202, 0}, {255, 202, 0}, {255, 203, 0},
  2791. {255, 203, 0}, {255, 203, 0}, {255, 203, 0}, {255, 204, 0}, {255, 204, 0},
  2792. {255, 204, 0}, {255, 204, 0}, {255, 205, 0}, {255, 205, 0}, {255, 205, 0},
  2793. {255, 205, 0}, {255, 206, 0}, {255, 206, 0}, {255, 206, 0}, {255, 207, 0},
  2794. {255, 207, 0}, {255, 207, 0}, {255, 207, 0}, {255, 208, 0}, {255, 208, 0},
  2795. {255, 208, 0}, {255, 208, 0}, {255, 209, 0}, {255, 209, 0}, {255, 209, 0},
  2796. {255, 209, 0}, {255, 210, 0}, {255, 210, 0}, {255, 210, 0}, {255, 210, 0},
  2797. {255, 211, 0}, {255, 211, 0}, {255, 211, 0}, {255, 211, 0}, {255, 212, 0},
  2798. {255, 212, 0}, {255, 212, 0}, {255, 212, 0}, {255, 213, 0}, {255, 213, 0},
  2799. {255, 213, 0}, {255, 213, 0}, {255, 214, 0}, {255, 214, 0}, {255, 214, 0},
  2800. {255, 214, 0}, {255, 215, 0}, {255, 215, 0}, {255, 215, 0}, {255, 215, 0},
  2801. {255, 216, 0}, {255, 216, 0}, {255, 216, 0}, {255, 216, 0}, {255, 217, 0},
  2802. {255, 217, 0}, {255, 217, 0}, {255, 217, 0}, {255, 218, 0}, {255, 218, 0},
  2803. {255, 218, 0}, {255, 218, 0}, {255, 219, 0}, {255, 219, 0}, {255, 219, 0},
  2804. {255, 220, 0}, {255, 220, 0}, {255, 220, 0}, {255, 220, 0}, {255, 221, 0},
  2805. {255, 221, 0}, {255, 221, 0}, {255, 221, 0}, {255, 222, 0}, {255, 222, 0},
  2806. {255, 222, 0}, {255, 222, 0}, {255, 223, 0}, {255, 223, 0}, {255, 223, 0},
  2807. {255, 223, 0}, {255, 224, 0}, {255, 224, 0}, {255, 224, 0}, {255, 224, 0},
  2808. {255, 225, 0}, {255, 225, 0}, {255, 225, 0}, {255, 225, 0}, {255, 226, 0},
  2809. {255, 226, 0}, {255, 226, 0}, {255, 226, 0}, {255, 227, 0}, {255, 227, 0},
  2810. {255, 227, 0}, {255, 227, 0}, {255, 228, 0}, {255, 228, 0}, {255, 228, 0},
  2811. {255, 228, 0}, {255, 229, 0}, {255, 229, 0}, {255, 229, 0}, {255, 229, 0},
  2812. {255, 230, 0}, {255, 230, 0}, {255, 230, 0}, {255, 230, 0}, {255, 231, 0},
  2813. {255, 231, 0}, {255, 231, 0}, {255, 232, 0}, {255, 232, 0}, {255, 232, 0},
  2814. {255, 232, 0}, {255, 233, 0}, {255, 233, 0}, {255, 233, 0}, {255, 233, 0},
  2815. {255, 234, 0}, {255, 234, 0}, {255, 234, 0}, {255, 234, 0}, {255, 235, 0},
  2816. {255, 235, 0}, {255, 235, 0}, {255, 235, 0}, {255, 236, 0}, {255, 236, 0},
  2817. {255, 236, 0}, {255, 236, 0}, {255, 237, 0}, {255, 237, 0}, {255, 237, 0},
  2818. {255, 237, 0}, {255, 238, 0}, {255, 238, 0}, {255, 238, 0}, {255, 238, 0},
  2819. {255, 239, 0}, {255, 239, 0}, {255, 239, 0}, {255, 239, 0}, {255, 240, 0},
  2820. {255, 240, 0}, {255, 240, 0}, {255, 240, 0}, {255, 241, 0}, {255, 241, 0},
  2821. {255, 241, 0}, {255, 241, 0}, {255, 242, 0}, {255, 242, 0}, {255, 242, 0},
  2822. {255, 242, 0}, {255, 243, 0}, {255, 243, 0}, {255, 243, 0}, {255, 244, 0},
  2823. {255, 244, 0}, {255, 244, 0}, {255, 244, 0}, {255, 245, 0}, {255, 245, 0},
  2824. {255, 245, 0}, {255, 245, 0}, {255, 246, 0}, {255, 246, 0}, {255, 246, 0},
  2825. {255, 246, 0}, {255, 247, 0}, {255, 247, 0}, {255, 247, 0}, {255, 247, 0},
  2826. {255, 248, 0}, {255, 248, 0}, {255, 248, 0}, {255, 248, 0}, {255, 249, 0},
  2827. {255, 249, 0}, {255, 249, 0}, {255, 249, 0}, {255, 250, 0}, {255, 250, 0},
  2828. {255, 250, 0}, {255, 250, 0}, {255, 251, 0}, {255, 251, 0}, {255, 251, 0},
  2829. {255, 251, 0}, {255, 252, 0}, {255, 252, 0}, {255, 252, 0}, {255, 252, 0},
  2830. {255, 253, 0}, {255, 253, 0}, {255, 253, 0}, {255, 253, 0}, {255, 254, 0},
  2831. {255, 254, 0}, {255, 254, 0}, {255, 254, 0}, {255, 255, 0}, {255, 255, 0}
  2832. };
  2833. const rgb_t copper_colormap[1000] = {
  2834. { 0, 0, 0}, { 0, 0, 0}, { 1, 0, 0}, { 1, 1, 0}, { 1, 1, 1},
  2835. { 2, 1, 1}, { 2, 1, 1}, { 2, 1, 1}, { 3, 2, 1}, { 3, 2, 1},
  2836. { 3, 2, 1}, { 4, 2, 1}, { 4, 2, 2}, { 4, 3, 2}, { 4, 3, 2},
  2837. { 5, 3, 2}, { 5, 3, 2}, { 5, 3, 2}, { 6, 4, 2}, { 6, 4, 2},
  2838. { 6, 4, 3}, { 7, 4, 3}, { 7, 4, 3}, { 7, 5, 3}, { 8, 5, 3},
  2839. { 8, 5, 3}, { 8, 5, 3}, { 9, 5, 3}, { 9, 6, 4}, { 9, 6, 4},
  2840. { 10, 6, 4}, { 10, 6, 4}, { 10, 6, 4}, { 11, 7, 4}, { 11, 7, 4},
  2841. { 11, 7, 4}, { 11, 7, 5}, { 12, 7, 5}, { 12, 8, 5}, { 12, 8, 5},
  2842. { 13, 8, 5}, { 13, 8, 5}, { 13, 8, 5}, { 14, 9, 5}, { 14, 9, 6},
  2843. { 14, 9, 6}, { 15, 9, 6}, { 15, 9, 6}, { 15, 10, 6}, { 16, 10, 6},
  2844. { 16, 10, 6}, { 16, 10, 6}, { 17, 10, 7}, { 17, 11, 7}, { 17, 11, 7},
  2845. { 18, 11, 7}, { 18, 11, 7}, { 18, 11, 7}, { 19, 12, 7}, { 19, 12, 7},
  2846. { 19, 12, 8}, { 19, 12, 8}, { 20, 12, 8}, { 20, 13, 8}, { 20, 13, 8},
  2847. { 21, 13, 8}, { 21, 13, 8}, { 21, 13, 9}, { 22, 14, 9}, { 22, 14, 9},
  2848. { 22, 14, 9}, { 23, 14, 9}, { 23, 14, 9}, { 23, 15, 9}, { 24, 15, 9},
  2849. { 24, 15, 10}, { 24, 15, 10}, { 25, 15, 10}, { 25, 16, 10}, { 25, 16, 10},
  2850. { 26, 16, 10}, { 26, 16, 10}, { 26, 16, 10}, { 26, 17, 11}, { 27, 17, 11},
  2851. { 27, 17, 11}, { 27, 17, 11}, { 28, 17, 11}, { 28, 18, 11}, { 28, 18, 11},
  2852. { 29, 18, 11}, { 29, 18, 12}, { 29, 18, 12}, { 30, 19, 12}, { 30, 19, 12},
  2853. { 30, 19, 12}, { 31, 19, 12}, { 31, 19, 12}, { 31, 20, 12}, { 32, 20, 13},
  2854. { 32, 20, 13}, { 32, 20, 13}, { 33, 20, 13}, { 33, 21, 13}, { 33, 21, 13},
  2855. { 34, 21, 13}, { 34, 21, 13}, { 34, 21, 14}, { 34, 22, 14}, { 35, 22, 14},
  2856. { 35, 22, 14}, { 35, 22, 14}, { 36, 22, 14}, { 36, 23, 14}, { 36, 23, 14},
  2857. { 37, 23, 15}, { 37, 23, 15}, { 37, 23, 15}, { 38, 24, 15}, { 38, 24, 15},
  2858. { 38, 24, 15}, { 39, 24, 15}, { 39, 24, 15}, { 39, 25, 16}, { 40, 25, 16},
  2859. { 40, 25, 16}, { 40, 25, 16}, { 41, 25, 16}, { 41, 26, 16}, { 41, 26, 16},
  2860. { 41, 26, 17}, { 42, 26, 17}, { 42, 26, 17}, { 42, 27, 17}, { 43, 27, 17},
  2861. { 43, 27, 17}, { 43, 27, 17}, { 44, 27, 17}, { 44, 28, 18}, { 44, 28, 18},
  2862. { 45, 28, 18}, { 45, 28, 18}, { 45, 28, 18}, { 46, 29, 18}, { 46, 29, 18},
  2863. { 46, 29, 18}, { 47, 29, 19}, { 47, 29, 19}, { 47, 30, 19}, { 48, 30, 19},
  2864. { 48, 30, 19}, { 48, 30, 19}, { 48, 30, 19}, { 49, 31, 19}, { 49, 31, 20},
  2865. { 49, 31, 20}, { 50, 31, 20}, { 50, 31, 20}, { 50, 32, 20}, { 51, 32, 20},
  2866. { 51, 32, 20}, { 51, 32, 20}, { 52, 32, 21}, { 52, 33, 21}, { 52, 33, 21},
  2867. { 53, 33, 21}, { 53, 33, 21}, { 53, 33, 21}, { 54, 34, 21}, { 54, 34, 21},
  2868. { 54, 34, 22}, { 55, 34, 22}, { 55, 34, 22}, { 55, 34, 22}, { 56, 35, 22},
  2869. { 56, 35, 22}, { 56, 35, 22}, { 56, 35, 22}, { 57, 35, 23}, { 57, 36, 23},
  2870. { 57, 36, 23}, { 58, 36, 23}, { 58, 36, 23}, { 58, 36, 23}, { 59, 37, 23},
  2871. { 59, 37, 23}, { 59, 37, 24}, { 60, 37, 24}, { 60, 37, 24}, { 60, 38, 24},
  2872. { 61, 38, 24}, { 61, 38, 24}, { 61, 38, 24}, { 62, 38, 25}, { 62, 39, 25},
  2873. { 62, 39, 25}, { 63, 39, 25}, { 63, 39, 25}, { 63, 39, 25}, { 63, 40, 25},
  2874. { 64, 40, 25}, { 64, 40, 26}, { 64, 40, 26}, { 65, 40, 26}, { 65, 41, 26},
  2875. { 65, 41, 26}, { 66, 41, 26}, { 66, 41, 26}, { 66, 41, 26}, { 67, 42, 27},
  2876. { 67, 42, 27}, { 67, 42, 27}, { 68, 42, 27}, { 68, 42, 27}, { 68, 43, 27},
  2877. { 69, 43, 27}, { 69, 43, 27}, { 69, 43, 28}, { 70, 43, 28}, { 70, 44, 28},
  2878. { 70, 44, 28}, { 71, 44, 28}, { 71, 44, 28}, { 71, 44, 28}, { 71, 45, 28},
  2879. { 72, 45, 29}, { 72, 45, 29}, { 72, 45, 29}, { 73, 45, 29}, { 73, 46, 29},
  2880. { 73, 46, 29}, { 74, 46, 29}, { 74, 46, 29}, { 74, 46, 30}, { 75, 47, 30},
  2881. { 75, 47, 30}, { 75, 47, 30}, { 76, 47, 30}, { 76, 47, 30}, { 76, 48, 30},
  2882. { 77, 48, 30}, { 77, 48, 31}, { 77, 48, 31}, { 78, 48, 31}, { 78, 49, 31},
  2883. { 78, 49, 31}, { 78, 49, 31}, { 79, 49, 31}, { 79, 49, 31}, { 79, 50, 32},
  2884. { 80, 50, 32}, { 80, 50, 32}, { 80, 50, 32}, { 81, 50, 32}, { 81, 51, 32},
  2885. { 81, 51, 32}, { 82, 51, 33}, { 82, 51, 33}, { 82, 51, 33}, { 83, 52, 33},
  2886. { 83, 52, 33}, { 83, 52, 33}, { 84, 52, 33}, { 84, 52, 33}, { 84, 53, 34},
  2887. { 85, 53, 34}, { 85, 53, 34}, { 85, 53, 34}, { 86, 53, 34}, { 86, 54, 34},
  2888. { 86, 54, 34}, { 86, 54, 34}, { 87, 54, 35}, { 87, 54, 35}, { 87, 55, 35},
  2889. { 88, 55, 35}, { 88, 55, 35}, { 88, 55, 35}, { 89, 55, 35}, { 89, 56, 35},
  2890. { 89, 56, 36}, { 90, 56, 36}, { 90, 56, 36}, { 90, 56, 36}, { 91, 57, 36},
  2891. { 91, 57, 36}, { 91, 57, 36}, { 92, 57, 36}, { 92, 57, 37}, { 92, 58, 37},
  2892. { 93, 58, 37}, { 93, 58, 37}, { 93, 58, 37}, { 93, 58, 37}, { 94, 59, 37},
  2893. { 94, 59, 37}, { 94, 59, 38}, { 95, 59, 38}, { 95, 59, 38}, { 95, 60, 38},
  2894. { 96, 60, 38}, { 96, 60, 38}, { 96, 60, 38}, { 97, 60, 38}, { 97, 61, 39},
  2895. { 97, 61, 39}, { 98, 61, 39}, { 98, 61, 39}, { 98, 61, 39}, { 99, 62, 39},
  2896. { 99, 62, 39}, { 99, 62, 39}, {100, 62, 40}, {100, 62, 40}, {100, 63, 40},
  2897. {101, 63, 40}, {101, 63, 40}, {101, 63, 40}, {101, 63, 40}, {102, 64, 41},
  2898. {102, 64, 41}, {102, 64, 41}, {103, 64, 41}, {103, 64, 41}, {103, 65, 41},
  2899. {104, 65, 41}, {104, 65, 41}, {104, 65, 42}, {105, 65, 42}, {105, 66, 42},
  2900. {105, 66, 42}, {106, 66, 42}, {106, 66, 42}, {106, 66, 42}, {107, 67, 42},
  2901. {107, 67, 43}, {107, 67, 43}, {108, 67, 43}, {108, 67, 43}, {108, 68, 43},
  2902. {108, 68, 43}, {109, 68, 43}, {109, 68, 43}, {109, 68, 44}, {110, 69, 44},
  2903. {110, 69, 44}, {110, 69, 44}, {111, 69, 44}, {111, 69, 44}, {111, 70, 44},
  2904. {112, 70, 44}, {112, 70, 45}, {112, 70, 45}, {113, 70, 45}, {113, 71, 45},
  2905. {113, 71, 45}, {114, 71, 45}, {114, 71, 45}, {114, 71, 45}, {115, 72, 46},
  2906. {115, 72, 46}, {115, 72, 46}, {116, 72, 46}, {116, 72, 46}, {116, 73, 46},
  2907. {116, 73, 46}, {117, 73, 46}, {117, 73, 47}, {117, 73, 47}, {118, 74, 47},
  2908. {118, 74, 47}, {118, 74, 47}, {119, 74, 47}, {119, 74, 47}, {119, 75, 47},
  2909. {120, 75, 48}, {120, 75, 48}, {120, 75, 48}, {121, 75, 48}, {121, 76, 48},
  2910. {121, 76, 48}, {122, 76, 48}, {122, 76, 49}, {122, 76, 49}, {123, 77, 49},
  2911. {123, 77, 49}, {123, 77, 49}, {123, 77, 49}, {124, 77, 49}, {124, 78, 49},
  2912. {124, 78, 50}, {125, 78, 50}, {125, 78, 50}, {125, 78, 50}, {126, 79, 50},
  2913. {126, 79, 50}, {126, 79, 50}, {127, 79, 50}, {127, 79, 51}, {127, 80, 51},
  2914. {128, 80, 51}, {128, 80, 51}, {128, 80, 51}, {129, 80, 51}, {129, 81, 51},
  2915. {129, 81, 51}, {130, 81, 52}, {130, 81, 52}, {130, 81, 52}, {130, 82, 52},
  2916. {131, 82, 52}, {131, 82, 52}, {131, 82, 52}, {132, 82, 52}, {132, 83, 53},
  2917. {132, 83, 53}, {133, 83, 53}, {133, 83, 53}, {133, 83, 53}, {134, 84, 53},
  2918. {134, 84, 53}, {134, 84, 53}, {135, 84, 54}, {135, 84, 54}, {135, 85, 54},
  2919. {136, 85, 54}, {136, 85, 54}, {136, 85, 54}, {137, 85, 54}, {137, 86, 54},
  2920. {137, 86, 55}, {138, 86, 55}, {138, 86, 55}, {138, 86, 55}, {138, 87, 55},
  2921. {139, 87, 55}, {139, 87, 55}, {139, 87, 55}, {140, 87, 56}, {140, 88, 56},
  2922. {140, 88, 56}, {141, 88, 56}, {141, 88, 56}, {141, 88, 56}, {142, 89, 56},
  2923. {142, 89, 57}, {142, 89, 57}, {143, 89, 57}, {143, 89, 57}, {143, 90, 57},
  2924. {144, 90, 57}, {144, 90, 57}, {144, 90, 57}, {145, 90, 58}, {145, 91, 58},
  2925. {145, 91, 58}, {145, 91, 58}, {146, 91, 58}, {146, 91, 58}, {146, 92, 58},
  2926. {147, 92, 58}, {147, 92, 59}, {147, 92, 59}, {148, 92, 59}, {148, 93, 59},
  2927. {148, 93, 59}, {149, 93, 59}, {149, 93, 59}, {149, 93, 59}, {150, 94, 60},
  2928. {150, 94, 60}, {150, 94, 60}, {151, 94, 60}, {151, 94, 60}, {151, 95, 60},
  2929. {152, 95, 60}, {152, 95, 60}, {152, 95, 61}, {153, 95, 61}, {153, 96, 61},
  2930. {153, 96, 61}, {153, 96, 61}, {154, 96, 61}, {154, 96, 61}, {154, 97, 61},
  2931. {155, 97, 62}, {155, 97, 62}, {155, 97, 62}, {156, 97, 62}, {156, 98, 62},
  2932. {156, 98, 62}, {157, 98, 62}, {157, 98, 62}, {157, 98, 63}, {158, 99, 63},
  2933. {158, 99, 63}, {158, 99, 63}, {159, 99, 63}, {159, 99, 63}, {159, 100, 63},
  2934. {160, 100, 63}, {160, 100, 64}, {160, 100, 64}, {160, 100, 64}, {161, 101, 64},
  2935. {161, 101, 64}, {161, 101, 64}, {162, 101, 64}, {162, 101, 65}, {162, 101, 65},
  2936. {163, 102, 65}, {163, 102, 65}, {163, 102, 65}, {164, 102, 65}, {164, 102, 65},
  2937. {164, 103, 65}, {165, 103, 66}, {165, 103, 66}, {165, 103, 66}, {166, 103, 66},
  2938. {166, 104, 66}, {166, 104, 66}, {167, 104, 66}, {167, 104, 66}, {167, 104, 67},
  2939. {168, 105, 67}, {168, 105, 67}, {168, 105, 67}, {168, 105, 67}, {169, 105, 67},
  2940. {169, 106, 67}, {169, 106, 67}, {170, 106, 68}, {170, 106, 68}, {170, 106, 68},
  2941. {171, 107, 68}, {171, 107, 68}, {171, 107, 68}, {172, 107, 68}, {172, 107, 68},
  2942. {172, 108, 69}, {173, 108, 69}, {173, 108, 69}, {173, 108, 69}, {174, 108, 69},
  2943. {174, 109, 69}, {174, 109, 69}, {175, 109, 69}, {175, 109, 70}, {175, 109, 70},
  2944. {175, 110, 70}, {176, 110, 70}, {176, 110, 70}, {176, 110, 70}, {177, 110, 70},
  2945. {177, 111, 70}, {177, 111, 71}, {178, 111, 71}, {178, 111, 71}, {178, 111, 71},
  2946. {179, 112, 71}, {179, 112, 71}, {179, 112, 71}, {180, 112, 71}, {180, 112, 72},
  2947. {180, 113, 72}, {181, 113, 72}, {181, 113, 72}, {181, 113, 72}, {182, 113, 72},
  2948. {182, 114, 72}, {182, 114, 73}, {183, 114, 73}, {183, 114, 73}, {183, 114, 73},
  2949. {183, 115, 73}, {184, 115, 73}, {184, 115, 73}, {184, 115, 73}, {185, 115, 74},
  2950. {185, 116, 74}, {185, 116, 74}, {186, 116, 74}, {186, 116, 74}, {186, 116, 74},
  2951. {187, 117, 74}, {187, 117, 74}, {187, 117, 75}, {188, 117, 75}, {188, 117, 75},
  2952. {188, 118, 75}, {189, 118, 75}, {189, 118, 75}, {189, 118, 75}, {190, 118, 75},
  2953. {190, 119, 76}, {190, 119, 76}, {190, 119, 76}, {191, 119, 76}, {191, 119, 76},
  2954. {191, 120, 76}, {192, 120, 76}, {192, 120, 76}, {192, 120, 77}, {193, 120, 77},
  2955. {193, 121, 77}, {193, 121, 77}, {194, 121, 77}, {194, 121, 77}, {194, 121, 77},
  2956. {195, 122, 77}, {195, 122, 78}, {195, 122, 78}, {196, 122, 78}, {196, 122, 78},
  2957. {196, 123, 78}, {197, 123, 78}, {197, 123, 78}, {197, 123, 78}, {198, 123, 79},
  2958. {198, 124, 79}, {198, 124, 79}, {198, 124, 79}, {199, 124, 79}, {199, 124, 79},
  2959. {199, 125, 79}, {200, 125, 79}, {200, 125, 80}, {200, 125, 80}, {201, 125, 80},
  2960. {201, 126, 80}, {201, 126, 80}, {202, 126, 80}, {202, 126, 80}, {202, 126, 81},
  2961. {203, 127, 81}, {203, 127, 81}, {203, 127, 81}, {204, 127, 81}, {204, 127, 81},
  2962. {204, 128, 81}, {205, 128, 81}, {205, 128, 82}, {205, 128, 82}, {205, 128, 82},
  2963. {206, 129, 82}, {206, 129, 82}, {206, 129, 82}, {207, 129, 82}, {207, 129, 82},
  2964. {207, 130, 83}, {208, 130, 83}, {208, 130, 83}, {208, 130, 83}, {209, 130, 83},
  2965. {209, 131, 83}, {209, 131, 83}, {210, 131, 83}, {210, 131, 84}, {210, 131, 84},
  2966. {211, 132, 84}, {211, 132, 84}, {211, 132, 84}, {212, 132, 84}, {212, 132, 84},
  2967. {212, 133, 84}, {212, 133, 85}, {213, 133, 85}, {213, 133, 85}, {213, 133, 85},
  2968. {214, 134, 85}, {214, 134, 85}, {214, 134, 85}, {215, 134, 85}, {215, 134, 86},
  2969. {215, 135, 86}, {216, 135, 86}, {216, 135, 86}, {216, 135, 86}, {217, 135, 86},
  2970. {217, 136, 86}, {217, 136, 86}, {218, 136, 87}, {218, 136, 87}, {218, 136, 87},
  2971. {219, 137, 87}, {219, 137, 87}, {219, 137, 87}, {220, 137, 87}, {220, 137, 87},
  2972. {220, 138, 88}, {220, 138, 88}, {221, 138, 88}, {221, 138, 88}, {221, 138, 88},
  2973. {222, 139, 88}, {222, 139, 88}, {222, 139, 89}, {223, 139, 89}, {223, 139, 89},
  2974. {223, 140, 89}, {224, 140, 89}, {224, 140, 89}, {224, 140, 89}, {225, 140, 89},
  2975. {225, 141, 90}, {225, 141, 90}, {226, 141, 90}, {226, 141, 90}, {226, 141, 90},
  2976. {227, 142, 90}, {227, 142, 90}, {227, 142, 90}, {227, 142, 91}, {228, 142, 91},
  2977. {228, 143, 91}, {228, 143, 91}, {229, 143, 91}, {229, 143, 91}, {229, 143, 91},
  2978. {230, 144, 91}, {230, 144, 92}, {230, 144, 92}, {231, 144, 92}, {231, 144, 92},
  2979. {231, 145, 92}, {232, 145, 92}, {232, 145, 92}, {232, 145, 92}, {233, 145, 93},
  2980. {233, 146, 93}, {233, 146, 93}, {234, 146, 93}, {234, 146, 93}, {234, 146, 93},
  2981. {235, 147, 93}, {235, 147, 93}, {235, 147, 94}, {235, 147, 94}, {236, 147, 94},
  2982. {236, 148, 94}, {236, 148, 94}, {237, 148, 94}, {237, 148, 94}, {237, 148, 94},
  2983. {238, 149, 95}, {238, 149, 95}, {238, 149, 95}, {239, 149, 95}, {239, 149, 95},
  2984. {239, 150, 95}, {240, 150, 95}, {240, 150, 95}, {240, 150, 96}, {241, 150, 96},
  2985. {241, 151, 96}, {241, 151, 96}, {242, 151, 96}, {242, 151, 96}, {242, 151, 96},
  2986. {242, 152, 97}, {243, 152, 97}, {243, 152, 97}, {243, 152, 97}, {244, 152, 97},
  2987. {244, 153, 97}, {244, 153, 97}, {245, 153, 97}, {245, 153, 98}, {245, 153, 98},
  2988. {246, 154, 98}, {246, 154, 98}, {246, 154, 98}, {247, 154, 98}, {247, 154, 98},
  2989. {247, 155, 98}, {248, 155, 99}, {248, 155, 99}, {248, 155, 99}, {249, 155, 99},
  2990. {249, 156, 99}, {249, 156, 99}, {250, 156, 99}, {250, 156, 99}, {250, 156, 100},
  2991. {250, 157, 100}, {251, 157, 100}, {251, 157, 100}, {251, 157, 100}, {252, 157, 100},
  2992. {252, 158, 100}, {252, 158, 100}, {253, 158, 101}, {253, 158, 101}, {253, 158, 101},
  2993. {253, 159, 101}, {253, 159, 101}, {254, 159, 101}, {254, 159, 101}, {254, 159, 101},
  2994. {254, 160, 102}, {254, 160, 102}, {254, 160, 102}, {254, 160, 102}, {254, 160, 102},
  2995. {255, 161, 102}, {255, 161, 102}, {255, 161, 102}, {255, 161, 103}, {255, 161, 103},
  2996. {255, 162, 103}, {255, 162, 103}, {255, 162, 103}, {255, 162, 103}, {255, 162, 103},
  2997. {255, 163, 103}, {255, 163, 104}, {255, 163, 104}, {255, 163, 104}, {255, 163, 104},
  2998. {255, 164, 104}, {255, 164, 104}, {255, 164, 104}, {255, 164, 105}, {255, 164, 105},
  2999. {255, 165, 105}, {255, 165, 105}, {255, 165, 105}, {255, 165, 105}, {255, 165, 105},
  3000. {255, 166, 105}, {255, 166, 106}, {255, 166, 106}, {255, 166, 106}, {255, 166, 106},
  3001. {255, 167, 106}, {255, 167, 106}, {255, 167, 106}, {255, 167, 106}, {255, 167, 107},
  3002. {255, 168, 107}, {255, 168, 107}, {255, 168, 107}, {255, 168, 107}, {255, 168, 107},
  3003. {255, 168, 107}, {255, 169, 107}, {255, 169, 108}, {255, 169, 108}, {255, 169, 108},
  3004. {255, 169, 108}, {255, 170, 108}, {255, 170, 108}, {255, 170, 108}, {255, 170, 108},
  3005. {255, 170, 109}, {255, 171, 109}, {255, 171, 109}, {255, 171, 109}, {255, 171, 109},
  3006. {255, 171, 109}, {255, 172, 109}, {255, 172, 109}, {255, 172, 110}, {255, 172, 110},
  3007. {255, 172, 110}, {255, 173, 110}, {255, 173, 110}, {255, 173, 110}, {255, 173, 110},
  3008. {255, 173, 110}, {255, 174, 111}, {255, 174, 111}, {255, 174, 111}, {255, 174, 111},
  3009. {255, 174, 111}, {255, 175, 111}, {255, 175, 111}, {255, 175, 111}, {255, 175, 112},
  3010. {255, 175, 112}, {255, 176, 112}, {255, 176, 112}, {255, 176, 112}, {255, 176, 112},
  3011. {255, 176, 112}, {255, 177, 113}, {255, 177, 113}, {255, 177, 113}, {255, 177, 113},
  3012. {255, 177, 113}, {255, 178, 113}, {255, 178, 113}, {255, 178, 113}, {255, 178, 114},
  3013. {255, 178, 114}, {255, 179, 114}, {255, 179, 114}, {255, 179, 114}, {255, 179, 114},
  3014. {255, 179, 114}, {255, 180, 114}, {255, 180, 115}, {255, 180, 115}, {255, 180, 115},
  3015. {255, 180, 115}, {255, 181, 115}, {255, 181, 115}, {255, 181, 115}, {255, 181, 115},
  3016. {255, 181, 116}, {255, 182, 116}, {255, 182, 116}, {255, 182, 116}, {255, 182, 116},
  3017. {255, 182, 116}, {255, 183, 116}, {255, 183, 116}, {255, 183, 117}, {255, 183, 117},
  3018. {255, 183, 117}, {255, 184, 117}, {255, 184, 117}, {255, 184, 117}, {255, 184, 117},
  3019. {255, 184, 117}, {255, 185, 118}, {255, 185, 118}, {255, 185, 118}, {255, 185, 118},
  3020. {255, 185, 118}, {255, 186, 118}, {255, 186, 118}, {255, 186, 118}, {255, 186, 119},
  3021. {255, 186, 119}, {255, 187, 119}, {255, 187, 119}, {255, 187, 119}, {255, 187, 119},
  3022. {255, 187, 119}, {255, 188, 119}, {255, 188, 120}, {255, 188, 120}, {255, 188, 120},
  3023. {255, 188, 120}, {255, 189, 120}, {255, 189, 120}, {255, 189, 120}, {255, 189, 121},
  3024. {255, 189, 121}, {255, 190, 121}, {255, 190, 121}, {255, 190, 121}, {255, 190, 121},
  3025. {255, 190, 121}, {255, 191, 121}, {255, 191, 122}, {255, 191, 122}, {255, 191, 122},
  3026. {255, 191, 122}, {255, 192, 122}, {255, 192, 122}, {255, 192, 122}, {255, 192, 122},
  3027. {255, 192, 123}, {255, 193, 123}, {255, 193, 123}, {255, 193, 123}, {255, 193, 123},
  3028. {255, 193, 123}, {255, 194, 123}, {255, 194, 123}, {255, 194, 124}, {255, 194, 124},
  3029. {255, 194, 124}, {255, 195, 124}, {255, 195, 124}, {255, 195, 124}, {255, 195, 124},
  3030. {255, 195, 124}, {255, 196, 125}, {255, 196, 125}, {255, 196, 125}, {255, 196, 125},
  3031. {255, 196, 125}, {255, 197, 125}, {255, 197, 125}, {255, 197, 125}, {255, 197, 126},
  3032. {255, 197, 126}, {255, 198, 126}, {255, 198, 126}, {255, 198, 126}, {255, 198, 126},
  3033. {255, 198, 126}, {255, 199, 126}, {255, 199, 127}, {255, 199, 127}, {255, 199, 127}
  3034. };
  3035. const rgb_t gray_colormap[1000] = {
  3036. {255, 255, 255}, {255, 255, 255}, {254, 254, 254}, {254, 254, 254}, {254, 254, 254},
  3037. {254, 254, 254}, {253, 253, 253}, {253, 253, 253}, {253, 253, 253}, {253, 253, 253},
  3038. {252, 252, 252}, {252, 252, 252}, {252, 252, 252}, {252, 252, 252}, {251, 251, 251},
  3039. {251, 251, 251}, {251, 251, 251}, {251, 251, 251}, {250, 250, 250}, {250, 250, 250},
  3040. {250, 250, 250}, {250, 250, 250}, {249, 249, 249}, {249, 249, 249}, {249, 249, 249},
  3041. {249, 249, 249}, {248, 248, 248}, {248, 248, 248}, {248, 248, 248}, {248, 248, 248},
  3042. {247, 247, 247}, {247, 247, 247}, {247, 247, 247}, {247, 247, 247}, {246, 246, 246},
  3043. {246, 246, 246}, {246, 246, 246}, {246, 246, 246}, {245, 245, 245}, {245, 245, 245},
  3044. {245, 245, 245}, {245, 245, 245}, {244, 244, 244}, {244, 244, 244}, {244, 244, 244},
  3045. {244, 244, 244}, {243, 243, 243}, {243, 243, 243}, {243, 243, 243}, {242, 242, 242},
  3046. {242, 242, 242}, {242, 242, 242}, {242, 242, 242}, {241, 241, 241}, {241, 241, 241},
  3047. {241, 241, 241}, {241, 241, 241}, {240, 240, 240}, {240, 240, 240}, {240, 240, 240},
  3048. {240, 240, 240}, {239, 239, 239}, {239, 239, 239}, {239, 239, 239}, {239, 239, 239},
  3049. {238, 238, 238}, {238, 238, 238}, {238, 238, 238}, {238, 238, 238}, {237, 237, 237},
  3050. {237, 237, 237}, {237, 237, 237}, {237, 237, 237}, {236, 236, 236}, {236, 236, 236},
  3051. {236, 236, 236}, {236, 236, 236}, {235, 235, 235}, {235, 235, 235}, {235, 235, 235},
  3052. {235, 235, 235}, {234, 234, 234}, {234, 234, 234}, {234, 234, 234}, {234, 234, 234},
  3053. {233, 233, 233}, {233, 233, 233}, {233, 233, 233}, {233, 233, 233}, {232, 232, 232},
  3054. {232, 232, 232}, {232, 232, 232}, {232, 232, 232}, {231, 231, 231}, {231, 231, 231},
  3055. {231, 231, 231}, {230, 230, 230}, {230, 230, 230}, {230, 230, 230}, {230, 230, 230},
  3056. {229, 229, 229}, {229, 229, 229}, {229, 229, 229}, {229, 229, 229}, {228, 228, 228},
  3057. {228, 228, 228}, {228, 228, 228}, {228, 228, 228}, {227, 227, 227}, {227, 227, 227},
  3058. {227, 227, 227}, {227, 227, 227}, {226, 226, 226}, {226, 226, 226}, {226, 226, 226},
  3059. {226, 226, 226}, {225, 225, 225}, {225, 225, 225}, {225, 225, 225}, {225, 225, 225},
  3060. {224, 224, 224}, {224, 224, 224}, {224, 224, 224}, {224, 224, 224}, {223, 223, 223},
  3061. {223, 223, 223}, {223, 223, 223}, {223, 223, 223}, {222, 222, 222}, {222, 222, 222},
  3062. {222, 222, 222}, {222, 222, 222}, {221, 221, 221}, {221, 221, 221}, {221, 221, 221},
  3063. {221, 221, 221}, {220, 220, 220}, {220, 220, 220}, {220, 220, 220}, {220, 220, 220},
  3064. {219, 219, 219}, {219, 219, 219}, {219, 219, 219}, {218, 218, 218}, {218, 218, 218},
  3065. {218, 218, 218}, {218, 218, 218}, {217, 217, 217}, {217, 217, 217}, {217, 217, 217},
  3066. {217, 217, 217}, {216, 216, 216}, {216, 216, 216}, {216, 216, 216}, {216, 216, 216},
  3067. {215, 215, 215}, {215, 215, 215}, {215, 215, 215}, {215, 215, 215}, {214, 214, 214},
  3068. {214, 214, 214}, {214, 214, 214}, {214, 214, 214}, {213, 213, 213}, {213, 213, 213},
  3069. {213, 213, 213}, {213, 213, 213}, {212, 212, 212}, {212, 212, 212}, {212, 212, 212},
  3070. {212, 212, 212}, {211, 211, 211}, {211, 211, 211}, {211, 211, 211}, {211, 211, 211},
  3071. {210, 210, 210}, {210, 210, 210}, {210, 210, 210}, {210, 210, 210}, {209, 209, 209},
  3072. {209, 209, 209}, {209, 209, 209}, {209, 209, 209}, {208, 208, 208}, {208, 208, 208},
  3073. {208, 208, 208}, {208, 208, 208}, {207, 207, 207}, {207, 207, 207}, {207, 207, 207},
  3074. {207, 207, 207}, {206, 206, 206}, {206, 206, 206}, {206, 206, 206}, {205, 205, 205},
  3075. {205, 205, 205}, {205, 205, 205}, {205, 205, 205}, {204, 204, 204}, {204, 204, 204},
  3076. {204, 204, 204}, {204, 204, 204}, {203, 203, 203}, {203, 203, 203}, {203, 203, 203},
  3077. {203, 203, 203}, {202, 202, 202}, {202, 202, 202}, {202, 202, 202}, {202, 202, 202},
  3078. {201, 201, 201}, {201, 201, 201}, {201, 201, 201}, {201, 201, 201}, {200, 200, 200},
  3079. {200, 200, 200}, {200, 200, 200}, {200, 200, 200}, {199, 199, 199}, {199, 199, 199},
  3080. {199, 199, 199}, {199, 199, 199}, {198, 198, 198}, {198, 198, 198}, {198, 198, 198},
  3081. {198, 198, 198}, {197, 197, 197}, {197, 197, 197}, {197, 197, 197}, {197, 197, 197},
  3082. {196, 196, 196}, {196, 196, 196}, {196, 196, 196}, {196, 196, 196}, {195, 195, 195},
  3083. {195, 195, 195}, {195, 195, 195}, {195, 195, 195}, {194, 194, 194}, {194, 194, 194},
  3084. {194, 194, 194}, {193, 193, 193}, {193, 193, 193}, {193, 193, 193}, {193, 193, 193},
  3085. {192, 192, 192}, {192, 192, 192}, {192, 192, 192}, {192, 192, 192}, {191, 191, 191},
  3086. {191, 191, 191}, {191, 191, 191}, {191, 191, 191}, {190, 190, 190}, {190, 190, 190},
  3087. {190, 190, 190}, {190, 190, 190}, {189, 189, 189}, {189, 189, 189}, {189, 189, 189},
  3088. {189, 189, 189}, {188, 188, 188}, {188, 188, 188}, {188, 188, 188}, {188, 188, 188},
  3089. {187, 187, 187}, {187, 187, 187}, {187, 187, 187}, {187, 187, 187}, {186, 186, 186},
  3090. {186, 186, 186}, {186, 186, 186}, {186, 186, 186}, {185, 185, 185}, {185, 185, 185},
  3091. {185, 185, 185}, {185, 185, 185}, {184, 184, 184}, {184, 184, 184}, {184, 184, 184},
  3092. {184, 184, 184}, {183, 183, 183}, {183, 183, 183}, {183, 183, 183}, {183, 183, 183},
  3093. {182, 182, 182}, {182, 182, 182}, {182, 182, 182}, {181, 181, 181}, {181, 181, 181},
  3094. {181, 181, 181}, {181, 181, 181}, {180, 180, 180}, {180, 180, 180}, {180, 180, 180},
  3095. {180, 180, 180}, {179, 179, 179}, {179, 179, 179}, {179, 179, 179}, {179, 179, 179},
  3096. {178, 178, 178}, {178, 178, 178}, {178, 178, 178}, {178, 178, 178}, {177, 177, 177},
  3097. {177, 177, 177}, {177, 177, 177}, {177, 177, 177}, {176, 176, 176}, {176, 176, 176},
  3098. {176, 176, 176}, {176, 176, 176}, {175, 175, 175}, {175, 175, 175}, {175, 175, 175},
  3099. {175, 175, 175}, {174, 174, 174}, {174, 174, 174}, {174, 174, 174}, {174, 174, 174},
  3100. {173, 173, 173}, {173, 173, 173}, {173, 173, 173}, {173, 173, 173}, {172, 172, 172},
  3101. {172, 172, 172}, {172, 172, 172}, {172, 172, 172}, {171, 171, 171}, {171, 171, 171},
  3102. {171, 171, 171}, {171, 171, 171}, {170, 170, 170}, {170, 170, 170}, {170, 170, 170},
  3103. {169, 169, 169}, {169, 169, 169}, {169, 169, 169}, {169, 169, 169}, {168, 168, 168},
  3104. {168, 168, 168}, {168, 168, 168}, {168, 168, 168}, {167, 167, 167}, {167, 167, 167},
  3105. {167, 167, 167}, {167, 167, 167}, {166, 166, 166}, {166, 166, 166}, {166, 166, 166},
  3106. {166, 166, 166}, {165, 165, 165}, {165, 165, 165}, {165, 165, 165}, {165, 165, 165},
  3107. {164, 164, 164}, {164, 164, 164}, {164, 164, 164}, {164, 164, 164}, {163, 163, 163},
  3108. {163, 163, 163}, {163, 163, 163}, {163, 163, 163}, {162, 162, 162}, {162, 162, 162},
  3109. {162, 162, 162}, {162, 162, 162}, {161, 161, 161}, {161, 161, 161}, {161, 161, 161},
  3110. {161, 161, 161}, {160, 160, 160}, {160, 160, 160}, {160, 160, 160}, {160, 160, 160},
  3111. {159, 159, 159}, {159, 159, 159}, {159, 159, 159}, {159, 159, 159}, {158, 158, 158},
  3112. {158, 158, 158}, {158, 158, 158}, {157, 157, 157}, {157, 157, 157}, {157, 157, 157},
  3113. {157, 157, 157}, {156, 156, 156}, {156, 156, 156}, {156, 156, 156}, {156, 156, 156},
  3114. {155, 155, 155}, {155, 155, 155}, {155, 155, 155}, {155, 155, 155}, {154, 154, 154},
  3115. {154, 154, 154}, {154, 154, 154}, {154, 154, 154}, {153, 153, 153}, {153, 153, 153},
  3116. {153, 153, 153}, {153, 153, 153}, {152, 152, 152}, {152, 152, 152}, {152, 152, 152},
  3117. {152, 152, 152}, {151, 151, 151}, {151, 151, 151}, {151, 151, 151}, {151, 151, 151},
  3118. {150, 150, 150}, {150, 150, 150}, {150, 150, 150}, {150, 150, 150}, {149, 149, 149},
  3119. {149, 149, 149}, {149, 149, 149}, {149, 149, 149}, {148, 148, 148}, {148, 148, 148},
  3120. {148, 148, 148}, {148, 148, 148}, {147, 147, 147}, {147, 147, 147}, {147, 147, 147},
  3121. {147, 147, 147}, {146, 146, 146}, {146, 146, 146}, {146, 146, 146}, {145, 145, 145},
  3122. {145, 145, 145}, {145, 145, 145}, {145, 145, 145}, {144, 144, 144}, {144, 144, 144},
  3123. {144, 144, 144}, {144, 144, 144}, {143, 143, 143}, {143, 143, 143}, {143, 143, 143},
  3124. {143, 143, 143}, {142, 142, 142}, {142, 142, 142}, {142, 142, 142}, {142, 142, 142},
  3125. {141, 141, 141}, {141, 141, 141}, {141, 141, 141}, {141, 141, 141}, {140, 140, 140},
  3126. {140, 140, 140}, {140, 140, 140}, {140, 140, 140}, {139, 139, 139}, {139, 139, 139},
  3127. {139, 139, 139}, {139, 139, 139}, {138, 138, 138}, {138, 138, 138}, {138, 138, 138},
  3128. {138, 138, 138}, {137, 137, 137}, {137, 137, 137}, {137, 137, 137}, {137, 137, 137},
  3129. {136, 136, 136}, {136, 136, 136}, {136, 136, 136}, {136, 136, 136}, {135, 135, 135},
  3130. {135, 135, 135}, {135, 135, 135}, {135, 135, 135}, {134, 134, 134}, {134, 134, 134},
  3131. {134, 134, 134}, {133, 133, 133}, {133, 133, 133}, {133, 133, 133}, {133, 133, 133},
  3132. {132, 132, 132}, {132, 132, 132}, {132, 132, 132}, {132, 132, 132}, {131, 131, 131},
  3133. {131, 131, 131}, {131, 131, 131}, {131, 131, 131}, {130, 130, 130}, {130, 130, 130},
  3134. {130, 130, 130}, {130, 130, 130}, {129, 129, 129}, {129, 129, 129}, {129, 129, 129},
  3135. {129, 129, 129}, {128, 128, 128}, {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
  3136. {127, 127, 127}, {127, 127, 127}, {127, 127, 127}, {127, 127, 127}, {126, 126, 126},
  3137. {126, 126, 126}, {126, 126, 126}, {126, 126, 126}, {125, 125, 125}, {125, 125, 125},
  3138. {125, 125, 125}, {125, 125, 125}, {124, 124, 124}, {124, 124, 124}, {124, 124, 124},
  3139. {124, 124, 124}, {123, 123, 123}, {123, 123, 123}, {123, 123, 123}, {123, 123, 123},
  3140. {122, 122, 122}, {122, 122, 122}, {122, 122, 122}, {122, 122, 122}, {121, 121, 121},
  3141. {121, 121, 121}, {121, 121, 121}, {120, 120, 120}, {120, 120, 120}, {120, 120, 120},
  3142. {120, 120, 120}, {119, 119, 119}, {119, 119, 119}, {119, 119, 119}, {119, 119, 119},
  3143. {118, 118, 118}, {118, 118, 118}, {118, 118, 118}, {118, 118, 118}, {117, 117, 117},
  3144. {117, 117, 117}, {117, 117, 117}, {117, 117, 117}, {116, 116, 116}, {116, 116, 116},
  3145. {116, 116, 116}, {116, 116, 116}, {115, 115, 115}, {115, 115, 115}, {115, 115, 115},
  3146. {115, 115, 115}, {114, 114, 114}, {114, 114, 114}, {114, 114, 114}, {114, 114, 114},
  3147. {113, 113, 113}, {113, 113, 113}, {113, 113, 113}, {113, 113, 113}, {112, 112, 112},
  3148. {112, 112, 112}, {112, 112, 112}, {112, 112, 112}, {111, 111, 111}, {111, 111, 111},
  3149. {111, 111, 111}, {111, 111, 111}, {110, 110, 110}, {110, 110, 110}, {110, 110, 110},
  3150. {110, 110, 110}, {109, 109, 109}, {109, 109, 109}, {109, 109, 109}, {108, 108, 108},
  3151. {108, 108, 108}, {108, 108, 108}, {108, 108, 108}, {107, 107, 107}, {107, 107, 107},
  3152. {107, 107, 107}, {107, 107, 107}, {106, 106, 106}, {106, 106, 106}, {106, 106, 106},
  3153. {106, 106, 106}, {105, 105, 105}, {105, 105, 105}, {105, 105, 105}, {105, 105, 105},
  3154. {104, 104, 104}, {104, 104, 104}, {104, 104, 104}, {104, 104, 104}, {103, 103, 103},
  3155. {103, 103, 103}, {103, 103, 103}, {103, 103, 103}, {102, 102, 102}, {102, 102, 102},
  3156. {102, 102, 102}, {102, 102, 102}, {101, 101, 101}, {101, 101, 101}, {101, 101, 101},
  3157. {101, 101, 101}, {100, 100, 100}, {100, 100, 100}, {100, 100, 100}, {100, 100, 100},
  3158. { 99, 99, 99}, { 99, 99, 99}, { 99, 99, 99}, { 99, 99, 99}, { 98, 98, 98},
  3159. { 98, 98, 98}, { 98, 98, 98}, { 98, 98, 98}, { 97, 97, 97}, { 97, 97, 97},
  3160. { 97, 97, 97}, { 96, 96, 96}, { 96, 96, 96}, { 96, 96, 96}, { 96, 96, 96},
  3161. { 95, 95, 95}, { 95, 95, 95}, { 95, 95, 95}, { 95, 95, 95}, { 94, 94, 94},
  3162. { 94, 94, 94}, { 94, 94, 94}, { 94, 94, 94}, { 93, 93, 93}, { 93, 93, 93},
  3163. { 93, 93, 93}, { 93, 93, 93}, { 92, 92, 92}, { 92, 92, 92}, { 92, 92, 92},
  3164. { 92, 92, 92}, { 91, 91, 91}, { 91, 91, 91}, { 91, 91, 91}, { 91, 91, 91},
  3165. { 90, 90, 90}, { 90, 90, 90}, { 90, 90, 90}, { 90, 90, 90}, { 89, 89, 89},
  3166. { 89, 89, 89}, { 89, 89, 89}, { 89, 89, 89}, { 88, 88, 88}, { 88, 88, 88},
  3167. { 88, 88, 88}, { 88, 88, 88}, { 87, 87, 87}, { 87, 87, 87}, { 87, 87, 87},
  3168. { 87, 87, 87}, { 86, 86, 86}, { 86, 86, 86}, { 86, 86, 86}, { 86, 86, 86},
  3169. { 85, 85, 85}, { 85, 85, 85}, { 85, 85, 85}, { 84, 84, 84}, { 84, 84, 84},
  3170. { 84, 84, 84}, { 84, 84, 84}, { 83, 83, 83}, { 83, 83, 83}, { 83, 83, 83},
  3171. { 83, 83, 83}, { 82, 82, 82}, { 82, 82, 82}, { 82, 82, 82}, { 82, 82, 82},
  3172. { 81, 81, 81}, { 81, 81, 81}, { 81, 81, 81}, { 81, 81, 81}, { 80, 80, 80},
  3173. { 80, 80, 80}, { 80, 80, 80}, { 80, 80, 80}, { 79, 79, 79}, { 79, 79, 79},
  3174. { 79, 79, 79}, { 79, 79, 79}, { 78, 78, 78}, { 78, 78, 78}, { 78, 78, 78},
  3175. { 78, 78, 78}, { 77, 77, 77}, { 77, 77, 77}, { 77, 77, 77}, { 77, 77, 77},
  3176. { 76, 76, 76}, { 76, 76, 76}, { 76, 76, 76}, { 76, 76, 76}, { 75, 75, 75},
  3177. { 75, 75, 75}, { 75, 75, 75}, { 75, 75, 75}, { 74, 74, 74}, { 74, 74, 74},
  3178. { 74, 74, 74}, { 74, 74, 74}, { 73, 73, 73}, { 73, 73, 73}, { 73, 73, 73},
  3179. { 72, 72, 72}, { 72, 72, 72}, { 72, 72, 72}, { 72, 72, 72}, { 71, 71, 71},
  3180. { 71, 71, 71}, { 71, 71, 71}, { 71, 71, 71}, { 70, 70, 70}, { 70, 70, 70},
  3181. { 70, 70, 70}, { 70, 70, 70}, { 69, 69, 69}, { 69, 69, 69}, { 69, 69, 69},
  3182. { 69, 69, 69}, { 68, 68, 68}, { 68, 68, 68}, { 68, 68, 68}, { 68, 68, 68},
  3183. { 67, 67, 67}, { 67, 67, 67}, { 67, 67, 67}, { 67, 67, 67}, { 66, 66, 66},
  3184. { 66, 66, 66}, { 66, 66, 66}, { 66, 66, 66}, { 65, 65, 65}, { 65, 65, 65},
  3185. { 65, 65, 65}, { 65, 65, 65}, { 64, 64, 64}, { 64, 64, 64}, { 64, 64, 64},
  3186. { 64, 64, 64}, { 63, 63, 63}, { 63, 63, 63}, { 63, 63, 63}, { 63, 63, 63},
  3187. { 62, 62, 62}, { 62, 62, 62}, { 62, 62, 62}, { 62, 62, 62}, { 61, 61, 61},
  3188. { 61, 61, 61}, { 61, 61, 61}, { 60, 60, 60}, { 60, 60, 60}, { 60, 60, 60},
  3189. { 60, 60, 60}, { 59, 59, 59}, { 59, 59, 59}, { 59, 59, 59}, { 59, 59, 59},
  3190. { 58, 58, 58}, { 58, 58, 58}, { 58, 58, 58}, { 58, 58, 58}, { 57, 57, 57},
  3191. { 57, 57, 57}, { 57, 57, 57}, { 57, 57, 57}, { 56, 56, 56}, { 56, 56, 56},
  3192. { 56, 56, 56}, { 56, 56, 56}, { 55, 55, 55}, { 55, 55, 55}, { 55, 55, 55},
  3193. { 55, 55, 55}, { 54, 54, 54}, { 54, 54, 54}, { 54, 54, 54}, { 54, 54, 54},
  3194. { 53, 53, 53}, { 53, 53, 53}, { 53, 53, 53}, { 53, 53, 53}, { 52, 52, 52},
  3195. { 52, 52, 52}, { 52, 52, 52}, { 52, 52, 52}, { 51, 51, 51}, { 51, 51, 51},
  3196. { 51, 51, 51}, { 51, 51, 51}, { 50, 50, 50}, { 50, 50, 50}, { 50, 50, 50},
  3197. { 50, 50, 50}, { 49, 49, 49}, { 49, 49, 49}, { 49, 49, 49}, { 48, 48, 48},
  3198. { 48, 48, 48}, { 48, 48, 48}, { 48, 48, 48}, { 47, 47, 47}, { 47, 47, 47},
  3199. { 47, 47, 47}, { 47, 47, 47}, { 46, 46, 46}, { 46, 46, 46}, { 46, 46, 46},
  3200. { 46, 46, 46}, { 45, 45, 45}, { 45, 45, 45}, { 45, 45, 45}, { 45, 45, 45},
  3201. { 44, 44, 44}, { 44, 44, 44}, { 44, 44, 44}, { 44, 44, 44}, { 43, 43, 43},
  3202. { 43, 43, 43}, { 43, 43, 43}, { 43, 43, 43}, { 42, 42, 42}, { 42, 42, 42},
  3203. { 42, 42, 42}, { 42, 42, 42}, { 41, 41, 41}, { 41, 41, 41}, { 41, 41, 41},
  3204. { 41, 41, 41}, { 40, 40, 40}, { 40, 40, 40}, { 40, 40, 40}, { 40, 40, 40},
  3205. { 39, 39, 39}, { 39, 39, 39}, { 39, 39, 39}, { 39, 39, 39}, { 38, 38, 38},
  3206. { 38, 38, 38}, { 38, 38, 38}, { 38, 38, 38}, { 37, 37, 37}, { 37, 37, 37},
  3207. { 37, 37, 37}, { 37, 37, 37}, { 36, 36, 36}, { 36, 36, 36}, { 36, 36, 36},
  3208. { 35, 35, 35}, { 35, 35, 35}, { 35, 35, 35}, { 35, 35, 35}, { 34, 34, 34},
  3209. { 34, 34, 34}, { 34, 34, 34}, { 34, 34, 34}, { 33, 33, 33}, { 33, 33, 33},
  3210. { 33, 33, 33}, { 33, 33, 33}, { 32, 32, 32}, { 32, 32, 32}, { 32, 32, 32},
  3211. { 32, 32, 32}, { 31, 31, 31}, { 31, 31, 31}, { 31, 31, 31}, { 31, 31, 31},
  3212. { 30, 30, 30}, { 30, 30, 30}, { 30, 30, 30}, { 30, 30, 30}, { 29, 29, 29},
  3213. { 29, 29, 29}, { 29, 29, 29}, { 29, 29, 29}, { 28, 28, 28}, { 28, 28, 28},
  3214. { 28, 28, 28}, { 28, 28, 28}, { 27, 27, 27}, { 27, 27, 27}, { 27, 27, 27},
  3215. { 27, 27, 27}, { 26, 26, 26}, { 26, 26, 26}, { 26, 26, 26}, { 26, 26, 26},
  3216. { 25, 25, 25}, { 25, 25, 25}, { 25, 25, 25}, { 25, 25, 25}, { 24, 24, 24},
  3217. { 24, 24, 24}, { 24, 24, 24}, { 23, 23, 23}, { 23, 23, 23}, { 23, 23, 23},
  3218. { 23, 23, 23}, { 22, 22, 22}, { 22, 22, 22}, { 22, 22, 22}, { 22, 22, 22},
  3219. { 21, 21, 21}, { 21, 21, 21}, { 21, 21, 21}, { 21, 21, 21}, { 20, 20, 20},
  3220. { 20, 20, 20}, { 20, 20, 20}, { 20, 20, 20}, { 19, 19, 19}, { 19, 19, 19},
  3221. { 19, 19, 19}, { 19, 19, 19}, { 18, 18, 18}, { 18, 18, 18}, { 18, 18, 18},
  3222. { 18, 18, 18}, { 17, 17, 17}, { 17, 17, 17}, { 17, 17, 17}, { 17, 17, 17},
  3223. { 16, 16, 16}, { 16, 16, 16}, { 16, 16, 16}, { 16, 16, 16}, { 15, 15, 15},
  3224. { 15, 15, 15}, { 15, 15, 15}, { 15, 15, 15}, { 14, 14, 14}, { 14, 14, 14},
  3225. { 14, 14, 14}, { 14, 14, 14}, { 13, 13, 13}, { 13, 13, 13}, { 13, 13, 13},
  3226. { 13, 13, 13}, { 12, 12, 12}, { 12, 12, 12}, { 12, 12, 12}, { 11, 11, 11},
  3227. { 11, 11, 11}, { 11, 11, 11}, { 11, 11, 11}, { 10, 10, 10}, { 10, 10, 10},
  3228. { 10, 10, 10}, { 10, 10, 10}, { 9, 9, 9}, { 9, 9, 9}, { 9, 9, 9},
  3229. { 9, 9, 9}, { 8, 8, 8}, { 8, 8, 8}, { 8, 8, 8}, { 8, 8, 8},
  3230. { 7, 7, 7}, { 7, 7, 7}, { 7, 7, 7}, { 7, 7, 7}, { 6, 6, 6},
  3231. { 6, 6, 6}, { 6, 6, 6}, { 6, 6, 6}, { 5, 5, 5}, { 5, 5, 5},
  3232. { 5, 5, 5}, { 5, 5, 5}, { 4, 4, 4}, { 4, 4, 4}, { 4, 4, 4},
  3233. { 4, 4, 4}, { 3, 3, 3}, { 3, 3, 3}, { 3, 3, 3}, { 3, 3, 3},
  3234. { 2, 2, 2}, { 2, 2, 2}, { 2, 2, 2}, { 2, 2, 2}, { 1, 1, 1},
  3235. { 1, 1, 1}, { 1, 1, 1}, { 1, 1, 1}, { 0, 0, 0}, { 0, 0, 0}
  3236. };
  3237. const rgb_t hot_colormap[1000] = {
  3238. { 11, 0, 0}, { 11, 0, 0}, { 12, 0, 0}, { 13, 0, 0}, { 13, 0, 0},
  3239. { 14, 0, 0}, { 15, 0, 0}, { 15, 0, 0}, { 16, 0, 0}, { 17, 0, 0},
  3240. { 17, 0, 0}, { 18, 0, 0}, { 19, 0, 0}, { 19, 0, 0}, { 20, 0, 0},
  3241. { 21, 0, 0}, { 21, 0, 0}, { 22, 0, 0}, { 23, 0, 0}, { 23, 0, 0},
  3242. { 24, 0, 0}, { 25, 0, 0}, { 25, 0, 0}, { 26, 0, 0}, { 27, 0, 0},
  3243. { 27, 0, 0}, { 28, 0, 0}, { 29, 0, 0}, { 29, 0, 0}, { 30, 0, 0},
  3244. { 31, 0, 0}, { 31, 0, 0}, { 32, 0, 0}, { 33, 0, 0}, { 33, 0, 0},
  3245. { 34, 0, 0}, { 35, 0, 0}, { 35, 0, 0}, { 36, 0, 0}, { 37, 0, 0},
  3246. { 37, 0, 0}, { 38, 0, 0}, { 39, 0, 0}, { 39, 0, 0}, { 40, 0, 0},
  3247. { 41, 0, 0}, { 41, 0, 0}, { 42, 0, 0}, { 43, 0, 0}, { 43, 0, 0},
  3248. { 44, 0, 0}, { 45, 0, 0}, { 45, 0, 0}, { 46, 0, 0}, { 47, 0, 0},
  3249. { 47, 0, 0}, { 48, 0, 0}, { 49, 0, 0}, { 49, 0, 0}, { 50, 0, 0},
  3250. { 51, 0, 0}, { 51, 0, 0}, { 52, 0, 0}, { 53, 0, 0}, { 54, 0, 0},
  3251. { 54, 0, 0}, { 55, 0, 0}, { 56, 0, 0}, { 56, 0, 0}, { 57, 0, 0},
  3252. { 58, 0, 0}, { 58, 0, 0}, { 59, 0, 0}, { 60, 0, 0}, { 60, 0, 0},
  3253. { 61, 0, 0}, { 62, 0, 0}, { 62, 0, 0}, { 63, 0, 0}, { 64, 0, 0},
  3254. { 64, 0, 0}, { 65, 0, 0}, { 66, 0, 0}, { 66, 0, 0}, { 67, 0, 0},
  3255. { 68, 0, 0}, { 68, 0, 0}, { 69, 0, 0}, { 70, 0, 0}, { 70, 0, 0},
  3256. { 71, 0, 0}, { 72, 0, 0}, { 72, 0, 0}, { 73, 0, 0}, { 74, 0, 0},
  3257. { 74, 0, 0}, { 75, 0, 0}, { 76, 0, 0}, { 76, 0, 0}, { 77, 0, 0},
  3258. { 78, 0, 0}, { 78, 0, 0}, { 79, 0, 0}, { 80, 0, 0}, { 80, 0, 0},
  3259. { 81, 0, 0}, { 82, 0, 0}, { 82, 0, 0}, { 83, 0, 0}, { 84, 0, 0},
  3260. { 84, 0, 0}, { 85, 0, 0}, { 86, 0, 0}, { 86, 0, 0}, { 87, 0, 0},
  3261. { 88, 0, 0}, { 88, 0, 0}, { 89, 0, 0}, { 90, 0, 0}, { 90, 0, 0},
  3262. { 91, 0, 0}, { 92, 0, 0}, { 92, 0, 0}, { 93, 0, 0}, { 94, 0, 0},
  3263. { 94, 0, 0}, { 95, 0, 0}, { 96, 0, 0}, { 96, 0, 0}, { 97, 0, 0},
  3264. { 98, 0, 0}, { 98, 0, 0}, { 99, 0, 0}, {100, 0, 0}, {100, 0, 0},
  3265. {101, 0, 0}, {102, 0, 0}, {102, 0, 0}, {103, 0, 0}, {104, 0, 0},
  3266. {104, 0, 0}, {105, 0, 0}, {106, 0, 0}, {106, 0, 0}, {107, 0, 0},
  3267. {108, 0, 0}, {108, 0, 0}, {109, 0, 0}, {110, 0, 0}, {110, 0, 0},
  3268. {111, 0, 0}, {112, 0, 0}, {112, 0, 0}, {113, 0, 0}, {114, 0, 0},
  3269. {114, 0, 0}, {115, 0, 0}, {116, 0, 0}, {116, 0, 0}, {117, 0, 0},
  3270. {118, 0, 0}, {119, 0, 0}, {119, 0, 0}, {120, 0, 0}, {121, 0, 0},
  3271. {121, 0, 0}, {122, 0, 0}, {123, 0, 0}, {123, 0, 0}, {124, 0, 0},
  3272. {125, 0, 0}, {125, 0, 0}, {126, 0, 0}, {127, 0, 0}, {127, 0, 0},
  3273. {128, 0, 0}, {129, 0, 0}, {129, 0, 0}, {130, 0, 0}, {131, 0, 0},
  3274. {131, 0, 0}, {132, 0, 0}, {133, 0, 0}, {133, 0, 0}, {134, 0, 0},
  3275. {135, 0, 0}, {135, 0, 0}, {136, 0, 0}, {137, 0, 0}, {137, 0, 0},
  3276. {138, 0, 0}, {139, 0, 0}, {139, 0, 0}, {140, 0, 0}, {141, 0, 0},
  3277. {141, 0, 0}, {142, 0, 0}, {143, 0, 0}, {143, 0, 0}, {144, 0, 0},
  3278. {145, 0, 0}, {145, 0, 0}, {146, 0, 0}, {147, 0, 0}, {147, 0, 0},
  3279. {148, 0, 0}, {149, 0, 0}, {149, 0, 0}, {150, 0, 0}, {151, 0, 0},
  3280. {151, 0, 0}, {152, 0, 0}, {153, 0, 0}, {153, 0, 0}, {154, 0, 0},
  3281. {155, 0, 0}, {155, 0, 0}, {156, 0, 0}, {157, 0, 0}, {157, 0, 0},
  3282. {158, 0, 0}, {159, 0, 0}, {159, 0, 0}, {160, 0, 0}, {161, 0, 0},
  3283. {161, 0, 0}, {162, 0, 0}, {163, 0, 0}, {163, 0, 0}, {164, 0, 0},
  3284. {165, 0, 0}, {165, 0, 0}, {166, 0, 0}, {167, 0, 0}, {167, 0, 0},
  3285. {168, 0, 0}, {169, 0, 0}, {169, 0, 0}, {170, 0, 0}, {171, 0, 0},
  3286. {171, 0, 0}, {172, 0, 0}, {173, 0, 0}, {173, 0, 0}, {174, 0, 0},
  3287. {175, 0, 0}, {175, 0, 0}, {176, 0, 0}, {177, 0, 0}, {177, 0, 0},
  3288. {178, 0, 0}, {179, 0, 0}, {179, 0, 0}, {180, 0, 0}, {181, 0, 0},
  3289. {181, 0, 0}, {182, 0, 0}, {183, 0, 0}, {183, 0, 0}, {184, 0, 0},
  3290. {185, 0, 0}, {186, 0, 0}, {186, 0, 0}, {187, 0, 0}, {188, 0, 0},
  3291. {188, 0, 0}, {189, 0, 0}, {190, 0, 0}, {190, 0, 0}, {191, 0, 0},
  3292. {192, 0, 0}, {192, 0, 0}, {193, 0, 0}, {194, 0, 0}, {194, 0, 0},
  3293. {195, 0, 0}, {196, 0, 0}, {196, 0, 0}, {197, 0, 0}, {198, 0, 0},
  3294. {198, 0, 0}, {199, 0, 0}, {200, 0, 0}, {200, 0, 0}, {201, 0, 0},
  3295. {202, 0, 0}, {202, 0, 0}, {203, 0, 0}, {204, 0, 0}, {204, 0, 0},
  3296. {205, 0, 0}, {206, 0, 0}, {206, 0, 0}, {207, 0, 0}, {208, 0, 0},
  3297. {208, 0, 0}, {209, 0, 0}, {210, 0, 0}, {210, 0, 0}, {211, 0, 0},
  3298. {212, 0, 0}, {212, 0, 0}, {213, 0, 0}, {214, 0, 0}, {214, 0, 0},
  3299. {215, 0, 0}, {216, 0, 0}, {216, 0, 0}, {217, 0, 0}, {218, 0, 0},
  3300. {218, 0, 0}, {219, 0, 0}, {220, 0, 0}, {220, 0, 0}, {221, 0, 0},
  3301. {222, 0, 0}, {222, 0, 0}, {223, 0, 0}, {224, 0, 0}, {224, 0, 0},
  3302. {225, 0, 0}, {226, 0, 0}, {226, 0, 0}, {227, 0, 0}, {228, 0, 0},
  3303. {228, 0, 0}, {229, 0, 0}, {230, 0, 0}, {230, 0, 0}, {231, 0, 0},
  3304. {232, 0, 0}, {232, 0, 0}, {233, 0, 0}, {234, 0, 0}, {234, 0, 0},
  3305. {235, 0, 0}, {236, 0, 0}, {236, 0, 0}, {237, 0, 0}, {238, 0, 0},
  3306. {238, 0, 0}, {239, 0, 0}, {240, 0, 0}, {240, 0, 0}, {241, 0, 0},
  3307. {242, 0, 0}, {242, 0, 0}, {243, 0, 0}, {244, 0, 0}, {244, 0, 0},
  3308. {245, 0, 0}, {246, 0, 0}, {246, 0, 0}, {247, 0, 0}, {248, 0, 0},
  3309. {248, 0, 0}, {249, 0, 0}, {250, 0, 0}, {251, 0, 0}, {251, 0, 0},
  3310. {252, 0, 0}, {253, 0, 0}, {253, 0, 0}, {254, 0, 0}, {255, 0, 0},
  3311. {255, 0, 0}, {255, 1, 0}, {255, 2, 0}, {255, 2, 0}, {255, 3, 0},
  3312. {255, 4, 0}, {255, 4, 0}, {255, 5, 0}, {255, 6, 0}, {255, 6, 0},
  3313. {255, 7, 0}, {255, 8, 0}, {255, 8, 0}, {255, 9, 0}, {255, 10, 0},
  3314. {255, 10, 0}, {255, 11, 0}, {255, 12, 0}, {255, 12, 0}, {255, 13, 0},
  3315. {255, 14, 0}, {255, 14, 0}, {255, 15, 0}, {255, 16, 0}, {255, 16, 0},
  3316. {255, 17, 0}, {255, 18, 0}, {255, 18, 0}, {255, 19, 0}, {255, 20, 0},
  3317. {255, 20, 0}, {255, 21, 0}, {255, 22, 0}, {255, 22, 0}, {255, 23, 0},
  3318. {255, 24, 0}, {255, 24, 0}, {255, 25, 0}, {255, 26, 0}, {255, 26, 0},
  3319. {255, 27, 0}, {255, 28, 0}, {255, 28, 0}, {255, 29, 0}, {255, 30, 0},
  3320. {255, 30, 0}, {255, 31, 0}, {255, 32, 0}, {255, 32, 0}, {255, 33, 0},
  3321. {255, 34, 0}, {255, 34, 0}, {255, 35, 0}, {255, 36, 0}, {255, 36, 0},
  3322. {255, 37, 0}, {255, 38, 0}, {255, 38, 0}, {255, 39, 0}, {255, 40, 0},
  3323. {255, 40, 0}, {255, 41, 0}, {255, 42, 0}, {255, 42, 0}, {255, 43, 0},
  3324. {255, 44, 0}, {255, 44, 0}, {255, 45, 0}, {255, 46, 0}, {255, 46, 0},
  3325. {255, 47, 0}, {255, 48, 0}, {255, 48, 0}, {255, 49, 0}, {255, 50, 0},
  3326. {255, 50, 0}, {255, 51, 0}, {255, 52, 0}, {255, 52, 0}, {255, 53, 0},
  3327. {255, 54, 0}, {255, 54, 0}, {255, 55, 0}, {255, 56, 0}, {255, 56, 0},
  3328. {255, 57, 0}, {255, 58, 0}, {255, 58, 0}, {255, 59, 0}, {255, 60, 0},
  3329. {255, 60, 0}, {255, 61, 0}, {255, 62, 0}, {255, 63, 0}, {255, 63, 0},
  3330. {255, 64, 0}, {255, 65, 0}, {255, 65, 0}, {255, 66, 0}, {255, 67, 0},
  3331. {255, 67, 0}, {255, 68, 0}, {255, 69, 0}, {255, 69, 0}, {255, 70, 0},
  3332. {255, 71, 0}, {255, 71, 0}, {255, 72, 0}, {255, 73, 0}, {255, 73, 0},
  3333. {255, 74, 0}, {255, 75, 0}, {255, 75, 0}, {255, 76, 0}, {255, 77, 0},
  3334. {255, 77, 0}, {255, 78, 0}, {255, 79, 0}, {255, 79, 0}, {255, 80, 0},
  3335. {255, 81, 0}, {255, 81, 0}, {255, 82, 0}, {255, 83, 0}, {255, 83, 0},
  3336. {255, 84, 0}, {255, 85, 0}, {255, 85, 0}, {255, 86, 0}, {255, 87, 0},
  3337. {255, 87, 0}, {255, 88, 0}, {255, 89, 0}, {255, 89, 0}, {255, 90, 0},
  3338. {255, 91, 0}, {255, 91, 0}, {255, 92, 0}, {255, 93, 0}, {255, 93, 0},
  3339. {255, 94, 0}, {255, 95, 0}, {255, 95, 0}, {255, 96, 0}, {255, 97, 0},
  3340. {255, 97, 0}, {255, 98, 0}, {255, 99, 0}, {255, 99, 0}, {255, 100, 0},
  3341. {255, 101, 0}, {255, 101, 0}, {255, 102, 0}, {255, 103, 0}, {255, 103, 0},
  3342. {255, 104, 0}, {255, 105, 0}, {255, 105, 0}, {255, 106, 0}, {255, 107, 0},
  3343. {255, 107, 0}, {255, 108, 0}, {255, 109, 0}, {255, 109, 0}, {255, 110, 0},
  3344. {255, 111, 0}, {255, 111, 0}, {255, 112, 0}, {255, 113, 0}, {255, 113, 0},
  3345. {255, 114, 0}, {255, 115, 0}, {255, 115, 0}, {255, 116, 0}, {255, 117, 0},
  3346. {255, 117, 0}, {255, 118, 0}, {255, 119, 0}, {255, 119, 0}, {255, 120, 0},
  3347. {255, 121, 0}, {255, 121, 0}, {255, 122, 0}, {255, 123, 0}, {255, 123, 0},
  3348. {255, 124, 0}, {255, 125, 0}, {255, 125, 0}, {255, 126, 0}, {255, 127, 0},
  3349. {255, 128, 0}, {255, 128, 0}, {255, 129, 0}, {255, 130, 0}, {255, 130, 0},
  3350. {255, 131, 0}, {255, 132, 0}, {255, 132, 0}, {255, 133, 0}, {255, 134, 0},
  3351. {255, 134, 0}, {255, 135, 0}, {255, 136, 0}, {255, 136, 0}, {255, 137, 0},
  3352. {255, 138, 0}, {255, 138, 0}, {255, 139, 0}, {255, 140, 0}, {255, 140, 0},
  3353. {255, 141, 0}, {255, 142, 0}, {255, 142, 0}, {255, 143, 0}, {255, 144, 0},
  3354. {255, 144, 0}, {255, 145, 0}, {255, 146, 0}, {255, 146, 0}, {255, 147, 0},
  3355. {255, 148, 0}, {255, 148, 0}, {255, 149, 0}, {255, 150, 0}, {255, 150, 0},
  3356. {255, 151, 0}, {255, 152, 0}, {255, 152, 0}, {255, 153, 0}, {255, 154, 0},
  3357. {255, 154, 0}, {255, 155, 0}, {255, 156, 0}, {255, 156, 0}, {255, 157, 0},
  3358. {255, 158, 0}, {255, 158, 0}, {255, 159, 0}, {255, 160, 0}, {255, 160, 0},
  3359. {255, 161, 0}, {255, 162, 0}, {255, 162, 0}, {255, 163, 0}, {255, 164, 0},
  3360. {255, 164, 0}, {255, 165, 0}, {255, 166, 0}, {255, 166, 0}, {255, 167, 0},
  3361. {255, 168, 0}, {255, 168, 0}, {255, 169, 0}, {255, 170, 0}, {255, 170, 0},
  3362. {255, 171, 0}, {255, 172, 0}, {255, 172, 0}, {255, 173, 0}, {255, 174, 0},
  3363. {255, 174, 0}, {255, 175, 0}, {255, 176, 0}, {255, 176, 0}, {255, 177, 0},
  3364. {255, 178, 0}, {255, 178, 0}, {255, 179, 0}, {255, 180, 0}, {255, 180, 0},
  3365. {255, 181, 0}, {255, 182, 0}, {255, 182, 0}, {255, 183, 0}, {255, 184, 0},
  3366. {255, 184, 0}, {255, 185, 0}, {255, 186, 0}, {255, 186, 0}, {255, 187, 0},
  3367. {255, 188, 0}, {255, 188, 0}, {255, 189, 0}, {255, 190, 0}, {255, 190, 0},
  3368. {255, 191, 0}, {255, 192, 0}, {255, 192, 0}, {255, 193, 0}, {255, 194, 0},
  3369. {255, 195, 0}, {255, 195, 0}, {255, 196, 0}, {255, 197, 0}, {255, 197, 0},
  3370. {255, 198, 0}, {255, 199, 0}, {255, 199, 0}, {255, 200, 0}, {255, 201, 0},
  3371. {255, 201, 0}, {255, 202, 0}, {255, 203, 0}, {255, 203, 0}, {255, 204, 0},
  3372. {255, 205, 0}, {255, 205, 0}, {255, 206, 0}, {255, 207, 0}, {255, 207, 0},
  3373. {255, 208, 0}, {255, 209, 0}, {255, 209, 0}, {255, 210, 0}, {255, 211, 0},
  3374. {255, 211, 0}, {255, 212, 0}, {255, 213, 0}, {255, 213, 0}, {255, 214, 0},
  3375. {255, 215, 0}, {255, 215, 0}, {255, 216, 0}, {255, 217, 0}, {255, 217, 0},
  3376. {255, 218, 0}, {255, 219, 0}, {255, 219, 0}, {255, 220, 0}, {255, 221, 0},
  3377. {255, 221, 0}, {255, 222, 0}, {255, 223, 0}, {255, 223, 0}, {255, 224, 0},
  3378. {255, 225, 0}, {255, 225, 0}, {255, 226, 0}, {255, 227, 0}, {255, 227, 0},
  3379. {255, 228, 0}, {255, 229, 0}, {255, 229, 0}, {255, 230, 0}, {255, 231, 0},
  3380. {255, 231, 0}, {255, 232, 0}, {255, 233, 0}, {255, 233, 0}, {255, 234, 0},
  3381. {255, 235, 0}, {255, 235, 0}, {255, 236, 0}, {255, 237, 0}, {255, 237, 0},
  3382. {255, 238, 0}, {255, 239, 0}, {255, 239, 0}, {255, 240, 0}, {255, 241, 0},
  3383. {255, 241, 0}, {255, 242, 0}, {255, 243, 0}, {255, 243, 0}, {255, 244, 0},
  3384. {255, 245, 0}, {255, 245, 0}, {255, 246, 0}, {255, 247, 0}, {255, 247, 0},
  3385. {255, 248, 0}, {255, 249, 0}, {255, 249, 0}, {255, 250, 0}, {255, 251, 0},
  3386. {255, 251, 0}, {255, 252, 0}, {255, 253, 0}, {255, 253, 0}, {255, 254, 0},
  3387. {255, 255, 0}, {255, 255, 1}, {255, 255, 2}, {255, 255, 3}, {255, 255, 4},
  3388. {255, 255, 5}, {255, 255, 6}, {255, 255, 7}, {255, 255, 8}, {255, 255, 9},
  3389. {255, 255, 10}, {255, 255, 11}, {255, 255, 12}, {255, 255, 13}, {255, 255, 14},
  3390. {255, 255, 15}, {255, 255, 16}, {255, 255, 17}, {255, 255, 18}, {255, 255, 19},
  3391. {255, 255, 20}, {255, 255, 21}, {255, 255, 22}, {255, 255, 23}, {255, 255, 24},
  3392. {255, 255, 25}, {255, 255, 26}, {255, 255, 27}, {255, 255, 28}, {255, 255, 29},
  3393. {255, 255, 30}, {255, 255, 31}, {255, 255, 32}, {255, 255, 33}, {255, 255, 34},
  3394. {255, 255, 35}, {255, 255, 36}, {255, 255, 37}, {255, 255, 38}, {255, 255, 39},
  3395. {255, 255, 40}, {255, 255, 41}, {255, 255, 42}, {255, 255, 43}, {255, 255, 44},
  3396. {255, 255, 45}, {255, 255, 46}, {255, 255, 47}, {255, 255, 48}, {255, 255, 49},
  3397. {255, 255, 50}, {255, 255, 51}, {255, 255, 52}, {255, 255, 53}, {255, 255, 54},
  3398. {255, 255, 55}, {255, 255, 56}, {255, 255, 57}, {255, 255, 58}, {255, 255, 59},
  3399. {255, 255, 60}, {255, 255, 61}, {255, 255, 62}, {255, 255, 63}, {255, 255, 64},
  3400. {255, 255, 65}, {255, 255, 66}, {255, 255, 67}, {255, 255, 68}, {255, 255, 69},
  3401. {255, 255, 70}, {255, 255, 71}, {255, 255, 72}, {255, 255, 73}, {255, 255, 74},
  3402. {255, 255, 75}, {255, 255, 76}, {255, 255, 77}, {255, 255, 78}, {255, 255, 79},
  3403. {255, 255, 80}, {255, 255, 81}, {255, 255, 82}, {255, 255, 83}, {255, 255, 84},
  3404. {255, 255, 85}, {255, 255, 86}, {255, 255, 87}, {255, 255, 88}, {255, 255, 89},
  3405. {255, 255, 90}, {255, 255, 91}, {255, 255, 92}, {255, 255, 93}, {255, 255, 94},
  3406. {255, 255, 95}, {255, 255, 96}, {255, 255, 97}, {255, 255, 98}, {255, 255, 99},
  3407. {255, 255, 100}, {255, 255, 101}, {255, 255, 102}, {255, 255, 103}, {255, 255, 104},
  3408. {255, 255, 105}, {255, 255, 106}, {255, 255, 107}, {255, 255, 108}, {255, 255, 109},
  3409. {255, 255, 110}, {255, 255, 111}, {255, 255, 112}, {255, 255, 113}, {255, 255, 114},
  3410. {255, 255, 115}, {255, 255, 116}, {255, 255, 117}, {255, 255, 118}, {255, 255, 119},
  3411. {255, 255, 120}, {255, 255, 121}, {255, 255, 122}, {255, 255, 123}, {255, 255, 124},
  3412. {255, 255, 125}, {255, 255, 126}, {255, 255, 127}, {255, 255, 128}, {255, 255, 129},
  3413. {255, 255, 130}, {255, 255, 131}, {255, 255, 132}, {255, 255, 133}, {255, 255, 134},
  3414. {255, 255, 135}, {255, 255, 136}, {255, 255, 137}, {255, 255, 138}, {255, 255, 139},
  3415. {255, 255, 140}, {255, 255, 141}, {255, 255, 142}, {255, 255, 143}, {255, 255, 144},
  3416. {255, 255, 145}, {255, 255, 146}, {255, 255, 147}, {255, 255, 148}, {255, 255, 149},
  3417. {255, 255, 150}, {255, 255, 151}, {255, 255, 152}, {255, 255, 153}, {255, 255, 154},
  3418. {255, 255, 155}, {255, 255, 157}, {255, 255, 158}, {255, 255, 159}, {255, 255, 160},
  3419. {255, 255, 161}, {255, 255, 162}, {255, 255, 163}, {255, 255, 164}, {255, 255, 165},
  3420. {255, 255, 166}, {255, 255, 167}, {255, 255, 168}, {255, 255, 169}, {255, 255, 170},
  3421. {255, 255, 171}, {255, 255, 172}, {255, 255, 173}, {255, 255, 174}, {255, 255, 175},
  3422. {255, 255, 176}, {255, 255, 177}, {255, 255, 178}, {255, 255, 179}, {255, 255, 180},
  3423. {255, 255, 181}, {255, 255, 182}, {255, 255, 183}, {255, 255, 184}, {255, 255, 185},
  3424. {255, 255, 186}, {255, 255, 187}, {255, 255, 188}, {255, 255, 189}, {255, 255, 190},
  3425. {255, 255, 191}, {255, 255, 192}, {255, 255, 193}, {255, 255, 194}, {255, 255, 195},
  3426. {255, 255, 196}, {255, 255, 197}, {255, 255, 198}, {255, 255, 199}, {255, 255, 200},
  3427. {255, 255, 201}, {255, 255, 202}, {255, 255, 203}, {255, 255, 204}, {255, 255, 205},
  3428. {255, 255, 206}, {255, 255, 207}, {255, 255, 208}, {255, 255, 209}, {255, 255, 210},
  3429. {255, 255, 211}, {255, 255, 212}, {255, 255, 213}, {255, 255, 214}, {255, 255, 215},
  3430. {255, 255, 216}, {255, 255, 217}, {255, 255, 218}, {255, 255, 219}, {255, 255, 220},
  3431. {255, 255, 221}, {255, 255, 222}, {255, 255, 223}, {255, 255, 224}, {255, 255, 225},
  3432. {255, 255, 226}, {255, 255, 227}, {255, 255, 228}, {255, 255, 229}, {255, 255, 230},
  3433. {255, 255, 231}, {255, 255, 232}, {255, 255, 233}, {255, 255, 234}, {255, 255, 235},
  3434. {255, 255, 236}, {255, 255, 237}, {255, 255, 238}, {255, 255, 239}, {255, 255, 240},
  3435. {255, 255, 241}, {255, 255, 242}, {255, 255, 243}, {255, 255, 244}, {255, 255, 245},
  3436. {255, 255, 246}, {255, 255, 247}, {255, 255, 248}, {255, 255, 249}, {255, 255, 250},
  3437. {255, 255, 251}, {255, 255, 252}, {255, 255, 253}, {255, 255, 254}, {255, 255, 255}
  3438. };
  3439. const rgb_t hsv_colormap[1000] = {
  3440. {255, 0, 0}, {255, 2, 0}, {255, 3, 0}, {255, 5, 0}, {255, 6, 0},
  3441. {255, 8, 0}, {255, 9, 0}, {255, 11, 0}, {255, 12, 0}, {255, 14, 0},
  3442. {255, 15, 0}, {255, 17, 0}, {255, 18, 0}, {255, 20, 0}, {255, 21, 0},
  3443. {255, 23, 0}, {255, 24, 0}, {255, 26, 0}, {255, 27, 0}, {255, 29, 0},
  3444. {255, 30, 0}, {255, 32, 0}, {255, 33, 0}, {255, 35, 0}, {255, 36, 0},
  3445. {255, 38, 0}, {255, 39, 0}, {255, 41, 0}, {255, 42, 0}, {255, 44, 0},
  3446. {255, 45, 0}, {255, 47, 0}, {255, 48, 0}, {255, 50, 0}, {255, 51, 0},
  3447. {255, 53, 0}, {255, 54, 0}, {255, 56, 0}, {255, 57, 0}, {255, 59, 0},
  3448. {255, 60, 0}, {255, 62, 0}, {255, 63, 0}, {255, 65, 0}, {255, 66, 0},
  3449. {255, 68, 0}, {255, 69, 0}, {255, 71, 0}, {255, 72, 0}, {255, 74, 0},
  3450. {255, 75, 0}, {255, 77, 0}, {255, 78, 0}, {255, 80, 0}, {255, 81, 0},
  3451. {255, 83, 0}, {255, 84, 0}, {255, 86, 0}, {255, 87, 0}, {255, 89, 0},
  3452. {255, 90, 0}, {255, 92, 0}, {255, 93, 0}, {255, 95, 0}, {255, 96, 0},
  3453. {255, 98, 0}, {255, 100, 0}, {255, 101, 0}, {255, 103, 0}, {255, 104, 0},
  3454. {255, 106, 0}, {255, 107, 0}, {255, 109, 0}, {255, 110, 0}, {255, 112, 0},
  3455. {255, 113, 0}, {255, 115, 0}, {255, 116, 0}, {255, 118, 0}, {255, 119, 0},
  3456. {255, 121, 0}, {255, 122, 0}, {255, 124, 0}, {255, 125, 0}, {255, 127, 0},
  3457. {255, 128, 0}, {255, 130, 0}, {255, 131, 0}, {255, 133, 0}, {255, 134, 0},
  3458. {255, 136, 0}, {255, 137, 0}, {255, 139, 0}, {255, 140, 0}, {255, 142, 0},
  3459. {255, 143, 0}, {255, 145, 0}, {255, 146, 0}, {255, 148, 0}, {255, 149, 0},
  3460. {255, 151, 0}, {255, 152, 0}, {255, 154, 0}, {255, 155, 0}, {255, 157, 0},
  3461. {255, 158, 0}, {255, 160, 0}, {255, 161, 0}, {255, 163, 0}, {255, 164, 0},
  3462. {255, 166, 0}, {255, 167, 0}, {255, 169, 0}, {255, 170, 0}, {255, 172, 0},
  3463. {255, 173, 0}, {255, 175, 0}, {255, 176, 0}, {255, 178, 0}, {255, 179, 0},
  3464. {255, 181, 0}, {255, 182, 0}, {255, 184, 0}, {255, 185, 0}, {255, 187, 0},
  3465. {255, 188, 0}, {255, 190, 0}, {255, 191, 0}, {255, 193, 0}, {255, 194, 0},
  3466. {255, 196, 0}, {255, 197, 0}, {255, 199, 0}, {255, 201, 0}, {255, 202, 0},
  3467. {255, 204, 0}, {255, 205, 0}, {255, 207, 0}, {255, 208, 0}, {255, 210, 0},
  3468. {255, 211, 0}, {255, 213, 0}, {255, 214, 0}, {255, 216, 0}, {255, 217, 0},
  3469. {255, 219, 0}, {255, 220, 0}, {255, 222, 0}, {255, 223, 0}, {255, 225, 0},
  3470. {255, 226, 0}, {255, 228, 0}, {255, 229, 0}, {255, 231, 0}, {255, 232, 0},
  3471. {255, 234, 0}, {255, 235, 0}, {255, 237, 0}, {255, 238, 0}, {255, 239, 0},
  3472. {254, 240, 0}, {254, 242, 0}, {253, 243, 0}, {253, 244, 0}, {252, 245, 0},
  3473. {252, 246, 0}, {251, 247, 0}, {251, 248, 0}, {250, 249, 0}, {250, 250, 0},
  3474. {249, 251, 0}, {249, 252, 0}, {248, 253, 0}, {248, 254, 0}, {247, 255, 0},
  3475. {246, 255, 0}, {245, 255, 0}, {243, 255, 0}, {242, 255, 0}, {240, 255, 0},
  3476. {239, 255, 0}, {237, 255, 0}, {236, 255, 0}, {234, 255, 0}, {233, 255, 0},
  3477. {231, 255, 0}, {230, 255, 0}, {228, 255, 0}, {227, 255, 0}, {225, 255, 0},
  3478. {224, 255, 0}, {222, 255, 0}, {221, 255, 0}, {219, 255, 0}, {218, 255, 0},
  3479. {216, 255, 0}, {215, 255, 0}, {213, 255, 0}, {211, 255, 0}, {210, 255, 0},
  3480. {208, 255, 0}, {207, 255, 0}, {205, 255, 0}, {204, 255, 0}, {202, 255, 0},
  3481. {201, 255, 0}, {199, 255, 0}, {198, 255, 0}, {196, 255, 0}, {195, 255, 0},
  3482. {193, 255, 0}, {192, 255, 0}, {190, 255, 0}, {189, 255, 0}, {187, 255, 0},
  3483. {186, 255, 0}, {184, 255, 0}, {183, 255, 0}, {181, 255, 0}, {180, 255, 0},
  3484. {178, 255, 0}, {177, 255, 0}, {175, 255, 0}, {174, 255, 0}, {172, 255, 0},
  3485. {171, 255, 0}, {169, 255, 0}, {168, 255, 0}, {166, 255, 0}, {165, 255, 0},
  3486. {163, 255, 0}, {162, 255, 0}, {160, 255, 0}, {159, 255, 0}, {157, 255, 0},
  3487. {156, 255, 0}, {154, 255, 0}, {153, 255, 0}, {151, 255, 0}, {150, 255, 0},
  3488. {148, 255, 0}, {147, 255, 0}, {145, 255, 0}, {144, 255, 0}, {142, 255, 0},
  3489. {141, 255, 0}, {139, 255, 0}, {138, 255, 0}, {136, 255, 0}, {135, 255, 0},
  3490. {133, 255, 0}, {132, 255, 0}, {130, 255, 0}, {129, 255, 0}, {127, 255, 0},
  3491. {126, 255, 0}, {124, 255, 0}, {123, 255, 0}, {121, 255, 0}, {120, 255, 0},
  3492. {118, 255, 0}, {117, 255, 0}, {115, 255, 0}, {114, 255, 0}, {112, 255, 0},
  3493. {110, 255, 0}, {109, 255, 0}, {107, 255, 0}, {106, 255, 0}, {104, 255, 0},
  3494. {103, 255, 0}, {101, 255, 0}, {100, 255, 0}, { 98, 255, 0}, { 97, 255, 0},
  3495. { 95, 255, 0}, { 94, 255, 0}, { 92, 255, 0}, { 91, 255, 0}, { 89, 255, 0},
  3496. { 88, 255, 0}, { 86, 255, 0}, { 85, 255, 0}, { 83, 255, 0}, { 82, 255, 0},
  3497. { 80, 255, 0}, { 79, 255, 0}, { 77, 255, 0}, { 76, 255, 0}, { 74, 255, 0},
  3498. { 73, 255, 0}, { 71, 255, 0}, { 70, 255, 0}, { 68, 255, 0}, { 67, 255, 0},
  3499. { 65, 255, 0}, { 64, 255, 0}, { 62, 255, 0}, { 61, 255, 0}, { 59, 255, 0},
  3500. { 58, 255, 0}, { 56, 255, 0}, { 55, 255, 0}, { 53, 255, 0}, { 52, 255, 0},
  3501. { 50, 255, 0}, { 49, 255, 0}, { 47, 255, 0}, { 46, 255, 0}, { 44, 255, 0},
  3502. { 43, 255, 0}, { 41, 255, 0}, { 40, 255, 0}, { 38, 255, 0}, { 37, 255, 0},
  3503. { 35, 255, 0}, { 34, 255, 0}, { 32, 255, 0}, { 31, 255, 0}, { 29, 255, 0},
  3504. { 28, 255, 0}, { 26, 255, 0}, { 25, 255, 0}, { 23, 255, 0}, { 22, 255, 0},
  3505. { 20, 255, 0}, { 19, 255, 0}, { 17, 255, 0}, { 16, 255, 0}, { 14, 255, 0},
  3506. { 12, 255, 0}, { 11, 255, 0}, { 9, 255, 0}, { 8, 255, 0}, { 7, 255, 1},
  3507. { 7, 255, 2}, { 6, 255, 3}, { 6, 255, 4}, { 5, 255, 5}, { 5, 255, 6},
  3508. { 4, 255, 7}, { 4, 255, 8}, { 3, 255, 9}, { 3, 255, 10}, { 2, 255, 11},
  3509. { 2, 255, 12}, { 1, 255, 13}, { 1, 255, 14}, { 0, 255, 15}, { 0, 255, 16},
  3510. { 0, 255, 18}, { 0, 255, 19}, { 0, 255, 21}, { 0, 255, 22}, { 0, 255, 24},
  3511. { 0, 255, 25}, { 0, 255, 27}, { 0, 255, 28}, { 0, 255, 30}, { 0, 255, 31},
  3512. { 0, 255, 33}, { 0, 255, 34}, { 0, 255, 36}, { 0, 255, 37}, { 0, 255, 39},
  3513. { 0, 255, 40}, { 0, 255, 42}, { 0, 255, 43}, { 0, 255, 45}, { 0, 255, 46},
  3514. { 0, 255, 48}, { 0, 255, 49}, { 0, 255, 51}, { 0, 255, 52}, { 0, 255, 54},
  3515. { 0, 255, 55}, { 0, 255, 57}, { 0, 255, 58}, { 0, 255, 60}, { 0, 255, 61},
  3516. { 0, 255, 63}, { 0, 255, 64}, { 0, 255, 66}, { 0, 255, 67}, { 0, 255, 69},
  3517. { 0, 255, 70}, { 0, 255, 72}, { 0, 255, 73}, { 0, 255, 75}, { 0, 255, 76},
  3518. { 0, 255, 78}, { 0, 255, 79}, { 0, 255, 81}, { 0, 255, 82}, { 0, 255, 84},
  3519. { 0, 255, 86}, { 0, 255, 87}, { 0, 255, 89}, { 0, 255, 90}, { 0, 255, 92},
  3520. { 0, 255, 93}, { 0, 255, 95}, { 0, 255, 96}, { 0, 255, 98}, { 0, 255, 99},
  3521. { 0, 255, 101}, { 0, 255, 102}, { 0, 255, 104}, { 0, 255, 105}, { 0, 255, 107},
  3522. { 0, 255, 108}, { 0, 255, 110}, { 0, 255, 111}, { 0, 255, 113}, { 0, 255, 114},
  3523. { 0, 255, 116}, { 0, 255, 117}, { 0, 255, 119}, { 0, 255, 120}, { 0, 255, 122},
  3524. { 0, 255, 123}, { 0, 255, 125}, { 0, 255, 126}, { 0, 255, 128}, { 0, 255, 129},
  3525. { 0, 255, 131}, { 0, 255, 132}, { 0, 255, 134}, { 0, 255, 135}, { 0, 255, 137},
  3526. { 0, 255, 138}, { 0, 255, 140}, { 0, 255, 141}, { 0, 255, 143}, { 0, 255, 144},
  3527. { 0, 255, 146}, { 0, 255, 147}, { 0, 255, 149}, { 0, 255, 150}, { 0, 255, 152},
  3528. { 0, 255, 153}, { 0, 255, 155}, { 0, 255, 156}, { 0, 255, 158}, { 0, 255, 159},
  3529. { 0, 255, 161}, { 0, 255, 162}, { 0, 255, 164}, { 0, 255, 165}, { 0, 255, 167},
  3530. { 0, 255, 168}, { 0, 255, 170}, { 0, 255, 171}, { 0, 255, 173}, { 0, 255, 174},
  3531. { 0, 255, 176}, { 0, 255, 177}, { 0, 255, 179}, { 0, 255, 180}, { 0, 255, 182},
  3532. { 0, 255, 183}, { 0, 255, 185}, { 0, 255, 187}, { 0, 255, 188}, { 0, 255, 190},
  3533. { 0, 255, 191}, { 0, 255, 193}, { 0, 255, 194}, { 0, 255, 196}, { 0, 255, 197},
  3534. { 0, 255, 199}, { 0, 255, 200}, { 0, 255, 202}, { 0, 255, 203}, { 0, 255, 205},
  3535. { 0, 255, 206}, { 0, 255, 208}, { 0, 255, 209}, { 0, 255, 211}, { 0, 255, 212},
  3536. { 0, 255, 214}, { 0, 255, 215}, { 0, 255, 217}, { 0, 255, 218}, { 0, 255, 220},
  3537. { 0, 255, 221}, { 0, 255, 223}, { 0, 255, 224}, { 0, 255, 226}, { 0, 255, 227},
  3538. { 0, 255, 229}, { 0, 255, 230}, { 0, 255, 232}, { 0, 255, 233}, { 0, 255, 235},
  3539. { 0, 255, 236}, { 0, 255, 238}, { 0, 255, 239}, { 0, 255, 241}, { 0, 255, 242},
  3540. { 0, 255, 244}, { 0, 255, 245}, { 0, 255, 247}, { 0, 255, 248}, { 0, 255, 250},
  3541. { 0, 255, 251}, { 0, 255, 253}, { 0, 255, 254}, { 0, 254, 255}, { 0, 253, 255},
  3542. { 0, 251, 255}, { 0, 250, 255}, { 0, 248, 255}, { 0, 247, 255}, { 0, 245, 255},
  3543. { 0, 244, 255}, { 0, 242, 255}, { 0, 241, 255}, { 0, 239, 255}, { 0, 238, 255},
  3544. { 0, 236, 255}, { 0, 235, 255}, { 0, 233, 255}, { 0, 232, 255}, { 0, 230, 255},
  3545. { 0, 229, 255}, { 0, 227, 255}, { 0, 225, 255}, { 0, 224, 255}, { 0, 222, 255},
  3546. { 0, 221, 255}, { 0, 219, 255}, { 0, 218, 255}, { 0, 216, 255}, { 0, 215, 255},
  3547. { 0, 213, 255}, { 0, 212, 255}, { 0, 210, 255}, { 0, 209, 255}, { 0, 207, 255},
  3548. { 0, 206, 255}, { 0, 204, 255}, { 0, 203, 255}, { 0, 201, 255}, { 0, 200, 255},
  3549. { 0, 198, 255}, { 0, 197, 255}, { 0, 195, 255}, { 0, 194, 255}, { 0, 192, 255},
  3550. { 0, 191, 255}, { 0, 189, 255}, { 0, 188, 255}, { 0, 186, 255}, { 0, 185, 255},
  3551. { 0, 183, 255}, { 0, 182, 255}, { 0, 180, 255}, { 0, 179, 255}, { 0, 177, 255},
  3552. { 0, 176, 255}, { 0, 174, 255}, { 0, 173, 255}, { 0, 171, 255}, { 0, 170, 255},
  3553. { 0, 168, 255}, { 0, 167, 255}, { 0, 165, 255}, { 0, 164, 255}, { 0, 162, 255},
  3554. { 0, 161, 255}, { 0, 159, 255}, { 0, 158, 255}, { 0, 156, 255}, { 0, 155, 255},
  3555. { 0, 153, 255}, { 0, 152, 255}, { 0, 150, 255}, { 0, 149, 255}, { 0, 147, 255},
  3556. { 0, 146, 255}, { 0, 144, 255}, { 0, 143, 255}, { 0, 141, 255}, { 0, 140, 255},
  3557. { 0, 138, 255}, { 0, 137, 255}, { 0, 135, 255}, { 0, 134, 255}, { 0, 132, 255},
  3558. { 0, 131, 255}, { 0, 129, 255}, { 0, 128, 255}, { 0, 126, 255}, { 0, 124, 255},
  3559. { 0, 123, 255}, { 0, 121, 255}, { 0, 120, 255}, { 0, 118, 255}, { 0, 117, 255},
  3560. { 0, 115, 255}, { 0, 114, 255}, { 0, 112, 255}, { 0, 111, 255}, { 0, 109, 255},
  3561. { 0, 108, 255}, { 0, 106, 255}, { 0, 105, 255}, { 0, 103, 255}, { 0, 102, 255},
  3562. { 0, 100, 255}, { 0, 99, 255}, { 0, 97, 255}, { 0, 96, 255}, { 0, 94, 255},
  3563. { 0, 93, 255}, { 0, 91, 255}, { 0, 90, 255}, { 0, 88, 255}, { 0, 87, 255},
  3564. { 0, 85, 255}, { 0, 84, 255}, { 0, 82, 255}, { 0, 81, 255}, { 0, 79, 255},
  3565. { 0, 78, 255}, { 0, 76, 255}, { 0, 75, 255}, { 0, 73, 255}, { 0, 72, 255},
  3566. { 0, 70, 255}, { 0, 69, 255}, { 0, 67, 255}, { 0, 66, 255}, { 0, 64, 255},
  3567. { 0, 63, 255}, { 0, 61, 255}, { 0, 60, 255}, { 0, 58, 255}, { 0, 57, 255},
  3568. { 0, 55, 255}, { 0, 54, 255}, { 0, 52, 255}, { 0, 51, 255}, { 0, 49, 255},
  3569. { 0, 48, 255}, { 0, 46, 255}, { 0, 45, 255}, { 0, 43, 255}, { 0, 42, 255},
  3570. { 0, 40, 255}, { 0, 39, 255}, { 0, 37, 255}, { 0, 36, 255}, { 0, 34, 255},
  3571. { 0, 33, 255}, { 0, 31, 255}, { 0, 30, 255}, { 0, 28, 255}, { 0, 26, 255},
  3572. { 0, 25, 255}, { 0, 23, 255}, { 0, 22, 255}, { 0, 20, 255}, { 0, 19, 255},
  3573. { 0, 17, 255}, { 0, 16, 255}, { 1, 15, 255}, { 1, 14, 255}, { 2, 13, 255},
  3574. { 2, 12, 255}, { 3, 11, 255}, { 3, 10, 255}, { 4, 9, 255}, { 4, 8, 255},
  3575. { 5, 7, 255}, { 5, 6, 255}, { 6, 5, 255}, { 6, 4, 255}, { 7, 3, 255},
  3576. { 7, 2, 255}, { 8, 1, 255}, { 8, 0, 255}, { 10, 0, 255}, { 11, 0, 255},
  3577. { 13, 0, 255}, { 14, 0, 255}, { 16, 0, 255}, { 17, 0, 255}, { 19, 0, 255},
  3578. { 20, 0, 255}, { 22, 0, 255}, { 23, 0, 255}, { 25, 0, 255}, { 26, 0, 255},
  3579. { 28, 0, 255}, { 29, 0, 255}, { 31, 0, 255}, { 32, 0, 255}, { 34, 0, 255},
  3580. { 35, 0, 255}, { 37, 0, 255}, { 38, 0, 255}, { 40, 0, 255}, { 41, 0, 255},
  3581. { 43, 0, 255}, { 44, 0, 255}, { 46, 0, 255}, { 47, 0, 255}, { 49, 0, 255},
  3582. { 50, 0, 255}, { 52, 0, 255}, { 53, 0, 255}, { 55, 0, 255}, { 56, 0, 255},
  3583. { 58, 0, 255}, { 59, 0, 255}, { 61, 0, 255}, { 62, 0, 255}, { 64, 0, 255},
  3584. { 65, 0, 255}, { 67, 0, 255}, { 68, 0, 255}, { 70, 0, 255}, { 72, 0, 255},
  3585. { 73, 0, 255}, { 75, 0, 255}, { 76, 0, 255}, { 78, 0, 255}, { 79, 0, 255},
  3586. { 81, 0, 255}, { 82, 0, 255}, { 84, 0, 255}, { 85, 0, 255}, { 87, 0, 255},
  3587. { 88, 0, 255}, { 90, 0, 255}, { 91, 0, 255}, { 93, 0, 255}, { 94, 0, 255},
  3588. { 96, 0, 255}, { 97, 0, 255}, { 99, 0, 255}, {100, 0, 255}, {102, 0, 255},
  3589. {103, 0, 255}, {105, 0, 255}, {106, 0, 255}, {108, 0, 255}, {109, 0, 255},
  3590. {111, 0, 255}, {112, 0, 255}, {114, 0, 255}, {115, 0, 255}, {117, 0, 255},
  3591. {118, 0, 255}, {120, 0, 255}, {121, 0, 255}, {123, 0, 255}, {124, 0, 255},
  3592. {126, 0, 255}, {127, 0, 255}, {129, 0, 255}, {130, 0, 255}, {132, 0, 255},
  3593. {133, 0, 255}, {135, 0, 255}, {136, 0, 255}, {138, 0, 255}, {139, 0, 255},
  3594. {141, 0, 255}, {142, 0, 255}, {144, 0, 255}, {145, 0, 255}, {147, 0, 255},
  3595. {148, 0, 255}, {150, 0, 255}, {151, 0, 255}, {153, 0, 255}, {154, 0, 255},
  3596. {156, 0, 255}, {157, 0, 255}, {159, 0, 255}, {160, 0, 255}, {162, 0, 255},
  3597. {163, 0, 255}, {165, 0, 255}, {166, 0, 255}, {168, 0, 255}, {169, 0, 255},
  3598. {171, 0, 255}, {173, 0, 255}, {174, 0, 255}, {176, 0, 255}, {177, 0, 255},
  3599. {179, 0, 255}, {180, 0, 255}, {182, 0, 255}, {183, 0, 255}, {185, 0, 255},
  3600. {186, 0, 255}, {188, 0, 255}, {189, 0, 255}, {191, 0, 255}, {192, 0, 255},
  3601. {194, 0, 255}, {195, 0, 255}, {197, 0, 255}, {198, 0, 255}, {200, 0, 255},
  3602. {201, 0, 255}, {203, 0, 255}, {204, 0, 255}, {206, 0, 255}, {207, 0, 255},
  3603. {209, 0, 255}, {210, 0, 255}, {212, 0, 255}, {213, 0, 255}, {215, 0, 255},
  3604. {216, 0, 255}, {218, 0, 255}, {219, 0, 255}, {221, 0, 255}, {222, 0, 255},
  3605. {224, 0, 255}, {225, 0, 255}, {227, 0, 255}, {228, 0, 255}, {230, 0, 255},
  3606. {231, 0, 255}, {233, 0, 255}, {234, 0, 255}, {236, 0, 255}, {237, 0, 255},
  3607. {239, 0, 255}, {240, 0, 255}, {242, 0, 255}, {243, 0, 255}, {245, 0, 255},
  3608. {246, 0, 255}, {247, 0, 254}, {248, 0, 253}, {248, 0, 252}, {249, 0, 251},
  3609. {249, 0, 250}, {250, 0, 249}, {250, 0, 248}, {251, 0, 247}, {251, 0, 246},
  3610. {252, 0, 245}, {252, 0, 244}, {253, 0, 243}, {253, 0, 242}, {254, 0, 241},
  3611. {254, 0, 240}, {255, 0, 239}, {255, 0, 238}, {255, 0, 236}, {255, 0, 235},
  3612. {255, 0, 233}, {255, 0, 232}, {255, 0, 230}, {255, 0, 229}, {255, 0, 227},
  3613. {255, 0, 226}, {255, 0, 224}, {255, 0, 223}, {255, 0, 221}, {255, 0, 220},
  3614. {255, 0, 218}, {255, 0, 217}, {255, 0, 215}, {255, 0, 214}, {255, 0, 212},
  3615. {255, 0, 211}, {255, 0, 209}, {255, 0, 208}, {255, 0, 206}, {255, 0, 205},
  3616. {255, 0, 203}, {255, 0, 202}, {255, 0, 200}, {255, 0, 199}, {255, 0, 197},
  3617. {255, 0, 196}, {255, 0, 194}, {255, 0, 193}, {255, 0, 191}, {255, 0, 190},
  3618. {255, 0, 188}, {255, 0, 187}, {255, 0, 185}, {255, 0, 184}, {255, 0, 182},
  3619. {255, 0, 181}, {255, 0, 179}, {255, 0, 178}, {255, 0, 176}, {255, 0, 175},
  3620. {255, 0, 173}, {255, 0, 172}, {255, 0, 170}, {255, 0, 169}, {255, 0, 167},
  3621. {255, 0, 166}, {255, 0, 164}, {255, 0, 163}, {255, 0, 161}, {255, 0, 160},
  3622. {255, 0, 158}, {255, 0, 157}, {255, 0, 155}, {255, 0, 154}, {255, 0, 152},
  3623. {255, 0, 151}, {255, 0, 149}, {255, 0, 148}, {255, 0, 146}, {255, 0, 145},
  3624. {255, 0, 143}, {255, 0, 141}, {255, 0, 140}, {255, 0, 138}, {255, 0, 137},
  3625. {255, 0, 135}, {255, 0, 134}, {255, 0, 132}, {255, 0, 131}, {255, 0, 129},
  3626. {255, 0, 128}, {255, 0, 126}, {255, 0, 125}, {255, 0, 123}, {255, 0, 122},
  3627. {255, 0, 120}, {255, 0, 119}, {255, 0, 117}, {255, 0, 116}, {255, 0, 114},
  3628. {255, 0, 113}, {255, 0, 111}, {255, 0, 110}, {255, 0, 108}, {255, 0, 107},
  3629. {255, 0, 105}, {255, 0, 104}, {255, 0, 102}, {255, 0, 101}, {255, 0, 99},
  3630. {255, 0, 98}, {255, 0, 96}, {255, 0, 95}, {255, 0, 93}, {255, 0, 92},
  3631. {255, 0, 90}, {255, 0, 89}, {255, 0, 87}, {255, 0, 86}, {255, 0, 84},
  3632. {255, 0, 83}, {255, 0, 81}, {255, 0, 80}, {255, 0, 78}, {255, 0, 77},
  3633. {255, 0, 75}, {255, 0, 74}, {255, 0, 72}, {255, 0, 71}, {255, 0, 69},
  3634. {255, 0, 68}, {255, 0, 66}, {255, 0, 65}, {255, 0, 63}, {255, 0, 62},
  3635. {255, 0, 60}, {255, 0, 59}, {255, 0, 57}, {255, 0, 56}, {255, 0, 54},
  3636. {255, 0, 53}, {255, 0, 51}, {255, 0, 50}, {255, 0, 48}, {255, 0, 47},
  3637. {255, 0, 45}, {255, 0, 44}, {255, 0, 42}, {255, 0, 40}, {255, 0, 39},
  3638. {255, 0, 37}, {255, 0, 36}, {255, 0, 34}, {255, 0, 33}, {255, 0, 31},
  3639. {255, 0, 30}, {255, 0, 28}, {255, 0, 27}, {255, 0, 25}, {255, 0, 24}
  3640. };
  3641. const rgb_t jet_colormap[1000] = {
  3642. { 29, 0, 102}, { 23, 0, 107}, { 17, 0, 112}, { 12, 0, 117}, { 6, 0, 122},
  3643. { 0, 0, 127}, { 0, 0, 128}, { 0, 0, 129}, { 0, 0, 129}, { 0, 0, 130},
  3644. { 0, 0, 131}, { 0, 0, 132}, { 0, 0, 133}, { 0, 0, 133}, { 0, 0, 134},
  3645. { 0, 0, 135}, { 0, 0, 136}, { 0, 0, 137}, { 0, 0, 138}, { 0, 0, 140},
  3646. { 0, 0, 141}, { 0, 0, 142}, { 0, 0, 143}, { 0, 0, 145}, { 0, 0, 146},
  3647. { 0, 0, 147}, { 0, 0, 148}, { 0, 0, 150}, { 0, 0, 151}, { 0, 0, 152},
  3648. { 0, 0, 153}, { 0, 0, 154}, { 0, 0, 156}, { 0, 0, 157}, { 0, 0, 158},
  3649. { 0, 0, 159}, { 0, 0, 160}, { 0, 0, 161}, { 0, 0, 163}, { 0, 0, 164},
  3650. { 0, 0, 165}, { 0, 0, 166}, { 0, 0, 168}, { 0, 0, 169}, { 0, 0, 170},
  3651. { 0, 0, 171}, { 0, 0, 173}, { 0, 0, 174}, { 0, 0, 175}, { 0, 0, 176},
  3652. { 0, 0, 178}, { 0, 0, 179}, { 0, 0, 180}, { 0, 0, 181}, { 0, 0, 183},
  3653. { 0, 0, 184}, { 0, 0, 185}, { 0, 0, 186}, { 0, 0, 188}, { 0, 0, 189},
  3654. { 0, 0, 190}, { 0, 0, 191}, { 0, 0, 193}, { 0, 0, 194}, { 0, 0, 195},
  3655. { 0, 0, 196}, { 0, 0, 197}, { 0, 0, 198}, { 0, 0, 200}, { 0, 0, 201},
  3656. { 0, 0, 202}, { 0, 0, 203}, { 0, 0, 204}, { 0, 0, 206}, { 0, 0, 207},
  3657. { 0, 0, 208}, { 0, 0, 209}, { 0, 0, 211}, { 0, 0, 212}, { 0, 0, 213},
  3658. { 0, 0, 214}, { 0, 0, 216}, { 0, 0, 217}, { 0, 0, 218}, { 0, 0, 219},
  3659. { 0, 0, 221}, { 0, 0, 222}, { 0, 0, 223}, { 0, 0, 225}, { 0, 0, 226},
  3660. { 0, 0, 227}, { 0, 0, 228}, { 0, 0, 230}, { 0, 0, 231}, { 0, 0, 232},
  3661. { 0, 0, 233}, { 0, 0, 234}, { 0, 0, 234}, { 0, 0, 235}, { 0, 0, 236},
  3662. { 0, 0, 237}, { 0, 0, 238}, { 0, 0, 239}, { 0, 0, 239}, { 0, 0, 240},
  3663. { 0, 0, 241}, { 0, 0, 242}, { 0, 0, 243}, { 0, 0, 244}, { 0, 0, 246},
  3664. { 0, 0, 247}, { 0, 0, 248}, { 0, 0, 249}, { 0, 0, 250}, { 0, 0, 251},
  3665. { 0, 0, 253}, { 0, 0, 254}, { 0, 0, 254}, { 0, 0, 254}, { 0, 0, 254},
  3666. { 0, 0, 254}, { 0, 0, 254}, { 0, 0, 255}, { 0, 0, 255}, { 0, 0, 255},
  3667. { 0, 0, 255}, { 0, 0, 255}, { 0, 0, 255}, { 0, 1, 255}, { 0, 1, 255},
  3668. { 0, 2, 255}, { 0, 3, 255}, { 0, 3, 255}, { 0, 4, 255}, { 0, 5, 255},
  3669. { 0, 6, 255}, { 0, 6, 255}, { 0, 7, 255}, { 0, 8, 255}, { 0, 9, 255},
  3670. { 0, 10, 255}, { 0, 11, 255}, { 0, 12, 255}, { 0, 13, 255}, { 0, 14, 255},
  3671. { 0, 15, 255}, { 0, 16, 255}, { 0, 17, 255}, { 0, 18, 255}, { 0, 19, 255},
  3672. { 0, 21, 255}, { 0, 22, 255}, { 0, 23, 255}, { 0, 24, 255}, { 0, 25, 255},
  3673. { 0, 26, 255}, { 0, 27, 255}, { 0, 28, 255}, { 0, 29, 255}, { 0, 30, 255},
  3674. { 0, 31, 255}, { 0, 32, 255}, { 0, 34, 255}, { 0, 35, 255}, { 0, 36, 255},
  3675. { 0, 37, 255}, { 0, 38, 255}, { 0, 39, 255}, { 0, 40, 255}, { 0, 41, 255},
  3676. { 0, 42, 255}, { 0, 43, 255}, { 0, 44, 255}, { 0, 45, 255}, { 0, 46, 255},
  3677. { 0, 48, 255}, { 0, 49, 255}, { 0, 50, 255}, { 0, 51, 255}, { 0, 52, 255},
  3678. { 0, 53, 255}, { 0, 54, 255}, { 0, 55, 255}, { 0, 56, 255}, { 0, 57, 255},
  3679. { 0, 58, 255}, { 0, 58, 255}, { 0, 59, 255}, { 0, 60, 255}, { 0, 60, 255},
  3680. { 0, 61, 255}, { 0, 62, 255}, { 0, 63, 255}, { 0, 63, 255}, { 0, 64, 255},
  3681. { 0, 65, 255}, { 0, 66, 255}, { 0, 67, 255}, { 0, 68, 255}, { 0, 69, 255},
  3682. { 0, 71, 255}, { 0, 72, 255}, { 0, 73, 255}, { 0, 74, 255}, { 0, 75, 255},
  3683. { 0, 76, 255}, { 0, 77, 255}, { 0, 78, 255}, { 0, 79, 255}, { 0, 80, 255},
  3684. { 0, 81, 255}, { 0, 82, 255}, { 0, 84, 255}, { 0, 85, 255}, { 0, 86, 255},
  3685. { 0, 87, 255}, { 0, 88, 255}, { 0, 89, 255}, { 0, 90, 255}, { 0, 91, 255},
  3686. { 0, 92, 255}, { 0, 93, 255}, { 0, 94, 255}, { 0, 95, 255}, { 0, 96, 255},
  3687. { 0, 98, 255}, { 0, 99, 255}, { 0, 100, 255}, { 0, 101, 255}, { 0, 102, 255},
  3688. { 0, 103, 255}, { 0, 104, 255}, { 0, 105, 255}, { 0, 106, 255}, { 0, 107, 255},
  3689. { 0, 108, 255}, { 0, 109, 255}, { 0, 111, 255}, { 0, 112, 255}, { 0, 113, 255},
  3690. { 0, 114, 255}, { 0, 115, 255}, { 0, 116, 255}, { 0, 117, 255}, { 0, 118, 255},
  3691. { 0, 119, 255}, { 0, 120, 255}, { 0, 121, 255}, { 0, 122, 255}, { 0, 123, 255},
  3692. { 0, 125, 255}, { 0, 126, 255}, { 0, 127, 255}, { 0, 128, 255}, { 0, 129, 255},
  3693. { 0, 130, 255}, { 0, 131, 255}, { 0, 132, 255}, { 0, 133, 255}, { 0, 134, 255},
  3694. { 0, 135, 255}, { 0, 136, 255}, { 0, 138, 255}, { 0, 139, 255}, { 0, 140, 255},
  3695. { 0, 141, 255}, { 0, 142, 255}, { 0, 143, 255}, { 0, 144, 255}, { 0, 145, 255},
  3696. { 0, 146, 255}, { 0, 147, 255}, { 0, 148, 255}, { 0, 149, 255}, { 0, 150, 255},
  3697. { 0, 150, 255}, { 0, 151, 255}, { 0, 152, 255}, { 0, 153, 255}, { 0, 153, 255},
  3698. { 0, 154, 255}, { 0, 155, 255}, { 0, 155, 255}, { 0, 156, 255}, { 0, 157, 255},
  3699. { 0, 158, 255}, { 0, 159, 255}, { 0, 161, 255}, { 0, 162, 255}, { 0, 163, 255},
  3700. { 0, 164, 255}, { 0, 165, 255}, { 0, 166, 255}, { 0, 167, 255}, { 0, 168, 255},
  3701. { 0, 169, 255}, { 0, 170, 255}, { 0, 171, 255}, { 0, 172, 255}, { 0, 173, 255},
  3702. { 0, 175, 255}, { 0, 176, 255}, { 0, 177, 255}, { 0, 178, 255}, { 0, 179, 255},
  3703. { 0, 180, 255}, { 0, 181, 255}, { 0, 182, 255}, { 0, 183, 255}, { 0, 184, 255},
  3704. { 0, 185, 255}, { 0, 186, 255}, { 0, 188, 255}, { 0, 189, 255}, { 0, 190, 255},
  3705. { 0, 191, 255}, { 0, 192, 255}, { 0, 193, 255}, { 0, 194, 255}, { 0, 195, 255},
  3706. { 0, 196, 255}, { 0, 197, 255}, { 0, 198, 255}, { 0, 199, 255}, { 0, 200, 255},
  3707. { 0, 202, 255}, { 0, 203, 255}, { 0, 204, 255}, { 0, 205, 255}, { 0, 206, 255},
  3708. { 0, 207, 255}, { 0, 208, 255}, { 0, 209, 255}, { 0, 210, 255}, { 0, 211, 255},
  3709. { 0, 212, 255}, { 0, 213, 255}, { 0, 215, 255}, { 0, 216, 255}, { 0, 217, 255},
  3710. { 0, 218, 254}, { 0, 219, 253}, { 0, 220, 252}, { 0, 221, 252}, { 0, 222, 251},
  3711. { 0, 223, 250}, { 0, 224, 250}, { 0, 225, 249}, { 0, 226, 248}, { 0, 227, 247},
  3712. { 0, 229, 247}, { 1, 230, 246}, { 2, 231, 245}, { 3, 232, 244}, { 3, 233, 243},
  3713. { 4, 234, 242}, { 5, 235, 241}, { 5, 236, 240}, { 6, 237, 239}, { 7, 238, 238},
  3714. { 8, 239, 238}, { 8, 240, 237}, { 9, 241, 236}, { 10, 242, 236}, { 10, 242, 235},
  3715. { 11, 243, 235}, { 11, 244, 234}, { 12, 245, 234}, { 13, 245, 233}, { 13, 246, 232},
  3716. { 14, 247, 232}, { 15, 247, 231}, { 15, 248, 231}, { 16, 249, 230}, { 17, 249, 229},
  3717. { 18, 250, 228}, { 18, 251, 227}, { 19, 251, 226}, { 20, 252, 225}, { 21, 253, 224},
  3718. { 22, 253, 224}, { 23, 254, 223}, { 23, 254, 222}, { 24, 255, 221}, { 25, 255, 220},
  3719. { 26, 255, 219}, { 27, 255, 218}, { 28, 255, 218}, { 29, 255, 217}, { 30, 255, 216},
  3720. { 30, 255, 215}, { 31, 255, 214}, { 32, 255, 214}, { 33, 255, 213}, { 34, 255, 212},
  3721. { 35, 255, 211}, { 36, 255, 210}, { 37, 255, 209}, { 38, 255, 208}, { 39, 255, 207},
  3722. { 39, 255, 207}, { 40, 255, 206}, { 41, 255, 205}, { 42, 255, 204}, { 43, 255, 203},
  3723. { 44, 255, 202}, { 45, 255, 201}, { 46, 255, 200}, { 47, 255, 199}, { 48, 255, 198},
  3724. { 48, 255, 198}, { 49, 255, 197}, { 50, 255, 196}, { 51, 255, 195}, { 52, 255, 194},
  3725. { 53, 255, 193}, { 54, 255, 192}, { 55, 255, 191}, { 55, 255, 191}, { 56, 255, 190},
  3726. { 57, 255, 189}, { 58, 255, 188}, { 59, 255, 187}, { 60, 255, 186}, { 60, 255, 186},
  3727. { 61, 255, 185}, { 62, 255, 184}, { 63, 255, 183}, { 64, 255, 182}, { 65, 255, 181},
  3728. { 65, 255, 181}, { 66, 255, 180}, { 67, 255, 179}, { 68, 255, 178}, { 69, 255, 177},
  3729. { 70, 255, 176}, { 71, 255, 175}, { 72, 255, 174}, { 73, 255, 173}, { 74, 255, 172},
  3730. { 74, 255, 172}, { 75, 255, 171}, { 76, 255, 170}, { 77, 255, 169}, { 78, 255, 168},
  3731. { 79, 255, 167}, { 80, 255, 166}, { 81, 255, 165}, { 82, 255, 164}, { 83, 255, 163},
  3732. { 83, 255, 163}, { 84, 255, 162}, { 84, 255, 162}, { 85, 255, 161}, { 85, 255, 161},
  3733. { 86, 255, 160}, { 87, 255, 159}, { 87, 255, 159}, { 88, 255, 158}, { 88, 255, 158},
  3734. { 89, 255, 157}, { 89, 255, 157}, { 90, 255, 156}, { 91, 255, 155}, { 92, 255, 154},
  3735. { 93, 255, 153}, { 94, 255, 152}, { 95, 255, 151}, { 96, 255, 150}, { 97, 255, 149},
  3736. { 97, 255, 149}, { 98, 255, 148}, { 99, 255, 147}, {100, 255, 146}, {101, 255, 145},
  3737. {102, 255, 144}, {102, 255, 143}, {103, 255, 142}, {104, 255, 141}, {105, 255, 140},
  3738. {106, 255, 140}, {107, 255, 139}, {107, 255, 138}, {108, 255, 137}, {109, 255, 136},
  3739. {110, 255, 135}, {111, 255, 134}, {112, 255, 134}, {113, 255, 133}, {114, 255, 132},
  3740. {114, 255, 131}, {115, 255, 130}, {116, 255, 130}, {117, 255, 129}, {118, 255, 128},
  3741. {119, 255, 127}, {120, 255, 126}, {121, 255, 125}, {122, 255, 124}, {123, 255, 123},
  3742. {123, 255, 123}, {124, 255, 122}, {125, 255, 121}, {126, 255, 120}, {127, 255, 119},
  3743. {128, 255, 118}, {129, 255, 117}, {130, 255, 116}, {130, 255, 115}, {131, 255, 114},
  3744. {132, 255, 114}, {133, 255, 113}, {134, 255, 112}, {134, 255, 111}, {135, 255, 110},
  3745. {136, 255, 109}, {137, 255, 108}, {138, 255, 107}, {139, 255, 107}, {140, 255, 106},
  3746. {140, 255, 105}, {141, 255, 104}, {142, 255, 103}, {143, 255, 102}, {144, 255, 102},
  3747. {145, 255, 101}, {146, 255, 100}, {147, 255, 99}, {148, 255, 98}, {149, 255, 97},
  3748. {149, 255, 97}, {150, 255, 96}, {151, 255, 95}, {152, 255, 94}, {153, 255, 93},
  3749. {154, 255, 92}, {155, 255, 91}, {156, 255, 90}, {157, 255, 89}, {157, 255, 89},
  3750. {158, 255, 88}, {158, 255, 88}, {159, 255, 87}, {159, 255, 87}, {160, 255, 86},
  3751. {161, 255, 85}, {161, 255, 85}, {162, 255, 84}, {162, 255, 84}, {163, 255, 83},
  3752. {163, 255, 83}, {164, 255, 82}, {165, 255, 81}, {166, 255, 80}, {167, 255, 79},
  3753. {168, 255, 78}, {169, 255, 77}, {170, 255, 76}, {171, 255, 75}, {172, 255, 74},
  3754. {172, 255, 74}, {173, 255, 73}, {174, 255, 72}, {175, 255, 71}, {176, 255, 70},
  3755. {177, 255, 69}, {178, 255, 68}, {179, 255, 67}, {180, 255, 66}, {181, 255, 65},
  3756. {181, 255, 65}, {182, 255, 64}, {183, 255, 63}, {184, 255, 62}, {185, 255, 61},
  3757. {186, 255, 60}, {186, 255, 60}, {187, 255, 59}, {188, 255, 58}, {189, 255, 57},
  3758. {190, 255, 56}, {191, 255, 55}, {191, 255, 55}, {192, 255, 54}, {193, 255, 53},
  3759. {194, 255, 52}, {195, 255, 51}, {196, 255, 50}, {197, 255, 49}, {198, 255, 48},
  3760. {198, 255, 48}, {199, 255, 47}, {200, 255, 46}, {201, 255, 45}, {202, 255, 44},
  3761. {203, 255, 43}, {204, 255, 42}, {205, 255, 41}, {206, 255, 40}, {207, 255, 39},
  3762. {207, 255, 39}, {208, 255, 38}, {209, 255, 37}, {210, 255, 36}, {211, 255, 35},
  3763. {212, 255, 34}, {213, 255, 33}, {214, 255, 32}, {214, 255, 31}, {215, 255, 30},
  3764. {216, 255, 30}, {217, 255, 29}, {218, 255, 28}, {218, 255, 27}, {219, 255, 26},
  3765. {220, 255, 25}, {221, 255, 24}, {222, 255, 23}, {223, 255, 23}, {224, 255, 22},
  3766. {224, 255, 21}, {225, 255, 20}, {226, 255, 19}, {227, 255, 18}, {228, 255, 18},
  3767. {229, 255, 17}, {230, 255, 16}, {231, 255, 15}, {231, 255, 15}, {232, 255, 14},
  3768. {232, 255, 13}, {233, 255, 13}, {234, 255, 12}, {234, 255, 11}, {235, 255, 11},
  3769. {235, 255, 10}, {236, 255, 10}, {236, 255, 9}, {237, 255, 8}, {238, 254, 8},
  3770. {238, 253, 7}, {239, 252, 6}, {240, 251, 5}, {241, 250, 5}, {242, 249, 4},
  3771. {243, 248, 3}, {244, 247, 3}, {245, 246, 2}, {246, 246, 1}, {247, 245, 0},
  3772. {247, 243, 0}, {248, 242, 0}, {249, 242, 0}, {250, 241, 0}, {250, 240, 0},
  3773. {251, 239, 0}, {252, 238, 0}, {252, 237, 0}, {253, 236, 0}, {254, 235, 0},
  3774. {255, 234, 0}, {255, 233, 0}, {255, 232, 0}, {255, 231, 0}, {255, 230, 0},
  3775. {255, 229, 0}, {255, 228, 0}, {255, 227, 0}, {255, 226, 0}, {255, 225, 0},
  3776. {255, 224, 0}, {255, 223, 0}, {255, 222, 0}, {255, 221, 0}, {255, 220, 0},
  3777. {255, 219, 0}, {255, 218, 0}, {255, 217, 0}, {255, 216, 0}, {255, 215, 0},
  3778. {255, 214, 0}, {255, 213, 0}, {255, 212, 0}, {255, 211, 0}, {255, 210, 0},
  3779. {255, 209, 0}, {255, 208, 0}, {255, 207, 0}, {255, 206, 0}, {255, 205, 0},
  3780. {255, 204, 0}, {255, 203, 0}, {255, 202, 0}, {255, 201, 0}, {255, 200, 0},
  3781. {255, 199, 0}, {255, 198, 0}, {255, 197, 0}, {255, 196, 0}, {255, 195, 0},
  3782. {255, 194, 0}, {255, 193, 0}, {255, 192, 0}, {255, 191, 0}, {255, 190, 0},
  3783. {255, 189, 0}, {255, 188, 0}, {255, 187, 0}, {255, 186, 0}, {255, 185, 0},
  3784. {255, 184, 0}, {255, 183, 0}, {255, 182, 0}, {255, 180, 0}, {255, 179, 0},
  3785. {255, 178, 0}, {255, 177, 0}, {255, 176, 0}, {255, 176, 0}, {255, 175, 0},
  3786. {255, 175, 0}, {255, 174, 0}, {255, 173, 0}, {255, 173, 0}, {255, 172, 0},
  3787. {255, 171, 0}, {255, 171, 0}, {255, 170, 0}, {255, 169, 0}, {255, 168, 0},
  3788. {255, 167, 0}, {255, 166, 0}, {255, 165, 0}, {255, 164, 0}, {255, 163, 0},
  3789. {255, 162, 0}, {255, 161, 0}, {255, 160, 0}, {255, 159, 0}, {255, 158, 0},
  3790. {255, 157, 0}, {255, 156, 0}, {255, 155, 0}, {255, 154, 0}, {255, 153, 0},
  3791. {255, 152, 0}, {255, 151, 0}, {255, 150, 0}, {255, 150, 0}, {255, 149, 0},
  3792. {255, 147, 0}, {255, 146, 0}, {255, 146, 0}, {255, 145, 0}, {255, 144, 0},
  3793. {255, 143, 0}, {255, 142, 0}, {255, 141, 0}, {255, 140, 0}, {255, 139, 0},
  3794. {255, 138, 0}, {255, 137, 0}, {255, 136, 0}, {255, 135, 0}, {255, 134, 0},
  3795. {255, 133, 0}, {255, 132, 0}, {255, 131, 0}, {255, 130, 0}, {255, 129, 0},
  3796. {255, 128, 0}, {255, 127, 0}, {255, 126, 0}, {255, 125, 0}, {255, 124, 0},
  3797. {255, 123, 0}, {255, 122, 0}, {255, 121, 0}, {255, 120, 0}, {255, 119, 0},
  3798. {255, 118, 0}, {255, 117, 0}, {255, 116, 0}, {255, 115, 0}, {255, 114, 0},
  3799. {255, 113, 0}, {255, 112, 0}, {255, 111, 0}, {255, 109, 0}, {255, 108, 0},
  3800. {255, 107, 0}, {255, 106, 0}, {255, 105, 0}, {255, 104, 0}, {255, 103, 0},
  3801. {255, 102, 0}, {255, 101, 0}, {255, 100, 0}, {255, 99, 0}, {255, 98, 0},
  3802. {255, 97, 0}, {255, 96, 0}, {255, 95, 0}, {255, 94, 0}, {255, 93, 0},
  3803. {255, 92, 0}, {255, 91, 0}, {255, 91, 0}, {255, 90, 0}, {255, 90, 0},
  3804. {255, 89, 0}, {255, 88, 0}, {255, 88, 0}, {255, 87, 0}, {255, 86, 0},
  3805. {255, 86, 0}, {255, 85, 0}, {255, 84, 0}, {255, 83, 0}, {255, 82, 0},
  3806. {255, 81, 0}, {255, 80, 0}, {255, 79, 0}, {255, 78, 0}, {255, 77, 0},
  3807. {255, 76, 0}, {255, 75, 0}, {255, 74, 0}, {255, 73, 0}, {255, 72, 0},
  3808. {255, 71, 0}, {255, 70, 0}, {255, 69, 0}, {255, 68, 0}, {255, 67, 0},
  3809. {255, 66, 0}, {255, 65, 0}, {255, 64, 0}, {255, 63, 0}, {255, 62, 0},
  3810. {255, 61, 0}, {255, 60, 0}, {255, 59, 0}, {255, 58, 0}, {255, 57, 0},
  3811. {255, 56, 0}, {255, 55, 0}, {255, 54, 0}, {255, 54, 0}, {255, 53, 0},
  3812. {255, 51, 0}, {255, 50, 0}, {255, 49, 0}, {255, 48, 0}, {255, 47, 0},
  3813. {255, 46, 0}, {255, 45, 0}, {255, 44, 0}, {255, 43, 0}, {255, 42, 0},
  3814. {255, 41, 0}, {255, 40, 0}, {255, 39, 0}, {255, 38, 0}, {255, 37, 0},
  3815. {255, 36, 0}, {255, 35, 0}, {255, 34, 0}, {255, 33, 0}, {255, 32, 0},
  3816. {255, 31, 0}, {255, 30, 0}, {255, 29, 0}, {255, 28, 0}, {255, 27, 0},
  3817. {255, 26, 0}, {255, 25, 0}, {255, 24, 0}, {254, 23, 0}, {254, 22, 0},
  3818. {254, 21, 0}, {254, 20, 0}, {254, 19, 0}, {254, 18, 0}, {253, 17, 0},
  3819. {251, 16, 0}, {250, 15, 0}, {249, 14, 0}, {248, 13, 0}, {247, 12, 0},
  3820. {246, 11, 0}, {244, 10, 0}, {243, 9, 0}, {242, 8, 0}, {241, 7, 0},
  3821. {240, 6, 0}, {239, 6, 0}, {239, 5, 0}, {238, 4, 0}, {237, 4, 0},
  3822. {236, 3, 0}, {235, 3, 0}, {234, 2, 0}, {234, 1, 0}, {233, 1, 0},
  3823. {232, 0, 0}, {231, 0, 0}, {230, 0, 0}, {228, 0, 0}, {227, 0, 0},
  3824. {226, 0, 0}, {225, 0, 0}, {223, 0, 0}, {222, 0, 0}, {221, 0, 0},
  3825. {219, 0, 0}, {218, 0, 0}, {217, 0, 0}, {216, 0, 0}, {214, 0, 0},
  3826. {213, 0, 0}, {212, 0, 0}, {211, 0, 0}, {209, 0, 0}, {208, 0, 0},
  3827. {207, 0, 0}, {206, 0, 0}, {204, 0, 0}, {203, 0, 0}, {202, 0, 0},
  3828. {201, 0, 0}, {200, 0, 0}, {198, 0, 0}, {197, 0, 0}, {196, 0, 0},
  3829. {195, 0, 0}, {194, 0, 0}, {193, 0, 0}, {191, 0, 0}, {190, 0, 0},
  3830. {189, 0, 0}, {188, 0, 0}, {186, 0, 0}, {185, 0, 0}, {184, 0, 0},
  3831. {183, 0, 0}, {181, 0, 0}, {180, 0, 0}, {179, 0, 0}, {178, 0, 0},
  3832. {176, 0, 0}, {175, 0, 0}, {174, 0, 0}, {173, 0, 0}, {171, 0, 0},
  3833. {170, 0, 0}, {169, 0, 0}, {168, 0, 0}, {166, 0, 0}, {165, 0, 0},
  3834. {164, 0, 0}, {163, 0, 0}, {161, 0, 0}, {160, 0, 0}, {159, 0, 0},
  3835. {158, 0, 0}, {157, 0, 0}, {156, 0, 0}, {154, 0, 0}, {153, 0, 0},
  3836. {152, 0, 0}, {151, 0, 0}, {150, 0, 0}, {148, 0, 0}, {147, 0, 0},
  3837. {146, 0, 0}, {145, 0, 0}, {143, 0, 0}, {142, 0, 0}, {141, 0, 0},
  3838. {140, 0, 0}, {138, 0, 0}, {137, 0, 0}, {136, 0, 0}, {135, 0, 0},
  3839. {134, 0, 0}, {133, 0, 0}, {133, 0, 0}, {132, 0, 0}, {131, 0, 0},
  3840. {130, 0, 0}, {129, 0, 0}, {129, 0, 0}, {128, 0, 0}, {127, 0, 0},
  3841. {122, 0, 9}, {117, 0, 18}, {112, 0, 27}, {107, 0, 36}, {102, 0, 45}
  3842. };
  3843. const rgb_t prism_colormap[1000] = {
  3844. {255, 0, 0}, {255, 2, 0}, {255, 4, 0}, {255, 6, 0}, {255, 8, 0},
  3845. {255, 10, 0}, {255, 11, 0}, {255, 13, 0}, {255, 15, 0}, {255, 17, 0},
  3846. {255, 19, 0}, {255, 21, 0}, {255, 23, 0}, {255, 25, 0}, {255, 27, 0},
  3847. {255, 29, 0}, {255, 31, 0}, {255, 33, 0}, {255, 34, 0}, {255, 36, 0},
  3848. {255, 38, 0}, {255, 40, 0}, {255, 42, 0}, {255, 44, 0}, {255, 46, 0},
  3849. {255, 48, 0}, {255, 50, 0}, {255, 52, 0}, {255, 54, 0}, {255, 56, 0},
  3850. {255, 57, 0}, {255, 59, 0}, {255, 61, 0}, {255, 63, 0}, {255, 65, 0},
  3851. {255, 67, 0}, {255, 69, 0}, {255, 71, 0}, {255, 73, 0}, {255, 75, 0},
  3852. {255, 77, 0}, {255, 78, 0}, {255, 80, 0}, {255, 82, 0}, {255, 84, 0},
  3853. {255, 86, 0}, {255, 88, 0}, {255, 90, 0}, {255, 92, 0}, {255, 94, 0},
  3854. {255, 96, 0}, {255, 98, 0}, {255, 100, 0}, {255, 101, 0}, {255, 103, 0},
  3855. {255, 105, 0}, {255, 107, 0}, {255, 109, 0}, {255, 111, 0}, {255, 113, 0},
  3856. {255, 115, 0}, {255, 117, 0}, {255, 119, 0}, {255, 121, 0}, {255, 123, 0},
  3857. {255, 124, 0}, {255, 126, 0}, {255, 128, 0}, {255, 130, 0}, {255, 132, 0},
  3858. {255, 134, 0}, {255, 136, 0}, {255, 138, 0}, {255, 140, 0}, {255, 142, 0},
  3859. {255, 144, 0}, {255, 145, 0}, {255, 147, 0}, {255, 149, 0}, {255, 151, 0},
  3860. {255, 153, 0}, {255, 155, 0}, {255, 157, 0}, {255, 159, 0}, {255, 161, 0},
  3861. {255, 163, 0}, {255, 165, 0}, {255, 167, 0}, {255, 168, 0}, {255, 170, 0},
  3862. {255, 172, 0}, {255, 174, 0}, {255, 176, 0}, {255, 178, 0}, {255, 180, 0},
  3863. {255, 182, 0}, {255, 184, 0}, {255, 186, 0}, {255, 188, 0}, {255, 190, 0},
  3864. {255, 191, 0}, {255, 193, 0}, {255, 195, 0}, {255, 197, 0}, {255, 199, 0},
  3865. {255, 201, 0}, {255, 203, 0}, {255, 205, 0}, {255, 207, 0}, {255, 209, 0},
  3866. {255, 211, 0}, {255, 212, 0}, {255, 214, 0}, {255, 216, 0}, {255, 218, 0},
  3867. {255, 220, 0}, {255, 222, 0}, {255, 224, 0}, {255, 226, 0}, {255, 228, 0},
  3868. {255, 230, 0}, {255, 232, 0}, {255, 234, 0}, {255, 235, 0}, {255, 237, 0},
  3869. {255, 239, 0}, {255, 241, 0}, {255, 243, 0}, {255, 245, 0}, {255, 247, 0},
  3870. {255, 249, 0}, {255, 251, 0}, {255, 253, 0}, {255, 255, 0}, {252, 255, 0},
  3871. {248, 255, 0}, {244, 255, 0}, {240, 255, 0}, {237, 255, 0}, {233, 255, 0},
  3872. {229, 255, 0}, {225, 255, 0}, {221, 255, 0}, {217, 255, 0}, {214, 255, 0},
  3873. {210, 255, 0}, {206, 255, 0}, {202, 255, 0}, {198, 255, 0}, {195, 255, 0},
  3874. {191, 255, 0}, {187, 255, 0}, {183, 255, 0}, {179, 255, 0}, {175, 255, 0},
  3875. {172, 255, 0}, {168, 255, 0}, {164, 255, 0}, {160, 255, 0}, {156, 255, 0},
  3876. {152, 255, 0}, {149, 255, 0}, {145, 255, 0}, {141, 255, 0}, {137, 255, 0},
  3877. {133, 255, 0}, {129, 255, 0}, {126, 255, 0}, {122, 255, 0}, {118, 255, 0},
  3878. {114, 255, 0}, {110, 255, 0}, {106, 255, 0}, {103, 255, 0}, { 99, 255, 0},
  3879. { 95, 255, 0}, { 91, 255, 0}, { 87, 255, 0}, { 83, 255, 0}, { 80, 255, 0},
  3880. { 76, 255, 0}, { 72, 255, 0}, { 68, 255, 0}, { 64, 255, 0}, { 60, 255, 0},
  3881. { 57, 255, 0}, { 53, 255, 0}, { 49, 255, 0}, { 45, 255, 0}, { 41, 255, 0},
  3882. { 38, 255, 0}, { 34, 255, 0}, { 30, 255, 0}, { 26, 255, 0}, { 22, 255, 0},
  3883. { 18, 255, 0}, { 15, 255, 0}, { 11, 255, 0}, { 7, 255, 0}, { 3, 255, 0},
  3884. { 0, 254, 1}, { 0, 250, 5}, { 0, 247, 8}, { 0, 243, 12}, { 0, 239, 16},
  3885. { 0, 235, 20}, { 0, 231, 24}, { 0, 227, 28}, { 0, 224, 31}, { 0, 220, 35},
  3886. { 0, 216, 39}, { 0, 212, 43}, { 0, 208, 47}, { 0, 204, 51}, { 0, 201, 54},
  3887. { 0, 197, 58}, { 0, 193, 62}, { 0, 189, 66}, { 0, 185, 70}, { 0, 181, 74},
  3888. { 0, 178, 77}, { 0, 174, 81}, { 0, 170, 85}, { 0, 166, 89}, { 0, 162, 93},
  3889. { 0, 159, 96}, { 0, 155, 100}, { 0, 151, 104}, { 0, 147, 108}, { 0, 143, 112},
  3890. { 0, 139, 116}, { 0, 136, 119}, { 0, 132, 123}, { 0, 128, 127}, { 0, 124, 131},
  3891. { 0, 120, 135}, { 0, 116, 139}, { 0, 113, 142}, { 0, 109, 146}, { 0, 105, 150},
  3892. { 0, 101, 154}, { 0, 97, 158}, { 0, 93, 162}, { 0, 90, 165}, { 0, 86, 169},
  3893. { 0, 82, 173}, { 0, 78, 177}, { 0, 74, 181}, { 0, 70, 185}, { 0, 67, 188},
  3894. { 0, 63, 192}, { 0, 59, 196}, { 0, 55, 200}, { 0, 51, 204}, { 0, 47, 208},
  3895. { 0, 44, 211}, { 0, 40, 215}, { 0, 36, 219}, { 0, 32, 223}, { 0, 28, 227},
  3896. { 0, 25, 230}, { 0, 21, 234}, { 0, 17, 238}, { 0, 13, 242}, { 0, 9, 246},
  3897. { 0, 5, 250}, { 0, 2, 253}, { 2, 0, 255}, { 4, 0, 255}, { 7, 0, 255},
  3898. { 9, 0, 255}, { 12, 0, 255}, { 14, 0, 255}, { 17, 0, 255}, { 19, 0, 255},
  3899. { 22, 0, 255}, { 25, 0, 255}, { 27, 0, 255}, { 30, 0, 255}, { 32, 0, 255},
  3900. { 35, 0, 255}, { 37, 0, 255}, { 40, 0, 255}, { 42, 0, 255}, { 45, 0, 255},
  3901. { 47, 0, 255}, { 50, 0, 255}, { 53, 0, 255}, { 55, 0, 255}, { 58, 0, 255},
  3902. { 60, 0, 255}, { 63, 0, 255}, { 65, 0, 255}, { 68, 0, 255}, { 70, 0, 255},
  3903. { 73, 0, 255}, { 76, 0, 255}, { 78, 0, 255}, { 81, 0, 255}, { 83, 0, 255},
  3904. { 86, 0, 255}, { 88, 0, 255}, { 91, 0, 255}, { 93, 0, 255}, { 96, 0, 255},
  3905. { 99, 0, 255}, {101, 0, 255}, {104, 0, 255}, {106, 0, 255}, {109, 0, 255},
  3906. {111, 0, 255}, {114, 0, 255}, {116, 0, 255}, {119, 0, 255}, {122, 0, 255},
  3907. {124, 0, 255}, {127, 0, 255}, {129, 0, 255}, {132, 0, 255}, {134, 0, 255},
  3908. {137, 0, 255}, {139, 0, 255}, {142, 0, 255}, {144, 0, 255}, {147, 0, 255},
  3909. {150, 0, 255}, {152, 0, 255}, {155, 0, 255}, {157, 0, 255}, {160, 0, 255},
  3910. {162, 0, 255}, {165, 0, 255}, {167, 0, 255}, {170, 0, 255}, {171, 0, 251},
  3911. {173, 0, 247}, {174, 0, 244}, {175, 0, 240}, {176, 0, 236}, {178, 0, 232},
  3912. {179, 0, 228}, {180, 0, 224}, {181, 0, 221}, {183, 0, 217}, {184, 0, 213},
  3913. {185, 0, 209}, {187, 0, 205}, {188, 0, 201}, {189, 0, 198}, {190, 0, 194},
  3914. {192, 0, 190}, {193, 0, 186}, {194, 0, 182}, {196, 0, 178}, {197, 0, 175},
  3915. {198, 0, 171}, {199, 0, 167}, {201, 0, 163}, {202, 0, 159}, {203, 0, 155},
  3916. {204, 0, 152}, {206, 0, 148}, {207, 0, 144}, {208, 0, 140}, {210, 0, 136},
  3917. {211, 0, 132}, {212, 0, 129}, {213, 0, 125}, {215, 0, 121}, {216, 0, 117},
  3918. {217, 0, 113}, {218, 0, 110}, {220, 0, 106}, {221, 0, 102}, {222, 0, 98},
  3919. {224, 0, 94}, {225, 0, 90}, {226, 0, 87}, {227, 0, 83}, {229, 0, 79},
  3920. {230, 0, 75}, {231, 0, 71}, {233, 0, 67}, {234, 0, 64}, {235, 0, 60},
  3921. {236, 0, 56}, {238, 0, 52}, {239, 0, 48}, {240, 0, 44}, {241, 0, 41},
  3922. {243, 0, 37}, {244, 0, 33}, {245, 0, 29}, {247, 0, 25}, {248, 0, 21},
  3923. {249, 0, 18}, {250, 0, 14}, {252, 0, 10}, {253, 0, 6}, {254, 0, 2},
  3924. {255, 1, 0}, {255, 3, 0}, {255, 5, 0}, {255, 7, 0}, {255, 8, 0},
  3925. {255, 10, 0}, {255, 12, 0}, {255, 14, 0}, {255, 16, 0}, {255, 18, 0},
  3926. {255, 20, 0}, {255, 22, 0}, {255, 24, 0}, {255, 26, 0}, {255, 28, 0},
  3927. {255, 29, 0}, {255, 31, 0}, {255, 33, 0}, {255, 35, 0}, {255, 37, 0},
  3928. {255, 39, 0}, {255, 41, 0}, {255, 43, 0}, {255, 45, 0}, {255, 47, 0},
  3929. {255, 49, 0}, {255, 51, 0}, {255, 52, 0}, {255, 54, 0}, {255, 56, 0},
  3930. {255, 58, 0}, {255, 60, 0}, {255, 62, 0}, {255, 64, 0}, {255, 66, 0},
  3931. {255, 68, 0}, {255, 70, 0}, {255, 72, 0}, {255, 74, 0}, {255, 75, 0},
  3932. {255, 77, 0}, {255, 79, 0}, {255, 81, 0}, {255, 83, 0}, {255, 85, 0},
  3933. {255, 87, 0}, {255, 89, 0}, {255, 91, 0}, {255, 93, 0}, {255, 95, 0},
  3934. {255, 96, 0}, {255, 98, 0}, {255, 100, 0}, {255, 102, 0}, {255, 104, 0},
  3935. {255, 106, 0}, {255, 108, 0}, {255, 110, 0}, {255, 112, 0}, {255, 114, 0},
  3936. {255, 116, 0}, {255, 118, 0}, {255, 119, 0}, {255, 121, 0}, {255, 123, 0},
  3937. {255, 125, 0}, {255, 127, 0}, {255, 129, 0}, {255, 131, 0}, {255, 133, 0},
  3938. {255, 135, 0}, {255, 137, 0}, {255, 139, 0}, {255, 141, 0}, {255, 142, 0},
  3939. {255, 144, 0}, {255, 146, 0}, {255, 148, 0}, {255, 150, 0}, {255, 152, 0},
  3940. {255, 154, 0}, {255, 156, 0}, {255, 158, 0}, {255, 160, 0}, {255, 162, 0},
  3941. {255, 163, 0}, {255, 165, 0}, {255, 167, 0}, {255, 169, 0}, {255, 171, 0},
  3942. {255, 173, 0}, {255, 175, 0}, {255, 177, 0}, {255, 179, 0}, {255, 181, 0},
  3943. {255, 183, 0}, {255, 185, 0}, {255, 186, 0}, {255, 188, 0}, {255, 190, 0},
  3944. {255, 192, 0}, {255, 194, 0}, {255, 196, 0}, {255, 198, 0}, {255, 200, 0},
  3945. {255, 202, 0}, {255, 204, 0}, {255, 206, 0}, {255, 208, 0}, {255, 209, 0},
  3946. {255, 211, 0}, {255, 213, 0}, {255, 215, 0}, {255, 217, 0}, {255, 219, 0},
  3947. {255, 221, 0}, {255, 223, 0}, {255, 225, 0}, {255, 227, 0}, {255, 229, 0},
  3948. {255, 230, 0}, {255, 232, 0}, {255, 234, 0}, {255, 236, 0}, {255, 238, 0},
  3949. {255, 240, 0}, {255, 242, 0}, {255, 244, 0}, {255, 246, 0}, {255, 248, 0},
  3950. {255, 250, 0}, {255, 252, 0}, {255, 253, 0}, {254, 255, 0}, {250, 255, 0},
  3951. {247, 255, 0}, {243, 255, 0}, {239, 255, 0}, {235, 255, 0}, {231, 255, 0},
  3952. {227, 255, 0}, {224, 255, 0}, {220, 255, 0}, {216, 255, 0}, {212, 255, 0},
  3953. {208, 255, 0}, {204, 255, 0}, {201, 255, 0}, {197, 255, 0}, {193, 255, 0},
  3954. {189, 255, 0}, {185, 255, 0}, {181, 255, 0}, {178, 255, 0}, {174, 255, 0},
  3955. {170, 255, 0}, {166, 255, 0}, {162, 255, 0}, {159, 255, 0}, {155, 255, 0},
  3956. {151, 255, 0}, {147, 255, 0}, {143, 255, 0}, {139, 255, 0}, {136, 255, 0},
  3957. {132, 255, 0}, {128, 255, 0}, {124, 255, 0}, {120, 255, 0}, {116, 255, 0},
  3958. {113, 255, 0}, {109, 255, 0}, {105, 255, 0}, {101, 255, 0}, { 97, 255, 0},
  3959. { 93, 255, 0}, { 90, 255, 0}, { 86, 255, 0}, { 82, 255, 0}, { 78, 255, 0},
  3960. { 74, 255, 0}, { 70, 255, 0}, { 67, 255, 0}, { 63, 255, 0}, { 59, 255, 0},
  3961. { 55, 255, 0}, { 51, 255, 0}, { 47, 255, 0}, { 44, 255, 0}, { 40, 255, 0},
  3962. { 36, 255, 0}, { 32, 255, 0}, { 28, 255, 0}, { 25, 255, 0}, { 21, 255, 0},
  3963. { 17, 255, 0}, { 13, 255, 0}, { 9, 255, 0}, { 5, 255, 0}, { 2, 255, 0},
  3964. { 0, 253, 2}, { 0, 249, 6}, { 0, 245, 10}, { 0, 241, 14}, { 0, 237, 18},
  3965. { 0, 234, 21}, { 0, 230, 25}, { 0, 226, 29}, { 0, 222, 33}, { 0, 218, 37},
  3966. { 0, 214, 41}, { 0, 211, 44}, { 0, 207, 48}, { 0, 203, 52}, { 0, 199, 56},
  3967. { 0, 195, 60}, { 0, 191, 64}, { 0, 188, 67}, { 0, 184, 71}, { 0, 180, 75},
  3968. { 0, 176, 79}, { 0, 172, 83}, { 0, 168, 87}, { 0, 165, 90}, { 0, 161, 94},
  3969. { 0, 157, 98}, { 0, 153, 102}, { 0, 149, 106}, { 0, 145, 110}, { 0, 142, 113},
  3970. { 0, 138, 117}, { 0, 134, 121}, { 0, 130, 125}, { 0, 126, 129}, { 0, 123, 132},
  3971. { 0, 119, 136}, { 0, 115, 140}, { 0, 111, 144}, { 0, 107, 148}, { 0, 103, 152},
  3972. { 0, 100, 155}, { 0, 96, 159}, { 0, 92, 163}, { 0, 88, 167}, { 0, 84, 171},
  3973. { 0, 80, 175}, { 0, 77, 178}, { 0, 73, 182}, { 0, 69, 186}, { 0, 65, 190},
  3974. { 0, 61, 194}, { 0, 57, 198}, { 0, 54, 201}, { 0, 50, 205}, { 0, 46, 209},
  3975. { 0, 42, 213}, { 0, 38, 217}, { 0, 34, 221}, { 0, 31, 224}, { 0, 27, 228},
  3976. { 0, 23, 232}, { 0, 19, 236}, { 0, 15, 240}, { 0, 11, 244}, { 0, 8, 247},
  3977. { 0, 4, 251}, { 0, 0, 255}, { 3, 0, 255}, { 5, 0, 255}, { 8, 0, 255},
  3978. { 10, 0, 255}, { 13, 0, 255}, { 15, 0, 255}, { 18, 0, 255}, { 20, 0, 255},
  3979. { 23, 0, 255}, { 26, 0, 255}, { 28, 0, 255}, { 31, 0, 255}, { 33, 0, 255},
  3980. { 36, 0, 255}, { 38, 0, 255}, { 41, 0, 255}, { 43, 0, 255}, { 46, 0, 255},
  3981. { 48, 0, 255}, { 51, 0, 255}, { 54, 0, 255}, { 56, 0, 255}, { 59, 0, 255},
  3982. { 61, 0, 255}, { 64, 0, 255}, { 66, 0, 255}, { 69, 0, 255}, { 71, 0, 255},
  3983. { 74, 0, 255}, { 77, 0, 255}, { 79, 0, 255}, { 82, 0, 255}, { 84, 0, 255},
  3984. { 87, 0, 255}, { 89, 0, 255}, { 92, 0, 255}, { 94, 0, 255}, { 97, 0, 255},
  3985. {100, 0, 255}, {102, 0, 255}, {105, 0, 255}, {107, 0, 255}, {110, 0, 255},
  3986. {112, 0, 255}, {115, 0, 255}, {117, 0, 255}, {120, 0, 255}, {123, 0, 255},
  3987. {125, 0, 255}, {128, 0, 255}, {130, 0, 255}, {133, 0, 255}, {135, 0, 255},
  3988. {138, 0, 255}, {140, 0, 255}, {143, 0, 255}, {145, 0, 255}, {148, 0, 255},
  3989. {151, 0, 255}, {153, 0, 255}, {156, 0, 255}, {158, 0, 255}, {161, 0, 255},
  3990. {163, 0, 255}, {166, 0, 255}, {168, 0, 255}, {171, 0, 253}, {172, 0, 250},
  3991. {173, 0, 246}, {174, 0, 242}, {176, 0, 238}, {177, 0, 234}, {178, 0, 230},
  3992. {179, 0, 227}, {181, 0, 223}, {182, 0, 219}, {183, 0, 215}, {185, 0, 211},
  3993. {186, 0, 208}, {187, 0, 204}, {188, 0, 200}, {190, 0, 196}, {191, 0, 192},
  3994. {192, 0, 188}, {193, 0, 185}, {195, 0, 181}, {196, 0, 177}, {197, 0, 173},
  3995. {199, 0, 169}, {200, 0, 165}, {201, 0, 162}, {202, 0, 158}, {204, 0, 154},
  3996. {205, 0, 150}, {206, 0, 146}, {208, 0, 142}, {209, 0, 139}, {210, 0, 135},
  3997. {211, 0, 131}, {213, 0, 127}, {214, 0, 123}, {215, 0, 119}, {216, 0, 116},
  3998. {218, 0, 112}, {219, 0, 108}, {220, 0, 104}, {222, 0, 100}, {223, 0, 96},
  3999. {224, 0, 93}, {225, 0, 89}, {227, 0, 85}, {228, 0, 81}, {229, 0, 77},
  4000. {230, 0, 74}, {232, 0, 70}, {233, 0, 66}, {234, 0, 62}, {236, 0, 58},
  4001. {237, 0, 54}, {238, 0, 51}, {239, 0, 47}, {241, 0, 43}, {242, 0, 39},
  4002. {243, 0, 35}, {245, 0, 31}, {246, 0, 28}, {247, 0, 24}, {248, 0, 20},
  4003. {250, 0, 16}, {251, 0, 12}, {252, 0, 8}, {253, 0, 5}, {255, 0, 1},
  4004. {255, 2, 0}, {255, 3, 0}, {255, 5, 0}, {255, 7, 0}, {255, 9, 0},
  4005. {255, 11, 0}, {255, 13, 0}, {255, 15, 0}, {255, 17, 0}, {255, 19, 0},
  4006. {255, 21, 0}, {255, 23, 0}, {255, 25, 0}, {255, 26, 0}, {255, 28, 0},
  4007. {255, 30, 0}, {255, 32, 0}, {255, 34, 0}, {255, 36, 0}, {255, 38, 0},
  4008. {255, 40, 0}, {255, 42, 0}, {255, 44, 0}, {255, 46, 0}, {255, 47, 0},
  4009. {255, 49, 0}, {255, 51, 0}, {255, 53, 0}, {255, 55, 0}, {255, 57, 0},
  4010. {255, 59, 0}, {255, 61, 0}, {255, 63, 0}, {255, 65, 0}, {255, 67, 0},
  4011. {255, 69, 0}, {255, 70, 0}, {255, 72, 0}, {255, 74, 0}, {255, 76, 0},
  4012. {255, 78, 0}, {255, 80, 0}, {255, 82, 0}, {255, 84, 0}, {255, 86, 0},
  4013. {255, 88, 0}, {255, 90, 0}, {255, 92, 0}, {255, 93, 0}, {255, 95, 0},
  4014. {255, 97, 0}, {255, 99, 0}, {255, 101, 0}, {255, 103, 0}, {255, 105, 0},
  4015. {255, 107, 0}, {255, 109, 0}, {255, 111, 0}, {255, 113, 0}, {255, 114, 0},
  4016. {255, 116, 0}, {255, 118, 0}, {255, 120, 0}, {255, 122, 0}, {255, 124, 0},
  4017. {255, 126, 0}, {255, 128, 0}, {255, 130, 0}, {255, 132, 0}, {255, 134, 0},
  4018. {255, 136, 0}, {255, 137, 0}, {255, 139, 0}, {255, 141, 0}, {255, 143, 0},
  4019. {255, 145, 0}, {255, 147, 0}, {255, 149, 0}, {255, 151, 0}, {255, 153, 0},
  4020. {255, 155, 0}, {255, 157, 0}, {255, 159, 0}, {255, 160, 0}, {255, 162, 0},
  4021. {255, 164, 0}, {255, 166, 0}, {255, 168, 0}, {255, 170, 0}, {255, 172, 0},
  4022. {255, 174, 0}, {255, 176, 0}, {255, 178, 0}, {255, 180, 0}, {255, 181, 0},
  4023. {255, 183, 0}, {255, 185, 0}, {255, 187, 0}, {255, 189, 0}, {255, 191, 0},
  4024. {255, 193, 0}, {255, 195, 0}, {255, 197, 0}, {255, 199, 0}, {255, 201, 0},
  4025. {255, 203, 0}, {255, 204, 0}, {255, 206, 0}, {255, 208, 0}, {255, 210, 0},
  4026. {255, 212, 0}, {255, 214, 0}, {255, 216, 0}, {255, 218, 0}, {255, 220, 0},
  4027. {255, 222, 0}, {255, 224, 0}, {255, 226, 0}, {255, 227, 0}, {255, 229, 0},
  4028. {255, 231, 0}, {255, 233, 0}, {255, 235, 0}, {255, 237, 0}, {255, 239, 0},
  4029. {255, 241, 0}, {255, 243, 0}, {255, 245, 0}, {255, 247, 0}, {255, 248, 0},
  4030. {255, 250, 0}, {255, 252, 0}, {255, 254, 0}, {253, 255, 0}, {249, 255, 0},
  4031. {245, 255, 0}, {241, 255, 0}, {237, 255, 0}, {234, 255, 0}, {230, 255, 0},
  4032. {226, 255, 0}, {222, 255, 0}, {218, 255, 0}, {214, 255, 0}, {211, 255, 0},
  4033. {207, 255, 0}, {203, 255, 0}, {199, 255, 0}, {195, 255, 0}, {191, 255, 0},
  4034. {188, 255, 0}, {184, 255, 0}, {180, 255, 0}, {176, 255, 0}, {172, 255, 0},
  4035. {168, 255, 0}, {165, 255, 0}, {161, 255, 0}, {157, 255, 0}, {153, 255, 0},
  4036. {149, 255, 0}, {145, 255, 0}, {142, 255, 0}, {138, 255, 0}, {134, 255, 0},
  4037. {130, 255, 0}, {126, 255, 0}, {123, 255, 0}, {119, 255, 0}, {115, 255, 0},
  4038. {111, 255, 0}, {107, 255, 0}, {103, 255, 0}, {100, 255, 0}, { 96, 255, 0},
  4039. { 92, 255, 0}, { 88, 255, 0}, { 84, 255, 0}, { 80, 255, 0}, { 77, 255, 0},
  4040. { 73, 255, 0}, { 69, 255, 0}, { 65, 255, 0}, { 61, 255, 0}, { 57, 255, 0},
  4041. { 54, 255, 0}, { 50, 255, 0}, { 46, 255, 0}, { 42, 255, 0}, { 38, 255, 0},
  4042. { 34, 255, 0}, { 31, 255, 0}, { 27, 255, 0}, { 23, 255, 0}, { 19, 255, 0},
  4043. { 15, 255, 0}, { 11, 255, 0}, { 8, 255, 0}, { 4, 255, 0}, { 0, 255, 0}
  4044. };
  4045. const rgb_t vga_colormap[1000] = {
  4046. {255, 255, 255}, {254, 254, 254}, {253, 253, 253}, {252, 252, 252}, {251, 251, 251},
  4047. {250, 250, 250}, {249, 249, 249}, {248, 248, 248}, {247, 247, 247}, {246, 246, 246},
  4048. {245, 245, 245}, {244, 244, 244}, {244, 244, 244}, {243, 243, 243}, {242, 242, 242},
  4049. {241, 241, 241}, {240, 240, 240}, {239, 239, 239}, {238, 238, 238}, {237, 237, 237},
  4050. {236, 236, 236}, {235, 235, 235}, {234, 234, 234}, {233, 233, 233}, {232, 232, 232},
  4051. {231, 231, 231}, {230, 230, 230}, {229, 229, 229}, {228, 228, 228}, {227, 227, 227},
  4052. {226, 226, 226}, {225, 225, 225}, {224, 224, 224}, {223, 223, 223}, {222, 222, 222},
  4053. {221, 221, 221}, {221, 221, 221}, {220, 220, 220}, {219, 219, 219}, {218, 218, 218},
  4054. {217, 217, 217}, {216, 216, 216}, {215, 215, 215}, {214, 214, 214}, {213, 213, 213},
  4055. {212, 212, 212}, {211, 211, 211}, {210, 210, 210}, {209, 209, 209}, {208, 208, 208},
  4056. {207, 207, 207}, {206, 206, 206}, {205, 205, 205}, {204, 204, 204}, {203, 203, 203},
  4057. {202, 202, 202}, {201, 201, 201}, {200, 200, 200}, {199, 199, 199}, {199, 199, 199},
  4058. {198, 198, 198}, {197, 197, 197}, {196, 196, 196}, {195, 195, 195}, {194, 194, 194},
  4059. {193, 193, 193}, {192, 192, 192}, {192, 190, 190}, {193, 187, 187}, {194, 184, 184},
  4060. {195, 181, 181}, {195, 179, 179}, {196, 176, 176}, {197, 173, 173}, {198, 170, 170},
  4061. {199, 167, 167}, {200, 164, 164}, {201, 161, 161}, {202, 159, 159}, {203, 156, 156},
  4062. {204, 153, 153}, {205, 150, 150}, {206, 147, 147}, {207, 144, 144}, {208, 141, 141},
  4063. {209, 138, 138}, {210, 136, 136}, {211, 133, 133}, {212, 130, 130}, {213, 127, 127},
  4064. {214, 124, 124}, {215, 121, 121}, {216, 118, 118}, {217, 115, 115}, {217, 113, 113},
  4065. {218, 110, 110}, {219, 107, 107}, {220, 104, 104}, {221, 101, 101}, {222, 98, 98},
  4066. {223, 95, 95}, {224, 92, 92}, {225, 90, 90}, {226, 87, 87}, {227, 84, 84},
  4067. {228, 81, 81}, {229, 78, 78}, {230, 75, 75}, {231, 72, 72}, {232, 69, 69},
  4068. {233, 67, 67}, {234, 64, 64}, {235, 61, 61}, {236, 58, 58}, {237, 55, 55},
  4069. {238, 52, 52}, {239, 49, 49}, {239, 47, 47}, {240, 44, 44}, {241, 41, 41},
  4070. {242, 38, 38}, {243, 35, 35}, {244, 32, 32}, {245, 29, 29}, {246, 26, 26},
  4071. {247, 24, 24}, {248, 21, 21}, {249, 18, 18}, {250, 15, 15}, {251, 12, 12},
  4072. {252, 9, 9}, {253, 6, 6}, {254, 3, 3}, {255, 1, 1}, {255, 3, 0},
  4073. {255, 7, 0}, {255, 11, 0}, {255, 15, 0}, {255, 18, 0}, {255, 22, 0},
  4074. {255, 26, 0}, {255, 30, 0}, {255, 34, 0}, {255, 38, 0}, {255, 41, 0},
  4075. {255, 45, 0}, {255, 49, 0}, {255, 53, 0}, {255, 57, 0}, {255, 60, 0},
  4076. {255, 64, 0}, {255, 68, 0}, {255, 72, 0}, {255, 76, 0}, {255, 80, 0},
  4077. {255, 83, 0}, {255, 87, 0}, {255, 91, 0}, {255, 95, 0}, {255, 99, 0},
  4078. {255, 103, 0}, {255, 106, 0}, {255, 110, 0}, {255, 114, 0}, {255, 118, 0},
  4079. {255, 122, 0}, {255, 126, 0}, {255, 129, 0}, {255, 133, 0}, {255, 137, 0},
  4080. {255, 141, 0}, {255, 145, 0}, {255, 149, 0}, {255, 152, 0}, {255, 156, 0},
  4081. {255, 160, 0}, {255, 164, 0}, {255, 168, 0}, {255, 172, 0}, {255, 175, 0},
  4082. {255, 179, 0}, {255, 183, 0}, {255, 187, 0}, {255, 191, 0}, {255, 195, 0},
  4083. {255, 198, 0}, {255, 202, 0}, {255, 206, 0}, {255, 210, 0}, {255, 214, 0},
  4084. {255, 217, 0}, {255, 221, 0}, {255, 225, 0}, {255, 229, 0}, {255, 233, 0},
  4085. {255, 237, 0}, {255, 240, 0}, {255, 244, 0}, {255, 248, 0}, {255, 252, 0},
  4086. {254, 255, 0}, {250, 255, 0}, {247, 255, 0}, {243, 255, 0}, {239, 255, 0},
  4087. {235, 255, 0}, {231, 255, 0}, {227, 255, 0}, {224, 255, 0}, {220, 255, 0},
  4088. {216, 255, 0}, {212, 255, 0}, {208, 255, 0}, {204, 255, 0}, {201, 255, 0},
  4089. {197, 255, 0}, {193, 255, 0}, {189, 255, 0}, {185, 255, 0}, {181, 255, 0},
  4090. {178, 255, 0}, {174, 255, 0}, {170, 255, 0}, {166, 255, 0}, {162, 255, 0},
  4091. {159, 255, 0}, {155, 255, 0}, {151, 255, 0}, {147, 255, 0}, {143, 255, 0},
  4092. {139, 255, 0}, {136, 255, 0}, {132, 255, 0}, {128, 255, 0}, {124, 255, 0},
  4093. {120, 255, 0}, {116, 255, 0}, {113, 255, 0}, {109, 255, 0}, {105, 255, 0},
  4094. {101, 255, 0}, { 97, 255, 0}, { 93, 255, 0}, { 90, 255, 0}, { 86, 255, 0},
  4095. { 82, 255, 0}, { 78, 255, 0}, { 74, 255, 0}, { 70, 255, 0}, { 67, 255, 0},
  4096. { 63, 255, 0}, { 59, 255, 0}, { 55, 255, 0}, { 51, 255, 0}, { 47, 255, 0},
  4097. { 44, 255, 0}, { 40, 255, 0}, { 36, 255, 0}, { 32, 255, 0}, { 28, 255, 0},
  4098. { 25, 255, 0}, { 21, 255, 0}, { 17, 255, 0}, { 13, 255, 0}, { 9, 255, 0},
  4099. { 5, 255, 0}, { 2, 255, 0}, { 0, 255, 2}, { 0, 255, 6}, { 0, 255, 10},
  4100. { 0, 255, 14}, { 0, 255, 18}, { 0, 255, 21}, { 0, 255, 25}, { 0, 255, 29},
  4101. { 0, 255, 33}, { 0, 255, 37}, { 0, 255, 41}, { 0, 255, 44}, { 0, 255, 48},
  4102. { 0, 255, 52}, { 0, 255, 56}, { 0, 255, 60}, { 0, 255, 64}, { 0, 255, 67},
  4103. { 0, 255, 71}, { 0, 255, 75}, { 0, 255, 79}, { 0, 255, 83}, { 0, 255, 87},
  4104. { 0, 255, 90}, { 0, 255, 94}, { 0, 255, 98}, { 0, 255, 102}, { 0, 255, 106},
  4105. { 0, 255, 110}, { 0, 255, 113}, { 0, 255, 117}, { 0, 255, 121}, { 0, 255, 125},
  4106. { 0, 255, 129}, { 0, 255, 132}, { 0, 255, 136}, { 0, 255, 140}, { 0, 255, 144},
  4107. { 0, 255, 148}, { 0, 255, 152}, { 0, 255, 155}, { 0, 255, 159}, { 0, 255, 163},
  4108. { 0, 255, 167}, { 0, 255, 171}, { 0, 255, 175}, { 0, 255, 178}, { 0, 255, 182},
  4109. { 0, 255, 186}, { 0, 255, 190}, { 0, 255, 194}, { 0, 255, 198}, { 0, 255, 201},
  4110. { 0, 255, 205}, { 0, 255, 209}, { 0, 255, 213}, { 0, 255, 217}, { 0, 255, 221},
  4111. { 0, 255, 224}, { 0, 255, 228}, { 0, 255, 232}, { 0, 255, 236}, { 0, 255, 240},
  4112. { 0, 255, 244}, { 0, 255, 247}, { 0, 255, 251}, { 0, 255, 255}, { 0, 251, 255},
  4113. { 0, 247, 255}, { 0, 244, 255}, { 0, 240, 255}, { 0, 236, 255}, { 0, 232, 255},
  4114. { 0, 228, 255}, { 0, 224, 255}, { 0, 221, 255}, { 0, 217, 255}, { 0, 213, 255},
  4115. { 0, 209, 255}, { 0, 205, 255}, { 0, 201, 255}, { 0, 198, 255}, { 0, 194, 255},
  4116. { 0, 190, 255}, { 0, 186, 255}, { 0, 182, 255}, { 0, 178, 255}, { 0, 175, 255},
  4117. { 0, 171, 255}, { 0, 167, 255}, { 0, 163, 255}, { 0, 159, 255}, { 0, 155, 255},
  4118. { 0, 152, 255}, { 0, 148, 255}, { 0, 144, 255}, { 0, 140, 255}, { 0, 136, 255},
  4119. { 0, 132, 255}, { 0, 129, 255}, { 0, 125, 255}, { 0, 121, 255}, { 0, 117, 255},
  4120. { 0, 113, 255}, { 0, 110, 255}, { 0, 106, 255}, { 0, 102, 255}, { 0, 98, 255},
  4121. { 0, 94, 255}, { 0, 90, 255}, { 0, 87, 255}, { 0, 83, 255}, { 0, 79, 255},
  4122. { 0, 75, 255}, { 0, 71, 255}, { 0, 67, 255}, { 0, 64, 255}, { 0, 60, 255},
  4123. { 0, 56, 255}, { 0, 52, 255}, { 0, 48, 255}, { 0, 44, 255}, { 0, 41, 255},
  4124. { 0, 37, 255}, { 0, 33, 255}, { 0, 29, 255}, { 0, 25, 255}, { 0, 21, 255},
  4125. { 0, 18, 255}, { 0, 14, 255}, { 0, 10, 255}, { 0, 6, 255}, { 0, 2, 255},
  4126. { 2, 0, 255}, { 5, 0, 255}, { 9, 0, 255}, { 13, 0, 255}, { 17, 0, 255},
  4127. { 21, 0, 255}, { 25, 0, 255}, { 28, 0, 255}, { 32, 0, 255}, { 36, 0, 255},
  4128. { 40, 0, 255}, { 44, 0, 255}, { 47, 0, 255}, { 51, 0, 255}, { 55, 0, 255},
  4129. { 59, 0, 255}, { 63, 0, 255}, { 67, 0, 255}, { 70, 0, 255}, { 74, 0, 255},
  4130. { 78, 0, 255}, { 82, 0, 255}, { 86, 0, 255}, { 90, 0, 255}, { 93, 0, 255},
  4131. { 97, 0, 255}, {101, 0, 255}, {105, 0, 255}, {109, 0, 255}, {113, 0, 255},
  4132. {116, 0, 255}, {120, 0, 255}, {124, 0, 255}, {128, 0, 255}, {132, 0, 255},
  4133. {136, 0, 255}, {139, 0, 255}, {143, 0, 255}, {147, 0, 255}, {151, 0, 255},
  4134. {155, 0, 255}, {159, 0, 255}, {162, 0, 255}, {166, 0, 255}, {170, 0, 255},
  4135. {174, 0, 255}, {178, 0, 255}, {181, 0, 255}, {185, 0, 255}, {189, 0, 255},
  4136. {193, 0, 255}, {197, 0, 255}, {201, 0, 255}, {204, 0, 255}, {208, 0, 255},
  4137. {212, 0, 255}, {216, 0, 255}, {220, 0, 255}, {224, 0, 255}, {227, 0, 255},
  4138. {231, 0, 255}, {235, 0, 255}, {239, 0, 255}, {243, 0, 255}, {247, 0, 255},
  4139. {250, 0, 255}, {254, 0, 255}, {252, 0, 252}, {248, 0, 248}, {244, 0, 244},
  4140. {240, 0, 240}, {237, 0, 237}, {233, 0, 233}, {229, 0, 229}, {225, 0, 225},
  4141. {221, 0, 221}, {217, 0, 217}, {214, 0, 214}, {210, 0, 210}, {206, 0, 206},
  4142. {202, 0, 202}, {198, 0, 198}, {195, 0, 195}, {191, 0, 191}, {187, 0, 187},
  4143. {183, 0, 183}, {179, 0, 179}, {175, 0, 175}, {172, 0, 172}, {168, 0, 168},
  4144. {164, 0, 164}, {160, 0, 160}, {156, 0, 156}, {152, 0, 152}, {149, 0, 149},
  4145. {145, 0, 145}, {141, 0, 141}, {137, 0, 137}, {133, 0, 133}, {129, 0, 129},
  4146. {126, 0, 126}, {122, 0, 122}, {118, 0, 118}, {114, 0, 114}, {110, 0, 110},
  4147. {106, 0, 106}, {103, 0, 103}, { 99, 0, 99}, { 95, 0, 95}, { 91, 0, 91},
  4148. { 87, 0, 87}, { 83, 0, 83}, { 80, 0, 80}, { 76, 0, 76}, { 72, 0, 72},
  4149. { 68, 0, 68}, { 64, 0, 64}, { 60, 0, 60}, { 57, 0, 57}, { 53, 0, 53},
  4150. { 49, 0, 49}, { 45, 0, 45}, { 41, 0, 41}, { 38, 0, 38}, { 34, 0, 34},
  4151. { 30, 0, 30}, { 26, 0, 26}, { 22, 0, 22}, { 18, 0, 18}, { 15, 0, 15},
  4152. { 11, 0, 11}, { 7, 0, 7}, { 3, 0, 3}, { 0, 0, 0}, { 2, 2, 2},
  4153. { 4, 4, 4}, { 6, 6, 6}, { 8, 8, 8}, { 10, 10, 10}, { 12, 12, 12},
  4154. { 14, 14, 14}, { 16, 16, 16}, { 18, 18, 18}, { 20, 20, 20}, { 21, 21, 21},
  4155. { 23, 23, 23}, { 25, 25, 25}, { 27, 27, 27}, { 29, 29, 29}, { 31, 31, 31},
  4156. { 33, 33, 33}, { 35, 35, 35}, { 37, 37, 37}, { 39, 39, 39}, { 41, 41, 41},
  4157. { 43, 43, 43}, { 44, 44, 44}, { 46, 46, 46}, { 48, 48, 48}, { 50, 50, 50},
  4158. { 52, 52, 52}, { 54, 54, 54}, { 56, 56, 56}, { 58, 58, 58}, { 60, 60, 60},
  4159. { 62, 62, 62}, { 64, 64, 64}, { 65, 65, 65}, { 67, 67, 67}, { 69, 69, 69},
  4160. { 71, 71, 71}, { 73, 73, 73}, { 75, 75, 75}, { 77, 77, 77}, { 79, 79, 79},
  4161. { 81, 81, 81}, { 83, 83, 83}, { 85, 85, 85}, { 87, 87, 87}, { 88, 88, 88},
  4162. { 90, 90, 90}, { 92, 92, 92}, { 94, 94, 94}, { 96, 96, 96}, { 98, 98, 98},
  4163. {100, 100, 100}, {102, 102, 102}, {104, 104, 104}, {106, 106, 106}, {108, 108, 108},
  4164. {110, 110, 110}, {111, 111, 111}, {113, 113, 113}, {115, 115, 115}, {117, 117, 117},
  4165. {119, 119, 119}, {121, 121, 121}, {123, 123, 123}, {125, 125, 125}, {127, 127, 127},
  4166. {128, 126, 126}, {128, 124, 124}, {128, 123, 123}, {128, 121, 121}, {128, 119, 119},
  4167. {128, 117, 117}, {128, 115, 115}, {128, 113, 113}, {128, 111, 111}, {128, 109, 109},
  4168. {128, 107, 107}, {128, 105, 105}, {128, 103, 103}, {128, 101, 101}, {128, 100, 100},
  4169. {128, 98, 98}, {128, 96, 96}, {128, 94, 94}, {128, 92, 92}, {128, 90, 90},
  4170. {128, 88, 88}, {128, 86, 86}, {128, 84, 84}, {128, 82, 82}, {128, 80, 80},
  4171. {128, 78, 78}, {128, 77, 77}, {128, 75, 75}, {128, 73, 73}, {128, 71, 71},
  4172. {128, 69, 69}, {128, 67, 67}, {128, 65, 65}, {128, 63, 63}, {128, 61, 61},
  4173. {128, 59, 59}, {128, 57, 57}, {128, 56, 56}, {128, 54, 54}, {128, 52, 52},
  4174. {128, 50, 50}, {128, 48, 48}, {128, 46, 46}, {128, 44, 44}, {128, 42, 42},
  4175. {128, 40, 40}, {128, 38, 38}, {128, 36, 36}, {128, 34, 34}, {128, 33, 33},
  4176. {128, 31, 31}, {128, 29, 29}, {128, 27, 27}, {128, 25, 25}, {128, 23, 23},
  4177. {128, 21, 21}, {128, 19, 19}, {128, 17, 17}, {128, 15, 15}, {128, 13, 13},
  4178. {128, 11, 11}, {128, 10, 10}, {128, 8, 8}, {128, 6, 6}, {128, 4, 4},
  4179. {128, 2, 2}, {128, 0, 0}, {128, 2, 0}, {128, 4, 0}, {128, 6, 0},
  4180. {128, 8, 0}, {128, 10, 0}, {128, 11, 0}, {128, 13, 0}, {128, 15, 0},
  4181. {128, 17, 0}, {128, 19, 0}, {128, 21, 0}, {128, 23, 0}, {128, 25, 0},
  4182. {128, 27, 0}, {128, 29, 0}, {128, 31, 0}, {128, 33, 0}, {128, 34, 0},
  4183. {128, 36, 0}, {128, 38, 0}, {128, 40, 0}, {128, 42, 0}, {128, 44, 0},
  4184. {128, 46, 0}, {128, 48, 0}, {128, 50, 0}, {128, 52, 0}, {128, 54, 0},
  4185. {128, 56, 0}, {128, 57, 0}, {128, 59, 0}, {128, 61, 0}, {128, 63, 0},
  4186. {128, 65, 0}, {128, 67, 0}, {128, 69, 0}, {128, 71, 0}, {128, 73, 0},
  4187. {128, 75, 0}, {128, 77, 0}, {128, 78, 0}, {128, 80, 0}, {128, 82, 0},
  4188. {128, 84, 0}, {128, 86, 0}, {128, 88, 0}, {128, 90, 0}, {128, 92, 0},
  4189. {128, 94, 0}, {128, 96, 0}, {128, 98, 0}, {128, 100, 0}, {128, 101, 0},
  4190. {128, 103, 0}, {128, 105, 0}, {128, 107, 0}, {128, 109, 0}, {128, 111, 0},
  4191. {128, 113, 0}, {128, 115, 0}, {128, 117, 0}, {128, 119, 0}, {128, 121, 0},
  4192. {128, 123, 0}, {128, 124, 0}, {128, 126, 0}, {127, 128, 0}, {125, 128, 0},
  4193. {123, 128, 0}, {121, 128, 0}, {119, 128, 0}, {117, 128, 0}, {115, 128, 0},
  4194. {113, 128, 0}, {111, 128, 0}, {110, 128, 0}, {108, 128, 0}, {106, 128, 0},
  4195. {104, 128, 0}, {102, 128, 0}, {100, 128, 0}, { 98, 128, 0}, { 96, 128, 0},
  4196. { 94, 128, 0}, { 92, 128, 0}, { 90, 128, 0}, { 88, 128, 0}, { 87, 128, 0},
  4197. { 85, 128, 0}, { 83, 128, 0}, { 81, 128, 0}, { 79, 128, 0}, { 77, 128, 0},
  4198. { 75, 128, 0}, { 73, 128, 0}, { 71, 128, 0}, { 69, 128, 0}, { 67, 128, 0},
  4199. { 65, 128, 0}, { 64, 128, 0}, { 62, 128, 0}, { 60, 128, 0}, { 58, 128, 0},
  4200. { 56, 128, 0}, { 54, 128, 0}, { 52, 128, 0}, { 50, 128, 0}, { 48, 128, 0},
  4201. { 46, 128, 0}, { 44, 128, 0}, { 43, 128, 0}, { 41, 128, 0}, { 39, 128, 0},
  4202. { 37, 128, 0}, { 35, 128, 0}, { 33, 128, 0}, { 31, 128, 0}, { 29, 128, 0},
  4203. { 27, 128, 0}, { 25, 128, 0}, { 23, 128, 0}, { 21, 128, 0}, { 20, 128, 0},
  4204. { 18, 128, 0}, { 16, 128, 0}, { 14, 128, 0}, { 12, 128, 0}, { 10, 128, 0},
  4205. { 8, 128, 0}, { 6, 128, 0}, { 4, 128, 0}, { 2, 128, 0}, { 0, 128, 0},
  4206. { 0, 128, 2}, { 0, 128, 3}, { 0, 128, 5}, { 0, 128, 7}, { 0, 128, 9},
  4207. { 0, 128, 11}, { 0, 128, 13}, { 0, 128, 15}, { 0, 128, 17}, { 0, 128, 19},
  4208. { 0, 128, 21}, { 0, 128, 23}, { 0, 128, 25}, { 0, 128, 26}, { 0, 128, 28},
  4209. { 0, 128, 30}, { 0, 128, 32}, { 0, 128, 34}, { 0, 128, 36}, { 0, 128, 38},
  4210. { 0, 128, 40}, { 0, 128, 42}, { 0, 128, 44}, { 0, 128, 46}, { 0, 128, 47},
  4211. { 0, 128, 49}, { 0, 128, 51}, { 0, 128, 53}, { 0, 128, 55}, { 0, 128, 57},
  4212. { 0, 128, 59}, { 0, 128, 61}, { 0, 128, 63}, { 0, 128, 65}, { 0, 128, 67},
  4213. { 0, 128, 69}, { 0, 128, 70}, { 0, 128, 72}, { 0, 128, 74}, { 0, 128, 76},
  4214. { 0, 128, 78}, { 0, 128, 80}, { 0, 128, 82}, { 0, 128, 84}, { 0, 128, 86},
  4215. { 0, 128, 88}, { 0, 128, 90}, { 0, 128, 92}, { 0, 128, 93}, { 0, 128, 95},
  4216. { 0, 128, 97}, { 0, 128, 99}, { 0, 128, 101}, { 0, 128, 103}, { 0, 128, 105},
  4217. { 0, 128, 107}, { 0, 128, 109}, { 0, 128, 111}, { 0, 128, 113}, { 0, 128, 114},
  4218. { 0, 128, 116}, { 0, 128, 118}, { 0, 128, 120}, { 0, 128, 122}, { 0, 128, 124},
  4219. { 0, 128, 126}, { 0, 127, 128}, { 0, 125, 128}, { 0, 123, 128}, { 0, 121, 128},
  4220. { 0, 119, 128}, { 0, 118, 128}, { 0, 116, 128}, { 0, 114, 128}, { 0, 112, 128},
  4221. { 0, 110, 128}, { 0, 108, 128}, { 0, 106, 128}, { 0, 104, 128}, { 0, 102, 128},
  4222. { 0, 100, 128}, { 0, 98, 128}, { 0, 96, 128}, { 0, 95, 128}, { 0, 93, 128},
  4223. { 0, 91, 128}, { 0, 89, 128}, { 0, 87, 128}, { 0, 85, 128}, { 0, 83, 128},
  4224. { 0, 81, 128}, { 0, 79, 128}, { 0, 77, 128}, { 0, 75, 128}, { 0, 74, 128},
  4225. { 0, 72, 128}, { 0, 70, 128}, { 0, 68, 128}, { 0, 66, 128}, { 0, 64, 128},
  4226. { 0, 62, 128}, { 0, 60, 128}, { 0, 58, 128}, { 0, 56, 128}, { 0, 54, 128},
  4227. { 0, 52, 128}, { 0, 51, 128}, { 0, 49, 128}, { 0, 47, 128}, { 0, 45, 128},
  4228. { 0, 43, 128}, { 0, 41, 128}, { 0, 39, 128}, { 0, 37, 128}, { 0, 35, 128},
  4229. { 0, 33, 128}, { 0, 31, 128}, { 0, 29, 128}, { 0, 28, 128}, { 0, 26, 128},
  4230. { 0, 24, 128}, { 0, 22, 128}, { 0, 20, 128}, { 0, 18, 128}, { 0, 16, 128},
  4231. { 0, 14, 128}, { 0, 12, 128}, { 0, 10, 128}, { 0, 8, 128}, { 0, 7, 128},
  4232. { 0, 5, 128}, { 0, 3, 128}, { 0, 1, 128}, { 1, 0, 128}, { 3, 0, 128},
  4233. { 5, 0, 128}, { 7, 0, 128}, { 9, 0, 128}, { 11, 0, 128}, { 13, 0, 128},
  4234. { 15, 0, 128}, { 16, 0, 128}, { 18, 0, 128}, { 20, 0, 128}, { 22, 0, 128},
  4235. { 24, 0, 128}, { 26, 0, 128}, { 28, 0, 128}, { 30, 0, 128}, { 32, 0, 128},
  4236. { 34, 0, 128}, { 36, 0, 128}, { 38, 0, 128}, { 39, 0, 128}, { 41, 0, 128},
  4237. { 43, 0, 128}, { 45, 0, 128}, { 47, 0, 128}, { 49, 0, 128}, { 51, 0, 128},
  4238. { 53, 0, 128}, { 55, 0, 128}, { 57, 0, 128}, { 59, 0, 128}, { 60, 0, 128},
  4239. { 62, 0, 128}, { 64, 0, 128}, { 66, 0, 128}, { 68, 0, 128}, { 70, 0, 128},
  4240. { 72, 0, 128}, { 74, 0, 128}, { 76, 0, 128}, { 78, 0, 128}, { 80, 0, 128},
  4241. { 82, 0, 128}, { 83, 0, 128}, { 85, 0, 128}, { 87, 0, 128}, { 89, 0, 128},
  4242. { 91, 0, 128}, { 93, 0, 128}, { 95, 0, 128}, { 97, 0, 128}, { 99, 0, 128},
  4243. {101, 0, 128}, {103, 0, 128}, {105, 0, 128}, {106, 0, 128}, {108, 0, 128},
  4244. {110, 0, 128}, {112, 0, 128}, {114, 0, 128}, {116, 0, 128}, {118, 0, 128},
  4245. {120, 0, 128}, {122, 0, 128}, {124, 0, 128}, {126, 0, 128}, {128, 0, 128}
  4246. };
  4247. const rgb_t yarg_colormap[1000] = {
  4248. { 0, 0, 0}, { 0, 0, 0}, { 1, 1, 1}, { 1, 1, 1}, { 1, 1, 1},
  4249. { 1, 1, 1}, { 2, 2, 2}, { 2, 2, 2}, { 2, 2, 2}, { 2, 2, 2},
  4250. { 3, 3, 3}, { 3, 3, 3}, { 3, 3, 3}, { 3, 3, 3}, { 4, 4, 4},
  4251. { 4, 4, 4}, { 4, 4, 4}, { 4, 4, 4}, { 5, 5, 5}, { 5, 5, 5},
  4252. { 5, 5, 5}, { 5, 5, 5}, { 6, 6, 6}, { 6, 6, 6}, { 6, 6, 6},
  4253. { 6, 6, 6}, { 7, 7, 7}, { 7, 7, 7}, { 7, 7, 7}, { 7, 7, 7},
  4254. { 8, 8, 8}, { 8, 8, 8}, { 8, 8, 8}, { 8, 8, 8}, { 9, 9, 9},
  4255. { 9, 9, 9}, { 9, 9, 9}, { 9, 9, 9}, { 10, 10, 10}, { 10, 10, 10},
  4256. { 10, 10, 10}, { 10, 10, 10}, { 11, 11, 11}, { 11, 11, 11}, { 11, 11, 11},
  4257. { 11, 11, 11}, { 12, 12, 12}, { 12, 12, 12}, { 12, 12, 12}, { 13, 13, 13},
  4258. { 13, 13, 13}, { 13, 13, 13}, { 13, 13, 13}, { 14, 14, 14}, { 14, 14, 14},
  4259. { 14, 14, 14}, { 14, 14, 14}, { 15, 15, 15}, { 15, 15, 15}, { 15, 15, 15},
  4260. { 15, 15, 15}, { 16, 16, 16}, { 16, 16, 16}, { 16, 16, 16}, { 16, 16, 16},
  4261. { 17, 17, 17}, { 17, 17, 17}, { 17, 17, 17}, { 17, 17, 17}, { 18, 18, 18},
  4262. { 18, 18, 18}, { 18, 18, 18}, { 18, 18, 18}, { 19, 19, 19}, { 19, 19, 19},
  4263. { 19, 19, 19}, { 19, 19, 19}, { 20, 20, 20}, { 20, 20, 20}, { 20, 20, 20},
  4264. { 20, 20, 20}, { 21, 21, 21}, { 21, 21, 21}, { 21, 21, 21}, { 21, 21, 21},
  4265. { 22, 22, 22}, { 22, 22, 22}, { 22, 22, 22}, { 22, 22, 22}, { 23, 23, 23},
  4266. { 23, 23, 23}, { 23, 23, 23}, { 23, 23, 23}, { 24, 24, 24}, { 24, 24, 24},
  4267. { 24, 24, 24}, { 25, 25, 25}, { 25, 25, 25}, { 25, 25, 25}, { 25, 25, 25},
  4268. { 26, 26, 26}, { 26, 26, 26}, { 26, 26, 26}, { 26, 26, 26}, { 27, 27, 27},
  4269. { 27, 27, 27}, { 27, 27, 27}, { 27, 27, 27}, { 28, 28, 28}, { 28, 28, 28},
  4270. { 28, 28, 28}, { 28, 28, 28}, { 29, 29, 29}, { 29, 29, 29}, { 29, 29, 29},
  4271. { 29, 29, 29}, { 30, 30, 30}, { 30, 30, 30}, { 30, 30, 30}, { 30, 30, 30},
  4272. { 31, 31, 31}, { 31, 31, 31}, { 31, 31, 31}, { 31, 31, 31}, { 32, 32, 32},
  4273. { 32, 32, 32}, { 32, 32, 32}, { 32, 32, 32}, { 33, 33, 33}, { 33, 33, 33},
  4274. { 33, 33, 33}, { 33, 33, 33}, { 34, 34, 34}, { 34, 34, 34}, { 34, 34, 34},
  4275. { 34, 34, 34}, { 35, 35, 35}, { 35, 35, 35}, { 35, 35, 35}, { 35, 35, 35},
  4276. { 36, 36, 36}, { 36, 36, 36}, { 36, 36, 36}, { 37, 37, 37}, { 37, 37, 37},
  4277. { 37, 37, 37}, { 37, 37, 37}, { 38, 38, 38}, { 38, 38, 38}, { 38, 38, 38},
  4278. { 38, 38, 38}, { 39, 39, 39}, { 39, 39, 39}, { 39, 39, 39}, { 39, 39, 39},
  4279. { 40, 40, 40}, { 40, 40, 40}, { 40, 40, 40}, { 40, 40, 40}, { 41, 41, 41},
  4280. { 41, 41, 41}, { 41, 41, 41}, { 41, 41, 41}, { 42, 42, 42}, { 42, 42, 42},
  4281. { 42, 42, 42}, { 42, 42, 42}, { 43, 43, 43}, { 43, 43, 43}, { 43, 43, 43},
  4282. { 43, 43, 43}, { 44, 44, 44}, { 44, 44, 44}, { 44, 44, 44}, { 44, 44, 44},
  4283. { 45, 45, 45}, { 45, 45, 45}, { 45, 45, 45}, { 45, 45, 45}, { 46, 46, 46},
  4284. { 46, 46, 46}, { 46, 46, 46}, { 46, 46, 46}, { 47, 47, 47}, { 47, 47, 47},
  4285. { 47, 47, 47}, { 47, 47, 47}, { 48, 48, 48}, { 48, 48, 48}, { 48, 48, 48},
  4286. { 48, 48, 48}, { 49, 49, 49}, { 49, 49, 49}, { 49, 49, 49}, { 50, 50, 50},
  4287. { 50, 50, 50}, { 50, 50, 50}, { 50, 50, 50}, { 51, 51, 51}, { 51, 51, 51},
  4288. { 51, 51, 51}, { 51, 51, 51}, { 52, 52, 52}, { 52, 52, 52}, { 52, 52, 52},
  4289. { 52, 52, 52}, { 53, 53, 53}, { 53, 53, 53}, { 53, 53, 53}, { 53, 53, 53},
  4290. { 54, 54, 54}, { 54, 54, 54}, { 54, 54, 54}, { 54, 54, 54}, { 55, 55, 55},
  4291. { 55, 55, 55}, { 55, 55, 55}, { 55, 55, 55}, { 56, 56, 56}, { 56, 56, 56},
  4292. { 56, 56, 56}, { 56, 56, 56}, { 57, 57, 57}, { 57, 57, 57}, { 57, 57, 57},
  4293. { 57, 57, 57}, { 58, 58, 58}, { 58, 58, 58}, { 58, 58, 58}, { 58, 58, 58},
  4294. { 59, 59, 59}, { 59, 59, 59}, { 59, 59, 59}, { 59, 59, 59}, { 60, 60, 60},
  4295. { 60, 60, 60}, { 60, 60, 60}, { 60, 60, 60}, { 61, 61, 61}, { 61, 61, 61},
  4296. { 61, 61, 61}, { 62, 62, 62}, { 62, 62, 62}, { 62, 62, 62}, { 62, 62, 62},
  4297. { 63, 63, 63}, { 63, 63, 63}, { 63, 63, 63}, { 63, 63, 63}, { 64, 64, 64},
  4298. { 64, 64, 64}, { 64, 64, 64}, { 64, 64, 64}, { 65, 65, 65}, { 65, 65, 65},
  4299. { 65, 65, 65}, { 65, 65, 65}, { 66, 66, 66}, { 66, 66, 66}, { 66, 66, 66},
  4300. { 66, 66, 66}, { 67, 67, 67}, { 67, 67, 67}, { 67, 67, 67}, { 67, 67, 67},
  4301. { 68, 68, 68}, { 68, 68, 68}, { 68, 68, 68}, { 68, 68, 68}, { 69, 69, 69},
  4302. { 69, 69, 69}, { 69, 69, 69}, { 69, 69, 69}, { 70, 70, 70}, { 70, 70, 70},
  4303. { 70, 70, 70}, { 70, 70, 70}, { 71, 71, 71}, { 71, 71, 71}, { 71, 71, 71},
  4304. { 71, 71, 71}, { 72, 72, 72}, { 72, 72, 72}, { 72, 72, 72}, { 72, 72, 72},
  4305. { 73, 73, 73}, { 73, 73, 73}, { 73, 73, 73}, { 74, 74, 74}, { 74, 74, 74},
  4306. { 74, 74, 74}, { 74, 74, 74}, { 75, 75, 75}, { 75, 75, 75}, { 75, 75, 75},
  4307. { 75, 75, 75}, { 76, 76, 76}, { 76, 76, 76}, { 76, 76, 76}, { 76, 76, 76},
  4308. { 77, 77, 77}, { 77, 77, 77}, { 77, 77, 77}, { 77, 77, 77}, { 78, 78, 78},
  4309. { 78, 78, 78}, { 78, 78, 78}, { 78, 78, 78}, { 79, 79, 79}, { 79, 79, 79},
  4310. { 79, 79, 79}, { 79, 79, 79}, { 80, 80, 80}, { 80, 80, 80}, { 80, 80, 80},
  4311. { 80, 80, 80}, { 81, 81, 81}, { 81, 81, 81}, { 81, 81, 81}, { 81, 81, 81},
  4312. { 82, 82, 82}, { 82, 82, 82}, { 82, 82, 82}, { 82, 82, 82}, { 83, 83, 83},
  4313. { 83, 83, 83}, { 83, 83, 83}, { 83, 83, 83}, { 84, 84, 84}, { 84, 84, 84},
  4314. { 84, 84, 84}, { 84, 84, 84}, { 85, 85, 85}, { 85, 85, 85}, { 85, 85, 85},
  4315. { 86, 86, 86}, { 86, 86, 86}, { 86, 86, 86}, { 86, 86, 86}, { 87, 87, 87},
  4316. { 87, 87, 87}, { 87, 87, 87}, { 87, 87, 87}, { 88, 88, 88}, { 88, 88, 88},
  4317. { 88, 88, 88}, { 88, 88, 88}, { 89, 89, 89}, { 89, 89, 89}, { 89, 89, 89},
  4318. { 89, 89, 89}, { 90, 90, 90}, { 90, 90, 90}, { 90, 90, 90}, { 90, 90, 90},
  4319. { 91, 91, 91}, { 91, 91, 91}, { 91, 91, 91}, { 91, 91, 91}, { 92, 92, 92},
  4320. { 92, 92, 92}, { 92, 92, 92}, { 92, 92, 92}, { 93, 93, 93}, { 93, 93, 93},
  4321. { 93, 93, 93}, { 93, 93, 93}, { 94, 94, 94}, { 94, 94, 94}, { 94, 94, 94},
  4322. { 94, 94, 94}, { 95, 95, 95}, { 95, 95, 95}, { 95, 95, 95}, { 95, 95, 95},
  4323. { 96, 96, 96}, { 96, 96, 96}, { 96, 96, 96}, { 96, 96, 96}, { 97, 97, 97},
  4324. { 97, 97, 97}, { 97, 97, 97}, { 98, 98, 98}, { 98, 98, 98}, { 98, 98, 98},
  4325. { 98, 98, 98}, { 99, 99, 99}, { 99, 99, 99}, { 99, 99, 99}, { 99, 99, 99},
  4326. {100, 100, 100}, {100, 100, 100}, {100, 100, 100}, {100, 100, 100}, {101, 101, 101},
  4327. {101, 101, 101}, {101, 101, 101}, {101, 101, 101}, {102, 102, 102}, {102, 102, 102},
  4328. {102, 102, 102}, {102, 102, 102}, {103, 103, 103}, {103, 103, 103}, {103, 103, 103},
  4329. {103, 103, 103}, {104, 104, 104}, {104, 104, 104}, {104, 104, 104}, {104, 104, 104},
  4330. {105, 105, 105}, {105, 105, 105}, {105, 105, 105}, {105, 105, 105}, {106, 106, 106},
  4331. {106, 106, 106}, {106, 106, 106}, {106, 106, 106}, {107, 107, 107}, {107, 107, 107},
  4332. {107, 107, 107}, {107, 107, 107}, {108, 108, 108}, {108, 108, 108}, {108, 108, 108},
  4333. {108, 108, 108}, {109, 109, 109}, {109, 109, 109}, {109, 109, 109}, {110, 110, 110},
  4334. {110, 110, 110}, {110, 110, 110}, {110, 110, 110}, {111, 111, 111}, {111, 111, 111},
  4335. {111, 111, 111}, {111, 111, 111}, {112, 112, 112}, {112, 112, 112}, {112, 112, 112},
  4336. {112, 112, 112}, {113, 113, 113}, {113, 113, 113}, {113, 113, 113}, {113, 113, 113},
  4337. {114, 114, 114}, {114, 114, 114}, {114, 114, 114}, {114, 114, 114}, {115, 115, 115},
  4338. {115, 115, 115}, {115, 115, 115}, {115, 115, 115}, {116, 116, 116}, {116, 116, 116},
  4339. {116, 116, 116}, {116, 116, 116}, {117, 117, 117}, {117, 117, 117}, {117, 117, 117},
  4340. {117, 117, 117}, {118, 118, 118}, {118, 118, 118}, {118, 118, 118}, {118, 118, 118},
  4341. {119, 119, 119}, {119, 119, 119}, {119, 119, 119}, {119, 119, 119}, {120, 120, 120},
  4342. {120, 120, 120}, {120, 120, 120}, {120, 120, 120}, {121, 121, 121}, {121, 121, 121},
  4343. {121, 121, 121}, {122, 122, 122}, {122, 122, 122}, {122, 122, 122}, {122, 122, 122},
  4344. {123, 123, 123}, {123, 123, 123}, {123, 123, 123}, {123, 123, 123}, {124, 124, 124},
  4345. {124, 124, 124}, {124, 124, 124}, {124, 124, 124}, {125, 125, 125}, {125, 125, 125},
  4346. {125, 125, 125}, {125, 125, 125}, {126, 126, 126}, {126, 126, 126}, {126, 126, 126},
  4347. {126, 126, 126}, {127, 127, 127}, {127, 127, 127}, {127, 127, 127}, {127, 127, 127},
  4348. {128, 128, 128}, {128, 128, 128}, {128, 128, 128}, {128, 128, 128}, {129, 129, 129},
  4349. {129, 129, 129}, {129, 129, 129}, {129, 129, 129}, {130, 130, 130}, {130, 130, 130},
  4350. {130, 130, 130}, {130, 130, 130}, {131, 131, 131}, {131, 131, 131}, {131, 131, 131},
  4351. {131, 131, 131}, {132, 132, 132}, {132, 132, 132}, {132, 132, 132}, {132, 132, 132},
  4352. {133, 133, 133}, {133, 133, 133}, {133, 133, 133}, {133, 133, 133}, {134, 134, 134},
  4353. {134, 134, 134}, {134, 134, 134}, {135, 135, 135}, {135, 135, 135}, {135, 135, 135},
  4354. {135, 135, 135}, {136, 136, 136}, {136, 136, 136}, {136, 136, 136}, {136, 136, 136},
  4355. {137, 137, 137}, {137, 137, 137}, {137, 137, 137}, {137, 137, 137}, {138, 138, 138},
  4356. {138, 138, 138}, {138, 138, 138}, {138, 138, 138}, {139, 139, 139}, {139, 139, 139},
  4357. {139, 139, 139}, {139, 139, 139}, {140, 140, 140}, {140, 140, 140}, {140, 140, 140},
  4358. {140, 140, 140}, {141, 141, 141}, {141, 141, 141}, {141, 141, 141}, {141, 141, 141},
  4359. {142, 142, 142}, {142, 142, 142}, {142, 142, 142}, {142, 142, 142}, {143, 143, 143},
  4360. {143, 143, 143}, {143, 143, 143}, {143, 143, 143}, {144, 144, 144}, {144, 144, 144},
  4361. {144, 144, 144}, {144, 144, 144}, {145, 145, 145}, {145, 145, 145}, {145, 145, 145},
  4362. {145, 145, 145}, {146, 146, 146}, {146, 146, 146}, {146, 146, 146}, {147, 147, 147},
  4363. {147, 147, 147}, {147, 147, 147}, {147, 147, 147}, {148, 148, 148}, {148, 148, 148},
  4364. {148, 148, 148}, {148, 148, 148}, {149, 149, 149}, {149, 149, 149}, {149, 149, 149},
  4365. {149, 149, 149}, {150, 150, 150}, {150, 150, 150}, {150, 150, 150}, {150, 150, 150},
  4366. {151, 151, 151}, {151, 151, 151}, {151, 151, 151}, {151, 151, 151}, {152, 152, 152},
  4367. {152, 152, 152}, {152, 152, 152}, {152, 152, 152}, {153, 153, 153}, {153, 153, 153},
  4368. {153, 153, 153}, {153, 153, 153}, {154, 154, 154}, {154, 154, 154}, {154, 154, 154},
  4369. {154, 154, 154}, {155, 155, 155}, {155, 155, 155}, {155, 155, 155}, {155, 155, 155},
  4370. {156, 156, 156}, {156, 156, 156}, {156, 156, 156}, {156, 156, 156}, {157, 157, 157},
  4371. {157, 157, 157}, {157, 157, 157}, {157, 157, 157}, {158, 158, 158}, {158, 158, 158},
  4372. {158, 158, 158}, {159, 159, 159}, {159, 159, 159}, {159, 159, 159}, {159, 159, 159},
  4373. {160, 160, 160}, {160, 160, 160}, {160, 160, 160}, {160, 160, 160}, {161, 161, 161},
  4374. {161, 161, 161}, {161, 161, 161}, {161, 161, 161}, {162, 162, 162}, {162, 162, 162},
  4375. {162, 162, 162}, {162, 162, 162}, {163, 163, 163}, {163, 163, 163}, {163, 163, 163},
  4376. {163, 163, 163}, {164, 164, 164}, {164, 164, 164}, {164, 164, 164}, {164, 164, 164},
  4377. {165, 165, 165}, {165, 165, 165}, {165, 165, 165}, {165, 165, 165}, {166, 166, 166},
  4378. {166, 166, 166}, {166, 166, 166}, {166, 166, 166}, {167, 167, 167}, {167, 167, 167},
  4379. {167, 167, 167}, {167, 167, 167}, {168, 168, 168}, {168, 168, 168}, {168, 168, 168},
  4380. {168, 168, 168}, {169, 169, 169}, {169, 169, 169}, {169, 169, 169}, {169, 169, 169},
  4381. {170, 170, 170}, {170, 170, 170}, {170, 170, 170}, {171, 171, 171}, {171, 171, 171},
  4382. {171, 171, 171}, {171, 171, 171}, {172, 172, 172}, {172, 172, 172}, {172, 172, 172},
  4383. {172, 172, 172}, {173, 173, 173}, {173, 173, 173}, {173, 173, 173}, {173, 173, 173},
  4384. {174, 174, 174}, {174, 174, 174}, {174, 174, 174}, {174, 174, 174}, {175, 175, 175},
  4385. {175, 175, 175}, {175, 175, 175}, {175, 175, 175}, {176, 176, 176}, {176, 176, 176},
  4386. {176, 176, 176}, {176, 176, 176}, {177, 177, 177}, {177, 177, 177}, {177, 177, 177},
  4387. {177, 177, 177}, {178, 178, 178}, {178, 178, 178}, {178, 178, 178}, {178, 178, 178},
  4388. {179, 179, 179}, {179, 179, 179}, {179, 179, 179}, {179, 179, 179}, {180, 180, 180},
  4389. {180, 180, 180}, {180, 180, 180}, {180, 180, 180}, {181, 181, 181}, {181, 181, 181},
  4390. {181, 181, 181}, {181, 181, 181}, {182, 182, 182}, {182, 182, 182}, {182, 182, 182},
  4391. {183, 183, 183}, {183, 183, 183}, {183, 183, 183}, {183, 183, 183}, {184, 184, 184},
  4392. {184, 184, 184}, {184, 184, 184}, {184, 184, 184}, {185, 185, 185}, {185, 185, 185},
  4393. {185, 185, 185}, {185, 185, 185}, {186, 186, 186}, {186, 186, 186}, {186, 186, 186},
  4394. {186, 186, 186}, {187, 187, 187}, {187, 187, 187}, {187, 187, 187}, {187, 187, 187},
  4395. {188, 188, 188}, {188, 188, 188}, {188, 188, 188}, {188, 188, 188}, {189, 189, 189},
  4396. {189, 189, 189}, {189, 189, 189}, {189, 189, 189}, {190, 190, 190}, {190, 190, 190},
  4397. {190, 190, 190}, {190, 190, 190}, {191, 191, 191}, {191, 191, 191}, {191, 191, 191},
  4398. {191, 191, 191}, {192, 192, 192}, {192, 192, 192}, {192, 192, 192}, {192, 192, 192},
  4399. {193, 193, 193}, {193, 193, 193}, {193, 193, 193}, {193, 193, 193}, {194, 194, 194},
  4400. {194, 194, 194}, {194, 194, 194}, {195, 195, 195}, {195, 195, 195}, {195, 195, 195},
  4401. {195, 195, 195}, {196, 196, 196}, {196, 196, 196}, {196, 196, 196}, {196, 196, 196},
  4402. {197, 197, 197}, {197, 197, 197}, {197, 197, 197}, {197, 197, 197}, {198, 198, 198},
  4403. {198, 198, 198}, {198, 198, 198}, {198, 198, 198}, {199, 199, 199}, {199, 199, 199},
  4404. {199, 199, 199}, {199, 199, 199}, {200, 200, 200}, {200, 200, 200}, {200, 200, 200},
  4405. {200, 200, 200}, {201, 201, 201}, {201, 201, 201}, {201, 201, 201}, {201, 201, 201},
  4406. {202, 202, 202}, {202, 202, 202}, {202, 202, 202}, {202, 202, 202}, {203, 203, 203},
  4407. {203, 203, 203}, {203, 203, 203}, {203, 203, 203}, {204, 204, 204}, {204, 204, 204},
  4408. {204, 204, 204}, {204, 204, 204}, {205, 205, 205}, {205, 205, 205}, {205, 205, 205},
  4409. {205, 205, 205}, {206, 206, 206}, {206, 206, 206}, {206, 206, 206}, {207, 207, 207},
  4410. {207, 207, 207}, {207, 207, 207}, {207, 207, 207}, {208, 208, 208}, {208, 208, 208},
  4411. {208, 208, 208}, {208, 208, 208}, {209, 209, 209}, {209, 209, 209}, {209, 209, 209},
  4412. {209, 209, 209}, {210, 210, 210}, {210, 210, 210}, {210, 210, 210}, {210, 210, 210},
  4413. {211, 211, 211}, {211, 211, 211}, {211, 211, 211}, {211, 211, 211}, {212, 212, 212},
  4414. {212, 212, 212}, {212, 212, 212}, {212, 212, 212}, {213, 213, 213}, {213, 213, 213},
  4415. {213, 213, 213}, {213, 213, 213}, {214, 214, 214}, {214, 214, 214}, {214, 214, 214},
  4416. {214, 214, 214}, {215, 215, 215}, {215, 215, 215}, {215, 215, 215}, {215, 215, 215},
  4417. {216, 216, 216}, {216, 216, 216}, {216, 216, 216}, {216, 216, 216}, {217, 217, 217},
  4418. {217, 217, 217}, {217, 217, 217}, {217, 217, 217}, {218, 218, 218}, {218, 218, 218},
  4419. {218, 218, 218}, {218, 218, 218}, {219, 219, 219}, {219, 219, 219}, {219, 219, 219},
  4420. {220, 220, 220}, {220, 220, 220}, {220, 220, 220}, {220, 220, 220}, {221, 221, 221},
  4421. {221, 221, 221}, {221, 221, 221}, {221, 221, 221}, {222, 222, 222}, {222, 222, 222},
  4422. {222, 222, 222}, {222, 222, 222}, {223, 223, 223}, {223, 223, 223}, {223, 223, 223},
  4423. {223, 223, 223}, {224, 224, 224}, {224, 224, 224}, {224, 224, 224}, {224, 224, 224},
  4424. {225, 225, 225}, {225, 225, 225}, {225, 225, 225}, {225, 225, 225}, {226, 226, 226},
  4425. {226, 226, 226}, {226, 226, 226}, {226, 226, 226}, {227, 227, 227}, {227, 227, 227},
  4426. {227, 227, 227}, {227, 227, 227}, {228, 228, 228}, {228, 228, 228}, {228, 228, 228},
  4427. {228, 228, 228}, {229, 229, 229}, {229, 229, 229}, {229, 229, 229}, {229, 229, 229},
  4428. {230, 230, 230}, {230, 230, 230}, {230, 230, 230}, {230, 230, 230}, {231, 231, 231},
  4429. {231, 231, 231}, {231, 231, 231}, {232, 232, 232}, {232, 232, 232}, {232, 232, 232},
  4430. {232, 232, 232}, {233, 233, 233}, {233, 233, 233}, {233, 233, 233}, {233, 233, 233},
  4431. {234, 234, 234}, {234, 234, 234}, {234, 234, 234}, {234, 234, 234}, {235, 235, 235},
  4432. {235, 235, 235}, {235, 235, 235}, {235, 235, 235}, {236, 236, 236}, {236, 236, 236},
  4433. {236, 236, 236}, {236, 236, 236}, {237, 237, 237}, {237, 237, 237}, {237, 237, 237},
  4434. {237, 237, 237}, {238, 238, 238}, {238, 238, 238}, {238, 238, 238}, {238, 238, 238},
  4435. {239, 239, 239}, {239, 239, 239}, {239, 239, 239}, {239, 239, 239}, {240, 240, 240},
  4436. {240, 240, 240}, {240, 240, 240}, {240, 240, 240}, {241, 241, 241}, {241, 241, 241},
  4437. {241, 241, 241}, {241, 241, 241}, {242, 242, 242}, {242, 242, 242}, {242, 242, 242},
  4438. {242, 242, 242}, {243, 243, 243}, {243, 243, 243}, {243, 243, 243}, {244, 244, 244},
  4439. {244, 244, 244}, {244, 244, 244}, {244, 244, 244}, {245, 245, 245}, {245, 245, 245},
  4440. {245, 245, 245}, {245, 245, 245}, {246, 246, 246}, {246, 246, 246}, {246, 246, 246},
  4441. {246, 246, 246}, {247, 247, 247}, {247, 247, 247}, {247, 247, 247}, {247, 247, 247},
  4442. {248, 248, 248}, {248, 248, 248}, {248, 248, 248}, {248, 248, 248}, {249, 249, 249},
  4443. {249, 249, 249}, {249, 249, 249}, {249, 249, 249}, {250, 250, 250}, {250, 250, 250},
  4444. {250, 250, 250}, {250, 250, 250}, {251, 251, 251}, {251, 251, 251}, {251, 251, 251},
  4445. {251, 251, 251}, {252, 252, 252}, {252, 252, 252}, {252, 252, 252}, {252, 252, 252},
  4446. {253, 253, 253}, {253, 253, 253}, {253, 253, 253}, {253, 253, 253}, {254, 254, 254},
  4447. {254, 254, 254}, {254, 254, 254}, {254, 254, 254}, {255, 255, 255}, {255, 255, 255}
  4448. };
  4449. #endif