protected virtual void Dispose(bool disposing) { if (!DisposedValue) { if (disposing) { JpegDecoder.Dispose(); ActiveCamera = null; if (Cameras != null) { foreach (Camera camera in Cameras) { try { camera.Disconnect(); camera.Dispose(); } catch (Exception) { } } Cameras = null; } Context.Dispose(); } DisposedValue = true; } }
public void Dispose() { if (_decompress) { _decompressor.Dispose(); } else { _compressor.Dispose(); } }
/// <summary> /// Call this when finished with the instance. If using a C# using block, you won't need to call this. /// </summary> public void Dispose() { try { lock (this) { if (isDisposed) { return; } isDisposed = true; decomp.Dispose(); } } catch (Exception) { Console.WriteLine("Exception disposing TurboJpeg stuff in JpegDiffVideoDecoder"); } }
public void Clean() { _decompressor.Dispose(); }
public static void DoThing() { try { //Console.WriteLine("DoThing"); int pos = 0; bool isTop = false; bool iscomplete = false; int lastSeq = 0; int lastSub = 0; bool loop = true; while (loop) { int length = udpClient.Client.ReceiveFrom(data, ref udpEP); if (data[3] == 0x00) { lastSeq = data[0]; lastSub = -1; pos = 0; } if (data[0] == lastSeq && lastSub + 1 == data[3]) { lastSub = data[3]; if (data[1] == 0x01 || data[1] == 0x11) { isTop = true; } else if (isTop) { isTop = false; //LIES! } //Need to valid that the entire UDP stream is received before proceeding... Otherwise TDJ crashes. //Console.WriteLine("{0:x2} {1:x2} {2:x2} {3:x2}", data[0], data[1], data[2], data[3]); if (pos + length > jpegImage.Length) { loop = false; pos = 0; } else { Array.Copy(data, 4, jpegImage, pos, length - 4); pos += length - 4; if (data[1] >= 0x10) { iscomplete = true; loop = false; //Console.WriteLine("S"); } } } else { loop = false; pos = 0; //Console.WriteLine("FB"); } } if (iscomplete) { byte[] decom; tjd = new TJDecompressor(jpegImage); if (isTop) { decom = new byte[240 * 400 * TJ.getPixelSize(turbojpegCLI.PixelFormat.RGB)]; tjd.decompress(decom, turbojpegCLI.PixelFormat.RGB, Flag.NONE); if (FormMain.viewerTop != null) { FormMain.viewerTop.LoadTexture(400, 240, decom); } } else { decom = new byte[240 * 320 * TJ.getPixelSize(turbojpegCLI.PixelFormat.RGB)]; tjd.decompress(decom, turbojpegCLI.PixelFormat.RGB, Flag.NONE); if (FormMain.viewerTop != null) { FormMain.viewerBottom.LoadTexture(320, 240, decom); } } tjd.Dispose(); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }