Beispiel #1
0
 public void CreateUI(GLEx g)
 {
     if (isClose)
     {
         return;
     }
     if (!visible)
     {
         return;
     }
     lock (image)
     {
         if (alpha > 0 && alpha < 1)
         {
             g.SetAlpha(alpha);
         }
         if (!IsComplete() && isDirty)
         {
             g.DrawTexture2D(image.GetBitmap(), X(), Y(), width, height);
             isDirty = false;
         }
         else if (!IsComplete())
         {
             g.DrawTexture2D(image.GetBitmap(), X(), Y(), width, height);
         }
         if (alpha > 0 && alpha < 1)
         {
             g.SetAlpha(1f);
         }
     }
 }
Beispiel #2
0
        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;
            }
        }
Beispiel #3
0
        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;
            }
        }