コード例 #1
0
 internal PackEntry(LImage image)
 {
     this.image = image;
     if (image != null)
     {
         this.fileName = image.GetPath();
         this.width    = image.GetWidth();
         this.height   = image.GetHeight();
     }
 }
コード例 #2
0
ファイル: LTexturePack.cs プロジェクト: 207h2Flogintvg/LGame
            internal PackEntry(LImage image)
            {
				this.image = image;
				if (image != null) {
					this.fileName = image.GetPath();
					this.width = image.GetWidth();
					this.height = image.GetHeight();
				}
			}
コード例 #3
0
ファイル: GLLoader.cs プロジェクト: keppelcao/LGame
        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;
            }
        }
コード例 #4
0
ファイル: GLLoader.cs プロジェクト: zhwk022/LGame
        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;
            }
        }