{"id":459260,"date":"2025-05-12T03:33:14","date_gmt":"2025-05-12T03:33:14","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=459260"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=459260","title":{"rendered":"<span>\u041a\u0430\u043a \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f?<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/cd5\/f36\/c82\/cd5f36c82acd0a23a6e25dc2f8785b41.jpg\" width=\"1920\" height=\"1080\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/cd5\/f36\/c82\/cd5f36c82acd0a23a6e25dc2f8785b41.jpg 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/cd5\/f36\/c82\/cd5f36c82acd0a23a6e25dc2f8785b41.jpg 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u042d\u0442\u043e\u0442 \u043f\u043e\u0441\u0442 \u2014 \u043f\u043e\u0433\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0432 \u043a\u0440\u043e\u043b\u0438\u0447\u044c\u044e \u043d\u043e\u0440\u0443. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u041c\u043e\u043d\u0441\u0435\u0444 \u0410\u0431\u0431\u0430\u0434 \u0437\u0430\u0434\u0443\u043c\u0430\u043b\u0441\u044f \u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u0445 \u2014 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u043f\u043e\u0441\u043b\u0435 <a href=\"https:\/\/cefboud.com\/posts\/compression\/\">\u043d\u0435\u0434\u0430\u0432\u043d\u0435\u0433\u043e \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f<\/a> \u0438\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0445\u0435\u043c \u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u0438. \u041e\u0431\u0449\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0447\u0442\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0431\u044b\u0432\u0430\u044e\u0442 \u043b\u0438\u0431\u043e \u043f\u043e\u043b\u0443\u0442\u043e\u043d\u043e\u0432\u044b\u043c\u0438, \u043b\u0438\u0431\u043e RGB, \u043a\u043e\u0433\u0434\u0430 \u043d\u043e\u0432\u044b\u0435 \u0446\u0432\u0435\u0442\u0430 \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u043c\u0435\u0448\u0435\u043d\u0438\u044f \u043a\u0440\u0430\u0441\u043d\u043e\u0433\u043e, \u0437\u0435\u043b\u0451\u043d\u043e\u0433\u043e \u0438 \u0441\u0438\u043d\u0435\u0433\u043e. \u041d\u043e \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u0447\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0435\u0435, \u0447\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u0435 \u0442\u0440\u0435\u0445\u0431\u0430\u0439\u0442\u043e\u0432\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 RGB. <\/p>\n<p>\u0427\u0442\u043e-\u0442\u043e \u0432 \u044d\u0442\u043e\u0439 \u0438\u0434\u0435\u0435 \u043f\u0440\u043e\u0431\u0443\u0434\u0438\u043b\u043e \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u0441\u0442\u0432\u043e \u0430\u0432\u0442\u043e\u0440\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u043e\u043d \u043f\u043e\u043f\u044b\u0442\u0430\u043b\u0441\u044f \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0438\u0442\u044c \u0435\u0433\u043e \u0438 \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441: \u043a\u0430\u043a \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f?<\/p>\n<hr\/>\n<h2>\u041e\u0441\u043d\u043e\u0432\u044b  <\/h2>\n<p>\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u2014 \u044d\u0442\u043e \u043d\u0430\u0431\u043e\u0440 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439. \u041f\u0438\u043a\u0441\u0435\u043b\u044c \u2014 \u00a0\u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0430\u044f \u0435\u0434\u0438\u043d\u0438\u0446\u0430 \u0446\u0432\u0435\u0442\u0430 \u0432 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0438\u0437 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0433\u043e <a href=\"https:\/\/en.wikipedia.org\/wiki\/MNIST_database\">\u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430 MNIST<\/a>:<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1a7\/ed6\/521\/1a7ed652160402b799d4121884ea8648.png\" width=\"3164\" height=\"1660\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/1a7\/ed6\/521\/1a7ed652160402b799d4121884ea8648.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1a7\/ed6\/521\/1a7ed652160402b799d4121884ea8648.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u042d\u0442\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 28&#215;28 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 (\u0438\u043b\u0438 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043e\u0432). \u041e\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043e \u0432 \u0433\u0440\u0430\u0434\u0430\u0446\u0438\u044f\u0445 \u0441\u0435\u0440\u043e\u0433\u043e, \u0442\u043e \u0435\u0441\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u0438\u043a\u0441\u0435\u043b\u044c \u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043e\u0442 0 \u0434\u043e 255, \u0433\u0434\u0435 0 \u2014 \u0447\u0451\u0440\u043d\u044b\u0439, \u0430 255 \u2014 \u0431\u0435\u043b\u044b\u0439.<\/p>\n<p>\u0410 \u043a\u0430\u043a \u043d\u0430\u0441\u0447\u0435\u0442 \u0446\u0432\u0435\u0442\u043d\u044b\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439? \u0412 \u043d\u0438\u0445 \u0442\u0430\u043a\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043f\u0438\u043a\u0441\u0435\u043b\u0438, \u043d\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u0438\u043a\u0441\u0435\u043b\u044c \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0435 RGB-\u0442\u0440\u0438\u043f\u043b\u0435\u0442\u0430. \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f 3 \u0431\u0430\u0439\u0442\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0435\u0433\u043e \u0446\u0432\u0435\u0442: \u043a\u0440\u0430\u0441\u043d\u044b\u0439, \u0437\u0435\u043b\u0435\u043d\u044b\u0439 \u0438 \u0441\u0438\u043d\u0438\u0439. (0, 0, 0) \u2014 \u044d\u0442\u043e \u0447\u0451\u0440\u043d\u044b\u0439 \u0446\u0432\u0435\u0442, \u0430 (255, 255, 255) \u2014 \u0431\u0435\u043b\u044b\u0439. \u0421\u0443\u0442\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0438 \u0441\u0432\u0435\u0442\u043b\u043e\u0433\u043e (0, 0, 0), \u0446\u0432\u0435\u0442 \u2014 \u0447\u0451\u0440\u043d\u044b\u0439, \u0430 \u0441\u043c\u0435\u0448\u0438\u0432\u0430\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0446\u0432\u0435\u0442\u0430, \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0435 \u0431\u0435\u043b\u044b\u0439. \u041a\u0440\u0430\u0441\u043d\u044b\u0439 \u2014 \u044d\u0442\u043e (255, 0, 0), \u0437\u0435\u043b\u0435\u043d\u044b\u0439 \u2014 (0, 255, 0), \u0430 \u0441\u0438\u043d\u0438\u0439 \u2014 (0, 0, 255).<\/p>\n<p>RGB \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0447\u0435\u0442\u0432\u0451\u0440\u0442\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u0430\u043b\u044c\u0444\u0430, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0435\u0433\u043e RGBA. \u0410\u043b\u044c\u0444\u0430 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u043d\u0435\u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c \u0438\u043b\u0438 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c \u043f\u0438\u043a\u0441\u0435\u043b\u044f. \u041e\u043d \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442, \u043a\u0430\u043a \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c. \u0427\u0435\u043c \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u0435\u0435 \u043f\u0438\u043a\u0441\u0435\u043b\u044c, \u0442\u0435\u043c \u043c\u0435\u043d\u044c\u0448\u0435 \u043e\u043d \u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0444\u043e\u043d \u0437\u0430 \u043d\u0438\u043c. \u041f\u0440\u0438 \u043d\u0430\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0434\u0432\u0443\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0430\u043b\u044c\u0444\u0430-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0444\u043e\u043d\u043e\u0432\u043e\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043f\u0438\u043a\u0441\u0435\u043b\u044c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0434\u043d\u0435\u0433\u043e \u043f\u043b\u0430\u043d\u0430.<\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0437\u043d\u0430\u043c\u0435\u043d\u0438\u0442\u044b\u0439 \u043a\u043b\u0435\u0442\u0447\u0430\u0442\u044b\u0439 \u0443\u0437\u043e\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u0438. \u0412 \u043b\u0435\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043d\u0435\u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0441\u043e\u043a\u0430\u044f (\u0430\u043b\u044c\u0444\u0430-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432\u044b\u0441\u043e\u043a\u043e\u0435), \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0444\u043e\u043d \u043d\u0435\u0432\u0438\u0434\u0438\u043c\u044b\u043c. \u041d\u0430\u043f\u0440\u043e\u0442\u0438\u0432, \u0432 \u043f\u0440\u0430\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438, \u0433\u0434\u0435 \u043d\u0435\u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c \u043d\u0438\u0436\u0435 (\u0430\u043b\u044c\u0444\u0430 \u043d\u0438\u0437\u043a\u0430\u044f), \u043a\u043b\u0435\u0442\u0447\u0430\u0442\u044b\u0439 \u0444\u043e\u043d \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0432\u0438\u0434\u0438\u043c\u044b\u043c.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/340\/53d\/973\/34053d9735f43dc00fc27c27074e7179.jpg\" width=\"800\" height=\"532\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/340\/53d\/973\/34053d9735f43dc00fc27c27074e7179.jpg 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/340\/53d\/973\/34053d9735f43dc00fc27c27074e7179.jpg 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u0445\u0440\u0430\u043d\u0438\u043c \u0446\u0432\u0435\u0442\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 (3 \u0431\u0430\u0439\u0442\u0430 \u043d\u0430 \u043f\u0438\u043a\u0441\u0435\u043b\u044c) \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 1920&#215;1080 \u0431\u0435\u0437 \u0441\u0436\u0430\u0442\u0438\u044f, \u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f 1920x1080x3 = 6 220 800 \u0431\u0430\u0439\u0442 (\u043e\u043a\u043e\u043b\u043e 6 \u041c\u0411)!<\/p>\n<p>1080p \u2014 \u043e\u0431\u044b\u0447\u043d\u043e\u0435 \u0434\u0435\u043b\u043e \u0434\u043b\u044f \u0432\u0438\u0434\u0435\u043e, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a 240p (\u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 VHS) \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043d\u0438\u0437\u043a\u0438\u043c \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e\u043c. 480p \u2014 \u044d\u0442\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0443 DVD.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u043b\u0438 \u043d\u0435\u0441\u0436\u0430\u0442\u043e\u0435 \u0432\u0438\u0434\u0435\u043e 1080p \u0441 \u0447\u0430\u0441\u0442\u043e\u0442\u043e\u0439 24 \u043a\u0430\u0434\u0440\u0430 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443, \u044d\u0442\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e \u0431\u044b \u0431\u043e\u043b\u0435\u0435 1 \u0433\u0438\u0433\u0430\u0431\u0438\u0442\u0430 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443, \u0447\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u043e\u043b\u043e\u0441\u0441\u0430\u043b\u044c\u043d\u043e! \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0435\u0441\u043b\u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0436\u0430\u0442\u0438\u0435 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0443\u0445\u0438\u0449\u0440\u0435\u043d\u0438\u044f, \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u0430\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0432\u044b\u0441\u043e\u043a\u043e\u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u0438\u0434\u0435\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u0430.<\/p>\n<p><a href=\"https:\/\/cefboud.com\/posts\/compression\/\">\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0441\u0436\u0430\u0442\u0438\u044f \u0431\u0435\u0437 \u043f\u043e\u0442\u0435\u0440\u044c<\/a> \u043e\u0431\u044b\u0447\u043d\u043e \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u044e\u0442 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u0430 \u0441\u0436\u0430\u0442\u0438\u044f \u0432 \u043b\u0443\u0447\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 3:4. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u044e\u0442 \u0442\u0430\u043a\u0438\u0445 \u0432\u044b\u0441\u043e\u043a\u0438\u0445 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432, \u0447\u0430\u0441\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u0442\u0440\u0430\u0442 \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0438\u0445 \u043d\u0435\u043f\u0440\u0438\u0433\u043e\u0434\u043d\u044b\u043c\u0438 \u0434\u043b\u044f \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u043e\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u0414\u0430\u0436\u0435 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u0430 3:4 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0432\u0438\u0434\u0435\u043e \u0432\u044b\u0441\u043e\u043a\u043e\u0433\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0441 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0447\u0430\u0441\u0442\u043e\u0442\u043e\u0439 \u043a\u0430\u0434\u0440\u043e\u0432.<\/p>\n<p>\u0418\u043c\u0435\u043d\u043d\u043e \u0437\u0434\u0435\u0441\u044c \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0441\u0436\u0430\u0442\u0438\u0435 \u0441 \u043f\u043e\u0442\u0435\u0440\u044f\u043c\u0438. \u041e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0445, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043b\u0443\u0447\u0448\u0435\u0433\u043e \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u0430 \u0441\u0436\u0430\u0442\u0438\u044f. \u0421\u0445\u0435\u043c\u044b \u0441\u0436\u0430\u0442\u0438\u044f \u0441 \u043f\u043e\u0442\u0435\u0440\u044f\u043c\u0438 \u0447\u0430\u0441\u0442\u043e \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439, \u0432 \u043a\u0430\u043a\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u043c\u044b \u0433\u043e\u0442\u043e\u0432\u044b \u043f\u043e\u0436\u0435\u0440\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0432 \u043e\u0431\u043c\u0435\u043d \u043d\u0430 \u043b\u0443\u0447\u0448\u0438\u0439 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u0441\u0436\u0430\u0442\u0438\u044f.<\/p>\n<h2>\u0424\u043e\u0440\u043c\u0430\u0442\u044b \u0431\u0435\u0437 \u043f\u043e\u0442\u0435\u0440\u044c<\/h2>\n<h3>GIF<\/h3>\n<p>Graphical Interchange Format, GIF (\u043f\u0440\u043e\u0438\u0437\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a\u0430\u043a \u00abgif\u00bb \u043e\u0442 \u00abgift\u00bb) \u2014 \u044d\u0442\u043e \u0444\u043e\u0440\u043c\u0430\u0442 \u0441\u0436\u0430\u0442\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0431\u0435\u0437 \u043f\u043e\u0442\u0435\u0440\u044c. \u0412 \u043d\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u043f\u0430\u043b\u0438\u0442\u0440\u0430 \u0438\u0437 256 \u0446\u0432\u0435\u0442\u043e\u0432, \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u0430\u0434\u0430\u0435\u0442\u0441\u044f 3 \u0431\u0430\u0439\u0442\u0430\u043c\u0438 \u0434\u043b\u044f RGB. \u0418 \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c 3 \u0431\u0430\u0439\u0442\u0430 \u0434\u043b\u044f \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f, \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0438\u043d\u0434\u0435\u043a\u0441, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u043d\u0430 \u043e\u0434\u0438\u043d \u0438\u0437 \u0446\u0432\u0435\u0442\u043e\u0432 \u0432 \u043f\u0430\u043b\u0438\u0442\u0440\u0435. \u0418\u0434\u0435\u044f \u0437\u0434\u0435\u0441\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0430\u043b\u0438\u0442\u0440\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043e\u0442\u0442\u0435\u043d\u043a\u043e\u0432 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u0440\u0438 256 \u0446\u0432\u0435\u0442\u0430\u0445 \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0432\u0441\u0435\u0433\u043e 1 \u0431\u0430\u0439\u0442 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0438 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u0441\u0436\u0430\u0442\u0438\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 3:1. \u0425\u043e\u0442\u044f \u043c\u0430\u043b\u043e\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043c\u0438\u0440\u0435 \u0438\u043c\u0435\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e 256 \u0446\u0432\u0435\u0442\u043e\u0432, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0444\u043e\u0440\u043c\u0430 \u0441\u0436\u0430\u0442\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u043b\u0430 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0442\u0438 \u0440\u0430\u043d\u044c\u0448\u0435. \u041e\u0434\u043d\u0430\u043a\u043e \u0441\u0430\u043c GIF \u043d\u0435 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u044d\u0442\u043e \u0441\u0436\u0430\u0442\u0438\u0435.<\/p>\n<p>\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 w \u00d7 h 8-\u0431\u0438\u0442\u043d\u044b\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u043f\u0430\u043b\u0438\u0442\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u0442\u0435\u043c \u043a\u043e\u0434\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0435\u0445\u043d\u0438\u043a\u0438 <a href=\"https:\/\/cefboud.com\/posts\/compression\/#primer-on-compression\">LZ <\/a>(\u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0435\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0441 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u043e\u0439).<\/p>\n<p>\u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, GIF \u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d \u0442\u0435\u043c, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0432 \u043e\u0434\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0430\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f.<\/p>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2e0\/b3c\/b52\/2e0b3cb525620acc688b87f5a39940cb.gif\" width=\"330\" height=\"216\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2e0\/b3c\/b52\/2e0b3cb525620acc688b87f5a39940cb.gif 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2e0\/b3c\/b52\/2e0b3cb525620acc688b87f5a39940cb.gif 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e GIF \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 Go. \u041f\u043e\u043b\u0430\u0433\u0430\u044e, \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e GIF, \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043d\u044f\u0442\u044c \u044d\u0442\u043e\u0442 \u0444\u043e\u0440\u043c\u0430\u0442:<\/p>\n<pre><code class=\"go\">images := []*image.Paletted{...} \/\/ The successive delay times, one per frame, in 100ths of a second \/\/ In this example, we have three images with 0.5 second delay between each delays := []int{50,50,50}  f, _ := os.OpenFile(\"amazing.gif\", os.O_WRONLY|os.O_CREATE, 0600) defer f.Close() gif.EncodeAll(f, &amp;gif.GIF{     Image: images,     Delay: delays,  })<\/code><\/pre>\n<p>API \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f GIF \u0432 Go \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442: \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0441 \u043f\u0430\u043b\u0438\u0442\u0440\u043e\u0439 \u0438 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u043d\u0443\u0436\u043d\u044b\u0439 \u043d\u0430\u043c \u0444\u0430\u0439\u043b.<\/p>\n<p>\u0412\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 <a href=\"https:\/\/github.com\/golang\/go\/blob\/f6d17c540024418ca8a92371931b1b4fb076d2b6\/src\/image\/image.go#L1148-L1159\">Paletted<\/a>:<\/p>\n<pre><code class=\"go\">package image  \/\/ Paletted is an in-memory image of uint8 indices into a given palette. type Paletted struct { \/\/ Pix holds the image's pixels, as palette indices. The pixel at \/\/ (x, y) starts at Pix[(y-Rect.Min.Y)*Stride + (x-Rect.Min.X)*1]. Pix []uint8 \/\/ Stride is the Pix stride (in bytes) between vertically adjacent pixels. Stride int \/\/ Rect is the image's bounds. Rect Rectangle \/\/ Palette is the image's palette. Palette color.Palette }  type Palette []Color  \/\/ Color can convert itself to alpha-premultiplied 16-bits per channel RGBA. \/\/ The conversion may be lossy. type Color interface { \/\/ RGBA returns the alpha-premultiplied red, green, blue and alpha values \/\/ for the color. Each value ranges within [0, 0xffff], but is represented \/\/ by a uint32 so that multiplying by a blend factor up to 0xffff will not \/\/ overflow. \/\/ \/\/ An alpha-premultiplied color component c has been scaled by alpha (a), \/\/ so has valid values 0 &lt;= c &lt;= a. RGBA() (r, g, b, a uint32) }  \/\/ A Rectangle contains the points with Min.X &lt;= X &lt; Max.X, Min.Y &lt;= Y &lt; Max.Y. \/\/ It is well-formed if Min.X &lt;= Max.X and likewise for Y. Points are always \/\/ well-formed. A rectangle's methods always return well-formed outputs for \/\/ well-formed inputs. type Rectangle struct { Min, Max Point }  \/\/ A Point is an X, Y coordinate pair. The axes increase right and down. type Point struct { X, Y int }<\/code><\/pre>\n<p>\u041f\u0430\u043b\u0438\u0442\u0440\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c\u0438 \u043f\u043e\u043b\u044f\u043c\u0438:<\/p>\n<ul>\n<li>\n<p><strong>Rectangle<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0435\u0440\u0445\u043d\u0435\u0439 \u043b\u0435\u0432\u043e\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 (min) \u0438 \u043d\u0438\u0436\u043d\u0435\u0439 \u043f\u0440\u0430\u0432\u043e\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 (max). \u041f\u0440\u043e\u0441\u0442\u043e \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e! \u0427\u0442\u043e\u0431\u044b \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443, \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e <code>Min = (0, 0)<\/code>.<\/p>\n<\/li>\n<li>\n<p><strong>color.Palette<\/strong> \u2014 \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432 <code>Color<\/code>, \u0441\u043b\u0443\u0436\u0430\u0449\u0438\u0439, \u043f\u043e \u0441\u0443\u0442\u0438, \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435\u043c \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 RGB-\u0446\u0432\u0435\u0442\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p><strong>Stride <\/strong>\u2014 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u043e \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u043c\u0438 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u043c\u0438; \u0447\u0430\u0441\u0442\u043e \u044d\u0442\u043e \u0434\u043b\u0438\u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0438, \u0442. \u0435. <code>Max.X - Min.X<\/code>.<\/p>\n<\/li>\n<li>\n<p><strong>Pix <\/strong>\u2014 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u0432\u0438\u0434\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0446\u0432\u0435\u0442\u043e\u0432\u043e\u0439 \u043f\u0430\u043b\u0438\u0442\u0440\u044b. \u041c\u0430\u0441\u0441\u0438\u0432 \u043e\u0434\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u0439, \u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435. \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, <code>Min = (0, 0)<\/code>. \u042d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0435\u0441\u0441\u0438\u044f \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p><code>(0, 0)<\/code>,\u00a0<code>(1, 0)<\/code>, \u2026,\u00a0<code>(Max.X-1, 0)<\/code>,<\/p>\n<\/li>\n<li>\n<p><code>(0, 1)<\/code>,\u00a0<code>(1, 1)<\/code>, \u2026,\u00a0<code>(Max.X-1, 1)<\/code>,<\/p>\n<\/li>\n<li>\n<p>\u2026,<\/p>\n<\/li>\n<li>\n<p><code>(0, Max.Y-1)<\/code>,\u00a0<code>(1, Max.Y-1)<\/code>, \u2026,\u00a0<code>(Max.X-1, Max.Y-1)<\/code>.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0440\u043e\u0449\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, <code>image.Paletted<\/code> \u2014 \u044d\u0442\u043e \u0441\u043f\u0438\u0441\u043e\u043a \u0446\u0432\u0435\u0442\u043e\u0432 \u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439, \u0441\u0441\u044b\u043b\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u043d\u0430 \u044d\u0442\u0438 \u0446\u0432\u0435\u0442\u0430.<\/p>\n<p>\u041f\u0430\u043b\u0438\u0442\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 GIF-\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b. \u0412\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 \u043d\u0435\u0451:<\/p>\n<pre><code class=\"go\">\/\/ GIF represents the possibly multiple images stored in a GIF file. type GIF struct { Image []*image.Paletted \/\/ The successive images. Delay []int             \/\/ The successive delay times, one per frame, in 100ths of a second. \/\/ LoopCount controls the number of times an animation will be \/\/ restarted during display. \/\/ A LoopCount of 0 means to loop forever. \/\/ A LoopCount of -1 means to show each frame only once. \/\/ Otherwise, the animation is looped LoopCount+1 times. LoopCount int \/\/ Disposal is the successive disposal methods, one per frame. For \/\/ backwards compatibility, a nil Disposal is valid to pass to EncodeAll, \/\/ and implies that each frame's disposal method is 0 (no disposal \/\/ specified). Disposal []byte \/\/ Config is the global color table (palette), width and height. A nil or \/\/ empty-color.Palette Config.ColorModel means that each frame has its own \/\/ color table and there is no global color table. Each frame's bounds must \/\/ be within the rectangle defined by the two points (0, 0) and \/\/ (Config.Width, Config.Height). \/\/ \/\/ For backwards compatibility, a zero-valued Config is valid to pass to \/\/ EncodeAll, and implies that the overall GIF's width and height equals \/\/ the first frame's bounds' Rectangle.Max point. Config image.Config \/\/ BackgroundIndex is the background index in the global color table, for \/\/ use with the DisposalBackground disposal method. BackgroundIndex byte }<\/code><\/pre>\n<p>\u041e\u0442\u043c\u0435\u0442\u0438\u043c, \u0447\u0442\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u043e\u0432 (\u0446\u0438\u043a\u043b\u043e\u0432) \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0440\u0430\u0432\u043d\u043e \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0441\u0442\u0438, \u0435\u0441\u043b\u0438 <code>LoopCount == -1<\/code>. \u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0448\u0438\u0440\u0438\u043d\u0430 \u0438 \u0432\u044b\u0441\u043e\u0442\u0430 GIF \u043b\u0438\u0431\u043e \u0437\u0430\u0434\u0430\u044e\u0442\u0441\u044f \u044f\u0432\u043d\u043e, \u043b\u0438\u0431\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u0438\u0437 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432\u043d\u0443\u0442\u0440\u0438 GIF \u043c\u043e\u0433\u0443\u0442 \u0438\u043c\u0435\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u044b, \u0438 \u0437\u0434\u0435\u0441\u044c \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f \u0432\u0430\u0436\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <code>Min <\/code>\u0438 <code>Max <\/code>\u0432 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f: \u043e\u043d\u0438 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0440\u0430\u0432\u043d\u044b \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u043c <code>Min <\/code>\u0438 <code>Max<\/code>.<\/p>\n<p><code>Disposal <\/code>\u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u043a\u0430\u043a \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u043a\u0430\u0434\u0440. \u042d\u0442\u043e\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0441\u0432\u044f\u0437\u0430\u043d \u0441 \u0430\u043b\u044c\u0444\u0430-\u043a\u0430\u043d\u0430\u043b\u043e\u043c RGBA, \u0442\u043e \u0435\u0441\u0442\u044c \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u0438. \u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u043a\u0430\u0434\u0440\u0430 \u0442\u0430\u043a\u0438\u0435:<\/p>\n<ul>\n<li>\n<p><strong>Unspecified (\u041d\u0438\u0447\u0435\u0433\u043e)<\/strong>. \u041f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043e\u0434\u043d\u043e \u043f\u043e\u043b\u043d\u043e\u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0435 \u043d\u0435\u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u0440\u0443\u0433\u0438\u043c.<\/p>\n<\/li>\n<li>\n<p><strong>Do Not Dispose (\u041e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u0430\u043a \u0435\u0441\u0442\u044c)<\/strong>. \u0412\u0441\u0435 \u043f\u0438\u043a\u0441\u0435\u043b\u0438, \u043d\u0435 \u043f\u043e\u043a\u0440\u044b\u0442\u044b\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043a\u0430\u0434\u0440\u043e\u043c, \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f.<\/p>\n<\/li>\n<li>\n<p><strong>Restore to Background (\u0412\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0444\u043e\u043d)<\/strong>. \u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u0432 <code>BackgroundIndex<\/code>, \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u0435 \u043f\u0438\u043a\u0441\u0435\u043b\u0438 \u043d\u043e\u0432\u043e\u0433\u043e \u043a\u0430\u0434\u0440\u0430.<\/p>\n<\/li>\n<\/ul>\n<p><code>Config<\/code> \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c <code>color.Palette<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0430\u043b\u0438\u0442\u0440\u043e\u0439, \u043e\u0431\u0449\u0435\u0439 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439. \u0423 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u0432\u043e\u044f \u043f\u0430\u043b\u0438\u0442\u0440\u0430, \u0438\u043b\u0438 \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u043d\u0443 \u0434\u043b\u044f \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0438 \u043c\u0435\u0441\u0442\u0430, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u0445\u043e\u0436\u0438.<\/p>\n<p>\u0418\u0442\u0430\u043a. \u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0437\u043d\u0430\u0435\u043c, \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u043d\u0430\u0448\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b, \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a <a href=\"https:\/\/github.com\/golang\/go\/blob\/f6d17c540024418ca8a92371931b1b4fb076d2b6\/src\/image\/gif\/writer.go#L364\">\u0441\u0430\u043c\u043e\u043c\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0443 \u043a\u043e\u0434\u0438\u043d\u0433\u0430<\/a>:<\/p>\n<pre><code class=\"go\">\/\/ EncodeAll writes the images in g to w in GIF format with the \/\/ given loop count and delay between frames. func EncodeAll(w io.Writer, g *GIF) error { if len(g.Image) == 0 { return errors.New(\"gif: must provide at least one image\") } if len(g.Image) != len(g.Delay) { return errors.New(\"gif: mismatched image and delay lengths\") } e := encoder{g: *g}     \/\/ ...       if e.g.Config == (image.Config{}) {         \/\/ If the image has no Config, we use the first image dimensions. p := g.Image[0].Bounds().Max e.g.Config.Width = p.X e.g.Config.Height = p.Y } else if e.g.Config.ColorModel != nil { if _, ok := e.g.Config.ColorModel.(color.Palette); !ok { return errors.New(\"gif: GIF color model must be a color.Palette\") } }      \/\/ ensure we have a proper write to send our data to if ww, ok := w.(writer); ok { e.w = ww } else { e.w = bufio.NewWriter(w) }  e.writeHeader() for i, pm := range g.Image { disposal := uint8(0) if g.Disposal != nil { disposal = g.Disposal[i] } e.writeImageBlock(pm, g.Delay[i], disposal) } e.writeByte(sTrailer) \/\/ sTrailer = 0x3B =&gt; ascii semi-colon to signify EOF e.flush() return e.err }<\/code><\/pre>\n<p>\u041c\u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434! \u0427\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0430\u0431\u0437\u0430\u0446. \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \u043e\u0448\u0438\u0431\u043a\u0438, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043a\u043e\u043d\u0444\u0438\u0433\u0430, \u0437\u0430\u043f\u0438\u0441\u044c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430, \u0437\u0430\u0442\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u044c \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u0437\u0430\u043f\u0438\u0441\u044c \u0441\u0438\u043c\u0432\u043e\u043b\u0430 EOF \u0438 \u0441\u0431\u0440\u043e\u0441 \u0431\u0443\u0444\u0435\u0440\u0430.<\/p>\n<p>\u0412\u043e\u0442 <code>writeHeader<\/code> \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u043c\u0438 \u043e\u0442 \u043c\u0435\u043d\u044f:<\/p>\n<pre><code class=\"go\">func (e *encoder) writeHeader() { if e.err != nil { return } _, e.err = io.WriteString(e.w, \"GIF89a\") \/\/ Magic byte if e.err != nil { return }  \/\/ Logical screen width and height. \/\/ written in Little Endian byteorder.LEPutUint16(e.buf[0:2], uint16(e.g.Config.Width)) byteorder.LEPutUint16(e.buf[2:4], uint16(e.g.Config.Height)) e.write(e.buf[:4])       if p, ok := e.g.Config.ColorModel.(color.Palette); ok &amp;&amp; len(p) &gt; 0 { \/\/ write the global palette if we have it paddedSize := log2(len(p)) \/\/ Size of Global Color Table: 2^(1+n). e.buf[0] = fColorTable | uint8(paddedSize) e.buf[1] = e.g.BackgroundIndex e.buf[2] = 0x00 \/\/ Pixel Aspect Ratio. e.write(e.buf[:3]) var err error e.globalCT, err = encodeColorTable(e.globalColorTable[:], p, paddedSize) if err != nil &amp;&amp; e.err == nil { e.err = err return } e.write(e.globalColorTable[:e.globalCT]) } else { \/\/ All frames have a local color table, so a global color table \/\/ is not needed. e.buf[0] = 0x00 e.buf[1] = 0x00 \/\/ Background Color Index. e.buf[2] = 0x00 \/\/ Pixel Aspect Ratio. e.write(e.buf[:3]) }  \/\/ Add animation info if necessary. if len(e.g.Image) &gt; 1 &amp;&amp; e.g.LoopCount &gt;= 0 { e.buf[0] = 0x21 \/\/ Extension Introducer. e.buf[1] = 0xff \/\/ Application Label. e.buf[2] = 0x0b \/\/ Block Size. e.write(e.buf[:3]) _, err := io.WriteString(e.w, \"NETSCAPE2.0\") \/\/ Application Identifier. if err != nil &amp;&amp; e.err == nil { e.err = err return } e.buf[0] = 0x03 \/\/ Block Size. e.buf[1] = 0x01 \/\/ Sub-block Index. byteorder.LEPutUint16(e.buf[2:4], uint16(e.g.LoopCount)) e.buf[4] = 0x00 \/\/ Block Terminator. e.write(e.buf[:5]) } }<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0446\u0438\u043a\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043a\u043e\u0434\u0438\u0440\u0443\u0435\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 Palette:<\/p>\n<pre><code class=\"go\">for i, c := range p { if c == nil { return 0, errors.New(\"gif: cannot encode color table with nil entries\") } var r, g, b uint8 \/\/ It is most likely that the palette is full of color.RGBAs, so they \/\/ get a fast path. if rgba, ok := c.(color.RGBA); ok { r, g, b = rgba.R, rgba.G, rgba.B } else { rr, gg, bb, _ := c.RGBA() r, g, b = uint8(rr&gt;&gt;8), uint8(gg&gt;&gt;8), uint8(bb&gt;&gt;8) } dst[3*i+0] = r dst[3*i+1] = g dst[3*i+2] = b }<\/code><\/pre>\n<p>\u041d\u0438\u0447\u0435\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e. \u041c\u044b \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u043f\u043e \u0446\u0432\u0435\u0442\u0430\u043c \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043a\u043e\u0434\u0438\u0440\u0443\u0435\u043c \u043a\u0440\u0430\u0441\u043d\u044b\u0435, \u0441\u0438\u043d\u0438\u0435 \u0438 \u0437\u0435\u043b\u0451\u043d\u044b\u0435 \u0431\u0430\u0439\u0442\u044b \u0432 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0431\u0443\u0444\u0435\u0440.<\/p>\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 <code>writeImageBlock<\/code>. \u041e\u043d \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0434\u043b\u0438\u043d\u043d\u043e\u0432\u0430\u0442, \u043d\u043e \u0441\u0430\u043c\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442:<\/p>\n<pre><code class=\"go\">for i, c := range p { if c == nil { return 0, errors.New(\"gif: cannot encode color table with nil entries\") } var r, g, b uint8 \/\/ It is most likely that the palette is full of color.RGBAs, so they \/\/ get a fast path. if rgba, ok := c.(color.RGBA); ok { r, g, b = rgba.R, rgba.G, rgba.B } else { rr, gg, bb, _ := c.RGBA() r, g, b = uint8(rr&gt;&gt;8), uint8(gg&gt;&gt;8), uint8(bb&gt;&gt;8) } dst[3*i+0] = r dst[3*i+1] = g dst[3*i+2] = b }<\/code><\/pre>\n<p>\u0412 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u043c \u043a\u043e\u0434\u0435 <code>rect <\/code>\u0438\u043c\u0435\u0435\u0442 \u0438\u043c\u044f <code>b<\/code>. \u042f \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043b \u0435\u0433\u043e \u0434\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u041c\u044b \u0431\u0435\u0440\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432 <code>Pix\u00a0<\/code>\u0438\u0437 \u043d\u0430\u0448\u0435\u0439 \u043f\u0430\u043b\u0438\u0442\u0440\u044b \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0433\u0434\u0435 \u043a\u0430\u0436\u0434\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u0446\u0432\u0435\u0442\u043e\u0432, \u0437\u0430\u0442\u0435\u043c \u0441\u0436\u0438\u043c\u0430\u0435\u043c \u0435\u0433\u043e \u043f\u043e \u0441\u0445\u0435\u043c\u0435 <code>lzww <\/code>\u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c.<\/p>\n<p>\u0412\u0443\u0430\u043b\u044f! \u0412 \u044d\u0442\u043e\u043c \u0438 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043c\u0430\u0433\u0438\u044f \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f GIF.<\/p>\n<p>\u042f \u0441\u0447\u0438\u0442\u0430\u044e, \u0447\u0442\u043e \u0434\u0435\u043a\u043e\u0434\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 GIF-\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u2014 \u0442\u043e, \u0432 \u0447\u0451\u043c \u043a\u0440\u043e\u0435\u0442\u0441\u044f \u0438\u0441\u0442\u0438\u043d\u043d\u0430\u044f \u043c\u0430\u0433\u0438\u044f \u0444\u043e\u0440\u043c\u0430\u0442\u0430. \u041d\u043e \u044d\u0442\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0434\u0430\u0442\u044c \u043d\u0430\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u044b \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c \u0432\u0441\u0435 \u044d\u0442\u0438 \u0440\u0435\u0430\u043a\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u043c\u0435\u043c\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043b\u0438\u0447\u043d\u043e \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0447\u0430\u0441\u0442\u043e.<\/p>\n<p>\u041d\u0430\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a \u0432 \u044d\u0442\u043e\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0434\u043e \u0441\u043c\u0435\u0448\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0439 GIF: 3 \u043a\u0430\u0434\u0440\u0430 \u0441\u0438\u043d\u0435\u0433\u043e, \u0437\u0435\u043b\u0451\u043d\u043e\u0433\u043e \u0438 \u043a\u0440\u0430\u0441\u043d\u043e\u0433\u043e \u0446\u0432\u0435\u0442\u0430 \u0441 1-\u0441\u0435\u043a\u0443\u043d\u0434\u043d\u043e\u0439 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u043e\u0439. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0432 <code>go run main.go<\/code>, \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b <code>rgb.gif<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0446\u0438\u043a\u043b\u0438\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u0446\u0432\u0435\u0442\u0430.<\/p>\n<pre><code class=\"go\">package main  import ( \"fmt\" \"image\" \"image\/color\" \"image\/gif\" \"os\" )  func main() { var w, h int = 240, 240 fileName := \"rgb.gif\"  var palette = []color.Color{ color.RGBA{0x00, 0x00, 0xff, 0xff}, \/\/ Blue color.RGBA{0x00, 0xff, 0x00, 0xff}, \/\/ Green color.RGBA{0xff, 0x00, 0x00, 0xff}, \/\/ Red }  var images []*image.Paletted var delays []int for frame := 0; frame &lt; len(palette); frame++ { img := image.NewPaletted(image.Rect(0, 0, w, h), palette) paletteIndex := uint8(frame) \/\/ paletteIndex 0 is blue, 1 is green and 2 is red for p := 0; p &lt; 240*240; p++ { img.Pix[p] = paletteIndex }  images = append(images, img) delays = append(delays, 100) \/\/ 1 second delay between frames }  f, _ := os.OpenFile(fileName, os.O_WRONLY|os.O_CREATE, 0600) defer f.Close() gif.EncodeAll(f, &amp;gif.GIF{ Image: images, Delay: delays, }) fmt.Printf(\"Created '%v'.\\n\", fileName) }<\/code><\/pre>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5c7\/f05\/d2d\/5c7f05d2d5c4dd3eab5848bcbd8e04f3.gif\" width=\"240\" height=\"240\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5c7\/f05\/d2d\/5c7f05d2d5c4dd3eab5848bcbd8e04f3.gif 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5c7\/f05\/d2d\/5c7f05d2d5c4dd3eab5848bcbd8e04f3.gif 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<h3>PNG  <\/h3>\n<p>Portable Network Graphic (PNG) \u0431\u044b\u043b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d \u043a\u0430\u043a \u043f\u0440\u0435\u0435\u043c\u043d\u0438\u043a GIF. \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0441\u0432\u043e\u0435\u0433\u043e \u043f\u0440\u0435\u0434\u0448\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0438\u043a\u0430, PNG \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0446\u0432\u0435\u0442\u0430 \u0431\u0435\u0437 \u043f\u0430\u043b\u0438\u0442\u0440\u044b, \u0442\u043e \u0435\u0441\u0442\u044c \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0445\u0440\u0430\u043d\u0438\u0442 RGB \u0438\u043b\u0438 RGBA \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0446\u0432\u0435\u0442\u0430. \u041d\u043e \u043e\u043d \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043e\u0442\u0442\u0435\u043d\u043a\u0438 \u0441\u0435\u0440\u043e\u0433\u043e \u0438 \u043f\u0430\u043b\u0438\u0442\u0440\u044b \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 3 \u0431\u0430\u0439\u0442\u0430 RGB \u0438\u043b\u0438 4 \u0431\u0430\u0439\u0442\u0430 RGBA.<\/p>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0444\u0430\u0439\u043b PNG \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b:<\/p>\n<pre><code>89 50 4E 47 0D 0A 1A 0A<\/code><\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0447\u0430\u043d\u043a\u043e\u0432. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0447\u0430\u043d\u043a\u043e\u0432:<\/p>\n<ul>\n<li>\n<p>IHDR (\u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f). \u042d\u0442\u043e\u0442 \u0447\u0430\u043d\u043a \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u0434\u0442\u0438 \u043f\u0435\u0440\u0432\u044b\u043c \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u0430\u0436\u043d\u044b\u0435 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u0448\u0438\u0440\u0438\u043d\u0430, \u0432\u044b\u0441\u043e\u0442\u0430, \u0431\u0438\u0442\u043e\u0432\u0430\u044f \u0433\u043b\u0443\u0431\u0438\u043d\u0430, \u0442\u0438\u043f \u0446\u0432\u0435\u0442\u0430 \u0438 \u0442. \u0434.<\/p>\n<\/li>\n<li>\n<p>IDAT (\u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f): \u0412 \u044d\u0442\u043e\u043c \u0447\u0430\u043d\u043a\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0441\u0436\u0430\u0442\u044b\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/cefboud.com\/posts\/compression\/#deflate-algorithm\">\u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 Deflate<\/a> (GZIP). \u0414\u0430\u043d\u043d\u044b\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u044b \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e IDAT-\u0447\u0430\u043d\u043a\u043e\u0432, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439.<\/p>\n<\/li>\n<li>\n<p>IEND (End Chunk). \u042d\u0442\u043e\u0442 \u0447\u0430\u043d\u043a \u043e\u0442\u043c\u0435\u0447\u0430\u0435\u0442 \u043a\u043e\u043d\u0435\u0446 \u0444\u0430\u0439\u043b\u0430 PNG.<\/p>\n<\/li>\n<\/ul>\n<p>\u042f \u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u043e\u043a\u043b\u043e\u043d\u043d\u0438\u043a \u044d\u0442\u0438\u0445 \u0430\u0431\u0431\u0440\u0435\u0432\u0438\u0430\u0442\u0443\u0440 (IHDR, IDAT), \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u043e\u043d\u0438 \u0437\u0432\u0443\u0447\u0430\u0442 \u0438\u0437\u043b\u0438\u0448\u043d\u0435 \u0432\u044b\u0447\u0443\u0440\u043d\u043e.<\/p>\n<p>\u0422\u0430\u043a \u0438\u043b\u0438 \u0438\u043d\u0430\u0447\u0435, PNG \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <a href=\"https:\/\/cefboud.com\/posts\/compression\/#gzip\">\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c DEFLATE<\/a>, \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0439 \u0432 GZIP \u0434\u043b\u044f \u0441\u0436\u0430\u0442\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f.<\/p>\n<h4>\u0424\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044f  <\/h4>\n<p>\u041f\u0438\u043a\u0441\u0435\u043b\u0438 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u0445\u043e\u0442\u043d\u043e \u043f\u043e\u0434\u0434\u0430\u044e\u0442\u0441\u044f \u0441\u0436\u0430\u0442\u0438\u044e. \u041e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u043f\u0440\u043e\u044f\u0432\u043b\u044f\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0443\u043f\u0440\u044f\u043c\u0441\u0442\u0432\u043e. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u043c\u043e\u0433\u0443\u0442 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u043c\u0443 \u0448\u0430\u0431\u043b\u043e\u043d\u0443 (2,4,6,8 \u0438 \u0442. \u0434.). \u042d\u0442\u043e\u0442 \u0448\u0430\u0431\u043b\u043e\u043d, \u043a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043d\u0435 \u043f\u043e\u0434\u0434\u0430\u0451\u0442\u0441\u044f \u0441\u0436\u0430\u0442\u0438\u044e LZ. \u0425\u043e\u0442\u044c \u043c\u044b \u0438 \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0435\u0435\u0441\u044f \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439, \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<p>\u0420\u0435\u0448\u0435\u043d\u0438\u0435? \u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435. \u0421\u043a\u0430\u0436\u0435\u043c, \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u0437 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0435\u0433\u043e \u0441\u043e\u0441\u0435\u0434\u0430 \u0441\u043b\u0435\u0432\u0430. \u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c (2,2,2,2,2 \u0438 \u0442. \u0434.). \u042d\u0442\u043e \u043b\u0435\u0433\u043a\u043e \u0441\u0436\u0438\u043c\u0430\u0435\u0442\u0441\u044f. \u0422\u0430\u043a\u0430\u044f \u0442\u0435\u0445\u043d\u0438\u043a\u0430 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <code>Sub Filter<\/code>. \u0418\u043d\u043e\u0433\u0434\u0430 \u0437\u0430\u043a\u043e\u043d\u043e\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u0438, \u0430 \u043d\u0435 \u043f\u043e \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0438\u043a\u0441\u0435\u043b\u0438 \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 N &#8212; (12,18,44,89), \u0430 \u0447\u0443\u0442\u044c \u043d\u0438\u0436\u0435, \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 N+1, &#8212; (13,19,45,90). \u042d\u0442\u043e \u043d\u0435 \u0442\u0430\u043a \u0443\u0436 \u0438 \u043c\u0430\u043b\u043e\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0447\u0430\u0441\u0442\u043e \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442 \u0438\u043b\u0438 \u043f\u043b\u0430\u0432\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044b \u0446\u0432\u0435\u0442\u043e\u0432. \u0415\u0441\u043b\u0438 \u043c\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0444\u0438\u043b\u044c\u0442\u0440 <code>Up Filter<\/code>, \u0442\u043e \u0435\u0441\u0442\u044c \u0432\u044b\u0447\u0442\u0435\u043c \u0438\u0437 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0438\u043a\u0441\u0435\u043b\u044f \u0441\u0432\u0435\u0440\u0445\u0443, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u044b\u0439 (1,1,1,1), \u0447\u0442\u043e \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043f\u043e\u0434\u0434\u0430\u0451\u0442\u0441\u044f \u0441\u0436\u0430\u0442\u0438\u044e.<\/p>\n<p>PNG \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u0444\u0438\u043b\u044c\u0442\u0440\u044b \u043f\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c. \u041a\u0430\u043a \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440? \u0418\u0434\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u043e\u0439 \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434: <strong>\u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0441\u0443\u043c\u043c\u0443 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u044b\u0445 \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u0435\u0439 \u043c\u0435\u0436\u0434\u0443 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u043c\u0438 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u0430 \u0438 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u043c\u0438 \u0444\u0438\u043b\u044c\u0442\u0440\u0430 (\u0432\u0432\u0435\u0440\u0445, \u0434\u043e \u0438 \u0442. \u0434.)<\/strong>. \u041f\u043e\u0447\u0435\u043c\u0443? \u0415\u0441\u043b\u0438 \u0441\u0443\u043c\u043c\u0430 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u044b\u0445 \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u0435\u0439 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0430, \u0442\u043e \u0432\u043f\u043e\u043b\u043d\u0435 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u043c\u043d\u043e\u0433\u043e \u0431\u043b\u0438\u0437\u043a\u0438\u0445 \u0438\u043b\u0438 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0431\u043e\u043b\u0435\u0435 \u0441\u0436\u0438\u043c\u0430\u0435\u043c\u044b, \u0447\u0435\u043c \u00ab\u0440\u0430\u0437\u0440\u043e\u0437\u043d\u0435\u043d\u043d\u044b\u0435\u00bb \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u042f \u043f\u043e\u043d\u0438\u043c\u0430\u044e, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u043f\u0440\u0438\u043c\u0435\u0440: \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u0430\u0441\u0441\u0438\u0432 (100, 100, 100, 100, 100, 100, 100), \u0441\u0443\u043c\u043c\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0440\u0430\u0432\u043d\u0430 600, \u0431\u043e\u043b\u0435\u0435 \u0441\u0436\u0438\u043c\u0430\u0435\u043c, \u0447\u0435\u043c (1,2,3,4,5,6), \u0441\u0443\u043c\u043c\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043c\u0435\u043d\u044c\u0448\u0435. \u041d\u043e \u044d\u0442\u043e \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u0430, \u0438, \u0441\u0443\u0434\u044f \u043f\u043e \u0432\u0441\u0435\u043c\u0443, \u043e\u043d\u0430 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0430 \u0445\u043e\u0440\u043e\u0448\u0438\u0435 \u044d\u043c\u043f\u0438\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b. \u0412 <a href=\"https:\/\/github.com\/pnggroup\/libpng\/blob\/0024abd279d3a06435c0309a3f4172eed7c7a19a\/pngwutil.c#L2615\">libpng <\/a>(\u043a\u0430\u043d\u043e\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 PNG) \u0435\u0441\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439:<\/p>\n<pre><code class=\"go\">    * The prediction method we use is to find which method provides the     * smallest value when summing the absolute values of the distances     * from zero, using anything &gt;= 128 as negative numbers.  This is known     * as the \"minimum sum of absolute differences\" heuristic.  Other     * heuristics are the \"weighted minimum sum of absolute differences\"     * (experimental and can in theory improve compression), and the \"zlib     * predictive\" method (not implemented yet), which does test compressions     * of lines using different filter methods, and then chooses the     * (series of) filter(s) that give minimum compressed data size (VERY     * computationally expensive).     *     * GRR 980525:  consider also     *     *   (1) minimum sum of absolute differences from running average (i.e.,     *       keep running sum of non-absolute differences &amp; count of bytes)     *       [track dispersion, too?  restart average if dispersion too large?]     *     *  (1b) minimum sum of absolute differences from sliding average, probably     *       with window size &lt;= deflate window (usually 32K)     *     *   (2) minimum sum of squared differences from zero or running average     *       (i.e., ~ root-mean-square approach)     *\/<\/code><\/pre>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432 Golang \u0442\u0430\u043a\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0442\u0443 \u0436\u0435 \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u0443, \u043a\u0430\u043a \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u043d\u0438\u0436\u0435.<\/p>\n<p>\u0412\u043e\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 PNG:<\/p>\n<ul>\n<li>\n<p>None. \u041d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442.<\/p>\n<\/li>\n<li>\n<p>Sub. \u041a\u0430\u0436\u0434\u044b\u0439 \u0431\u0430\u0439\u0442 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u043d\u0438\u0446\u0435\u0439 \u043c\u0435\u0436\u0434\u0443 \u0442\u0435\u043a\u0443\u0449\u0438\u043c \u0438 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u043c \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u043c (\u0432 \u0442\u043e\u0439 \u0436\u0435 \u0441\u0442\u0440\u043e\u043a\u0435).<\/p>\n<\/li>\n<li>\n<p>Up. \u041a\u0430\u0436\u0434\u044b\u0439 \u0431\u0430\u0439\u0442 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u043d\u0438\u0446\u0435\u0439 \u043c\u0435\u0436\u0434\u0443 \u0442\u0435\u043a\u0443\u0449\u0438\u043c \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u043c \u0438 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u043c, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u043c \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0430\u0434 \u043d\u0438\u043c.<\/p>\n<\/li>\n<li>\n<p>Average. \u041a\u0430\u0436\u0434\u044b\u0439 \u0431\u0430\u0439\u0442 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u0440\u0435\u0434\u043d\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u043f\u0438\u043a\u0441\u0435\u043b\u044f \u0441\u043b\u0435\u0432\u0430 \u0438 \u043f\u0438\u043a\u0441\u0435\u043b\u044f \u0441\u0432\u0435\u0440\u0445\u0443.<\/p>\n<\/li>\n<li>\n<p>Paeth. \u041a\u0430\u0436\u0434\u044b\u0439 \u0431\u0430\u0439\u0442 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u043d\u0438\u0446\u0435\u0439 \u043c\u0435\u0436\u0434\u0443 \u0442\u0435\u043a\u0443\u0449\u0438\u043c \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u043c \u0438 \u043b\u0443\u0447\u0448\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0438\u0437 \u0442\u0440\u0435\u0445: \u0441\u043b\u0435\u0432\u0430, \u0441\u0432\u0435\u0440\u0445\u0443 \u0438\u043b\u0438 \u043f\u043e \u0434\u0438\u0430\u0433\u043e\u043d\u0430\u043b\u0438 \u0432\u0432\u0435\u0440\u0445-\u0432\u043b\u0435\u0432\u043e.<\/p>\n<\/li>\n<\/ul>\n<p>\u041e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0431\u0430\u0439\u0442\u043e\u0432, \u0438 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u0445 \u0441 \u043c\u0430\u043b\u043e\u0439 \u0433\u043b\u0443\u0431\u0438\u043d\u043e\u0439 (\u043c\u0435\u043d\u0435\u0435 8 \u0431\u0438\u0442 \u043d\u0430 \u043f\u0438\u043a\u0441\u0435\u043b\u044c) \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0444\u0438\u043b\u044c\u0442\u0440 NONE.<\/p>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0434\u0435\u043b\u0443 \u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c <a href=\"https:\/\/github.com\/golang\/go\/blob\/608acff8479640b00c85371d91280b64f5ec9594\/src\/image\/png\/writer.go#L207\">\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432 \u0432 Go<\/a>.<\/p>\n<pre><code class=\"go\">\/\/ Chooses the filter to use for encoding the current row, and applies it. \/\/ The return value is the index of the filter and also of the row in cr that has had it applied. func filter(cr *[nFilter][]byte, pr []byte, bpp int) int { \/\/ We try all five filter types, and pick the one that minimizes the sum of absolute differences. \/\/ This is the same heuristic that libpng uses, although the filters are attempted in order of \/\/ estimated most likely to be minimal (ftUp, ftPaeth, ftNone, ftSub, ftAverage), rather than \/\/ in their enumeration order (ftNone, ftSub, ftUp, ftAverage, ftPaeth). cdat0 := cr[0][1:] cdat1 := cr[1][1:] cdat2 := cr[2][1:] cdat3 := cr[3][1:] cdat4 := cr[4][1:] pdat := pr[1:] n := len(cdat0)  \/\/ The up filter. sum := 0 for i := 0; i &lt; n; i++ { cdat2[i] = cdat0[i] - pdat[i] sum += abs8(cdat2[i]) } best := sum filter := ftUp  \/\/ The Paeth filter. sum = 0 for i := 0; i &lt; bpp; i++ { cdat4[i] = cdat0[i] - pdat[i] sum += abs8(cdat4[i]) } for i := bpp; i &lt; n; i++ { cdat4[i] = cdat0[i] - paeth(cdat0[i-bpp], pdat[i], pdat[i-bpp]) sum += abs8(cdat4[i]) if sum &gt;= best { break } } if sum &lt; best { best = sum filter = ftPaeth }  \/\/ The none filter. sum = 0 for i := 0; i &lt; n; i++ { sum += abs8(cdat0[i]) if sum &gt;= best { break } } if sum &lt; best { best = sum filter = ftNone }  \/\/ The sub filter. sum = 0 for i := 0; i &lt; bpp; i++ { cdat1[i] = cdat0[i] sum += abs8(cdat1[i]) } for i := bpp; i &lt; n; i++ { cdat1[i] = cdat0[i] - cdat0[i-bpp] sum += abs8(cdat1[i]) if sum &gt;= best { break } } if sum &lt; best { best = sum filter = ftSub }  \/\/ The average filter. sum = 0 for i := 0; i &lt; bpp; i++ { cdat3[i] = cdat0[i] - pdat[i]\/2 sum += abs8(cdat3[i]) } for i := bpp; i &lt; n; i++ { cdat3[i] = cdat0[i] - uint8((int(cdat0[i-bpp])+int(pdat[i]))\/2) sum += abs8(cdat3[i]) if sum &gt;= best { break } } if sum &lt; best { filter = ftAverage }  return filter }<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b <code>cr *[nFilter][]byte, pr []byte, bpp int. cr<\/code> \u2014 \u044d\u0442\u043e \u043c\u0430\u0441\u0441\u0438\u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 (\u044f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u0438 \u0441\u0440\u0435\u0437 \u043a\u0430\u043a \u0432\u0437\u0430\u0438\u043c\u043e\u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0435), \u043e\u043d \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0440\u044f\u0434, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440 (\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u2014 \u044d\u0442\u043e \u0438\u043d\u0434\u0435\u043a\u0441\/\u0442\u0438\u043f \u0444\u0438\u043b\u044c\u0442\u0440\u0430).<\/p>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 <code>cr[filterNb]<\/code>. \u041a\u0430\u043a \u0441\u043a\u0430\u0437\u0430\u043d\u043e \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438, \u0444\u0438\u043b\u044c\u0442\u0440\u044b \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u044b\u0445 \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u043e\u0432 \u043d\u0430 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u0441\u0443\u043c\u043c\u0443 \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u0435\u0439, \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0435\u0440\u0432\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0444\u0438\u043b\u044c\u0442\u0440\u0430, \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0443\u043c\u043c\u0430 \u043f\u0440\u0435\u0432\u044b\u0441\u0438\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u043b\u0443\u0447\u0448\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. <code>pr<\/code> \u2014 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u0440\u044f\u0434. \u041f\u0435\u0440\u0432\u044b\u0439 \u0431\u0430\u0439\u0442 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0431\u0430\u0439\u0442\u043e\u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0442\u0438\u043f \u0444\u0438\u043b\u044c\u0442\u0440\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 <code>pdat = pr[1:]<\/code> \u2014 \u044d\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0431\u0435\u0437 \u0442\u0438\u043f\u0430 \u0444\u0438\u043b\u044c\u0442\u0440\u0430. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u0444\u0438\u043b\u044c\u0442\u0440 <code>up<\/code>.<\/p>\n<pre><code class=\"go\">\/\/ The up filter. sum := 0 for i := 0; i &lt; n; i++ { \/\/ loop over the row pixels cdat2[i] = cdat0[i] - pdat[i] \/\/ subsctract the previous row's pixel at the same position i.e. the pixel above sum += abs8(cdat2[i]) \/\/ add the absolute difference to our sum which we are trying to minimize }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u043d\u0430\u0441\u0447\u0435\u0442 \u0441\u0443\u0431\u0444\u0438\u043b\u044c\u0442\u0440\u0430?<\/p>\n<pre><code class=\"go\">\/\/ The sub filter. \/\/ bpp is bytes per pixel. For RGB, it's 3. For gray scale, it's 1. sum = 0 for i := 0; i &lt; bpp; i++ { cdat1[i] = cdat0[i] sum += abs8(cdat1[i]) } for i := bpp; i &lt; n; i++ { cdat1[i] = cdat0[i] - cdat0[i-bpp] \/\/ subtract each byte within a pixel from corresponding byte in previous pixel sum += abs8(cdat1[i]) if sum &gt;= best { \/\/ break early if this is worse than previous filter break } }<\/code><\/pre>\n<p><code>bpp <\/code>\u0438\u0433\u0440\u0430\u0435\u0442 \u0437\u0434\u0435\u0441\u044c \u0440\u0435\u0448\u0430\u044e\u0449\u0443\u044e \u0440\u043e\u043b\u044c. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043f\u0440\u0438 \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u0438 <code>cdat1[i] = cdat0[i] - cdat0[i - bpp]<\/code> \u043c\u044b \u0432\u044b\u0447\u0438\u0442\u0430\u0435\u043c \u043f\u0438\u043a\u0441\u0435\u043b\u044c \u043d\u0430 <code>bpp<\/code> \u043f\u043e\u0437\u0438\u0446\u0438\u0439 \u0440\u0430\u043d\u044c\u0448\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 RGB \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0438\u0437 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u0440\u0430\u0441\u043d\u043e\u0433\u043e \u0446\u0432\u0435\u0442\u0430 \u0432\u044b\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043a\u0440\u0430\u0441\u043d\u044b\u0439 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f, \u0438\u0437 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0437\u0435\u043b\u0451\u043d\u043e\u0433\u043e \u2014 \u0437\u0435\u043b\u0451\u043d\u044b\u0439 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435.<\/p>\n<p>\u041c\u044b \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u0441\u0443\u043c\u043c\u0443 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0444\u0438\u043b\u044c\u0442\u0440\u0430 \u0438 \u0431\u0435\u0440\u0435\u043c <code>min<\/code> \u2014 \u044d\u0442\u043e \u0438 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0448 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0439 \u0444\u0438\u043b\u044c\u0442\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u0436\u0430\u0442\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u043c DEFLATE. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u0444\u0438\u043b\u044c\u0442\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 <code>cr[chosenFilter]<\/code>.<\/p>\n<h4>\u041a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435  <\/h4>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043c\u0435\u0442\u043e\u0434 <code>Encode<\/code>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0434\u043b\u044f \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 PNG.<\/p>\n<pre><code class=\"go\">\/\/ Encode writes the Image m to w in PNG format. func (enc *Encoder) Encode(w io.Writer, m image.Image) error { \/\/ Obviously, negative widths and heights are invalid. Furthermore, the PNG \/\/ spec section 11.2.2 says that zero is invalid. Excessively large images are \/\/ also rejected. mw, mh := int64(m.Bounds().Dx()), int64(m.Bounds().Dy()) if mw &lt;= 0 || mh &lt;= 0 || mw &gt;= 1&lt;&lt;32 || mh &gt;= 1&lt;&lt;32 { return FormatError(\"invalid image size: \" + strconv.FormatInt(mw, 10) + \"x\" + strconv.FormatInt(mh, 10)) }  e := &amp;encoder{} \/\/....  e.enc = enc e.w = w e.m = m  var pal color.Palette \/\/ cbP8 encoding needs PalettedImage's ColorIndexAt method. if _, ok := m.(image.PalettedImage); ok { pal, _ = m.ColorModel().(color.Palette) } if pal != nil { if len(pal) &lt;= 2 { e.cb = cbP1 } else if len(pal) &lt;= 4 { e.cb = cbP2 } else if len(pal) &lt;= 16 { e.cb = cbP4 } else { e.cb = cbP8 } } else { switch m.ColorModel() { case color.GrayModel: e.cb = cbG8 case color.Gray16Model: e.cb = cbG16 case color.RGBAModel, color.NRGBAModel, color.AlphaModel: if opaque(m) { e.cb = cbTC8 } else { e.cb = cbTCA8 } default: if opaque(m) { e.cb = cbTC16 } else { e.cb = cbTCA16 } } }  _, e.err = io.WriteString(w, pngHeader) e.writeIHDR() if pal != nil { e.writePLTEAndTRNS(pal) } e.writeIDATs() e.writeIEND() return e.err }<\/code><\/pre>\n<p>\u041c\u043d\u043e\u0433\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u043e\u0438\u0442 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u0430\u0442\u044c. \u0412\u0435\u0441\u0435\u043b\u043e! \u041e\u0434\u043d\u0430 \u0438\u0437 \u043f\u0440\u0438\u0447\u0438\u043d, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u044f \u043b\u044e\u0431\u043b\u044e \u0447\u0438\u0442\u0430\u0442\u044c \u043a\u043e\u0434, \u044d\u0442\u043e \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u0432\u0440\u043e\u0434\u0435 \u00ab\u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0448\u0438\u0440\u0438\u043d\u044b \u0438 \u0432\u044b\u0441\u043e\u0442\u044b \u043d\u0435\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u00bb. \u041e\u043d \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u0440\u0430\u0441\u0438\u0432\u043e \u0437\u0432\u0443\u0447\u0438\u0442.<\/p>\n<p>\u041c\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0441 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432 \u043d\u0430\u0448\u0438\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u0437\u0430\u0442\u0435\u043c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0448 \u044d\u043d\u043a\u043e\u0434\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u043a:<\/p>\n<pre><code class=\"go\">type encoder struct { enc     *Encoder w       io.Writer m       image.Image cb      int \/\/  a combination of color type and bit depth. err     error header  [8]byte footer  [4]byte tmp     [4 * 256]byte cr      [nFilter][]uint8 \/\/ stores the current row and possible filter pr      []uint8          \/\/ previous row zw      *zlib.Writer     \/\/ used of compression zwLevel int              \/\/ compression level bw      *bufio.Writer }<\/code><\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 <code>image.PalettedImage<\/code> \u0438 \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0438\u0437 \u043d\u0435\u0433\u043e <code>Palette<\/code> (\u043a\u043e\u0442\u043e\u0440\u0430\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0441\u0435\u0432\u0434\u043e\u043d\u0438\u043c\u043e\u043c \u0434\u043b\u044f <code>[]Color<\/code>). \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u0443\u0434\u0430\u0451\u0442\u0441\u044f, \u0437\u043d\u0430\u0447\u0438\u0442, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043f\u0430\u043b\u0438\u0442\u0440\u043e\u0432\u043e\u0435, \u0438 \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0433\u043b\u0443\u0431\u0438\u043d\u0443 \u0446\u0432\u0435\u0442\u0430 (\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0438\u0442) \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0446\u0432\u0435\u0442\u043e\u0432 \u0432 \u043f\u0430\u043b\u0438\u0442\u0440\u0435. \u0415\u0441\u043b\u0438 \u043d\u0435\u0442, \u0442\u043e, \u043e\u0441\u043d\u043e\u0432\u044b\u0432\u0430\u044f\u0441\u044c \u043d\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u043c \u0442\u0438\u043f\u0435 <code>ColorModel<\/code>, \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c \u043d\u0430\u0448 <code>cb<\/code>. GrayModel, Gray16Model, RGBAModel, AlphaModel \u2014 \u0432\u0441\u0451 \u044d\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u043e, \u043e \u0447\u0435\u043c \u0433\u043e\u0432\u043e\u0440\u044f\u0442 \u0438\u0445 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>\u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u044b \u0443\u0437\u043d\u0430\u0435\u043c \u0442\u0438\u043f \u0438 \u0433\u043b\u0443\u0431\u0438\u043d\u0443 \u0446\u0432\u0435\u0442\u0430, \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0439\u0441\u044f \u043a\u043e\u0434 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u043c.<\/p>\n<pre><code class=\"go\">_, e.err = io.WriteString(w, pngHeader) \/\/ write magic \"\\x89PNG\\r\\n\\x1a\\n\" e.writeIHDR() \/\/ write the actual header  if pal != nil { e.writePLTEAndTRNS(pal) \/\/ write the palette, if there is one } e.writeIDATs() \/\/ the image data e.writeIEND() \/\/ write the footer: `IEND`<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>writeIHDR<\/code>, \u043f\u0435\u0440\u0435\u0434 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0438\u0434\u0443\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432 \u0446\u0432\u0435\u0442\u0430:<\/p>\n<pre><code class=\"go\">\/\/ Color type, as per the PNG spec. const ( ctGrayscale      = 0 ctTrueColor      = 2 ctPaletted       = 3 ctGrayscaleAlpha = 4 ctTrueColorAlpha = 6 )  func (e *encoder) writeIHDR() { b := e.m.Bounds() \/\/ Write image dimensions in BigEndian (most significant byte at the smallest memory address) binary.BigEndian.PutUint32(e.tmp[0:4], uint32(b.Dx())) \/\/ image width binary.BigEndian.PutUint32(e.tmp[4:8], uint32(b.Dy())) \/\/ image height \/\/ Set bit depth and color type. switch e.cb { case cbG8: e.tmp[8] = 8 e.tmp[9] = ctGrayscale case cbTC8: e.tmp[8] = 8 e.tmp[9] = ctTrueColor case cbP8: e.tmp[8] = 8 e.tmp[9] = ctPaletted case cbP4: e.tmp[8] = 4 e.tmp[9] = ctPaletted case cbP2: e.tmp[8] = 2 e.tmp[9] = ctPaletted case cbP1: e.tmp[8] = 1 \/\/ 1 bit per Pixel !!!! e.tmp[9] = ctPaletted case cbTCA8: e.tmp[8] = 8 e.tmp[9] = ctTrueColorAlpha case cbG16: e.tmp[8] = 16 e.tmp[9] = ctGrayscale case cbTC16: e.tmp[8] = 16 e.tmp[9] = ctTrueColor case cbTCA16: e.tmp[8] = 16 e.tmp[9] = ctTrueColorAlpha } e.tmp[10] = 0 \/\/ default compression method e.tmp[11] = 0 \/\/ default filter method e.tmp[12] = 0 \/\/ non-interlaced e.writeChunk(e.tmp[:13], \"IHDR\") } <\/code><\/pre>\n<p>\u041c\u044b \u043f\u043e\u0434\u0433\u043e\u0442\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 13 \u0431\u0430\u0439\u0442 \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0435\u0433\u043e \u043a\u0430\u043a \u0431\u043b\u043e\u043a <code>IHDR <\/code>\u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <a href=\"https:\/\/github.com\/golang\/go\/blob\/37f27fbecd422da9fefb8ae1cc601bc5b4fec44b\/src\/image\/png\/writer.go#L96\"><code>writeChunk<\/code><\/a>:<\/p>\n<pre><code class=\"go\">func (e *encoder) writeChunk(b []byte, name string) { if e.err != nil { return } \/\/ 4 Gib max chunk size n := uint32(len(b)) if int(n) != len(b) { e.err = UnsupportedError(name + \" chunk is too large: \" + strconv.Itoa(len(b))) return } \/\/ add the chunk length binary.BigEndian.PutUint32(e.header[:4], n) \/\/ chunk name e.header[4] = name[0] e.header[5] = name[1] e.header[6] = name[2] e.header[7] = name[3] crc := crc32.NewIEEE() \/\/ CRC check for the name + actual chunk data crc.Write(e.header[4:8]) crc.Write(b) binary.BigEndian.PutUint32(e.footer[:4], crc.Sum32())  \/\/ write header (length + name) _, e.err = e.w.Write(e.header[:8]) if e.err != nil { return } \/\/ actual data _, e.err = e.w.Write(b) if e.err != nil { return } \/\/ CRC _, e.err = e.w.Write(e.footer[:4]) }<\/code><\/pre>\n<p>\u042f \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438, \u043d\u043e \u043a\u043e\u0434 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442. \u041e\u043d \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0434\u043b\u0438\u043d\u0443 \u0438 \u0438\u043c\u044f \u0447\u0430\u043d\u043a\u0430, \u0437\u0430\u0442\u0435\u043c \u0441\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0435, \u0430 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u0443\u044e \u0441\u0443\u043c\u043c\u0443 (CRC).<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432 \u043d\u0430\u0448\u0435\u0439 \u0446\u0432\u0435\u0442\u043e\u0432\u043e\u0439 \u0441\u0445\u0435\u043c\u0435 \u0435\u0441\u0442\u044c \u043f\u0430\u043b\u0438\u0442\u0440\u0430, \u043c\u044b \u043f\u0438\u0448\u0435\u043c \u0447\u0430\u043d\u043a <code>PLTE<\/code>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f:<\/p>\n<pre><code class=\"go\">func (e *encoder) writePLTEAndTRNS(p color.Palette) { if len(p) &lt; 1 || len(p) &gt; 256 { e.err = FormatError(\"bad palette length: \" + strconv.Itoa(len(p))) return } last := -1 for i, c := range p { c1 := color.NRGBAModel.Convert(c).(color.NRGBA) e.tmp[3*i+0] = c1.R e.tmp[3*i+1] = c1.G e.tmp[3*i+2] = c1.B if c1.A != 0xff { last = i } e.tmp[3*256+i] = c1.A } e.writeChunk(e.tmp[:3*len(p)], \"PLTE\") if last != -1 { e.writeChunk(e.tmp[3*256:3*256+1+last], \"tRNS\") } }<\/code><\/pre>\n<p>\u0427\u0430\u043d\u043a <code>PLTE<\/code> \u0432\u0441\u0435\u0433\u0434\u0430 \u0445\u0440\u0430\u043d\u0438\u0442 \u0446\u0432\u0435\u0442\u0430 \u043f\u0430\u043b\u0438\u0442\u0440\u044b \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c 3 \u0431\u0430\u0439\u0442\u043e\u0432, \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0442\u0438\u043f\u0430 \u0446\u0432\u0435\u0442\u0430, \u0442\u043e \u0435\u0441\u0442\u044c \u0434\u0430\u0436\u0435 \u0446\u0432\u0435\u0442\u0430 \u0432 \u0433\u0440\u0430\u0434\u0430\u0446\u0438\u044f\u0445 \u0441\u0435\u0440\u043e\u0433\u043e (1 \u0431\u0430\u0439\u0442) \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 3 \u0431\u0430\u0439\u0442\u0430. \u0427\u0430\u043d\u043a <code>tRNS<\/code> \u0445\u0440\u0430\u043d\u0438\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u0438, \u043f\u0440\u0438\u0447\u0435\u043c \u0430\u043b\u044c\u0444\u0430-\u0431\u0430\u0439\u0442 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0446\u0432\u0435\u0442\u043e\u0432\u043e\u0439 \u043f\u0430\u043b\u0438\u0442\u0440\u044b \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u0431\u0430\u0439\u0442\u043e\u0432 \u0446\u0432\u0435\u0442\u0430 \u043f\u0430\u043b\u0438\u0442\u0440\u044b.<\/p>\n<p>\u0418 \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>writeIDATs<\/code>:<\/p>\n<pre><code class=\"go\">\/\/ Write the actual image data to one or more IDAT chunks. func (e *encoder) writeIDATs() { if e.err != nil { return } if e.bw == nil { e.bw = bufio.NewWriterSize(e, 1&lt;&lt;15) } else { e.bw.Reset(e) } e.err = e.writeImage(e.bw, e.m, e.cb, levelToZlib(e.enc.CompressionLevel)) if e.err != nil { return } e.err = e.bw.Flush() }<\/code><\/pre>\n<p>\u0415\u0433\u043e \u0441\u0443\u0442\u044c \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0446\u0438\u043a\u043b\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 <code>writeImage<\/code>:<\/p>\n<pre><code class=\"go\">for y := b.Min.Y; y &lt; b.Max.Y; y++ { \/\/ Convert from colors to bytes. i := 1 switch cb { case cbG8: if gray != nil { offset := (y - b.Min.Y) * gray.Stride copy(cr[0][1:], gray.Pix[offset:offset+b.Dx()]) } else { for x := b.Min.X; x &lt; b.Max.X; x++ { c := color.GrayModel.Convert(m.At(x, y)).(color.Gray) cr[0][i] = c.Y i++ } } \/\/ omitted ... case cbTC8: \/\/ We have previously verified that the alpha value is fully opaque.  \/\/ omitted ... for x := b.Min.X; x &lt; b.Max.X; x++ { r, g, b, _ := m.At(x, y).RGBA() cr0[i+0] = uint8(r &gt;&gt; 8) cr0[i+1] = uint8(g &gt;&gt; 8) cr0[i+2] = uint8(b &gt;&gt; 8) i += 3 }  case cbP8: \/\/ omitted ... pi := m.(image.PalettedImage) for x := b.Min.X; x &lt; b.Max.X; x++ { cr[0][i] = pi.ColorIndexAt(x, y) i += 1 }  \/\/ omitted ... }  \/\/ Apply the filter. \/\/ Skip filter for NoCompression and paletted images (cbP8) as \/\/ \"filters are rarely useful on palette images\" and will result \/\/ in larger files (see http:\/\/www.libpng.org\/pub\/png\/book\/chapter09.html). f := ftNone if level != zlib.NoCompression &amp;&amp; cb != cbP8 &amp;&amp; cb != cbP4 &amp;&amp; cb != cbP2 &amp;&amp; cb != cbP1 { \/\/ Since we skip paletted images we don't have to worry about \/\/ bitsPerPixel not being a multiple of 8 bpp := bitsPerPixel \/ 8 f = filter(&amp;cr, pr, bpp) }  \/\/ Write the compressed bytes. if _, err := e.zw.Write(cr[f]); err != nil { return err }  \/\/ The current row for y is the previous row for y+1. pr, cr[0] = cr[0], pr }<\/code><\/pre>\n<p>\u042f \u043e\u0441\u0442\u0430\u0432\u0438\u043b \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u0443\u0447\u0430\u0438 \u0434\u043b\u044f \u043e\u0442\u0442\u0435\u043d\u043a\u043e\u0432 \u0441\u0435\u0440\u043e\u0433\u043e, RGB (\u0438\u0441\u0442\u0438\u043d\u043d\u043e\u0433\u043e \u0446\u0432\u0435\u0442\u0430) \u0438 256-\u0446\u0432\u0435\u0442\u043d\u043e\u0439 \u043f\u0430\u043b\u0438\u0442\u0440\u044b <code>cbP8<\/code>. \u041a\u0430\u043a \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0438\u0434\u0435\u0442\u044c, \u043c\u044b \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f: <code>y := b.Min.Y; y &lt; b.Max.Y; y++<\/code>. \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0433\u0440\u0430\u0434\u0430\u0446\u0438\u0438 \u0441\u0435\u0440\u043e\u0433\u043e (<code>cbG8<\/code>), \u043c\u044b \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u043f\u043e 1 \u0431\u0430\u0439\u0442\u0443 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0446\u0432\u0435\u0442\u0430. \u0415\u0441\u043b\u0438 \u044d\u0442\u043e RGB, \u0442\u043e \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c 3 \u0431\u0430\u0439\u0442\u0430. \u0414\u043b\u044f \u043f\u0430\u043b\u0438\u0442\u0440\u044b \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0438\u043d\u0434\u0435\u043a\u0441 \u043f\u0430\u043b\u0438\u0442\u0440\u044b.<\/p>\n<p>\u0417\u0430\u0442\u0435\u043c, \u0435\u0441\u043b\u0438 \u0441\u0436\u0430\u0442\u0438\u0435 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043e (<code>level != zlib.NoCompression<\/code>) \u2014 \u043d\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0441\u0436\u0438\u043c\u0430\u0442\u044c, \u2014 \u0438 \u043c\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u0430\u043b\u0438\u0442\u0440\u044b, \u043c\u044b \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0444\u0438\u043b\u044c\u0442\u0440 \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>filter <\/code>, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0438\u0437\u0443\u0447\u0438\u043b\u0438 \u0440\u0430\u043d\u0435\u0435. \u0417\u0430\u0442\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u043e\u0442\u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 (\u0438\u043b\u0438 \u043d\u0435\u043e\u0442\u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435) \u0431\u0430\u0439\u0442\u044b \u0432 LZ-writer, \u0438 \u043d\u0430\u0448\u0438 \u0441\u0436\u0430\u0442\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0433\u043e\u0442\u043e\u0432\u044b \u043a \u0437\u0430\u043f\u0438\u0441\u0438.<\/p>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0447\u0430\u043d\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>writeIEND<\/code>, \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0439 \u0438 \u043f\u0440\u0438\u044f\u0442\u043d\u043e\u0439:<\/p>\n<p><code>func (e *encoder) writeIEND() { e.writeChunk(nil, \"IEND\") }<\/code><\/p>\n<p>\u0418 \u0432 \u044d\u0442\u043e\u043c \u0432\u0441\u044f \u0441\u0443\u0442\u044c PNG!<\/p>\n<h2>\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441 \u043f\u043e\u0442\u0435\u0440\u044f\u043c\u0438<\/h2>\n<h3>JPEG<\/h3>\n<p>JPEG, Joint Photographic Experts Group (\u0447\u0442\u043e \u0437\u0430 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435!), \u0447\u0440\u0435\u0437\u0432\u044b\u0447\u0430\u0439\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0451\u043d \u0432 \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435. \u041a\u0430\u0436\u0434\u044b\u0439, \u043a\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0441 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438 \u043d\u0430 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435, \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0441\u044f \u0441 PNG \u043b\u0438\u0431\u043e \u0441 JPEG. \u042d\u0442\u043e\u0442 \u0444\u043e\u0440\u043c\u0430\u0442 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u043e\u0441\u0442\u0438\u0447\u044c \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0441\u0436\u0430\u0442\u0438\u044f, \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u044f \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u043e +90% \u043e\u0442 \u0435\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043f\u0440\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0438 \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u043e\u0433\u043e \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430. \u0421\u0442\u0435\u043f\u0435\u043d\u044c \u0441\u0436\u0430\u0442\u0438\u044f \u0432\u0430\u0440\u044c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043e\u0442 5:1 \u0434\u043e 50:1. \u041a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u0440\u043e\u043c\u0438\u0441\u0441 \u043c\u0435\u0436\u0434\u0443 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u043c \u0441\u0436\u0430\u0442\u0438\u044f \u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>JPEG \u2014 \u044d\u0442\u043e \u0432\u043e\u043b\u0448\u0435\u0431\u043d\u044b\u0439 \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u043d\u044b\u0439 \u043f\u043e\u0434\u0432\u0438\u0433, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0438\u0437 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0430\u0441\u043f\u0435\u043a\u0442\u043e\u0432. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u0435\u0433\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0438\u0434\u0435\u0439 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043a\u043e\u0434. \u0414\u0430\u043b\u0435\u0435 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u0446\u0432\u0435\u0442\u043e\u0432\u043e\u0439 \u0441\u0443\u0431\u0434\u0438\u0441\u043a\u0440\u0435\u0442\u0438\u0437\u0430\u0446\u0438\u0438, DCT (\u0434\u0438\u0441\u043a\u0440\u0435\u0442\u043d\u043e\u0435 \u043a\u043e\u0441\u0438\u043d\u0443\u0441\u043d\u043e\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435) \u0438 \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u0430\u043d\u0438\u0438.<\/p>\n<h4>YCbCr \u0438 \u0446\u0432\u0435\u0442\u043e\u0432\u0430\u044f \u0441\u0443\u0431\u0434\u0438\u0441\u043a\u0440\u0435\u0442\u0438\u0437\u0430\u0446\u0438\u044f<\/h4>\n<p>\u042d\u0442\u043e\u0442 \u0448\u0430\u0433 \u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0438\u0434\u0435\u0435: \u0447\u0435\u043b\u043e\u0432\u0435\u0447\u0435\u0441\u043a\u0438\u0439 \u0433\u043b\u0430\u0437 \u0431\u043e\u043b\u0435\u0435 \u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u0435\u043d \u043a \u044f\u0440\u043a\u043e\u0441\u0442\u0438 (luma) \u0438 \u0437\u0435\u043b\u0451\u043d\u043e\u043c\u0443 \u0446\u0432\u0435\u0442\u0443, \u0447\u0435\u043c \u043a \u043a\u0440\u0430\u0441\u043d\u043e\u043c\u0443 \u0438 \u0441\u0438\u043d\u0435\u043c\u0443 (chroma).<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u043d\u0430\u0448 \u0446\u0432\u0435\u0442 RGB \u0432 \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0437\u043e\u043b\u0438\u0440\u0443\u0435\u0442 \u044f\u0440\u043a\u043e\u0441\u0442\u044c \u043e\u0442 \u043a\u0440\u0430\u0441\u043d\u044b\u0445 \u0438 \u0441\u0438\u043d\u0438\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432, \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0431\u0438\u0442\u044b luma (\u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043d\u0430\u0448 \u0433\u043b\u0430\u0437 \u0431\u043e\u043b\u0435\u0435 \u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u0435\u043d), \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0441\u0436\u0438\u043c\u0430\u044f (\u0441\u0443\u0431\u0434\u0438\u0441\u043a\u0440\u0435\u0442\u0438\u0437\u0438\u0440\u0443\u044f) chroma (\u043a\u0440\u0430\u0441\u043d\u044b\u0439 \u0438 \u0441\u0438\u043d\u0438\u0439), \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043c\u044b \u043c\u0435\u043d\u0435\u0435 \u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b.<\/p>\n<p>\u0422\u0430\u043a\u043e\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <strong>YCbCr (Y: Luma, Cb: Chroma Blue, Cr: Chroma Red)<\/strong>; \u043e\u043d\u043e \u043e\u0442\u0434\u0435\u043b\u044f\u0435\u0442 \u044f\u0440\u043a\u043e\u0441\u0442\u044c (Y) \u043e\u0442 \u0446\u0432\u0435\u0442\u043e\u0432\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 (Cb \u0438 Cr).<\/p>\n<p>\u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044f, \u0447\u0442\u043e \u043d\u0430\u0448\u0438 \u0433\u043b\u0430\u0437\u0430 \u0431\u043e\u043b\u0435\u0435 \u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b \u043a \u044f\u0440\u043a\u043e\u0441\u0442\u0438, \u0447\u0435\u043c \u043a \u0446\u0432\u0435\u0442\u0430\u043c, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0436\u0430\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0432\u044b\u0431\u0440\u0430\u0432 \u043c\u0435\u043d\u044c\u0448\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 CbCr \u0438 \u043e\u0441\u0442\u0430\u0432\u0438\u0432 \u0432\u0441\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u044f\u0440\u043a\u043e\u0441\u0442\u0438. \u042d\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <strong>\u0446\u0432\u0435\u0442\u043e\u0432\u043e\u0439 \u0441\u0443\u0431\u0434\u0438\u0441\u043a\u0440\u0435\u0442\u0438\u0437\u0430\u0446\u0438\u0435\u0439<\/strong>, \u0442. \u0435. \u043c\u044b \u0431\u0435\u0440\u0435\u043c \u043c\u0435\u043d\u044c\u0448\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0446\u0432\u0435\u0442\u0430\u0445. \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0438\u0437 4 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u0441\u0443\u0431\u0434\u0438\u0441\u043a\u0440\u0435\u0442\u0438\u0437\u0430\u0446\u0438\u044e, \u0437\u0430\u043c\u0435\u043d\u044f\u044f \u0438\u0445 \u043e\u0434\u043d\u0438\u043c \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u043c (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443\u0441\u0440\u0435\u0434\u043d\u044f\u044f \u0438\u043b\u0438 \u0431\u0435\u0440\u044f \u043b\u0435\u0432\u044b\u0439 \u0432\u0435\u0440\u0445\u043d\u0438\u0439 \u043f\u0438\u043a\u0441\u0435\u043b\u044c). \u0417\u0430\u043c\u0435\u043d\u044f\u044f 4 \u043f\u0438\u043a\u0441\u0435\u043b\u044f \u043d\u0430 1 \u0434\u043b\u044f Cb \u0438 Cr, \u043c\u044b \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u043d\u0430 50 %.<\/p>\n<p>JPEG \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0431\u043b\u043e\u043a\u0430\u043c\u0438 8&#215;8 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439. \u0412\u043e\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 Go \u0434\u043b\u044f <a href=\"https:\/\/github.com\/golang\/go\/blob\/37f27fbecd422da9fefb8ae1cc601bc5b4fec44b\/src\/image\/jpeg\/writer.go#L390-L391\">\u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432 YCbCr<\/a>:<\/p>\n<pre><code class=\"go\">const blockSize = 64 type block [blockSize]int32 \/\/ block holds 64 (8x8) pixels  \/\/ toYCbCr converts the 8x8 region of m whose top-left corner is p to its \/\/ YCbCr values. func toYCbCr(m image.Image, p image.Point, yBlock, cbBlock, crBlock *block) { b := m.Bounds() xmax := b.Max.X - 1 ymax := b.Max.Y - 1 for j := 0; j &lt; 8; j++ { \/\/ 8x8 pixel blocks for i := 0; i &lt; 8; i++ { r, g, b, _ := m.At(min(p.X+i, xmax), min(p.Y+j, ymax)).RGBA() yy, cb, cr := color.RGBToYCbCr(uint8(r&gt;&gt;8), uint8(g&gt;&gt;8), uint8(b&gt;&gt;8)) yBlock[8*j+i] = int32(yy) cbBlock[8*j+i] = int32(cb) crBlock[8*j+i] = int32(cr) } } }<\/code><\/pre>\n<p>\u0412\u043e\u043b\u0448\u0435\u0431\u043d\u043e\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u043d\u0443\u0442\u0440\u0438 <a href=\"https:\/\/github.com\/golang\/go\/blob\/37f27fbecd422da9fefb8ae1cc601bc5b4fec44b\/src\/image\/color\/ycbcr.go#L8\">RGBToYCbCr<\/a>:<\/p>\n<pre><code class=\"go\">\/\/ RGBToYCbCr converts an RGB triple to a Y'CbCr triple. func RGBToYCbCr(r, g, b uint8) (uint8, uint8, uint8) { \/\/ The JFIF specification says: \/\/Y' =  0.2990*R + 0.5870*G + 0.1140*B \/\/Cb = -0.1687*R - 0.3313*G + 0.5000*B + 128 \/\/Cr =  0.5000*R - 0.4187*G - 0.0813*B + 128 \/\/ https:\/\/www.w3.org\/Graphics\/JPEG\/jfif3.pdf says Y but means Y'.  yy := (19595*r1 + 38470*g1 + 7471*b1 + 1&lt;&lt;15) &gt;&gt; 16 \/\/ omitted ... cb := -11056*r1 - 21712*g1 + 32768*b1 + 257&lt;&lt;15 \/\/ omitted ... cr := 32768*r1 - 27440*g1 - 5328*b1 + 257&lt;&lt;15 \/\/ omitted ... return uint8(yy), uint8(cb), uint8(cr) }<\/code><\/pre>\n<p>\u042d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435. \u041c\u044b \u0437\u0430\u043c\u0435\u0447\u0430\u0435\u043c, \u0447\u0442\u043e Y \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0437\u0435\u043b\u0451\u043d\u044b\u0439, \u043d\u043e \u0432 \u043d\u0451\u043c \u0442\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043a\u0440\u0430\u0441\u043d\u043e\u0433\u043e \u0438 \u0441\u0438\u043d\u0435\u0433\u043e. \u041a\u0430\u043a \u043c\u044b \u0443\u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438, \u044d\u0442\u043e luma, \u0438 \u043d\u0430\u0448 \u0433\u043b\u0430\u0437 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u0435\u043d \u043a \u043d\u0435\u0439; \u043e\u043d\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u044f\u0440\u043a\u043e\u0441\u0442\u044c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f. Cb \u0438 Cr \u043c\u043e\u0436\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0446\u0432\u0435\u0442\u043e\u0432\u044b\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u044f \u0441\u0438\u043d\u0435\u0433\u043e \u0438 \u043a\u0440\u0430\u0441\u043d\u043e\u0433\u043e \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u044f\u0440\u043a\u043e\u0441\u0442\u0438.<\/p>\n<p>\u0412 <a href=\"https:\/\/youtu.be\/5S4XblwZzCY?si=rke1SIt3deDSvZhE\">\u044d\u0442\u043e\u0439 \u043f\u043e\u0442\u0440\u044f\u0441\u0430\u044e\u0449\u0435\u0439 \u043b\u0435\u043a\u0446\u0438\u0438<\/a> (\u044f \u043e\u0431\u043e\u0436\u0430\u044e \u0432\u0435\u0441\u044c \u0446\u0438\u043a\u043b \u043b\u0435\u043a\u0446\u0438\u0439, \u0430 \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u043e\u0440 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0441\u0445\u0438\u0442\u0438\u0442\u0435\u043b\u0435\u043d) \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0438 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 RGB \u0438 YCbCr \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0432\u043b\u0438\u044f\u0442\u044c \u043d\u0430 \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435. \u0423\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u043a\u0430\u043a \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u0435 \u0433\u043b\u0443\u0431\u0438\u043d\u044b (\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0438\u0442\u043e\u0432\/\u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438) \u0434\u043b\u044f Cb \u0438 Cr \u0438\u043c\u0435\u0435\u0442 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043c\u0435\u043d\u044c\u0448\u0438\u0439 \u044d\u0444\u0444\u0435\u043a\u0442, \u0447\u0435\u043c \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u0435 \u0441\u0438\u043d\u0435\u0433\u043e \u0438\u043b\u0438 \u043a\u0440\u0430\u0441\u043d\u043e\u0433\u043e \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 RGB.<\/p>\n<p>\u042d\u0442\u043e \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0435 \u043d\u0435\u0439\u0440\u043e\u0431\u0438\u043e\u043b\u043e\u0433\u0438\u0438 \u0438 \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u0438\u0438.<\/p>\n<p>\u041e\u0434\u0438\u043d \u0438\u0437 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u0432\u044b\u0432\u043e\u0434\u043e\u0432 \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u2014 \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0438\u0440 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d \u043f\u043e\u0434 \u0431\u0438\u043e\u043b\u043e\u0433\u0438\u044e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430. \u042d\u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0435 \u043d\u0430 \u0442\u043e, \u043a\u0430\u043a \u043e\u0447\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u0447\u0435\u043b\u043e\u0432\u0435\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043b\u0438\u0446\u0430, \u0443\u0448\u0435\u0439 \u0438 \u0433\u043b\u0430\u0437. \u042d\u0442\u043e \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043c\u0435\u043d\u044f \u0434\u0443\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u0440\u043e\u0431\u043e\u0442\u043e\u0432 \u043b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0433\u0443\u043c\u0430\u043d\u043e\u0438\u0434\u043d\u044b\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0438 \u0431\u044b\u043b\u0438 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u043c\u0438, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043d\u0430\u0448 \u043c\u0438\u0440 \u0441\u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d \u0434\u043b\u044f \u043d\u0430\u0441.<\/p>\n<p>\u041b\u0430\u0434\u043d\u043e, \u0445\u0432\u0430\u0442\u0438\u0442 \u0444\u0438\u043b\u043e\u0441\u043e\u0444\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c, \u043a\u0430\u043a \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0446\u0432\u0435\u0442\u043e\u0432\u0430\u044f \u0441\u0443\u0431\u0434\u0438\u0441\u043a\u0440\u0435\u0442\u0438\u0437\u0430\u0446\u0438\u044f?<\/p>\n<p>\u0412\u043e\u0442 \u0446\u0438\u043a\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 JPEG:<\/p>\n<pre><code class=\"go\">cb, cr [4]block \/\/ omitted for y := bounds.Min.Y; y &lt; bounds.Max.Y; y += 16 { for x := bounds.Min.X; x &lt; bounds.Max.X; x += 16 { for i := 0; i &lt; 4; i++ { xOff := (i &amp; 1) * 8 yOff := (i &amp; 2) * 4 p := image.Pt(x+xOff, y+yOff) \/\/ omitted .. toYCbCr(m, p, &amp;b, &amp;cb[i], &amp;cr[i]) prevDCY = e.writeBlock(&amp;b, 0, prevDCY) } scale(&amp;b, &amp;cb) prevDCCb = e.writeBlock(&amp;b, 1, prevDCCb) scale(&amp;b, &amp;cr) prevDCCr = e.writeBlock(&amp;b, 1, prevDCCr) } }<\/code><\/pre>\n<p><code>cb<\/code> \u0438 <code>cr<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u043f\u043e 4 \u0431\u043b\u043e\u043a\u0430 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 Cb \u0438 Cr \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 8&#215;8. \u041c\u044b \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u043f\u043e \u043e\u0431\u043b\u0430\u0441\u0442\u0438 16&#215;16 \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 4 \u0431\u043b\u043e\u043a\u043e\u0432 8&#215;8. \u042d\u0442\u0438 \u0431\u043b\u043e\u043a\u0438 \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u044e\u0442\u0441\u044f \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 <code>cb<\/code> \u0438 <code>cr<\/code>.<\/p>\n<p>\u0412 \u0441\u0430\u043c\u043e\u043c \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u043c \u0446\u0438\u043a\u043b\u0435 \u0435\u0441\u0442\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u0442\u0440\u044e\u043a. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 <code>xOff := (i &amp; 1) * 8<\/code><em> \u0438 <\/em><code>yOff := (i &amp; 2) * 4<\/code>. \u0418\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f <code>i = [0,1,2,3]<\/code> \u0431\u0443\u0434\u0443\u0442: <code>(xOff, yOff) = [(0,0), (8,0), (0,8), (8,8)]<\/code>. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u0431\u043b\u043e\u043a\u0443 16&#215;16: \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0434\u0432\u0438\u0433\u0430\u0435\u043c\u0441\u044f \u0441\u043b\u0435\u0432\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u043e \u043f\u043e \u0432\u0435\u0440\u0445\u043d\u0435\u043c\u0443 \u0440\u044f\u0434\u0443, \u0437\u0430\u0442\u0435\u043c \u0441\u043c\u0435\u0449\u0430\u0435\u043c\u0441\u044f \u043d\u0430 8 (\u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0431\u043b\u043e\u043a\u0443 8&#215;8 \u0432\u043f\u0440\u0430\u0432\u043e), \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 <em>\u0441\u0442\u0440\u043e\u043a\u0435 <\/em>\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435.<\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f Cb \u0438 Cr \u0432 4 \u0431\u043b\u043e\u043a\u0430\u0445 8&#215;8. \u0421\u0443\u0431\u0434\u0438\u0441\u043a\u0440\u0435\u0442\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>scale<\/code>:<\/p>\n<pre><code class=\"go\">\/\/ scale scales the 16x16 region represented by the 4 src blocks to the 8x8 \/\/ dst block. func scale(dst *block, src *[4]block) { for i := 0; i &lt; 4; i++ { dstOff := (i&amp;2)&lt;&lt;4 | (i&amp;1)&lt;&lt;2 for y := 0; y &lt; 4; y++ { for x := 0; x &lt; 4; x++ { j := 16*y + 2*x sum := src[i][j] + src[i][j+1] + src[i][j+8] + src[i][j+9] dst[8*y+x+dstOff] = (sum + 2) &gt;&gt; 2 } } } }<\/code><\/pre>\n<p>\u042d\u0442\u043e \u043d\u0435\u0447\u0442\u043e! \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043c\u044b \u0431\u0435\u0440\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 <code>block<\/code> \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c [4] \u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u0435\u0433\u043e \u0432 <code>block<\/code> dst. \u041d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u044e, \u0447\u0442\u043e <code>block<\/code> \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u0430\u0441\u0441\u0438\u0432 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 64 (8&#215;8).<\/p>\n<p><code>i<\/code> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0432\u0435\u0440\u0445\u043d\u0438\u0439 \u043b\u0435\u0432\u044b\u0439, \u0432\u0435\u0440\u0445\u043d\u0438\u0439 \u043f\u0440\u0430\u0432\u044b\u0439, \u043d\u0438\u0436\u043d\u0438\u0439 \u043b\u0435\u0432\u044b\u0439 \u0438 \u043d\u0438\u0436\u043d\u0438\u0439 \u043f\u0440\u0430\u0432\u044b\u0439 \u0431\u043b\u043e\u043a\u0438 8&#215;8 \u0432 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 16&#215;16 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u041a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u0431\u043b\u043e\u043a\u043e\u0432 8&#215;8 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f \u0432 \u0431\u043b\u043e\u043a 4&#215;4 (\u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u0435 \u043d\u0430 1\/4). \u041a\u0430\u0436\u0434\u044b\u0439 \u043f\u0438\u043a\u0441\u0435\u043b\u044c \u0431\u043b\u043e\u043a\u0430 4&#215;4 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442\u0441\u044f x \u0438 y. \u041a\u0430\u043a \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f?<\/p>\n<pre><code class=\"go\">j := 16*y + 2*x \/\/ top left point of the 4 pixel square sum := src[i][j] + src[i][j+1] + src[i][j+8] + src[i][j+9] \/\/ sum of pixel square values starting at j dst[8*y+x+dstOff] = (sum + 2) &gt;&gt; 2 \/\/ divide by 4 (&gt;&gt;2) to get the average but add 2 before to round up instead of down<\/code><\/pre>\n<p>\u042d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0441\u0440\u0435\u0434\u043d\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 4 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e 2-\u0431\u0438\u0442\u043d\u043e\u0433\u043e \u0441\u0434\u0432\u0438\u0433\u0430 \u0432\u043f\u0440\u0430\u0432\u043e \u0438 \u043e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u0438\u044f \u0432 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u043f\u0443\u0442\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f 2 \u043f\u0435\u0440\u0435\u0434 \u0441\u0434\u0432\u0438\u0433\u043e\u043c.<\/p>\n<p>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>dstOff<\/code> \u0438\u043d\u0442\u0440\u0438\u0433\u0443\u0435\u0442. \u0414\u043b\u044f <code>i=[0,1,2,3]<\/code> \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c <code>dstOff=[0,4,32,36]<\/code>. \u0427\u0442\u043e \u043e\u043d\u0438 \u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0442?<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043c, \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u044b\u0439 <code>i<\/code> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 4&#215;4 \u0431\u043b\u043e\u043a \u0432\u043d\u0443\u0442\u0440\u0438 \u043d\u0430\u0448\u0435\u0439 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 8&#215;8 \u043e\u0431\u043b\u0430\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e 16&#215;16. \u0415\u0441\u043b\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 8&#215;8, \u0442\u043e \u043b\u0435\u0432\u044b\u0439 \u0432\u0435\u0440\u0445\u043d\u0438\u0439 \u0431\u043b\u043e\u043a \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u0447\u043a\u0435 (0,0). \u041f\u0440\u0430\u0432\u044b\u0439 \u0432\u0435\u0440\u0445\u043d\u0438\u0439 \u0431\u043b\u043e\u043a \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u0447\u043a\u0435 (4,0). \u041b\u0435\u0432\u044b\u0439 \u043d\u0438\u0436\u043d\u0438\u0439 \u0431\u043b\u043e\u043a \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u0447\u043a\u0435 (4,0), \u0430 \u043f\u0440\u0430\u0432\u044b\u0439 \u043d\u0438\u0436\u043d\u0438\u0439 \u2014\u00a0\u0432 \u0442\u043e\u0447\u043a\u0435 (4,4). \u0415\u0441\u043b\u0438 \u043c\u044b \u043f\u0435\u0440\u0435\u0432\u0435\u0434\u0435\u043c \u0438\u0445 \u0432 \u043e\u0434\u043d\u043e\u043c\u0435\u0440\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>x + 8y<\/code>, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043c:<\/p>\n<pre><code>0 + 0 * 8 = 0  4 + 0 * 8 = 4 0 + 4 * 8 = 32 4 + 4 * 8 = 36<\/code><\/pre>\n<p>\u041a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043d\u0430\u0447\u0430\u043b\u043e \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430 4&#215;4. \u042d\u0442\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u0447\u0443\u0434\u043b\u0438\u0432\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>dstOff := (i&amp;2)&lt;&lt;4 | (i&amp;1)&lt;&lt;2<\/code>.<\/p>\n<p><code>(i&amp;2)&lt;&lt;4<\/code> \u0434\u0430\u0441\u0442 32 \u0434\u043b\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u0442\u043e\u0440\u043e\u0439 \u0431\u0438\u0442 \u0440\u0430\u0432\u0435\u043d \u0435\u0434\u0438\u043d\u0438\u0446\u0435, \u0442\u043e \u0435\u0441\u0442\u044c \u0434\u043b\u044f 2 (10) \u0438 3 (11) (\u0432\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430), \u0430 <code>(i&amp;1)&lt;&lt;2<\/code> \u0434\u0430\u0441\u0442 4 \u0434\u043b\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 1 (01) \u0438 3 (11). \u041d\u0430\u0441\u0442\u043e\u044f\u0449\u0430\u044f \u0431\u0438\u043d\u0430\u0440\u043d\u0430\u044f \u043c\u0430\u0433\u0438\u044f!<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0437\u0430\u0434\u0430\u0451\u0442\u0435\u0441\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u043c, \u0437\u0430\u0447\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0451 \u044d\u0442\u043e \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c 4 \u0431\u043b\u043e\u043a\u0430 \u0438\u0437 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 16&#215;16 \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0438\u0445 \u043f\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0442\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432 \u0438\u0442\u043e\u0433\u0435 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0431\u043b\u043e\u043a 8&#215;8, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0443 Y (luma). \u042d\u0442\u043e \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0448\u0430\u0433 JPEG, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0434\u0438\u0441\u043a\u0440\u0435\u0442\u043d\u043e\u0435 \u043a\u043e\u0441\u0438\u043d\u0443\u0441\u043d\u043e\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 (DCT), \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0442\u0435\u043c\u0438 \u0436\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u0430\u043c\u0438.<\/p>\n<p>\u0412 \u043e\u0431\u0449\u0435\u043c, \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>scale<\/code> \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0441\u0440\u0435\u0434\u043d\u0435\u043d\u0438\u0435 4 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u0432 1, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c 4 \u0431\u043b\u043e\u043a\u0430 8&#215;8 \u0434\u043e \u043e\u0434\u043d\u043e\u0433\u043e.<\/p>\n<h4>\u041f\u0440\u044f\u043c\u043e\u0435 \u043a\u043e\u0441\u0438\u043d\u0443\u0441\u043d\u043e\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435<\/h4>\n<p>\u0418\u0442\u0430\u043a, \u043c\u044b \u0434\u043e\u0441\u0442\u0438\u0433\u043b\u0438 \u043f\u0440\u0438\u043b\u0438\u0447\u043d\u043e\u0433\u043e 50-\u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u0441\u0436\u0430\u0442\u0438\u044f, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f YCbCr. \u041e\u0434\u043d\u0430\u043a\u043e \u0432\u0441\u0451 \u0435\u0449\u0451 \u0434\u0430\u043b\u0435\u043a\u0438 \u043e\u0442 \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u0438\u044f \u0432\u0441\u0435\u0433\u043e \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u0430 JPEG.<\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0448\u0430\u0433 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u2014 \u0434\u0438\u0441\u043a\u0440\u0435\u0442\u043d\u043e\u0435 \u043a\u043e\u0441\u0438\u043d\u0443\u0441\u043d\u043e\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 (DCT). \u0412\u043a\u0440\u0430\u0442\u0446\u0435, DCT \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442 \u0438 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u0442 \u0447\u0430\u0441\u0442\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u0440\u0435\u0437\u0430\u0442\u044c \u0438\u043b\u0438 \u043e\u0442\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u0431\u0435\u0437 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0443\u0445\u0443\u0434\u0448\u0435\u043d\u0438\u044f \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430.<\/p>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u0435\u0431\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043a\u0430\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044e. \u041a\u0430\u0436\u0434\u044b\u0439 \u043f\u0438\u043a\u0441\u0435\u043b\u044c \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 (x, y) \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u043c \u043d\u0430 \u0438\u043d\u0442\u0435\u043d\u0441\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u0435\u0433\u043e \u0446\u0432\u0435\u0442\u0430. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u043e \u043a\u0430\u043a <code>F(x, y) = pixelValue<\/code>. \u0415\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043e\u0431\u0445\u043e\u0434\u0438\u0442\u044c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0441\u043b\u0435\u0432\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u043e \u0438 \u0441\u0432\u0435\u0440\u0445\u0443 \u0432\u043d\u0438\u0437, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043e\u0434\u043d\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <code>x'<\/code>, \u0433\u0434\u0435 <code>x' = x + len(row) * y<\/code> (\u043f\u043e \u0441\u0443\u0442\u0438, \u044d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f Golang \u0441\u043e \u0441\u0432\u043e\u0438\u043c\u0438 64-\u0431\u0438\u0442\u043d\u044b\u043c\u0438 \u0431\u043b\u043e\u043a\u0430\u043c\u0438 \u0431\u0435\u0437\u0437\u043d\u0430\u043a\u043e\u0432\u044b\u0445 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b).<\/p>\n<p>\u0414\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u2014 \u044d\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f.<strong> <\/strong>\u0418 \u0447\u0442\u043e \u0441 \u0442\u043e\u0433\u043e? \u2014 \u0441\u043f\u0440\u043e\u0441\u0438\u0442\u0435 \u0432\u044b. \u0410 \u0447\u0442\u043e, \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0441\u043f\u043e\u0441\u043e\u0431 \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0430\u0431\u043e\u0440\u0430 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0440\u0430\u0437\u043d\u043e\u0439 \u0432\u0430\u0436\u043d\u043e\u0441\u0442\u0438 \u0438 \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u043c\u0435\u0441\u0442\u043e, \u043e\u0442\u0431\u0440\u043e\u0441\u0438\u0432 \u043d\u0430\u0438\u043c\u0435\u043d\u0435\u0435 \u0432\u0430\u0436\u043d\u044b\u0435 \u0438\u0437 \u043d\u0438\u0445?<\/p>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043d\u0430\u0431\u043e\u0440 \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u0439 \u0442\u0438\u043f\u0430 <code>(1, 2), (2, 4), ..., (10, 20), (1000, 2000)<\/code>. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c 2 * 1000 \u0447\u0438\u0441\u0435\u043b, \u0430 \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u0438 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u0445\u0435\u043c\u0435: <code>f(x) = 2x<\/code>. \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u0441\u0435 \u0442\u043e\u0447\u043a\u0438, \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0444\u043e\u0440\u043c\u0443\u043b\u0443, \u0447\u0442\u043e \u0434\u0430\u043b\u043e \u0431\u044b \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u044e \u043c\u0435\u0441\u0442\u0430.<\/p>\n<p>DCT \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u0432\u0438\u0434\u0435 \u0441\u0443\u043c\u043c\u044b \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0445 \u043a\u043e\u0441\u0438\u043d\u0443\u0441\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430\u044e\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u043e\u0442\u044b. \u041c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043e\u043a\u0430\u0437\u0430\u043d\u043e, \u0447\u0442\u043e \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e.<\/p>\n<p>\u0427\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0440\u0430\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438, \u0442\u0430\u043a \u044d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u0447\u0435\u0441\u043a\u0438\u0439 \u0433\u043b\u0430\u0437 (\u0431\u0438\u043e\u043b\u043e\u0433\u0438\u044f \u0441\u043d\u043e\u0432\u0430 \u043d\u0430\u043d\u043e\u0441\u0438\u0442 \u0443\u0434\u0430\u0440) \u043c\u0435\u043d\u0435\u0435 \u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u0435\u043d \u043a \u0432\u044b\u0441\u043e\u043a\u043e\u0447\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u043c \u0434\u0435\u0442\u0430\u043b\u044f\u043c, \u0447\u0435\u043c \u043a \u043d\u0438\u0437\u043a\u043e\u0447\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u043c. \u0415\u0449\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0435 \u0442\u043e, \u0447\u0442\u043e \u0432\u044b\u0441\u043e\u043a\u043e\u0447\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0440\u0435\u0437\u043a\u0438\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438, \u0430 \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u0442 \u0438\u0437 \u043d\u0438\u0437\u043a\u043e\u0447\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432. \u0414\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0446\u0432\u0435\u0442\u0430 \u0432 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u0445 \u043e\u0431\u044b\u0447\u043d\u043e \u043d\u0435 \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0440\u0435\u0437\u043a\u043e.<\/p>\n<p>\u0413\u043e\u0432\u043e\u0440\u044f \u0438\u043d\u0430\u0447\u0435, \u043b\u044e\u0431\u043e\u0439 \u0431\u043b\u043e\u043a \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 8&#215;8 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u044c \u043a\u0430\u043a \u0432\u0437\u0432\u0435\u0448\u0435\u043d\u043d\u0443\u044e \u0441\u0443\u043c\u043c\u0443 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 64 \u0431\u043b\u043e\u043a\u043e\u0432:<\/p>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1d1\/907\/ed6\/1d1907ed6d1adef2f9d47bd249658993.png\" width=\"250\" height=\"250\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/1d1\/907\/ed6\/1d1907ed6d1adef2f9d47bd249658993.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1d1\/907\/ed6\/1d1907ed6d1adef2f9d47bd249658993.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0434\u0443\u043c\u0430\u0435\u043c \u043e\u0431 \u044d\u0442\u043e\u043c \u0435\u0449\u0451 \u0440\u0430\u0437. \u041b\u044e\u0431\u043e\u0439 \u0431\u043b\u043e\u043a 8&#215;8 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u0440\u0430\u0436\u0435\u043d \u043a\u0430\u043a \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u044f \u044d\u0442\u0438\u0445 64 \u0431\u043b\u043e\u043a\u043e\u0432. \u0418 \u0447\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043c\u044b \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0430\u0435\u043c\u0441\u044f \u043a \u043f\u0440\u0430\u0432\u043e\u043c\u0443 \u043d\u0438\u0436\u043d\u0435\u043c\u0443 \u0443\u0433\u043b\u0443, \u0442\u0435\u043c \u0432\u044b\u0448\u0435 \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u2014 \u0438 \u0442\u0435\u043c \u043c\u0435\u043d\u0435\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u043c \u043e\u043d \u0434\u043b\u044f \u0447\u0435\u043b\u043e\u0432\u0435\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0433\u043b\u0430\u0437\u0430.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u043d\u0430\u0448 \u0431\u043b\u043e\u043a 8&#215;8 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0432\u0435\u0441\u0430\u043c\u0438 \u044d\u0442\u0438\u0445 \u043d\u0438\u0437\u043a\u043e\u0447\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u0445 \u0431\u043b\u043e\u043a\u043e\u0432 DCT \u2014 \u0441\u043a\u0430\u0436\u0435\u043c, \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u0432\u0441\u0435\u0433\u043e 16 \u0438\u043b\u0438 32 (\u0432\u043c\u0435\u0441\u0442\u043e 64 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439), \u043c\u044b \u0434\u043e\u0431\u044c\u0435\u043c\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0438 \u043c\u0435\u0441\u0442\u0430 \u0431\u0435\u0437 \u0437\u0430\u043c\u0435\u0442\u043d\u043e\u0439 \u043f\u043e\u0442\u0435\u0440\u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043c\u043e\u0439 \u043f\u043b\u0430\u0433\u0438\u043d Mathjax \u043d\u0435 \u043f\u044b\u043b\u0438\u043b\u0441\u044f \u0431\u0435\u0437 \u0434\u0435\u043b\u0430 \u0430 \u043c\u043e\u0438 \u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u044f \u0431\u044b\u043b\u0438 \u043f\u043e\u0434\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u044b \u043d\u0430\u0443\u043a\u043e\u0439, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0444\u043e\u0440\u043c\u0443\u043b\u0443:<\/p>\n<p><img decoding=\"async\" class=\"formula\" source=\"X_{k}=\\sum _{n=0}^{N-1}x_{n}\\cos \\left[\\,{\\tfrac {\\,\\pi \\,}{N}}\\left(n+{\\tfrac {1}{2}}\\right)k\\,\\right]\\qquad {\\text{ for }}~k=0,\\ \\dots \\ N-1~\" alt=\"X_{k}=\\sum _{n=0}^{N-1}x_{n}\\cos \\left[\\,{\\tfrac {\\,\\pi \\,}{N}}\\left(n+{\\tfrac {1}{2}}\\right)k\\,\\right]\\qquad {\\text{ for }}~k=0,\\ \\dots \\ N-1~\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/b\/bf\/bf3\/bf38f5a536aeb76b2b417069a2a8d9ba.svg\" width=\"auto\" height=\"auto\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/b\/bf\/bf3\/bf38f5a536aeb76b2b417069a2a8d9ba.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/formulas\/b\/bf\/bf3\/bf38f5a536aeb76b2b417069a2a8d9ba.svg 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<p>\u0422\u0430\u043a \u043c\u044b \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 K-\u0439 \u043a\u043e\u0441\u0438\u043d\u0443\u0441\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<p>\u0411\u0443\u0434\u0435\u0442 \u0443\u0434\u043e\u0431\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u0435\u0431\u0435 \u044d\u0442\u043e \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043a\u0430\u043a \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u043d\u0430\u0448\u0438\u043c\u0438 N \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u0438 N \u0432\u044b\u0431\u043e\u0440\u043a\u0430\u043c\u0438 \u043a\u043e\u0441\u0438\u043d\u0443\u0441\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438: <\/p>\n<p><img decoding=\"async\" class=\"formula\" source=\"\\cos \\left[\\,{\\tfrac {\\,\\pi \\,}{N}}\\left(n+{\\tfrac {1}{2}}\\right)k\\,\\right]\" alt=\"\\cos \\left[\\,{\\tfrac {\\,\\pi \\,}{N}}\\left(n+{\\tfrac {1}{2}}\\right)k\\,\\right]\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ec5\/c0e\/eeb\/ec5c0eeebf57605c976be679d83baf05.svg\" width=\"153\" height=\"27\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ec5\/c0e\/eeb\/ec5c0eeebf57605c976be679d83baf05.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ec5\/c0e\/eeb\/ec5c0eeebf57605c976be679d83baf05.svg 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<p>\u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441 \u0440\u043e\u0441\u0442\u043e\u043c k.<\/p>\n<p>\u041a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0441\u0445\u043e\u0434\u0441\u0442\u0432\u0430 (\u0442. \u0435. \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435) \u043c\u0435\u0436\u0434\u0443 \u043d\u0430\u0448\u0438\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u043a\u043e\u0441\u0438\u043d\u0443\u0441\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u0446\u0435\u043b\u0435\u0439 \u043c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 \u043e\u0434\u043d\u0438\u043c \u0438\u0437 64 \u0431\u043b\u043e\u043a\u043e\u0432 (\u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u0430\u044f \u0432\u044b\u0448\u0435 \u043a\u043e\u0441\u0438\u043d\u0443\u0441\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u043e\u043c\u0435\u0440\u043d\u043e\u0439, \u0430 \u0431\u043b\u043e\u043a \u2014 \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u044b\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u043d\u043d\u043e\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439).<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0441\u0435\u0442\u043a\u0430 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 8&#215;8, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u0441 \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u043a\u043e\u0441\u0438\u043d\u0443\u0441\u043d\u044b\u0445 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432, \u0442\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u0435\u043d 1, \u0430 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u0431\u043b\u043e\u043a\u043e\u0432 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0432\u043d\u044b 0. \u042d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0415\u0449\u0435 \u0440\u0430\u0437: \u0432\u0437\u0432\u0435\u0448\u0435\u043d\u043d\u0430\u044f \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u044f \u043d\u0438\u0437\u043a\u043e\u0447\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u0445 \u0431\u043b\u043e\u043a\u043e\u0432 (\u0431\u043b\u0438\u0436\u0435 \u043a \u043b\u0435\u0432\u043e\u043c\u0443 \u0432\u0435\u0440\u0445\u043d\u0435\u043c\u0443 \u0443\u0433\u043b\u0443) \u0441 \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u043c\u043e\u0436\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0431\u043b\u043e\u043a 8&#215;8 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0430\u0448\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u0432\u0438\u0434\u0435 64 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0442\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u0432\u044b\u0441\u043e\u043a\u043e\u0447\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u0435 \u043d\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u0442\u0435\u0440\u044f\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0433\u043e\u0442\u043e\u0432\u044b \u043a \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u0443\u043b\u0435:<\/p>\n<p><img decoding=\"async\" class=\"formula\" source=\"X_{k,l} = \\sum_{n=0}^{N-1} \\sum_{m=0}^{N-1} x_{n,m} \\cos\\left[\\frac{\\pi}{N} \\left(n + \\frac{1}{2}\\right) k \\right] \\cos\\left[\\frac{\\pi}{N} \\left(m + \\frac{1}{2}\\right) l \\right]\" alt=\"X_{k,l} = \\sum_{n=0}^{N-1} \\sum_{m=0}^{N-1} x_{n,m} \\cos\\left[\\frac{\\pi}{N} \\left(n + \\frac{1}{2}\\right) k \\right] \\cos\\left[\\frac{\\pi}{N} \\left(m + \\frac{1}{2}\\right) l \\right]\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/e\/e4\/e45\/e459c803c13c363f7bd03e9d332e9119.svg\" width=\"auto\" height=\"auto\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/e\/e4\/e45\/e459c803c13c363f7bd03e9d332e9119.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/formulas\/e\/e4\/e45\/e459c803c13c363f7bd03e9d332e9119.svg 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<p>\u041f\u0435\u0440\u0435\u0432\u0435\u0434\u044f \u0432 \u043a\u043e\u0434, \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code class=\"go\">    for i := 0; i &lt; N; i++ {         for j := 0; j &lt; N; j++ {             temp := 0.0             for x := 0; x &lt; N; x++ {                 for y := 0; y &lt; N; y++ {                     temp += Cosines[x][i] * Cosines[y][j] * Pixel[x][y]                 }             }             temp *= math.Sqrt(2 * float64(N)) * Coefficient[i][j]             DCT[i][j] = int(math.Round(temp))         }     }<\/code><\/pre>\n<p>\u041c\u0430\u0441\u0441\u0438\u0432 cosines \u0443\u0436\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u041c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0442\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u0441\u044f \u043f\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u043c \u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u044f\u0442 \u043e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u0438 \u043a\u043e\u0441\u0438\u043d\u0443\u0441\u043e\u0432.<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u043a\u0430\u043a \u0432\u0438\u0434\u043d\u043e, \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438 4 \u0434\u043b\u044f \u0446\u0438\u043a\u043b\u043e\u0432 \u043d\u0435 \u0442\u0430\u043a \u0443\u0436 \u0445\u043e\u0440\u043e\u0448 \u0434\u043b\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u0412 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f, \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430\u044f \u043a\u0430\u043a <a href=\"https:\/\/dl.acm.org\/doi\/pdf\/10.1145\/212066.212071\">Fast DCT<\/a>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0430 \u0441 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f.<\/p>\n<h4>\u041a\u0432\u0430\u043d\u0442\u043e\u0432\u0430\u043d\u0438\u0435  <\/h4>\n<p>\u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0441\u0440\u0430\u0437\u0443 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0432\u044b\u0441\u043e\u043a\u043e\u0447\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u0435 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b, \u043c\u044b \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u043c \u0438\u0445 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0438\u0442 \u0434\u043b\u044f \u0438\u0445 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f. \u042d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u0430\u043d\u0438\u0435\u043c. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u0430\u0436\u043d\u044b\u0435 \u043d\u0438\u0437\u043a\u043e\u0447\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u0435 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u0441 \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e, \u0430 \u0432\u044b\u0441\u043e\u043a\u043e\u0447\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u0435 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b \u043a\u0432\u0430\u043d\u0442\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0438 \u043c\u0435\u0441\u0442\u0430.<\/p>\n<p>\u041a\u0430\u043a \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435?<\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b DCT \u0434\u0435\u043b\u044f\u0442\u0441\u044f \u043d\u0430 Q \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0431\u0438\u0442. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 DCT \u0440\u0430\u0432\u0435\u043d 31, \u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 Q &#8212; 2, <code>Round(31\/Q)<\/code> \u0434\u0430\u0435\u0442 16. \u0415\u0441\u043b\u0438 Q \u0440\u0430\u0432\u043d\u043e 4, <code>Round(31\/Q)<\/code> \u0434\u0430\u0435\u0442 8. \u0427\u0442\u043e\u0431\u044b \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043c\u044b \u0443\u043c\u043d\u043e\u0436\u0430\u0435\u043c \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043d\u0430 Q, \u0445\u043e\u0442\u044f \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0431\u043b\u0438\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c.<\/p>\n<p>\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442 JPEG \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0434\u043b\u044f \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 64 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f DCT \u043a \u0431\u043b\u043e\u043a\u0443 8&#215;8 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439.<\/p>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0446\u0432\u0435\u0442\u043d\u043e\u0441\u0442\u0438 (Yb \u0438 Yr) \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u0432\u043b\u0438\u044f\u043d\u0438\u0435 \u043d\u0430 \u043d\u0430\u0448\u0435 \u0432\u043e\u0441\u043f\u0440\u0438\u044f\u0442\u0438\u0435, \u0438\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u043e\u043b\u0435\u0435 \u0430\u0433\u0440\u0435\u0441\u0441\u0438\u0432\u043d\u044b, \u0447\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0434\u043b\u044f \u044f\u0440\u043a\u043e\u0441\u0442\u0438 (Y). \u0412\u043e\u0442 \u044d\u0442\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b:<\/p>\n<pre><code class=\"go\">var unscaledQuant = [nQuantIndex][blockSize]byte{ \/\/ Luminance. { 16, 11, 12, 14, 12, 10, 16, 14, 13, 14, 18, 17, 16, 19, 24, 40, 26, 24, 22, 22, 24, 49, 35, 37, 29, 40, 58, 51, 61, 60, 57, 51, 56, 55, 64, 72, 92, 78, 64, 68, 87, 69, 55, 56, 80, 109, 81, 87, 95, 98, 103, 104, 103, 62, 77, 113, 121, 112, 100, 120, 92, 101, 103, 99, }, \/\/ Chrominance. { 17, 18, 18, 24, 21, 24, 47, 26, 26, 47, 99, 66, 56, 66, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, }, }<\/code><\/pre>\n<p>\u041c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043d\u0438\u0437\u043a\u0438\u0435 \u0447\u0430\u0441\u0442\u043e\u0442\u044b (\u0432\u0432\u0435\u0440\u0445\u0443 \u0441\u043b\u0435\u0432\u0430) \u0434\u0435\u043b\u044f\u0442\u0441\u044f \u043d\u0430 \u043c\u0435\u043d\u044c\u0448\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u0443\u044e \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u0432\u044b\u0441\u043e\u043a\u0438\u0435 \u0447\u0430\u0441\u0442\u043e\u0442\u044b (\u0432\u043d\u0438\u0437\u0443 \u0441\u043f\u0440\u0430\u0432\u0430) \u0434\u0435\u043b\u044f\u0442\u0441\u044f \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b Q, \u0447\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u043e\u0447\u0435\u043d\u044c \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c (\u0431\u043b\u0438\u0437\u043a\u0438\u043c \u043a 0 \u0438\u043b\u0438 1). \u042d\u0442\u0438 \u043c\u0430\u043b\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u0430\u043c\u0438 \u0434\u043b\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0441\u0436\u0430\u0442\u0438\u044f \u0431\u0435\u0437 \u043f\u043e\u0442\u0435\u0440\u044c, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a LZ77 \u0438\u043b\u0438 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u043b\u0438\u043d \u0441\u0435\u0440\u0438\u0439.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u0441\u0436\u0430\u0442\u0438\u044f, \u0431\u043b\u043e\u043a \u043e\u0431\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0437\u0438\u0433\u0437\u0430\u0433\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435. \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u0430\u043d\u0438\u044f, \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 Q (\u0438, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u0430\u043d\u0438\u044f) \u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e \u0442\u0438\u043f\u0438\u0447\u043d\u043e\u0439 \u0441\u0445\u0435\u043c\u0435 \u0441\u043b\u0435\u0432\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u043e, \u0441\u0432\u0435\u0440\u0445\u0443 \u0432\u043d\u0438\u0437. \u041d\u0430\u043f\u0440\u043e\u0442\u0438\u0432, \u043e\u043d\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u0442 \u043b\u0435\u0432\u043e\u0433\u043e \u0432\u0435\u0440\u0445\u043d\u0435\u0433\u043e \u043a\u0440\u0430\u044f \u043a \u043f\u0440\u0430\u0432\u043e\u043c\u0443 \u043d\u0438\u0436\u043d\u0435\u043c\u0443.<\/p>\n<p>\u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u043f\u043e\u0445\u043e\u0436\u0438 \u0438, \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0431\u043e\u043b\u0435\u0435 \u0441\u0436\u0438\u043c\u0430\u0435\u043c\u044b, \u0441\u043b\u0435\u0434\u0443\u044e\u0442 \u0434\u0440\u0443\u0433 \u0437\u0430 \u0434\u0440\u0443\u0433\u043e\u043c \u043f\u043e \u0434\u0438\u0430\u0433\u043e\u043d\u0430\u043b\u0438. \u0417\u0438\u0433\u0437\u0430\u0433\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u044b\u0439 \u043e\u0431\u0445\u043e\u0434 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u0443\u0435\u0442 \u044d\u0442\u0438 \u043f\u043e\u0445\u043e\u0436\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u044f \u0441\u0436\u0430\u0442\u0438\u0435.<\/p>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b1e\/55d\/6d0\/b1e55d6d0a5df517246250eb504dca6c.png\" width=\"360\" height=\"360\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/b1e\/55d\/6d0\/b1e55d6d0a5df517246250eb504dca6c.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b1e\/55d\/6d0\/b1e55d6d0a5df517246250eb504dca6c.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0417\u0438\u0433\u0437\u0430\u0433\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u044b\u0439 \u043e\u0431\u0445\u043e\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0445\u0438\u0442\u0440\u043e: \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0437 64 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u0430\u0436\u0434\u044b\u0439 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u0441 \u0435\u0433\u043e \u0437\u0438\u0433\u0437\u0430\u0433\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u044b\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u043e\u043c.<\/p>\n<pre><code class=\"go\">\/\/ unzig maps from the zig-zag ordering to the natural ordering. For example, \/\/ unzig[3] is the column and row of the fourth element in zig-zag order. The \/\/ value is 16, which means first column (16%8 == 0) and third row (16\/8 == 2). var unzig = [blockSize]int{ 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28, 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51, 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63, } <\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u0447\u0430\u0441\u0442\u0438 \u0432\u043c\u0435\u0441\u0442\u0435, \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f, \u0447\u0442\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0446\u0438\u043a\u043b JPEG \u2014 \u044d\u0442\u043e:<\/p>\n<pre><code class=\"go\">\/\/ writeBlock writes a block of pixel data using the given quantization table, \/\/ returning the post-quantized DC value of the DCT-transformed block. b is in \/\/ natural (not zig-zag) order. func (e *encoder) writeBlock(b *block, q quantIndex, prevDC int32) int32 { fdct(b) \/\/ apply DCT \/\/ ... for zig := 1; zig &lt; blockSize; zig++ { ac := div(b[unzig[zig]], 8*int32(e.quant[q][zig])) \/\/ divide zigzag DCT result by quantization number if ac == 0 { \/\/ quantization result is 0, increase RLE runLength++ } else { \/\/ ... \/\/ write the current RLE sequence e.emitHuffRLE(h, runLength, ac) runLength = 0 } } \/\/... } <\/code><\/pre>\n<p>\u041c\u044b \u043e\u043f\u0443\u0441\u0442\u0438\u043b\u0438 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0434\u0435\u0442\u0430\u043b\u0435\u0439, \u043d\u043e \u0432\u0441\u0451 \u0436\u0435 \u043c\u043e\u0436\u0435\u043c \u0432\u0438\u0434\u0435\u0442\u044c, \u043a\u0430\u043a \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0438\u0434\u0435\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438.<\/p>\n<p>JPEG \u2014 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0430\u044f \u0441\u043e\u043a\u0440\u043e\u0432\u0438\u0449\u043d\u0438\u0446\u0430 \u0432\u043e\u0441\u0445\u0438\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439, \u0438 \u0442\u043e, \u0447\u0442\u043e \u043c\u044b \u0437\u0434\u0435\u0441\u044c \u043e\u0431\u0441\u0443\u0434\u0438\u043b\u0438, \u2014 \u043b\u0438\u0448\u044c \u0432\u0435\u0440\u0445\u0443\u0448\u043a\u0430 \u0430\u0439\u0441\u0431\u0435\u0440\u0433\u0430. \u041d\u043e \u044f \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438 \u0443\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u044c\u043d\u043e.<\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u043f\u043e\u043a\u0430 \u0432\u0441\u0435. \u0426\u0435\u043d\u044e, \u0447\u0442\u043e \u0432\u044b \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0438\u043b\u0438\u0441\u044c \u043a\u043e \u043c\u043d\u0435 \u0432 \u044d\u0442\u043e\u043c \u043f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0438\u0438.<\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e!<\/p>\n<hr\/>\n<p><a href=\"https:\/\/t.me\/sravni_tech\"><strong>\u0422\u0413-\u043a\u0430\u043d\u0430\u043b \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u043d\u043e\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0430 Sravni Tech<\/strong><\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/906964\/\"> https:\/\/habr.com\/ru\/articles\/906964\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><\/figure>\n<p>\u042d\u0442\u043e\u0442 \u043f\u043e\u0441\u0442 \u2014 \u043f\u043e\u0433\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0432 \u043a\u0440\u043e\u043b\u0438\u0447\u044c\u044e \u043d\u043e\u0440\u0443. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u041c\u043e\u043d\u0441\u0435\u0444 \u0410\u0431\u0431\u0430\u0434 \u0437\u0430\u0434\u0443\u043c\u0430\u043b\u0441\u044f \u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u0445 \u2014 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u043f\u043e\u0441\u043b\u0435 <a href=\"https:\/\/cefboud.com\/posts\/compression\/\">\u043d\u0435\u0434\u0430\u0432\u043d\u0435\u0433\u043e \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f<\/a> \u0438\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0445\u0435\u043c \u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u0438. \u041e\u0431\u0449\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0447\u0442\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0431\u044b\u0432\u0430\u044e\u0442 \u043b\u0438\u0431\u043e \u043f\u043e\u043b\u0443\u0442\u043e\u043d\u043e\u0432\u044b\u043c\u0438, \u043b\u0438\u0431\u043e RGB, \u043a\u043e\u0433\u0434\u0430 \u043d\u043e\u0432\u044b\u0435 \u0446\u0432\u0435\u0442\u0430 \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u043c\u0435\u0448\u0435\u043d\u0438\u044f \u043a\u0440\u0430\u0441\u043d\u043e\u0433\u043e, \u0437\u0435\u043b\u0451\u043d\u043e\u0433\u043e \u0438 \u0441\u0438\u043d\u0435\u0433\u043e. \u041d\u043e \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u0447\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0435\u0435, \u0447\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u0435 \u0442\u0440\u0435\u0445\u0431\u0430\u0439\u0442\u043e\u0432\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 RGB. <\/p>\n<p>\u0427\u0442\u043e-\u0442\u043e \u0432 \u044d\u0442\u043e\u0439 \u0438\u0434\u0435\u0435 \u043f\u0440\u043e\u0431\u0443\u0434\u0438\u043b\u043e \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u0441\u0442\u0432\u043e \u0430\u0432\u0442\u043e\u0440\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u043e\u043d \u043f\u043e\u043f\u044b\u0442\u0430\u043b\u0441\u044f \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0438\u0442\u044c \u0435\u0433\u043e \u0438 \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441: \u043a\u0430\u043a \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f?<\/p>\n<hr\/>\n<h2>\u041e\u0441\u043d\u043e\u0432\u044b  <\/h2>\n<p>\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u2014 \u044d\u0442\u043e \u043d\u0430\u0431\u043e\u0440 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439. \u041f\u0438\u043a\u0441\u0435\u043b\u044c \u2014 \u00a0\u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0430\u044f \u0435\u0434\u0438\u043d\u0438\u0446\u0430 \u0446\u0432\u0435\u0442\u0430 \u0432 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0438\u0437 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0433\u043e <a href=\"https:\/\/en.wikipedia.org\/wiki\/MNIST_database\">\u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430 MNIST<\/a>:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u042d\u0442\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 28&#215;28 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 (\u0438\u043b\u0438 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043e\u0432). \u041e\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043e \u0432 \u0433\u0440\u0430\u0434\u0430\u0446\u0438\u044f\u0445 \u0441\u0435\u0440\u043e\u0433\u043e, \u0442\u043e \u0435\u0441\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u0438\u043a\u0441\u0435\u043b\u044c \u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043e\u0442 0 \u0434\u043e 255, \u0433\u0434\u0435 0 \u2014 \u0447\u0451\u0440\u043d\u044b\u0439, \u0430 255 \u2014 \u0431\u0435\u043b\u044b\u0439.<\/p>\n<p>\u0410 \u043a\u0430\u043a \u043d\u0430\u0441\u0447\u0435\u0442 \u0446\u0432\u0435\u0442\u043d\u044b\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439? \u0412 \u043d\u0438\u0445 \u0442\u0430\u043a\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043f\u0438\u043a\u0441\u0435\u043b\u0438, \u043d\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u0438\u043a\u0441\u0435\u043b\u044c \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0435 RGB-\u0442\u0440\u0438\u043f\u043b\u0435\u0442\u0430. \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f 3 \u0431\u0430\u0439\u0442\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0435\u0433\u043e \u0446\u0432\u0435\u0442: \u043a\u0440\u0430\u0441\u043d\u044b\u0439, \u0437\u0435\u043b\u0435\u043d\u044b\u0439 \u0438 \u0441\u0438\u043d\u0438\u0439. (0, 0, 0) \u2014 \u044d\u0442\u043e \u0447\u0451\u0440\u043d\u044b\u0439 \u0446\u0432\u0435\u0442, \u0430 (255, 255, 255) \u2014 \u0431\u0435\u043b\u044b\u0439. \u0421\u0443\u0442\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0438 \u0441\u0432\u0435\u0442\u043b\u043e\u0433\u043e (0, 0, 0), \u0446\u0432\u0435\u0442 \u2014 \u0447\u0451\u0440\u043d\u044b\u0439, \u0430 \u0441\u043c\u0435\u0448\u0438\u0432\u0430\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0446\u0432\u0435\u0442\u0430, \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0435 \u0431\u0435\u043b\u044b\u0439. \u041a\u0440\u0430\u0441\u043d\u044b\u0439 \u2014 \u044d\u0442\u043e (255, 0, 0), \u0437\u0435\u043b\u0435\u043d\u044b\u0439 \u2014 (0, 255, 0), \u0430 \u0441\u0438\u043d\u0438\u0439 \u2014 (0, 0, 255).<\/p>\n<p>RGB \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0447\u0435\u0442\u0432\u0451\u0440\u0442\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u0430\u043b\u044c\u0444\u0430, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0435\u0433\u043e RGBA. \u0410\u043b\u044c\u0444\u0430 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u043d\u0435\u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c \u0438\u043b\u0438 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c \u043f\u0438\u043a\u0441\u0435\u043b\u044f. \u041e\u043d \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442, \u043a\u0430\u043a \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c. \u0427\u0435\u043c \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u0435\u0435 \u043f\u0438\u043a\u0441\u0435\u043b\u044c, \u0442\u0435\u043c \u043c\u0435\u043d\u044c\u0448\u0435 \u043e\u043d \u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0444\u043e\u043d \u0437\u0430 \u043d\u0438\u043c. \u041f\u0440\u0438 \u043d\u0430\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0434\u0432\u0443\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0430\u043b\u044c\u0444\u0430-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0444\u043e\u043d\u043e\u0432\u043e\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043f\u0438\u043a\u0441\u0435\u043b\u044c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0434\u043d\u0435\u0433\u043e \u043f\u043b\u0430\u043d\u0430.<\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0437\u043d\u0430\u043c\u0435\u043d\u0438\u0442\u044b\u0439 \u043a\u043b\u0435\u0442\u0447\u0430\u0442\u044b\u0439 \u0443\u0437\u043e\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u0438. \u0412 \u043b\u0435\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043d\u0435\u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0441\u043e\u043a\u0430\u044f (\u0430\u043b\u044c\u0444\u0430-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432\u044b\u0441\u043e\u043a\u043e\u0435), \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0444\u043e\u043d \u043d\u0435\u0432\u0438\u0434\u0438\u043c\u044b\u043c. \u041d\u0430\u043f\u0440\u043e\u0442\u0438\u0432, \u0432 \u043f\u0440\u0430\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438, \u0433\u0434\u0435 \u043d\u0435\u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c \u043d\u0438\u0436\u0435 (\u0430\u043b\u044c\u0444\u0430 \u043d\u0438\u0437\u043a\u0430\u044f), \u043a\u043b\u0435\u0442\u0447\u0430\u0442\u044b\u0439 \u0444\u043e\u043d \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0432\u0438\u0434\u0438\u043c\u044b\u043c.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u0445\u0440\u0430\u043d\u0438\u043c \u0446\u0432\u0435\u0442\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 (3 \u0431\u0430\u0439\u0442\u0430 \u043d\u0430 \u043f\u0438\u043a\u0441\u0435\u043b\u044c) \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 1920&#215;1080 \u0431\u0435\u0437 \u0441\u0436\u0430\u0442\u0438\u044f, \u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f 1920x1080x3 = 6 220 800 \u0431\u0430\u0439\u0442 (\u043e\u043a\u043e\u043b\u043e 6 \u041c\u0411)!<\/p>\n<p>1080p \u2014 \u043e\u0431\u044b\u0447\u043d\u043e\u0435 \u0434\u0435\u043b\u043e \u0434\u043b\u044f \u0432\u0438\u0434\u0435\u043e, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a 240p (\u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 VHS) \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043d\u0438\u0437\u043a\u0438\u043c \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e\u043c. 480p \u2014 \u044d\u0442\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0443 DVD.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u043b\u0438 \u043d\u0435\u0441\u0436\u0430\u0442\u043e\u0435 \u0432\u0438\u0434\u0435\u043e 1080p \u0441 \u0447\u0430\u0441\u0442\u043e\u0442\u043e\u0439 24 \u043a\u0430\u0434\u0440\u0430 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443, \u044d\u0442\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e \u0431\u044b \u0431\u043e\u043b\u0435\u0435 1 \u0433\u0438\u0433\u0430\u0431\u0438\u0442\u0430 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443, \u0447\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u043e\u043b\u043e\u0441\u0441\u0430\u043b\u044c\u043d\u043e! \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0435\u0441\u043b\u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0436\u0430\u0442\u0438\u0435 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0443\u0445\u0438\u0449\u0440\u0435\u043d\u0438\u044f, \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u0430\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0432\u044b\u0441\u043e\u043a\u043e\u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u0438\u0434\u0435\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u0430.<\/p>\n<p><a href=\"https:\/\/cefboud.com\/posts\/compression\/\">\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0441\u0436\u0430\u0442\u0438\u044f \u0431\u0435\u0437 \u043f\u043e\u0442\u0435\u0440\u044c<\/a> \u043e\u0431\u044b\u0447\u043d\u043e \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u044e\u0442 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u0430 \u0441\u0436\u0430\u0442\u0438\u044f \u0432 \u043b\u0443\u0447\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 3:4. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u044e\u0442 \u0442\u0430\u043a\u0438\u0445 \u0432\u044b\u0441\u043e\u043a\u0438\u0445 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432, \u0447\u0430\u0441\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u0442\u0440\u0430\u0442 \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0438\u0445 \u043d\u0435\u043f\u0440\u0438\u0433\u043e\u0434\u043d\u044b\u043c\u0438 \u0434\u043b\u044f \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u043e\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u0414\u0430\u0436\u0435 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u0430 3:4 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0432\u0438\u0434\u0435\u043e \u0432\u044b\u0441\u043e\u043a\u043e\u0433\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0441 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0447\u0430\u0441\u0442\u043e\u0442\u043e\u0439 \u043a\u0430\u0434\u0440\u043e\u0432.<\/p>\n<p>\u0418\u043c\u0435\u043d\u043d\u043e \u0437\u0434\u0435\u0441\u044c \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0441\u0436\u0430\u0442\u0438\u0435 \u0441 \u043f\u043e\u0442\u0435\u0440\u044f\u043c\u0438. \u041e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0445, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043b\u0443\u0447\u0448\u0435\u0433\u043e \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u0430 \u0441\u0436\u0430\u0442\u0438\u044f. \u0421\u0445\u0435\u043c\u044b \u0441\u0436\u0430\u0442\u0438\u044f \u0441 \u043f\u043e\u0442\u0435\u0440\u044f\u043c\u0438 \u0447\u0430\u0441\u0442\u043e \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439, \u0432 \u043a\u0430\u043a\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u043c\u044b \u0433\u043e\u0442\u043e\u0432\u044b \u043f\u043e\u0436\u0435\u0440\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0432 \u043e\u0431\u043c\u0435\u043d \u043d\u0430 \u043b\u0443\u0447\u0448\u0438\u0439 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u0441\u0436\u0430\u0442\u0438\u044f.<\/p>\n<h2>\u0424\u043e\u0440\u043c\u0430\u0442\u044b \u0431\u0435\u0437 \u043f\u043e\u0442\u0435\u0440\u044c<\/h2>\n<h3>GIF<\/h3>\n<p>Graphical Interchange Format, GIF (\u043f\u0440\u043e\u0438\u0437\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a\u0430\u043a \u00abgif\u00bb \u043e\u0442 \u00abgift\u00bb) \u2014 \u044d\u0442\u043e \u0444\u043e\u0440\u043c\u0430\u0442 \u0441\u0436\u0430\u0442\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0431\u0435\u0437 \u043f\u043e\u0442\u0435\u0440\u044c. \u0412 \u043d\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u043f\u0430\u043b\u0438\u0442\u0440\u0430 \u0438\u0437 256 \u0446\u0432\u0435\u0442\u043e\u0432, \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u0430\u0434\u0430\u0435\u0442\u0441\u044f 3 \u0431\u0430\u0439\u0442\u0430\u043c\u0438 \u0434\u043b\u044f RGB. \u0418 \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c 3 \u0431\u0430\u0439\u0442\u0430 \u0434\u043b\u044f \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f, \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0438\u043d\u0434\u0435\u043a\u0441, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u043d\u0430 \u043e\u0434\u0438\u043d \u0438\u0437 \u0446\u0432\u0435\u0442\u043e\u0432 \u0432 \u043f\u0430\u043b\u0438\u0442\u0440\u0435. \u0418\u0434\u0435\u044f \u0437\u0434\u0435\u0441\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0430\u043b\u0438\u0442\u0440\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043e\u0442\u0442\u0435\u043d\u043a\u043e\u0432 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u0440\u0438 256 \u0446\u0432\u0435\u0442\u0430\u0445 \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0432\u0441\u0435\u0433\u043e 1 \u0431\u0430\u0439\u0442 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0438 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u0441\u0436\u0430\u0442\u0438\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 3:1. \u0425\u043e\u0442\u044f \u043c\u0430\u043b\u043e\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043c\u0438\u0440\u0435 \u0438\u043c\u0435\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e 256 \u0446\u0432\u0435\u0442\u043e\u0432, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0444\u043e\u0440\u043c\u0430 \u0441\u0436\u0430\u0442\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u043b\u0430 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0442\u0438 \u0440\u0430\u043d\u044c\u0448\u0435. \u041e\u0434\u043d\u0430\u043a\u043e \u0441\u0430\u043c GIF \u043d\u0435 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u044d\u0442\u043e \u0441\u0436\u0430\u0442\u0438\u0435.<\/p>\n<p>\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 w \u00d7 h 8-\u0431\u0438\u0442\u043d\u044b\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u043f\u0430\u043b\u0438\u0442\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u0442\u0435\u043c \u043a\u043e\u0434\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0435\u0445\u043d\u0438\u043a\u0438 <a href=\"https:\/\/cefboud.com\/posts\/compression\/#primer-on-compression\">LZ <\/a>(\u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0435\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0441 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u043e\u0439).<\/p>\n<p>\u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, GIF \u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d \u0442\u0435\u043c, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0432 \u043e\u0434\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0430\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f.<\/p>\n<figure class=\"\"><\/figure>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e GIF \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 Go. \u041f\u043e\u043b\u0430\u0433\u0430\u044e, \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e GIF, \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043d\u044f\u0442\u044c \u044d\u0442\u043e\u0442 \u0444\u043e\u0440\u043c\u0430\u0442:<\/p>\n<pre><code class=\"go\">images := []*image.Paletted{...} \/\/ The successive delay times, one per frame, in 100ths of a second \/\/ In this example, we have three images with 0.5 second delay between each delays := []int{50,50,50}  f, _ := os.OpenFile(\"amazing.gif\", os.O_WRONLY|os.O_CREATE, 0600) defer f.Close() gif.EncodeAll(f, &amp;gif.GIF{     Image: images,     Delay: delays,  })<\/code><\/pre>\n<p>API \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f GIF \u0432 Go \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442: \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0441 \u043f\u0430\u043b\u0438\u0442\u0440\u043e\u0439 \u0438 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u043d\u0443\u0436\u043d\u044b\u0439 \u043d\u0430\u043c \u0444\u0430\u0439\u043b.<\/p>\n<p>\u0412\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 <a href=\"https:\/\/github.com\/golang\/go\/blob\/f6d17c540024418ca8a92371931b1b4fb076d2b6\/src\/image\/image.go#L1148-L1159\">Paletted<\/a>:<\/p>\n<pre><code class=\"go\">package image  \/\/ Paletted is an in-memory image of uint8 indices into a given palette. type Paletted struct { \/\/ Pix holds the image's pixels, as palette indices. The pixel at \/\/ (x, y) starts at Pix[(y-Rect.Min.Y)*Stride + (x-Rect.Min.X)*1]. Pix []uint8 \/\/ Stride is the Pix stride (in bytes) between vertically adjacent pixels. Stride int \/\/ Rect is the image's bounds. Rect Rectangle \/\/ Palette is the image's palette. Palette color.Palette }  type Palette []Color  \/\/ Color can convert itself to alpha-premultiplied 16-bits per channel RGBA. \/\/ The conversion may be lossy. type Color interface { \/\/ RGBA returns the alpha-premultiplied red, green, blue and alpha values \/\/ for the color. Each value ranges within [0, 0xffff], but is represented \/\/ by a uint32 so that multiplying by a blend factor up to 0xffff will not \/\/ overflow. \/\/ \/\/ An alpha-premultiplied color component c has been scaled by alpha (a), \/\/ so has valid values 0 &lt;= c &lt;= a. RGBA() (r, g, b, a uint32) }  \/\/ A Rectangle contains the points with Min.X &lt;= X &lt; Max.X, Min.Y &lt;= Y &lt; Max.Y. \/\/ It is well-formed if Min.X &lt;= Max.X and likewise for Y. Points are always \/\/ well-formed. A rectangle's methods always return well-formed outputs for \/\/ well-formed inputs. type Rectangle struct { Min, Max Point }  \/\/ A Point is an X, Y coordinate pair. The axes increase right and down. type Point struct { X, Y int }<\/code><\/pre>\n<p>\u041f\u0430\u043b\u0438\u0442\u0440\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c\u0438 \u043f\u043e\u043b\u044f\u043c\u0438:<\/p>\n<ul>\n<li>\n<p><strong>Rectangle<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0435\u0440\u0445\u043d\u0435\u0439 \u043b\u0435\u0432\u043e\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 (min) \u0438 \u043d\u0438\u0436\u043d\u0435\u0439 \u043f\u0440\u0430\u0432\u043e\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 (max). \u041f\u0440\u043e\u0441\u0442\u043e \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e! \u0427\u0442\u043e\u0431\u044b \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443, \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e <code>Min = (0, 0)<\/code>.<\/p>\n<\/li>\n<li>\n<p><strong>color.Palette<\/strong> \u2014 \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432 <code>Color<\/code>, \u0441\u043b\u0443\u0436\u0430\u0449\u0438\u0439, \u043f\u043e \u0441\u0443\u0442\u0438, \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435\u043c \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 RGB-\u0446\u0432\u0435\u0442\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p><strong>Stride <\/strong>\u2014 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u043e \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u043c\u0438 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u043c\u0438; \u0447\u0430\u0441\u0442\u043e \u044d\u0442\u043e \u0434\u043b\u0438\u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0438, \u0442. \u0435. <code>Max.X - Min.X<\/code>.<\/p>\n<\/li>\n<li>\n<p><strong>Pix <\/strong>\u2014 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u0432\u0438\u0434\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0446\u0432\u0435\u0442\u043e\u0432\u043e\u0439 \u043f\u0430\u043b\u0438\u0442\u0440\u044b. \u041c\u0430\u0441\u0441\u0438\u0432 \u043e\u0434\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u0439, \u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435. \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, <code>Min = (0, 0)<\/code>. \u042d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0435\u0441\u0441\u0438\u044f \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p><code>(0, 0)<\/code>,\u00a0<code>(1, 0)<\/code>, \u2026,\u00a0<code>(Max.X-1, 0)<\/code>,<\/p>\n<\/li>\n<li>\n<p><code>(0, 1)<\/code>,\u00a0<code>(1, 1)<\/code>, \u2026,\u00a0<code>(Max.X-1, 1)<\/code>,<\/p>\n<\/li>\n<li>\n<p>\u2026,<\/p>\n<\/li>\n<li>\n<p><code>(0, Max.Y-1)<\/code>,\u00a0<code>(1, Max.Y-1)<\/code>, \u2026,\u00a0<code>(Max.X-1, Max.Y-1)<\/code>.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0440\u043e\u0449\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, <code>image.Paletted<\/code> \u2014 \u044d\u0442\u043e \u0441\u043f\u0438\u0441\u043e\u043a \u0446\u0432\u0435\u0442\u043e\u0432 \u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439, \u0441\u0441\u044b\u043b\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u043d\u0430 \u044d\u0442\u0438 \u0446\u0432\u0435\u0442\u0430.<\/p>\n<p>\u041f\u0430\u043b\u0438\u0442\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 GIF-\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b. \u0412\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 \u043d\u0435\u0451:<\/p>\n<pre><code class=\"go\">\/\/ GIF represents the possibly multiple images stored in a GIF file. type GIF struct { Image []*image.Paletted \/\/ The successive images. Delay []int             \/\/ The successive delay times, one per frame, in 100ths of a second. \/\/ LoopCount controls the number of times an animation will be \/\/ restarted during display. \/\/ A LoopCount of 0 means to loop forever. \/\/ A LoopCount of -1 means to show each frame only once. \/\/ Otherwise, the animation is looped LoopCount+1 times. LoopCount int \/\/ Disposal is the successive disposal methods, one per frame. For \/\/ backwards compatibility, a nil Disposal is valid to pass to EncodeAll, \/\/ and implies that each frame's disposal method is 0 (no disposal \/\/ specified). Disposal []byte \/\/ Config is the global color table (palette), width and height. A nil or \/\/ empty-color.Palette Config.ColorModel means that each frame has its own \/\/ color table and there is no global color table. Each frame's bounds must \/\/ be within the rectangle defined by the two points (0, 0) and \/\/ (Config.Width, Config.Height). \/\/ \/\/ For backwards compatibility, a zero-valued Config is valid to pass to \/\/ EncodeAll, and implies that the overall GIF's width and height equals \/\/ the first frame's bounds' Rectangle.Max point. Config image.Config \/\/ BackgroundIndex is the background index in the global color table, for \/\/ use with the DisposalBackground disposal method. BackgroundIndex byte }<\/code><\/pre>\n<p>\u041e\u0442\u043c\u0435\u0442\u0438\u043c, \u0447\u0442\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u043e\u0432 (\u0446\u0438\u043a\u043b\u043e\u0432) \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0440\u0430\u0432\u043d\u043e \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0441\u0442\u0438, \u0435\u0441\u043b\u0438 <code>LoopCount == -1<\/code>. \u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0448\u0438\u0440\u0438\u043d\u0430 \u0438 \u0432\u044b\u0441\u043e\u0442\u0430 GIF \u043b\u0438\u0431\u043e \u0437\u0430\u0434\u0430\u044e\u0442\u0441\u044f \u044f\u0432\u043d\u043e, \u043b\u0438\u0431\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u0438\u0437 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432\u043d\u0443\u0442\u0440\u0438 GIF \u043c\u043e\u0433\u0443\u0442 \u0438\u043c\u0435\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u044b, \u0438 \u0437\u0434\u0435\u0441\u044c \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f \u0432\u0430\u0436\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <code>Min <\/code>\u0438 <code>Max <\/code>\u0432 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f: \u043e\u043d\u0438 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0440\u0430\u0432\u043d\u044b \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u043c <code>Min <\/code>\u0438 <code>Max<\/code>.<\/p>\n<p><code>Disposal <\/code>\u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u043a\u0430\u043a \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u043a\u0430\u0434\u0440. \u042d\u0442\u043e\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0441\u0432\u044f\u0437\u0430\u043d \u0441 \u0430\u043b\u044c\u0444\u0430-\u043a\u0430\u043d\u0430\u043b\u043e\u043c RGBA, \u0442\u043e \u0435\u0441\u0442\u044c \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u0438. \u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u043a\u0430\u0434\u0440\u0430 \u0442\u0430\u043a\u0438\u0435:<\/p>\n<ul>\n<li>\n<p><strong>Unspecified (\u041d\u0438\u0447\u0435\u0433\u043e)<\/strong>. \u041f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043e\u0434\u043d\u043e \u043f\u043e\u043b\u043d\u043e\u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0435 \u043d\u0435\u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u0440\u0443\u0433\u0438\u043c.<\/p>\n<\/li>\n<li>\n<p><strong>Do Not Dispose (\u041e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u0430\u043a \u0435\u0441\u0442\u044c)<\/strong>. \u0412\u0441\u0435 \u043f\u0438\u043a\u0441\u0435\u043b\u0438, \u043d\u0435 \u043f\u043e\u043a\u0440\u044b\u0442\u044b\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043a\u0430\u0434\u0440\u043e\u043c, \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f.<\/p>\n<\/li>\n<li>\n<p><strong>Restore to Background (\u0412\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0444\u043e\u043d)<\/strong>. \u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u0432 <code>BackgroundIndex<\/code>, \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u0435 \u043f\u0438\u043a\u0441\u0435\u043b\u0438 \u043d\u043e\u0432\u043e\u0433\u043e \u043a\u0430\u0434\u0440\u0430.<\/p>\n<\/li>\n<\/ul>\n<p><code>Config<\/code> \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c <code>color.Palette<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0430\u043b\u0438\u0442\u0440\u043e\u0439, \u043e\u0431\u0449\u0435\u0439 \u0434\u043b\u044f \u0432\u0441\u0435\u0445<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-459260","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/459260","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=459260"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/459260\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=459260"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=459260"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=459260"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}