for (k = 0; k < MAXV; ++k) {
A[k] = SinXDivX(u + 1.0 - k);
C[k] = SinXDivX(v + 1.0 - k);
for (z = 0; z < MAXV; ++z) {
B[k][z] = availablePixel(src, srcWidth, srcHeight,
x + k - 1, y + z - 1);
}
}
dst[i+j*dstWidth] = MatrixMutiple(A, B, C, i, j);
}
}
//echo(dst, dstLen);
AS3_SetS(dstByte, "position", AS3_Int(0));
AS3_ByteArray_writeBytes(dstByte, dst, 4 * dstLen);
return AS3_True();
}
int main() {
AS3_Val biCubicMethod = AS3_Function(NULL, biCubic);
AS3_Val lib = AS3_Object("biCubic:AS3ValType", biCubicMethod);
AS3_Release(biCubicMethod);
AS3_LibInit(lib);
return 0;
}
as 代码
package {
import cmodule.ImageScaling.CLibInit;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.display.StageScaleMode;
import flash.geom.Rectangle;
import flash.utils.ByteArray;
import flash.utils.Timer;
[SWF(width="1000", height="600", backgroundColor="#000000", frameRate="24")]
public class Main extends Sprite {
[Embed(source='f_01.png')]
public static const image:Class;
public function Main() {
this.stage.scaleMode = StageScaleMode.NO_SCALE;
var bitmapdata:BitmapData = (new image() as Bitmap).bitmapData;
var t1:Number = (new Date()).time;
var bitmap:Bitmap = new Bitmap(Main.Cubic(bitmapdata, 256, 256));
var t2:Number = (new Date()).time;
trace((t2-t1)+"ms");
this.addChild(bitmap);
}
public static function Cubic (bitmapData:BitmapData, scalingWidth:uint, scalingHeight:uint):BitmapData {
var nbd:BitmapData = new BitmapData(scalingWidth, scalingHeight, true, 0xffffffff);
var loader:cmodule.ImageScaling.CLibInit = new cmodule.ImageScaling.CLibInit();
var lib:Object = loader.init();www.2cto.com
var byte:ByteArray = bitmapData.getPixels(new Rectangle(0, 0, bitmapData.width, bitmapData.height));
var byte2:ByteArray = nbd.getPixels(new Rectangle(0, 0, scalingWidth, scalingHeight));
lib.biCubic(byte, bitmapData.width, bitmapData.height, byte2, scalingWidth, scalingHeight);
byte2.position = 0;
nbd.setPixels(new Rectangle(0, 0, scalingWidth, scalingHeight), byte2);
return nbd;
}
}
}
作者:misschuer