private void Create(LImage image) { if (image == null) { return; } if (buffer != null) { return; } fileName = image.GetPath(); this.isExt = image.isExt; this.hasAlpha = image.hasAlpha; int srcWidth = image.Width; int srcHeight = image.Height; if (GLEx.IsPowerOfTwo(srcWidth) && GLEx.IsPowerOfTwo(srcHeight)) { this.width = srcWidth; this.height = srcHeight; this.texHeight = srcHeight; this.texWidth = srcWidth; this.buffer = image.GetBitmap(); if (image.IsAutoDispose()) { image.Dispose(); image = null; } return; } int texWidth = GLEx.ToPowerOfTwo(srcWidth); int texHeight = GLEx.ToPowerOfTwo(srcHeight); this.width = srcWidth; this.height = srcHeight; this.texHeight = texHeight; this.texWidth = texWidth; Color[] src = image.GetPixels(); Color[] dst = new Color[texWidth * texHeight]; for (int size = 0; size < height; size++) { Array.Copy(src, size * width , dst, size * texWidth, width); } if (buffer == null) { buffer = new Texture2D(GL.device, texWidth, texHeight); } buffer.SetData <Color>(dst); src = null; dst = null; if (image != null && image.IsAutoDispose()) { image.Dispose(); image = null; } }