Example #1
0
 public void Destroy()
 {
     if (textureBuffer != null)
     {
         textureBuffer.Destroy();
     }
 }
Example #2
0
 public virtual void Dispose()
 {
     if (texture != null)
     {
         texture.Destroy();
     }
 }
Example #3
0
 public LTexture Pack(Loon.Core.Graphics.Opengl.LTexture.Format format)
 {
     if (texture != null && !packing)
     {
         return(texture);
     }
     if (fileName != null)
     {
         texture       = new LTexture(GLLoader.GetTextureData(fileName), format);
         texture.isExt = true;
     }
     else
     {
         LImage image = PackImage();
         if (image == null)
         {
             return(null);
         }
         if (texture != null)
         {
             texture.Destroy();
             texture = null;
         }
         if (colorMask != null)
         {
             Color[] pixels = image.GetPixels();
             int     size   = pixels.Length;
             uint    color  = colorMask.GetRGB();
             for (int i = 0; i < size; i++)
             {
                 if (pixels[i].PackedValue == color)
                 {
                     pixels[i].PackedValue = LSystem.TRANSPARENT;
                 }
             }
             image.SetPixels(pixels, image.GetWidth(), image.GetHeight());
         }
         texture       = new LTexture(GLLoader.GetTextureData(image), format);
         texture.isExt = true;
         if (image != null)
         {
             image.Dispose();
             image = null;
         }
     }
     return(texture);
 }
Example #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);
		LImage image = tex2d.GetImage().ScaledInstance(scaleWidth, scaleHeight);
		Color[] pixels = image.GetPixels();
		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();
	}
Example #5
0
 public static void Close(LTexture texture)
 {
     if (texture != null)
     {
         texture.Destroy();
         texture = null;
     }
 }