jpg画像をぐりぐりGlitch undo forked:2favorite:9lines:80license : MIT License modified : 2009-10-15 15:44:52 Embed Tweet <?xml version = "1.0" encoding = "utf-8"?> <mx:Application xmlns:mx = "http://www.adobe.com/2006/mxml" layout = "absolute" applicationComplete = "init();"> <mx:Script> <![CDATA[ /* 今やバグもアートの時代 http://www.amazon.co.jp/Glitch-Perfet-Imperfections-Iman-Moradi/dp/0979966663 */ private var fr:FileReference = new FileReference(); private var ba:ByteArray = new ByteArray(); private var pl:Loader = new Loader(); private var glitched:ByteArray = new ByteArray(); private var rl:Loader = new Loader(); private function init():void { this.preview.addChild(this.pl); this.image.addChild(this.rl); Wonderfl.capture_delay( 20 ); } private function onBrowseBtnClick():void { //画像ファイルを参照 this.fr.addEventListener(Event.SELECT, onFileSelect); this.fr.browse([new FileFilter("Images", "*.jpg")]);//jpgじゃないとダメみたい・・ } private function onFileSelect(evt:Event):void { this.fr.removeEventListener(Event.SELECT, onFileSelect); this.fr.addEventListener(Event.COMPLETE, onFileComplete); this.fr.load(); } private function onFileComplete(evt:Event):void { //画像ファイルをちっちゃく表示、ByteArrayを取得 this.fr.removeEventListener(Event.COMPLETE, onFileComplete); this.ba = this.fr.data; this.pl.contentLoaderInfo.addEventListener(Event.COMPLETE, onPreviewLoadComp); this.pl.loadBytes(this.ba); } private function onPreviewLoadComp(evt:Event):void { this.pl.contentLoaderInfo.removeEventListener(Event.COMPLETE, onPreviewLoadComp); this.pl.scaleX = this.pl.scaleY = 1; this.pl.scaleX = this.pl.scaleY = Math.min(this.preview.width/this.pl.width,this.preview.height/this.pl.height); } private function onGlitchBtnClick():void { if(this.ba.length > 0) { startGlitch(); } else { //画像を参照してね } } // //画像をGlitchする // private function startGlitch():void { this.glitched = null; this.glitched = new ByteArray(); this.glitched.writeBytes(this.ba); var t:int = Math.floor(Number(this.time.text)); for(var i:int = 0; i < t; i++) { //ByteArrayをランダムに書き換え this.glitched.position = Math.floor(Math.random()*(this.glitched.length - 128)) + 128 this.glitched.writeByte(0); } //ByteArrayを画像としてLoaderにロード this.rl.contentLoaderInfo.addEventListener(Event.COMPLETE, onGlitchLoadComp); this.rl.loadBytes(this.glitched); } private function onGlitchLoadComp(evt:Event):void { this.rl.removeEventListener(Event.COMPLETE, onGlitchLoadComp); this.rl.scaleX = this.rl.scaleY = 1; this.rl.scaleX = this.rl.scaleY = this.width/Math.max(this.rl.width, this.rl.height); } ]]> </mx:Script> <mx:Image id = "image" /> <mx:HBox paddingTop = "10" paddingLeft = "10"> <mx:Image id = "preview" width = "50" height = "50" /> <mx:Button id = "browseBtn" label = "参照" click = "onBrowseBtnClick();" /> <mx:TextInput id = "time" text = "50" width = "50" /> <mx:Label text = "←処理量" /> <mx:Button id = "createBtn" label = "Glitch!" click = "onGlitchBtnClick();" /> </mx:HBox> </mx:Application> Code Fullscreen Preview Fullscreen paq ep91ckok everdibe nki2 miyaoka teageek narahater : glitch rafabarros : effectfotoglitchphotoupload sr_forest : art art bytearray effect flex foto glitch photo upload sort new page view favorite forked pv148 forked from: jpg画像をぐりぐりGlitch preatorian.lev forked:0 favorite:0lines:81 (diff:4) pv7082 保存ボタンつけるの忘れてた forked from: jpg.. undo forked:2 favorite:15lines:92 (diff:16) tag: bytearray flex glitch