Esempio n. 1
0
 public void Dispose()
 {
     if (texture != null)
     {
         texture.Destroy();
     }
 }
Esempio n. 2
0
 public LTexture Pack()
 {
     if (texture != null && !packing)
     {
         return(texture);
     }
     if (fileName != null)
     {
         texture = new LTexture(fileName);
     }
     else
     {
         LPixmap image = PackImage();
         if (image == null)
         {
             return(null);
         }
         if (texture != null)
         {
             texture.Destroy();
             texture = null;
         }
         if (colorMask != null)
         {
             Color[] pixels = image.GetData();
             int     size   = pixels.Length;
             uint    color  = colorMask.PackedValue;
             for (int i = 0; i < size; i++)
             {
                 if (pixels[i].PackedValue == color)
                 {
                     pixels[i].PackedValue = LSystem.TRANSPARENT;
                 }
             }
             image.SetData(pixels);
         }
         texture = image.Texture;
     }
     return(texture);
 }
Esempio n. 3
0
 public static void Close(LTexture texture)
 {
     if (texture != null)
     {
         texture.Destroy();
         texture = null;
     }
 }
Esempio n. 4
0
 private void Init(LTexture tex2d, float limit, bool remove, float scale)
 {
     this.isVisible = true;
     this.expandLimit = limit;
     this.width = tex2d.GetWidth();
     this.height = tex2d.GetHeight();
     this.scaleWidth = (int) (width * scale);
     this.scaleHeight = (int) (height * scale);
     this.loopMaxCount = (MathUtils.Max(scaleWidth, scaleHeight) / 2) + 1;
     this.fractions = new float[(scaleWidth * scaleHeight) * maxElements];
     this.exWidth = (int) (scaleWidth * expandLimit);
     this.exHeigth = (int) (scaleHeight * expandLimit);
     LPixmap image = tex2d.GetImage().ScaledInstance(scaleWidth, scaleHeight);
     Color[] pixels = image.GetData();
     if (image != null) {
     image.Dispose();
     image = null;
     }
     this.size = pixels.Length;
     this.pixmap = new LPixmapData(exWidth, exHeigth, true);
     int no = 0, idx = 0;
     int length = fractions.Length;
     float angle = 0;
     float speed = 0;
     System.Random random = LSystem.random;
     for (int y = 0; y < scaleHeight; y++) {
     for (int x = 0; x < scaleWidth; x++) {
         if (idx + maxElements < length) {
             no = y * scaleWidth + x;
             angle = random.Next(360);
             speed = 10f / random.Next(30);
             fractions[idx + 0] = x;
             fractions[idx + 1] = y;
             fractions[idx + 2] = (MathUtils.Cos(angle * MathUtils.PI
                     / 180) * speed);
             fractions[idx + 3] = (MathUtils.Sin(angle * MathUtils.PI
                     / 180) * speed);
             fractions[idx + 4] = (pixels[no].PackedValue == 0xff00 ? 0xffffff
                     : pixels[no].PackedValue);
             fractions[idx + 5] = x / 6 + random.Next(10);
             idx += maxElements;
         }
     }
     }
     if (remove) {
     if (tex2d != null) {
         tex2d.Destroy();
         tex2d = null;
     }
     }
     this.tmp = tex2d;
     this.StartUsePixelThread();
 }