コード例 #1
0
        public LTexture GetTexture(string name)
        {
            this.Pack();
            PackEntry entry = GetEntry(name);

            if (entry == null)
            {
                return(null);
            }
            return(texture.GetSubTexture(entry.bounds.left, entry.bounds.top,
                                         entry.bounds.right, entry.bounds.bottom));
        }
コード例 #2
0
        public static LTexture[][] GetSplit2Textures(LTexture image, int width,
                                                     int height)
        {
            if (image == null)
            {
                return(null);
            }
            if (!image.IsLoaded())
            {
                image.LoadTexture();
            }
            int wlength = image.GetWidth() / width;
            int hlength = image.GetHeight() / height;

            LTexture[][] textures = (LTexture[][])CollectionUtils.XNA_CreateJaggedArray(typeof(LTexture), wlength, hlength);
            for (int y = 0; y < hlength; y++)
            {
                for (int x = 0; x < wlength; x++)
                {
                    textures[x][y] = image.GetSubTexture((x * width), (y * height),
                                                         width, height);
                }
            }
            return(textures);
        }
コード例 #3
0
        public static LTexture[] GetSplitTextures(LTexture image, int width,
                                                  int height)
        {
            if (image == null)
            {
                return(null);
            }
            if (!image.IsLoaded())
            {
                image.LoadTexture();
            }
            int frame   = 0;
            int wlength = image.GetWidth() / width;
            int hlength = image.GetHeight() / height;
            int total   = wlength * hlength;

            LTexture[] images = new LTexture[total];
            for (int y = 0; y < hlength; y++)
            {
                for (int x = 0; x < wlength; x++)
                {
                    images[frame] = image.GetSubTexture((x * width), (y * height),
                                                        width, height);
                    frame++;
                }
            }
            return(images);
        }
コード例 #4
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);
        }
コード例 #5
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);
        }
コード例 #6
0
 public static LTexture[] GetSplitTextures(LTexture image, int width,
         int height)
 {
     if (image == null)
     {
         return null;
     }
     if (!image.IsLoaded())
     {
         image.LoadTexture();
     }
     int frame = 0;
     int wlength = image.GetWidth() / width;
     int hlength = image.GetHeight() / height;
     int total = wlength * hlength;
     LTexture[] images = new LTexture[total];
     for (int y = 0; y < hlength; y++)
     {
         for (int x = 0; x < wlength; x++)
         {
             images[frame] = image.GetSubTexture((x * width), (y * height),
                     width, height);
             frame++;
         }
     }
     return images;
 }
コード例 #7
0
 public static LTexture[][] GetSplit2Textures(LTexture image, int width,
         int height)
 {
     if (image == null)
     {
         return null;
     }
     if (!image.IsLoaded())
     {
         image.LoadTexture();
     }
     int wlength = image.GetWidth() / width;
     int hlength = image.GetHeight() / height;
     LTexture[][] textures = (LTexture[][])CollectionUtils.XNA_CreateJaggedArray(typeof(LTexture), wlength, hlength);
     for (int y = 0; y < hlength; y++)
     {
         for (int x = 0; x < wlength; x++)
         {
             textures[x][y] = image.GetSubTexture((x * width), (y * height),
                     width, height);
         }
     }
     return textures;
 }