public void DisposeInstance(object Anim) { Frames frames = (Frames)Anim; if ((frames != null) && (frames.FrameList != null)) { int length = frames.FrameList.Length; for (int i = 0; i < length; i++) { if ((frames.FrameList[i] != null) && (frames.FrameList[i].Image != null)) { frames.FrameList[i].Image.Dispose(); frames.FrameList[i].Image = null; } } } Anim = null; }
public void Dispose() { IEnumerator enumerator = this.m_Cache.Values.GetEnumerator(); while (enumerator.MoveNext()) { Frames current = (Frames)enumerator.Current; for (int i = 0; i < current.FrameCount; i++) { Frame frame = current.FrameList[i]; if ((frame != null) && (frame.Image != null)) { frame.Image.Dispose(); } } } this.m_Cache.Clear(); this.m_Cache = null; this.m_Hue = null; }
Frames IAnimationOwner.GetOwnedFrames(IHue hue, int realID) { if (((this.m_iAnimationPool != realID) || (this.m_hAnimationPool != hue)) || this.m_fAnimationPool.Disposed) { this.m_fAnimationPool = hue.GetAnimation(realID); this.m_hAnimationPool = hue; this.m_iAnimationPool = realID; } return this.m_fAnimationPool; }
public unsafe object Create(int realID, IHue hue) { int length; int lookup; int num3; Stream stream; switch (this.ConvertRealID(ref realID)) { case 1: { if (((realID < 0) || (realID >= this.m_Count)) || (realID >= this.m_Index.Length)) { return Frames.Empty; } Entry3D entryd = this.m_Index[realID]; length = entryd.m_Length; lookup = entryd.m_Lookup; num3 = entryd.m_Extra & 0xff; stream = m_Stream; break; } case 2: { if (((realID < 0) || (realID >= this.m_Count2)) || (realID >= this.m_Index2.Length)) { return Frames.Empty; } Entry3D entryd2 = this.m_Index2[realID]; length = entryd2.m_Length; lookup = entryd2.m_Lookup; num3 = entryd2.m_Extra & 0xff; stream = m_Stream2; break; } case 3: { if (((realID < 0) || (realID >= this.m_Count3)) || (realID >= this.m_Index3.Length)) { return Frames.Empty; } Entry3D entryd3 = this.m_Index3[realID]; length = entryd3.m_Length; lookup = entryd3.m_Lookup; num3 = entryd3.m_Extra & 0xff; stream = m_Stream3; break; } default: { if (((realID < 0) || (realID >= this.m_Count4)) || (realID >= this.m_Index4.Length)) { return Frames.Empty; } Entry3D entryd4 = this.m_Index4[realID]; length = entryd4.m_Length; lookup = entryd4.m_Lookup; num3 = entryd4.m_Extra & 0xff; stream = m_Stream4; break; } } if (((lookup < 0) || (length <= 0)) || ((num3 <= 0) || (stream == null))) { return Frames.Empty; } if ((this.m_Data == null) || (length > this.m_Data.Length)) { this.m_Data = new byte[length]; } stream.Seek((long) lookup, SeekOrigin.Begin); stream.Read(this.m_Data, 0, length); fixed (short* numRef = this.m_Palette) { short* numPtr = numRef; fixed (byte* numRef2 = this.m_Data) { if (hue.HueID() == 0) { numPtr = (short*) numRef2; int* numPtr2 = (int*) numPtr; int* numPtr3 = numPtr2 + 0x80; while (numPtr2 < numPtr3) { numPtr2[0] |= -2147450880; int* numPtr1 = numPtr2 + 1; numPtr1[0] |= -2147450880; int* numPtr9 = numPtr2 + 2; numPtr9[0] |= -2147450880; int* numPtr10 = numPtr2 + 3; numPtr10[0] |= -2147450880; numPtr2 += 4; } } else { hue.CopyPixels((void*) numRef2, (void*) numPtr, 0x100); } Frames frames = new Frames { FrameCount = num3, FrameList = new Frame[num3] }; for (int i = 0; i < num3; i++) { int num6 = (numRef2 + 0x204)[i << 2]; byte* numPtr4 = (numRef2 + 0x200) + num6; short* numPtr5 = (short*) numPtr4; int num7 = numPtr5[0]; int num8 = numPtr5[1]; int width = numPtr5[2]; int height = numPtr5[3]; numPtr4 += 8; frames.FrameList[i] = new Frame(); frames.FrameList[i].CenterX = num7; frames.FrameList[i].CenterY = num8; if ((width <= 0) || (height <= 0)) { frames.FrameList[i].Image = Texture.Empty; } else { Texture texture = new Texture(width, height, true); if (texture.IsEmpty()) { frames.FrameList[i].Image = Texture.Empty; } else { int num11 = 0; short* numPtr6 = null; int num12 = num7 - 0x200; int num13 = (num8 + height) - 0x200; LockData data = texture.Lock(LockFlags.WriteOnly); short* pvSrc = (short*) data.pvSrc; int num14 = data.Pitch >> 1; pvSrc += num12; pvSrc += num13 * num14; while ((num11 = *((int*) numPtr4)) != 0x7fff7fff) { numPtr4 += 4; num11 ^= -2145386496; numPtr6 = pvSrc + ((((num11 >> 12) & 0x3ff) * num14) + ((num11 >> 0x16) & 0x3ff)); short* numPtr8 = numPtr6 + (num11 & 0xffc); while (numPtr6 < numPtr8) { numPtr6[0] = numPtr[numPtr4[0]]; numPtr6[1] = numPtr[numPtr4[1]]; numPtr6[2] = numPtr[numPtr4[2]]; numPtr6[3] = numPtr[numPtr4[3]]; numPtr6 += 4; numPtr4 += 4; } switch ((num11 & 3)) { case 1: goto Label_04A6; case 2: break; case 3: numPtr6[2] = numPtr[numPtr4[2]]; break; default: goto Label_04B5; } numPtr6[1] = numPtr[numPtr4[1]]; Label_04A6: numPtr6[0] = numPtr[numPtr4[0]]; Label_04B5: numPtr4 += num11 & 3; } texture.Unlock(); texture.SetPriority(0); frames.FrameList[i].Image = texture; } } } this.m_Frames.Add(frames); return frames; } } }
public unsafe object Create(int realID, IHue hue) { int length; int lookup; int num3; Stream stream; switch (this.ConvertRealID(ref realID)) { case 1: { if (((realID < 0) || (realID >= this.m_Count)) || (realID >= this.m_Index.Length)) { return(Frames.Empty); } Entry3D entryd = this.m_Index[realID]; length = entryd.m_Length; lookup = entryd.m_Lookup; num3 = entryd.m_Extra & 0xff; stream = m_Stream; break; } case 2: { if (((realID < 0) || (realID >= this.m_Count2)) || (realID >= this.m_Index2.Length)) { return(Frames.Empty); } Entry3D entryd2 = this.m_Index2[realID]; length = entryd2.m_Length; lookup = entryd2.m_Lookup; num3 = entryd2.m_Extra & 0xff; stream = m_Stream2; break; } case 3: { if (((realID < 0) || (realID >= this.m_Count3)) || (realID >= this.m_Index3.Length)) { return(Frames.Empty); } Entry3D entryd3 = this.m_Index3[realID]; length = entryd3.m_Length; lookup = entryd3.m_Lookup; num3 = entryd3.m_Extra & 0xff; stream = m_Stream3; break; } default: { if (((realID < 0) || (realID >= this.m_Count4)) || (realID >= this.m_Index4.Length)) { return(Frames.Empty); } Entry3D entryd4 = this.m_Index4[realID]; length = entryd4.m_Length; lookup = entryd4.m_Lookup; num3 = entryd4.m_Extra & 0xff; stream = m_Stream4; break; } } if (((lookup < 0) || (length <= 0)) || ((num3 <= 0) || (stream == null))) { return(Frames.Empty); } if ((this.m_Data == null) || (length > this.m_Data.Length)) { this.m_Data = new byte[length]; } stream.Seek((long)lookup, SeekOrigin.Begin); stream.Read(this.m_Data, 0, length); fixed(short *numRef = this.m_Palette) { short *numPtr = numRef; fixed(byte *numRef2 = this.m_Data) { if (hue.HueID() == 0) { numPtr = (short *)numRef2; int *numPtr2 = (int *)numPtr; int *numPtr3 = numPtr2 + 0x80; while (numPtr2 < numPtr3) { numPtr2[0] |= -2147450880; int *numPtr1 = numPtr2 + 1; numPtr1[0] |= -2147450880; int *numPtr9 = numPtr2 + 2; numPtr9[0] |= -2147450880; int *numPtr10 = numPtr2 + 3; numPtr10[0] |= -2147450880; numPtr2 += 4; } } else { hue.CopyPixels((void *)numRef2, (void *)numPtr, 0x100); } Frames frames = new Frames { FrameCount = num3, FrameList = new Frame[num3] }; for (int i = 0; i < num3; i++) { int num6 = (numRef2 + 0x204)[i << 2]; byte * numPtr4 = (numRef2 + 0x200) + num6; short *numPtr5 = (short *)numPtr4; int num7 = numPtr5[0]; int num8 = numPtr5[1]; int width = numPtr5[2]; int height = numPtr5[3]; numPtr4 += 8; frames.FrameList[i] = new Frame(); frames.FrameList[i].CenterX = num7; frames.FrameList[i].CenterY = num8; if ((width <= 0) || (height <= 0)) { frames.FrameList[i].Image = Texture.Empty; } else { Texture texture = new Texture(width, height, true); if (texture.IsEmpty()) { frames.FrameList[i].Image = Texture.Empty; } else { int num11 = 0; short * numPtr6 = null; int num12 = num7 - 0x200; int num13 = (num8 + height) - 0x200; LockData data = texture.Lock(LockFlags.WriteOnly); short * pvSrc = (short *)data.pvSrc; int num14 = data.Pitch >> 1; pvSrc += num12; pvSrc += num13 * num14; while ((num11 = *((int *)numPtr4)) != 0x7fff7fff) { numPtr4 += 4; num11 ^= -2145386496; numPtr6 = pvSrc + ((((num11 >> 12) & 0x3ff) * num14) + ((num11 >> 0x16) & 0x3ff)); short *numPtr8 = numPtr6 + (num11 & 0xffc); while (numPtr6 < numPtr8) { numPtr6[0] = numPtr[numPtr4[0]]; numPtr6[1] = numPtr[numPtr4[1]]; numPtr6[2] = numPtr[numPtr4[2]]; numPtr6[3] = numPtr[numPtr4[3]]; numPtr6 += 4; numPtr4 += 4; } switch ((num11 & 3)) { case 1: goto Label_04A6; case 2: break; case 3: numPtr6[2] = numPtr[numPtr4[2]]; break; default: goto Label_04B5; } numPtr6[1] = numPtr[numPtr4[1]]; Label_04A6: numPtr6[0] = numPtr[numPtr4[0]]; Label_04B5: numPtr4 += num11 & 3; } texture.Unlock(); texture.SetPriority(0); frames.FrameList[i].Image = texture; } } } this.m_Frames.Add(frames); return(frames); } } }