Fast scaling algorithm

3 posts

Flag Post

Hey. All I want to achieve is to scale a BitmapData of 400 × 200 pixels, to twice its size. No anti-aliasing or anything, just simply scale it.. So I’ve been trying to write my own function because Bitmap.draw uses anti-aliasing and stuff. But I have not succeeded and my code runs way too slow.
Could anyone write something fast for me?
Source bmd is 400×200 pixels and destination is 800×400 px.

Flag Post

This will work without antiAliasing.

var bd1:BitmapData = //whatever
var bd2:BitmapData = new BitmapData(bd1.width * 2, bd1.height * 2);
var matrix:Matrix = new Matrix(); matrix.scale(2, 2);
bd2.draw(bd1, matrix);
var bitmap2:Bitmap = new Bitmap(bd2);

EDIT: Minor correction.

Flag Post

Oh it does actually not anti-alias it. It seems it’s rather just the text I draw to the bitmapdata that suddenly over night decided to anti-alias…

This is how I draw it. prescale is the BitmapData

var textField:TextField = new TextField();
textField.defaultTextFormat = Main.textFormat(size, colour);
textField.embedFonts = true;
textField.text = text;
textField.width = textField.textWidth + 5;
prescale.draw(textField, new Matrix(1, 0, 0, 1, x, y));


static public function textFormat(size:uint = 12, colour:uint = 0xFFFFFF):TextFormat
	return new TextFormat("Visitor TT2 BRK", size, colour);

The font is embedded and it’s this one