包含标签 bitmapdata 的文章

将图像的透明区域转换为Alpha通道原理

Sprite Sheep Editor中,使用了这样的一个小技术(思路来自这里):将透明图像的Alpha通道转换成黑白(灰度)图像,然后与正常图像拼合成一张大图,再存储成JPEG格式。

这方法其实是一个折衷方案。因为JPEG格式是不支持透明的,很多时候为了获得透明效果,我们只能使用PNG格式。但PNG是无损压缩的,在图像尺寸上没有优势。如果将Alpha通道转换成黑白图并保存到JPEG图像中,就能大幅降低最终的图像文件大小。

在我的测试中,一个2000x3300的32位带Alpha通道的PNG图像文件大小为2MB,转换为4000x3300(因为拼合了黑白图片,宽度增加一倍)70%压缩比的JPEG后,文件大小为1.1MB。

当然,转换后的JPEG文件画质比PNG要稍差一些。这可以通过调整压缩比得到一定程度的改善。

要将图像的Alpha通道转换为黑白图像,在AS3中很容易:

……

阅读全文

最近文章

分类

标签

3d aac actionscript adobe adobebug adsl air amd android ane ant antivirus apache api arch as2 as3 asdoc asp aspnet authorware bash bbpress benq bitandbyte bitmapdata bluetooth book box2d browser byewindows c camera capture centos character-set chinajoy choice chongrenxindu chrome class cms cocos2d-x codec collection color component conference cookbook coolplayer cpp css cygwin datagrid debug degrafa design-pattern develop devops director display-objects docker dragonbones ds eclipse editgrid egret embed emotion encrypt engine english eval excel exif fcs ffmpeg film filter firebase firefox flash flash-remoting flashbuilder flashdevelop flashplayer flask flex flexbuilder flv fms font framework freeware fromto fte ftp fxg game gamenote gcc general generator gin git gmail godaddy golang google gprs graphic graphviz gtd gui h264 hardware hexo host house howto hp html html5 http hugo i18n ie image ime ios iot jacky-cheung java javascript job joomla journey jquery json layout lecture library life lighttpd linux lisp list live loader lua mac macos mambo management markup master math mencoder mingw mjp mobile mobile-game-framework module monitor mvc mxmlc mysql ndk netconnection netstream network nginx node nodejs note objective-c office okr opengl openresty opensource ops osmf osx pay pda performance photoshop php physics player plist plugin portable posix ppc protocol proxy python qiqi qt quick2cocoslua reading readingnote reflection regexp ria robotlegs router rtmp ruby sagibookclub sagiteam sandbox sdk server sharedobject shell signals simulator skeletalanimation skin sleepmode smartphone socket software spark spreadsheet spritesheet sql sqlalchemy ssh staticize study svn swfobject terminal testing thread tipsandtricks tlf trace training translate translation tween typescript ubuntu ugly ui unity usingrobotlegs2 utf-8 uwsgi validator vcard vector video vim virtualization vr web weboffice websocket weekread wifi windows wine word wordpress wuhan xbeta xiaomi xinnet xml youshootfirst zhihu

其它