static Texture2D LoadTextureFromData(SwfBitmapData bitmap) { var texture = new Texture2D( bitmap.RealWidth, bitmap.RealHeight, TextureFormat.ARGB32, false); texture.LoadRawTextureData(bitmap.ARGB32); return(texture); }
static byte[] TrimBitmapByRect(SwfBitmapData bitmap, SwfRectIntData rect) { var argb32 = new byte[rect.area * 4]; for (var i = 0; i < rect.height; ++i) { var src_index = rect.xMin + (rect.yMin + i) * bitmap.RealWidth; var dst_index = i * rect.width; Array.Copy( bitmap.ARGB32, src_index * 4, argb32, dst_index * 4, rect.width * 4); } return(argb32); }
static Texture2D LoadTextureFromData(SwfBitmapData bitmap, SwfSettingsData settings) { var argb32 = settings.BitmapTrimming ? TrimBitmapByRect(bitmap, bitmap.TrimmedRect) : bitmap.ARGB32; var widht = settings.BitmapTrimming ? bitmap.TrimmedRect.width : bitmap.RealWidth; var height = settings.BitmapTrimming ? bitmap.TrimmedRect.height : bitmap.RealHeight; var texture = new Texture2D( widht, height, TextureFormat.ARGB32, false); texture.LoadRawTextureData(argb32); return(texture); }