| 1 |
package { |
|---|
| 2 |
|
|---|
| 3 |
import flash.display.Bitmap; |
|---|
| 4 |
import flash.display.BitmapData; |
|---|
| 5 |
import flash.display.Sprite; |
|---|
| 6 |
import flash.events.Event; |
|---|
| 7 |
import flash.geom.Matrix; |
|---|
| 8 |
import flash.geom.Point; |
|---|
| 9 |
import flash.geom.Rectangle; |
|---|
| 10 |
import flash.utils.ByteArray; |
|---|
| 11 |
|
|---|
| 12 |
import net.hires.controllers.VideoController; |
|---|
| 13 |
import net.saqoosha.colorlog.ColorLog; |
|---|
| 14 |
import net.saqoosha.colorlog.SGR; |
|---|
| 15 |
|
|---|
| 16 |
[SWF(width=320, height=136, backgroundColor=0x0, frameRate=10)] |
|---|
| 17 |
|
|---|
| 18 |
public class TestColorLog5 extends Sprite { |
|---|
| 19 |
|
|---|
| 20 |
private static const COLORS:Array = [ |
|---|
| 21 |
SGR.BG_NORMAL_BLACK, |
|---|
| 22 |
SGR.BG_BRIGHT_BLUE, |
|---|
| 23 |
SGR.BG_BRIGHT_GREEN, |
|---|
| 24 |
SGR.BG_BRIGHT_CYAN, |
|---|
| 25 |
SGR.BG_BRIGHT_RED, |
|---|
| 26 |
SGR.BG_BRIGHT_MAGENTA, |
|---|
| 27 |
SGR.BG_BRIGHT_YELLOW, |
|---|
| 28 |
SGR.BG_BRIGHT_WHITE |
|---|
| 29 |
]; |
|---|
| 30 |
|
|---|
| 31 |
private var _canvas:BitmapData; |
|---|
| 32 |
private var _video:VideoController; |
|---|
| 33 |
private var _drawMatrix:Matrix; |
|---|
| 34 |
private var _outRect:Rectangle; |
|---|
| 35 |
|
|---|
| 36 |
public function TestColorLog5() { |
|---|
| 37 |
ColorLog.hideCursor(); |
|---|
| 38 |
|
|---|
| 39 |
this._canvas = new BitmapData(100, 49, false, 0); |
|---|
| 40 |
var b:Bitmap = new Bitmap(this._canvas); |
|---|
| 41 |
b.scaleX = 5; |
|---|
| 42 |
b.scaleY = 10; |
|---|
| 43 |
// this.addChild(b); |
|---|
| 44 |
|
|---|
| 45 |
this._video = new VideoController(320, 136); |
|---|
| 46 |
this._video.load('wolverine-clip_h.320.mp4'); |
|---|
| 47 |
this._video.play(); |
|---|
| 48 |
this.addChild(this._video); |
|---|
| 49 |
this._drawMatrix = new Matrix(100 / 320, 0, 0, 100 / 320 * 0.5, 0, 0); |
|---|
| 50 |
this._outRect = new Rectangle(0, 0, int(320 * this._drawMatrix.a), int(136 * this._drawMatrix.d)); |
|---|
| 51 |
|
|---|
| 52 |
this.addEventListener(Event.ENTER_FRAME, this._update); |
|---|
| 53 |
} |
|---|
| 54 |
|
|---|
| 55 |
private function _update(e:Event):void { |
|---|
| 56 |
ColorLog.clearScreen(); |
|---|
| 57 |
this._canvas.draw(this._video, this._drawMatrix); |
|---|
| 58 |
this.drawBitmap(this._canvas, this._outRect); |
|---|
| 59 |
ColorLog.flush(); |
|---|
| 60 |
} |
|---|
| 61 |
|
|---|
| 62 |
private function drawBitmap(bmp:BitmapData, rect:Rectangle, dest:Point = null):void { |
|---|
| 63 |
var b:ByteArray = bmp.getPixels(rect); |
|---|
| 64 |
for (var y:int = 0; y < rect.height; y++) { |
|---|
| 65 |
ColorLog.moveTo(y + 1, 1); |
|---|
| 66 |
for (var x:int = 0; x <rect.width; x++) { |
|---|
| 67 |
var p:int = (y * rect.width + x) * 4; |
|---|
| 68 |
var c:int = (b[p + 1] & 0x80) ? 0x4 : 0; |
|---|
| 69 |
c |= (b[p + 2] & 0x80) ? 0x2 : 0; |
|---|
| 70 |
c |= (b[p + 3] & 0x80) ? 0x1 : 0; |
|---|
| 71 |
ColorLog.setColor(COLORS[c]); |
|---|
| 72 |
ColorLog.out(' '); |
|---|
| 73 |
} |
|---|
| 74 |
} |
|---|
| 75 |
} |
|---|
| 76 |
} |
|---|
| 77 |
} |
|---|