示例#1
0
        public static LTexture[] GetDivide(string fileName, int count, int[] width,
                                           int[] height)
        {
            if (count <= 0)
            {
                throw new Exception("Divide");
            }
            LTexture image = LTextures.LoadTexture(fileName);

            if (image == null)
            {
                return(null);
            }
            if (!image.IsLoaded())
            {
                image.LoadTexture();
            }

            if (width == null)
            {
                width = new int[count];
                int w = image.GetWidth();
                for (int j = 0; j < count; j++)
                {
                    width[j] = w / count;
                }
            }
            if (height == null)
            {
                height = new int[count];
                int h = image.GetHeight();
                for (int i = 0; i < count; i++)
                {
                    height[i] = h;
                }
            }
            LTexture[] images  = new LTexture[count];
            int        offsetX = 0;

            for (int i = 0; i < count; i++)
            {
                images[i] = image.GetSubTexture(offsetX, 0, width[i], height[i]);
                offsetX  += width[i];
            }
            return(images);
        }
示例#2
0
 public void LoadTexture()
 {
     if (parent != null)
     {
         parent.LoadTexture();
         textureID = parent.textureID;
         isLoaded  = parent.isLoaded;
         return;
     }
     if (imageData == null || isLoaded)
     {
         return;
     }
     isLoaded = true;
     LoadTextureBuffer();
     SetFormat(format);
     LTextures.LoadTexture(this);
     LTextureBatch.isBatchCacheDitry = true;
 }
示例#3
0
        public LTexture LoadTexture(string name)
        {
            if (imageList == null)
            {
                throw new Exception("Xml data not loaded !");
            }
            ImageData data = (ImageData)CollectionUtils.Get(imageList, name);

            if (data == null)
            {
                throw new Exception("No such image reference: '" + name
                                    + "'");
            }
            if (this.values[data.index] != null)
            {
                return(this.values[data.index].texture);
            }
            LTexture img = null;

            if (data.mask != null)
            {
                img = TextureUtils.FilterColor(data.xref, data.mask,
                                               data.scaleType == 0 ? Loon.Core.Graphics.Opengl.LTexture.Format.DEFAULT : Loon.Core.Graphics.Opengl.LTexture.Format.LINEAR);
            }
            else
            {
                img = LTextures.LoadTexture(data.xref,
                                            data.scaleType == 0 ? Loon.Core.Graphics.Opengl.LTexture.Format.DEFAULT : Loon.Core.Graphics.Opengl.LTexture.Format.LINEAR);
            }
            if ((data.w != 0) && (data.h != 0))
            {
                img = img.GetSubTexture(data.x, data.y, data.w, data.h);
            }
            if (data.scale != 0)
            {
                img = img.Scale(data.scale);
            }
            this.values[data.index] = new LTextureObject(img, 0, 0);
            return(img);
        }
示例#4
0
 public static LTexture[][] GetSplit2Textures(string fileName, int width,
                                              int height)
 {
     return(GetSplit2Textures(LTextures.LoadTexture(fileName), width, height));
 }
示例#5
0
 public static LTexture LoadTexture(string fileName)
 {
     return(LTextures.LoadTexture(fileName));
 }
示例#6
0
 public int Add(string res, float x, float y)
 {
     return(Add(new LTextureObject(LTextures.LoadTexture(res), x, y)));
 }
示例#7
0
 public LTextureRegion(string file, int x, int y, int width, int height)
     : this(LTextures.LoadTexture(file), x, y, width, height)
 {
 }
示例#8
0
 public LTextureRegion(string file, Loon.Core.Graphics.Opengl.LTexture.Format f)
     : this(LTextures.LoadTexture(file, f))
 {
 }
示例#9
0
 public int Add(string res, Loon.Core.Graphics.Opengl.LTexture.Format format, float x, float y)
 {
     return(Add(new LTextureObject(LTextures.LoadTexture(res, format), x, y)));
 }