{"id":33,"date":"2013-01-07T16:42:23","date_gmt":"2013-01-07T08:42:23","guid":{"rendered":"http:\/\/blog.dbgtech.net\/blog\/?p=33"},"modified":"2013-01-07T16:47:52","modified_gmt":"2013-01-07T08:47:52","slug":"as3-tga-codec","status":"publish","type":"post","link":"https:\/\/www.dbgtech.net\/blog\/2013\/01\/as3-tga-codec\/","title":{"rendered":"AS3 TGA Codec"},"content":{"rendered":"<p>\u8fd9\u6bb5\u65f6\u95f4\u7814\u7a76\u4e86\u4e00\u4e0bAS\u4e0b\u9762\u7684\u56fe\u50cf\u683c\u5f0f\u3002\u6d4b\u8bd5\u4e86\u4e00\u4e0b\uff0cTGA\u683c\u5f0f\u56fe\u7247\u7ecfzlib\u538b\u7f29\u4e4b\u540e\u4e00\u822c\u6bd4\u540c\u6837\u7684PNG\u56fe\u7247\u8981\u5c0f\u300232bit\u683c\u5f0fpng\u7ecf\u5904\u7406\u8fc7\u540e\u7684Pixel\u6570\u636e\u80fd\u901a\u8fc7SetPixels\u76f4\u63a5\u4f20\u9012\u7ed9BitmapData\uff0c\u52a0\u8f7d\u901f\u5ea6\u975e\u5e38\u5feb\u3002\u8fd9\u91cc\u53d1\u4e2a\u7f16\u89e3\u7801\u5668\u3002<\/p>\n<p>\u4e3b\u8981\u529f\u80fd\u6709\uff1a<\/p>\n<ul>\n<li>\u652f\u6301ImageType\u4e3a1\uff0c2\uff0c9\uff0c10\u7c7b\u578b\u7684\u56fe\u7247\u3002\u5373\u5e26\u8c03\u8272\u677f\uff0c\u6216\u8005\u76f4\u63a5\u771f\u5f69\u8272\u7684\u683c\u5f0f\u90fd\u53ef\u4ee5\u89e3\u7801\u3002\u540c\u65f6\u53ef\u4ee5\u89e3\u7801RLE\u7684\u8c03\u8272\u677f\u6216\u8005\u771f\u5f69\u683c\u5f0f\u3002<\/li>\n<li>\u652f\u63018bit\u300116bit\u300124bit\u300132bit\u8272\u6df1\u7684\u56fe\u7247\u300232bit\u56fe\u7247\u53ef\u4ee5\u652f\u6301alpha\u901a\u9053\u3002<\/li>\n<li>\u7f16\u7801\u5668\u53ea\u652f\u630132bit\u5e26Alpha\u901a\u9053\u683c\u5f0f\u3002\u5e76\u4e14\u8f93\u51fa\u56fe\u7247\u6309\u539f\u70b9\u5728\u5de6\u4e0a\u89d2\u7684\u65b9\u5f0f\u8f93\u51fa\u3002\u901a\u8fc7\u8fd9\u4e2a\u7f16\u7801\u5668\u7f16\u7801\u8fc7\u7684\u56fe\u7247\u5728\u4f7f\u7528TgaDecoder\u89e3\u7801\u65f6\u5019\u80fd\u591f\u76f4\u63a5\u8f6c\u6362\u4e3aBitmapData\uff0c\u56e0\u6b64\u89e3\u7801\u901f\u5ea6\u6bd4\u5176\u4ed6TGA\u683c\u5f0f\u90fd\u8981\u5feb\u3002\u5b9e\u9645\u9879\u76ee\u4e2d\u4f7f\u7528\u65f6\uff0c\u5e94\u8be5\u5c3d\u91cf\u91c7\u7528\u8fd9\u79cd\u683c\u5f0f\u7684tga\u3002<\/li>\n<li>\u7f16\u7801\u5668\u548c\u89e3\u7801\u5668\u90fd\u652f\u6301\u5904\u7406zlib\u538b\u7f29\u6570\u636e\u3002\u53ef\u901a\u8fc7\u53c2\u6570\u8bbe\u7f6e<\/li>\n<\/ul>\n<p>\u7531\u4e8e\u6709\u4e9b\u504f\u95e8\u683c\u5f0f\u6ca1\u6709\u627e\u5230\u6d4b\u8bd5\u6587\u4ef6\uff0c\u6240\u4ee5\u6d4b\u8bd5\u4e0d\u5b8c\u5168\u3002<\/p>\n<p>\u4f7f\u7528\u65b9\u6cd5\uff1a<\/p>\n<p>\u89e3\u7801\uff1a<\/p>\n<p><span style=\"color: #6699cc; font-family: Consolas; font-size: 10pt;\"><strong>var<\/strong><span style=\"color: black;\"> dec:TgaDecoder = <span style=\"color: #0033ff;\"><strong>new<\/strong><span style=\"color: black;\"> TgaDecoder();<\/span><br \/>\n<\/span><\/span><\/span><\/p>\n<p><span style=\"font-family: Consolas; font-size: 10pt;\"><span style=\"color: black;\">dec.Decode( barrData, m_cboxCompressed.selected);<\/span><br \/>\n<\/span><\/p>\n<p><span style=\"color: black; font-family: Consolas; font-size: 10pt;\">var bmp:Bitmap = <span style=\"color: #0033ff;\"><strong>new<\/strong><span style=\"color: black;\"> Bitmap( dec.bitmapData);<br \/>\n<\/span><\/span><\/span><\/p>\n<p><span style=\"color: black; font-size: 10pt;\"><span style=\"font-family: \u5b8b\u4f53;\">\u7f16\u7801\uff1a<\/span><span style=\"font-family: Consolas;\"><br \/>\n<\/span><\/span><\/p>\n<p><span style=\"color: #6699cc; font-family: Consolas; font-size: 10pt;\"><strong>var<\/strong><span style=\"color: black;\"> barrData:<span style=\"background-color: silver;\">ByteArray<\/span> = TgaEncoder.encode( m_bmpData.bitmapData, m_cboxCompressed.selected);<\/span><\/span><\/p>\n<p><span style=\"color: #6699cc; font-family: Consolas; font-size: 10pt;\"><span style=\"color: black;\">swc\u548c\u793a\u4f8b\u9879\u76ee\u4e0b\u8f7d\uff1a <\/span><\/span><\/p>\n<p><a href=\"http:\/\/blog.dbgtech.net\/blog\/wp-content\/uploads\/2013\/01\/TgaCodec.rar\">TgaCodec<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u6bb5\u65f6\u95f4\u7814\u7a76\u4e86\u4e00\u4e0bAS\u4e0b\u9762\u7684\u56fe\u50cf\u683c\u5f0f\u3002\u6d4b\u8bd5\u4e86\u4e00\u4e0b\uff0cTGA\u683c\u5f0f\u56fe\u7247\u7ecfzlib\u538b\u7f29\u4e4b &hellip; <a href=\"https:\/\/www.dbgtech.net\/blog\/2013\/01\/as3-tga-codec\/\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-33","post","type-post","status-publish","format-standard","hentry","category-5"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.dbgtech.net\/blog\/wp-json\/wp\/v2\/posts\/33","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbgtech.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbgtech.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbgtech.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbgtech.net\/blog\/wp-json\/wp\/v2\/comments?post=33"}],"version-history":[{"count":3,"href":"https:\/\/www.dbgtech.net\/blog\/wp-json\/wp\/v2\/posts\/33\/revisions"}],"predecessor-version":[{"id":38,"href":"https:\/\/www.dbgtech.net\/blog\/wp-json\/wp\/v2\/posts\/33\/revisions\/38"}],"wp:attachment":[{"href":"https:\/\/www.dbgtech.net\/blog\/wp-json\/wp\/v2\/media?parent=33"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbgtech.net\/blog\/wp-json\/wp\/v2\/categories?post=33"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbgtech.net\/blog\/wp-json\/wp\/v2\/tags?post=33"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}