void EnsurePow2(ref Bitmap bmp) { int width = Utils.NextPowerOf2(bmp.Width); int height = Utils.NextPowerOf2(bmp.Height); if (width == bmp.Width && height == bmp.Height) { return; } Bitmap scaled = Platform.CreateBmp(width, height); using (FastBitmap src = new FastBitmap(bmp, true, true)) using (FastBitmap dst = new FastBitmap(scaled, true, false)) { for (int y = 0; y < src.Height; y++) { FastBitmap.CopyRow(y, y, src, dst, src.Width); } } uScale = (float)bmp.Width / width; vScale = (float)bmp.Height / height; bmp.Dispose(); bmp = scaled; }