{"id":192912,"date":"2013-09-07T21:05:02","date_gmt":"2013-09-07T17:05:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=192912"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=192912","title":{"rendered":"<span class=\"post_title\">\u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u0432 ANSI<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u041d\u0435 \u0437\u043d\u0430\u044e, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u043c\u0443-\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043d\u043e \u043d\u0430 \u0434\u043d\u044f\u0445 \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0438\u0433\u0440\u0430\u0442\u044c\u0441\u044f \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<p>  \u0414\u0430\u043d\u043e: \u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, BMP) 640 \u043d\u0430 400, \u0448\u0440\u0438\u0444\u0442 8 \u043d\u0430 16<\/p>\n<p>  \u041d\u0430\u0434\u043e: \u041f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u0435\u0435 \u0432 ANSI \u043f\u0441\u0435\u0432\u0434\u043e\u0433\u0440\u0430\u0444\u0438\u043a\u0443 \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 80 \u043d\u0430 25 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u0438 \u0444\u043e\u043d \u043c\u043e\u0433\u0443\u0442 \u0438\u043c\u0435\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u0446\u0432\u0435\u0442 (true color).<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/392\/e7b\/b76\/392e7bb76f24230f03e19338a3358d64.png\" alt=\"image\"\/><\/p>\n<p>  <a name=\"habracut\"><\/a><br \/>  \u0417\u0434\u0435\u0441\u044c \u0441\u0442\u043e\u0438\u0442 \u043e\u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u00ab\u0442\u0440\u0443\u00bb EGA \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0440\u0435\u0436\u0438\u043c \u0441 16 \u0446\u0432\u0435\u0442\u0430\u043c\u0438 \u043d\u0430\u043c \u043d\u0435 \u043f\u043e\u0434\u043e\u0439\u0434\u0435\u0442, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043d\u0435\u043a\u0440\u0430\u0441\u0438\u0432\u043e \u0438\u0437-\u0437\u0430 \u043d\u0438\u0437\u043a\u043e\u0433\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0438 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432. \u0412\u0442\u043e\u0440\u043e\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442: \u0437\u0430\u0434\u0430\u0447\u0430 \u043d\u0435 \u0441\u0442\u043e\u0418\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u0438\u0431\u043b\u0438\u0437\u0438\u0442\u044c \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u0435\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u043e\u043c\u0443 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044e, \u0442\u0430\u043a \u043a\u0430\u043a \u0442\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0442\u044c \u0448\u0440\u0438\u0444\u0442, \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0438 \u0442.\u0434. \u0417\u0430\u0434\u0430\u0447\u0430 \u2014 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u0444\u0438\u043b\u044c\u0442\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043f\u0438\u0441\u0430\u043d \u0432\u044b\u0448\u0435.<\/p>\n<p>  \u0414\u043b\u044f \u0447\u0435\u0433\u043e \u044f \u0437\u0434\u0435\u0441\u044c \u044d\u0442\u043e \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u044e: \u043c\u043d\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430\u043c \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u043f\u043e\u043f\u0440\u0430\u043a\u0442\u0438\u043a\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043e\u0442\u043c\u0435\u0442\u0438\u043b \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b, \u043a\u0430\u043a \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b.<\/p>\n<p>  \u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043a\u0430\u043a\u0430\u044f-\u043d\u0438\u0431\u0443\u0434\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0439, \u0443\u043c\u0435\u044e\u0449\u0430\u044f getpixel \u0438 putpixel, \u0442\u043e \u0435\u0441\u0442\u044c \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0446\u0432\u0435\u0442 \u043f\u0438\u043a\u0441\u0435\u043b\u044f \u0441 \u044d\u043a\u0440\u0430\u043d\u0430 \u0438 \u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u043f\u0438\u043a\u0441\u0435\u043b\u044c \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c \u0446\u0432\u0435\u0442\u043e\u043c \u043d\u0430 \u044d\u043a\u0440\u0430\u043d. \u042f \u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0441\u044c \u0441\u0442\u0430\u0440\u0435\u043d\u044c\u043a\u043e\u0439, \u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 Allegro (www.allegro.cc), \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043b\u0435\u0433\u043a\u0430 \u0432 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u041e\u0421 (\u0434\u0430\u0436\u0435 \u0432 MSDOS!).<\/p>\n<p>  \u041d\u043e \u0445\u0432\u0430\u0442\u0438\u0442 \u0441\u043b\u043e\u0432, \u043f\u043e\u0440\u0430 \u043a \u0434\u0435\u043b\u0443.<\/p>\n<pre><code class=\"cpp\">const int size_x=640; const int size_y=400; const int ascii_x=80; const int ascii_y=25; <\/code><\/pre>\n<p>  \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0435 \u0437\u0430 \u0440\u0430\u0437\u043c\u0435\u0440 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0438 \u0440\u0430\u0437\u043c\u0435\u0440 \u0435\u0435 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"cpp\">for(int cx=0;cx&lt;ascii_x;cx++) \tfor(int cy=0;cy&lt;ascii_y;cy++){ \t\tint fullr=0; \t\tint fullg=0; \t\tint fullb=0; \t\tint pixels=0;  \/\/find background color \t\tfor(int i=0;i&lt;size_x\/ascii_x;i++) \t\tfor(int j=0;j&lt;size_y\/ascii_y;j++){ \t\t\tint col=getpixel(pic,i+cx*size_x\/ascii_x,j+cy*size_y\/ascii_y); \t\t\tint r=getr(col); \t\t\tint g=getg(col); \t\t\tint b=getb(col); \t\t\tfullr+=r;fullg+=g;fullb+=b; \t\t\tpixels++; \t\t} \t\tfullr\/=pixels;fullg\/=pixels;fullb\/=pixels; <\/code><\/pre>\n<p>  \u041d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0446\u0438\u043a\u043b, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0438\u0437 80 \u043d\u0430 25 \u043c\u0430\u0442\u0440\u0438\u0446\u044b. \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0446\u0438\u043a\u043b \u2014 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043f\u0438\u043a\u0441\u0435\u043b\u044e \u0442\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0441\u0438\u043c\u0432\u043e\u043b\u0443 \u0438\u0437 \u044d\u0442\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u044b. \u041a\u0430\u043a \u043b\u0435\u0433\u043a\u043e \u0441\u043e\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c, \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u044d\u0442\u0430 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 640\/80=8 \u043d\u0430 400\/25=16 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439. \u0417\u0434\u0435\u0441\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u043a\u0430\u043a \u0440\u0430\u0437 \u0440\u0430\u0432\u043d\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0443 \u043d\u0430\u0448\u0435\u0433\u043e \u0448\u0440\u0438\u0444\u0442\u0430.<\/p>\n<p>  \u0412 \u044d\u0442\u043e\u043c \u0432\u0442\u043e\u0440\u043e\u043c \u0446\u0438\u043a\u043b\u0435 \u043d\u0430\u0448\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u2014 \u043d\u0430\u0439\u0442\u0438 \u0441\u0440\u0435\u0434\u043d\u0438\u0439 \u0446\u0432\u0435\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0446\u0432\u0435\u0442\u0430 \u0444\u043e\u043d\u0430 \u043d\u0430\u0448\u0435\u0433\u043e ANSI \u0441\u0438\u043c\u0432\u043e\u043b\u0430. \u0421\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e: \u0440\u0430\u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u0446\u0432\u0435\u0442 \u043d\u0430 R, G, B \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u043d\u0438\u0445.<\/p>\n<pre><code class=\"cpp\">\/\/find ascii and its color \t\tint rms=100000000;  \t\tfor(int curch=1;curch&lt;256;curch++){ \/\/loop over ASCII table \t\t\tint charr=0; \t\t\tint charg=0; \t\t\tint charb=0;  \/\/find char color \t\t\tpixels=0; \/\/number of pixels for char \t\t\tfor(i=0;i&lt;size_x\/ascii_x;i++) \t\t\tfor(int j=0;j&lt;size_y\/ascii_y;j++){ \t\t\t\tint col=getpixel(pic,i+cx*size_x\/ascii_x,j+cy*size_y\/ascii_y); \t\t\t\tint r=getr(col); \t\t\t\tint g=getg(col); \t\t\t\tint b=getb(col);  \t\t\t\tint colch=getpixel(font,i+(curch%32)*8,j+(curch\/32)*16); \t\t\t\tint rc=getr(colch); \t\t\t\tint gc=getg(colch); \t\t\t\tint bc=getb(colch); \t\t\t\tif(rc!=0&&gc!=0&&bc!=0){ \/\/get actual char pixels only \t\t\t\t\tcharr+=r; \t\t\t\t\tcharg+=g; \t\t\t\t\tcharb+=b; \t\t\t\t\tpixels++; \t\t\t\t} \t\t\t} \t\t\tif(pixels!=0){ \t\t\t\tcharr\/=pixels;charg\/=pixels;charb\/=pixels; \t\t\t} <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u044c\u0448\u0435 \u0443\u0436\u0435 \u0431\u043e\u043b\u0435\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e. \u041d\u0430\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0446\u0438\u043a\u043b \u2014 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0441\u0438\u043c\u0432\u043e\u043b\u0443 \u0438\u0437 ASCII \u0442\u0430\u0431\u043b\u0438\u0446\u044b (\u0432\u0441\u0435\u0433\u043e \u0438\u0445 256). \u042f \u0431\u0435\u0440\u0443 \u0438\u0445 \u0438\u0437 \u0447\u0435\u0440\u043d\u043e-\u0431\u0435\u043b\u043e\u0439 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0441 \u0448\u0440\u0438\u0444\u0442\u043e\u043c, \u0442\u043e \u0435\u0441\u0442\u044c \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u0442\u0430\u043c \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043b\u044e\u0431\u044b\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f 8 \u043d\u0430 16 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u0430. \u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0432 \u044d\u0442\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043e\u0434\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u044c\u044e \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u0438\u0440\u0438\u043b\u043b\u0438\u0446\u0435\u0439), \u0447\u0442\u043e <\/p>\n<p>  \u0412 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u0432\u044b\u0448\u0435 \u043a\u0443\u0441\u043a\u0435 \u043a\u043e\u0434\u0430 \u043c\u044b \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0446\u0432\u0435\u0442 \u0441\u0438\u043c\u0432\u043e\u043b\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u0441\u0443\u043c\u043c\u0443 \u043a\u0430\u043a \u0432\u044b\u0448\u0435, \u043d\u043e \u0441 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c: \u043f\u0438\u043a\u0441\u0435\u043b\u0438 \u0431\u0435\u0440\u0443\u0442\u0441\u044f \u043f\u043e \u043c\u0430\u0441\u043a\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0438\u0437 \u0448\u0440\u0438\u0444\u0442\u0430. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0432\u0442\u043e\u0440\u043e\u0439 \u00ab\u0441\u0440\u0435\u0434\u043d\u0438\u0439 \u0446\u0432\u0435\u0442\u00bb \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u043d \u0441\u0430\u043c \u0441\u0438\u043c\u0432\u043e\u043b.<\/p>\n<p>  \u0421\u0442\u043e\u0438\u0442 \u0442\u0430\u043a\u0436\u0435 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0447\u0438\u0441\u043b\u043e \u0442\u0430\u043a\u0438\u0445 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0440\u0430\u0432\u043d\u043e \u043d\u0443\u043b\u044e (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0438\u043c\u0432\u043e\u043b 32 \u2014 \u043f\u0440\u043e\u0431\u0435\u043b). \u0421 \u044d\u0442\u0438\u043c \u043d\u0430\u0434\u043e \u0431\u044b\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u0435\u0435.<\/p>\n<pre><code class=\"cpp\">\/\/find rms \t\t\tint currms=0; \t\t\tfor(i=0;i&lt;size_x\/ascii_x;i++) \t\t\tfor(int j=0;j&lt;size_y\/ascii_y;j++){ \t\t\t\tint col=getpixel(pic,i+cx*size_x\/ascii_x,j+cy*size_y\/ascii_y); \t\t\t\tint r=getr(col); \t\t\t\tint g=getg(col); \t\t\t\tint b=getb(col); \t\t\t\tint rr=0,gg=0,bb=0;  \t\t\t\tint colch=getpixel(font,i+(curch%32)*8,j+(curch\/32)*16); \t\t\t\tint rc=getr(colch); \t\t\t\tint gc=getg(colch); \t\t\t\tint bc=getb(colch); \t\t\t\tif(rc!=0&&gc!=0&&bc!=0){ \/\/char pixel \t\t\t\t\trr=charr; \t\t\t\t\tgg=charg; \t\t\t\t\tbb=charb; \t\t\t\t} \t\t\t\telse{ \/\/back pixel \t\t\t\t\trr=fullr; \t\t\t\t\tgg=fullg; \t\t\t\t\tbb=fullb; \t\t\t\t} \t\t\t\tcurrms+=sqrt((r-rr)*(r-rr)+(g-gg)*(g-gg)+(b-bb)*(b-bb)); \t\t\t}  \t\t\tif(currms&lt;rms){ \/\/find minimal rms \t\t\t\tfindr=charr; \t\t\t\tfindg=charg; \t\t\t\tfindb=charb;  \t\t\t\tfindch=curch; \t\t\t\trms=currms; \t\t\t\tif(DEBUG)printf(&quot;!!!%d %d\\n&quot;,currms, curch); \t\t\t} \t\t\telse \t\t\t\tif(DEBUG)printf(&quot;%d %d\\n&quot;,currms, curch);  \t\t} \/\/find char <\/code><\/pre>\n<p>  \u041d\u0443 \u0438, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u043f\u0440\u0438\u0448\u043b\u0438 \u043a \u0441\u0430\u043c\u043e\u0439 \u0441\u043e\u043b\u0438. \u0412 \u044d\u0442\u043e\u043c \u043a\u0443\u0441\u043a\u0435 \u043a\u043e\u0434\u0430 \u043c\u044b \u0435\u0449\u0435 \u0440\u0430\u0437 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c\u0441\u044f \u043f\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u043c \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0438 \u0441\u0447\u0438\u0442\u0430\u0435\u043c RMS (\u0441\u0440\u0435\u0434\u043d\u0435\u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u043e\u0435 \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u0435) \u0432\u0441\u0435\u0445 \u0442\u0440\u0435\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0446\u0432\u0435\u0442\u0430 \u043e\u0442 \u0446\u0432\u0435\u0442\u0430 \u0444\u043e\u043d\u0430 \u0438\u043b\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 (\u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0438\u043a\u0441\u0435\u043b\u044c \u043d\u0430 \u0444\u043e\u043d\u0435 \u0438\u043b\u0438 \u043d\u0430 \u0441\u0438\u043c\u0432\u043e\u043b\u0435). \u0421\u0443\u043c\u043c\u0430\u0440\u043d\u044b\u0439 RMS \u0438 \u0431\u0443\u0434\u0435\u0442 \u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0435\u043c \u0442\u043e\u0433\u043e, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u0430\u043d\u043d\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0445\u043e\u0440\u043e\u0448\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u0430\u043d\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438.<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0432\u044b\u0432\u043e\u0434 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d (\u0432 \u0434\u0432\u0443\u0445 \u0440\u0435\u0436\u0438\u043c\u0430\u0445 \u2014 \u0441 \u0444\u043e\u043d\u043e\u043c \u0438 \u0431\u0435\u0437 (<a href=\"http:\/\/dimouse.ru\/images\/s.png\">\u043f\u0440\u0438\u043c\u0435\u0440<\/a>)), \u043d\u043e \u043d\u0430 \u043d\u0435\u043c \u043c\u044b \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0431\u0443\u0434\u0435\u043c, \u0442\u0430\u043a \u043a\u0430\u043a \u0442\u0430\u043c \u0432\u0441\u0451 \u0441\u0430\u043c\u043e\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/854\/984\/ec4\/854984ec47b098fe99f312db664f9659.png\" alt=\"image\"\/><\/p>\n<p>  \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0437\u0434\u0435\u0441\u044c: <a href=\"http:\/\/dimouse.ru\/data\/ansiconv.rar\">dimouse.ru\/data\/ansiconv.rar<\/a> (130 Kb).<\/p>\n<p>  \u041a\u0430\u043a \u043d\u0430\u0441\u0447\u0435\u0442 \u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u0434\u0435\u043b\u043e \u0432 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435? \u041a\u0430\u043a \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0444\u0430\u0439\u043b \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 (\u043a\u0440\u043e\u043c\u0435 \u043d\u043e\u0432\u043e\u0433\u043e bmp) \u2014 ascii. \u0422\u0430\u043c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 ASCII \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u0435\u0433\u043e \u0446\u0432\u0435\u0442 \u0438 \u0446\u0432\u0435\u0442 \u0435\u0433\u043e \u0444\u043e\u043d\u0430. \u042f \u0434\u043b\u044f \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u0440\u0435\u0436\u0438\u043c\u0430 \u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0441\u044c <a href=\"http:\/\/pdcurses.sourceforge.net\/\">pdcurses.sourceforge.net\/<\/a> (\u043f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445, \u0435\u0441\u043b\u0438 \u0437\u043d\u0430\u0435\u0442\u0435 \u0447\u0442\u043e-\u0442\u043e \u043b\u0443\u0447\u0448\u0435!), \u043d\u043e \u044d\u0442\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u0445\u043e\u0442\u044c \u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0440\u0430\u043f\u043f\u0435\u0440\u043e\u043c \u043d\u0430\u0434 SDL (\u0432\u043e \u0432\u0441\u044f\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0432\u0438\u043d\u0434\u043e\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u2014 \u0442\u043e\u0447\u043d\u043e), \u043d\u0435 \u0443\u043c\u0435\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0446\u0432\u0435\u0442\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 16: \u0442\u044f\u0436\u0435\u043b\u043e\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u0438\u0435 \u0434\u0440\u0435\u0432\u043d\u043e\u0441\u0442\u0438. \u041a\u0430\u043a \u0432\u044b, \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u043f\u043e\u043c\u043d\u0438\u0442\u0435, PDCurses \u0431\u0435\u0440\u0435\u0442 \u0441\u0432\u043e\u0435 \u043d\u0430\u0447\u0430\u043b\u043e \u043e\u0442 \u0437\u043d\u0430\u043c\u0435\u043d\u0438\u0442\u043e\u0439 Interactive Fiction \u0438\u0433\u0440\u044b <a href=\"http:\/\/en.wikipedia.org\/wiki\/Curses_(video_game)\">Curses<\/a>. \u041d\u043e \u043e\u0434\u0438\u043d \u0442\u043e\u0432\u0430\u0440\u0438\u0449 \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0443\u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0438 \u0432\u044b\u043b\u043e\u0436\u0438\u043b \u0437\u0434\u0435\u0441\u044c: <a href=\"http:\/\/www.projectpluto.com\/win32a.htm\">www.projectpluto.com\/win32a.htm<\/a><\/p>\n<p>  \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0432 \u043d\u0435\u0439 \u043d\u0435\u043b\u044c\u0437\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c bitmap \u0448\u0440\u0438\u0444\u0442, \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 (\u0437\u0430\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0439), \u0447\u0442\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0440\u0442\u0438\u0442 \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u0435\u043d\u0438\u0435. \u041d\u043e \u0437\u0430\u0434\u0430\u0447\u0443 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u043e\u0439.<\/p>\n<p>  \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f ascii \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0437\u0434\u0435\u0441\u044c: <a href=\"http:\/\/dimouse.ru\/data\/ascii.rar\">dimouse.ru\/data\/ascii.rar<\/a> (70 Kb).    \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/192912\/\"> http:\/\/habrahabr.ru\/post\/192912\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u041d\u0435 \u0437\u043d\u0430\u044e, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u043c\u0443-\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043d\u043e \u043d\u0430 \u0434\u043d\u044f\u0445 \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0438\u0433\u0440\u0430\u0442\u044c\u0441\u044f \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<p>  \u0414\u0430\u043d\u043e: \u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, BMP) 640 \u043d\u0430 400, \u0448\u0440\u0438\u0444\u0442 8 \u043d\u0430 16<\/p>\n<p>  \u041d\u0430\u0434\u043e: \u041f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u0435\u0435 \u0432 ANSI \u043f\u0441\u0435\u0432\u0434\u043e\u0433\u0440\u0430\u0444\u0438\u043a\u0443 \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 80 \u043d\u0430 25 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u0438 \u0444\u043e\u043d \u043c\u043e\u0433\u0443\u0442 \u0438\u043c\u0435\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u0446\u0432\u0435\u0442 (true color).<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/392\/e7b\/b76\/392e7bb76f24230f03e19338a3358d64.png\" alt=\"image\"\/><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-192912","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/192912","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=192912"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/192912\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=192912"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=192912"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=192912"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}