public void Dispose() { if (Img != null) { Img.Dispose(); } }
public void Dispose() { Transform = null; if (Img != null) { Img.Dispose(); } LayerText = null; }
public void Dispose() { if (null != Img) { Img.Dispose(); Img = null; Handler = null; } }
/// <summary> /// Disposes of the object by clearing the collection /// </summary> public void Dispose() { //Make sure each image is disposed of properly foreach (System.Drawing.Image Img in this) { Img.Dispose(); GC.Collect(); GC.WaitForPendingFinalizers(); } this.m_Disposed = true; this.Clear(); }
public void Dispose() { if (Img != null) { Img.Dispose(); } if (BaseStream != null) { BaseStream.Close(); } _attached = false; }
static void ExportTexture(Texture Tex, string FileName) { #if !FIRST_MIPMAP_ONLY if (Tex.MipmapCount == 1) { #endif Bitmap Img; if (PixelDecoder.TryDecode(Tex, out Img)) { Img.Save(FileName); Img.Dispose(); } else { Console.WriteLine("FAILED texture " + Tex.Name); #if DEBUG //Debugger.Break(); #endif } #if !FIRST_MIPMAP_ONLY } else { for (int Index = 0; Index < Tex.MipmapCount; Index++) { if (!PixelDecoder.TryDecode(Tex, out Bitmap Img, (int)Tex.MipOffsets[Index])) { Debugger.Break(); break; } string Ext = Path.GetExtension(FileName); Img.Save(FileName.Replace(Ext, "." + Index + "." + Ext)); Tex.Width = Math.Max(Tex.Width >> 1, 1); Tex.Height = Math.Max(Tex.Height >> 1, 1); while (Tex.GetBlockHeight() * 8 > Tex.GetPow2HeightInTexels() && Tex.BlockHeightLog2 > 0) { Tex.BlockHeightLog2--; } } } #endif }
/// <summary> /// Disposes of the resources used by this DGRP instance. /// <param name="Disposed">Was this resource disposed explicitly?</param> /// </summary> protected virtual void Dispose(bool Disposed) { if (Disposed) { foreach (DGRPImg Img in Images) { if (Img != null) { Img.Dispose(); } } // Prevent the finalizer from calling ~DGRP, since the object is already disposed at this point. GC.SuppressFinalize(this); } else { m_Logger.Error("DGRP not explicitly disposed!"); } }
private void CameraLiveAcq() { //------------------------------------------------------------ // INIT //------------------------------------------------------------ while (true) { //------------------------------------------------------------ // Grab Image //------------------------------------------------------------ GrabMutex.WaitOne(); HObject Img; Img = MainFrameGrabber.GrabImageAsync(-1); GrabMutex.ReleaseMutex(); //------------------------------------------------------------ // Add Image to List //------------------------------------------------------------ ProcessImageMutex.WaitOne(); if (imgList.Count < MAX_BUFFERS) { imgList.Add(Img); ImageInEvent.Set(); } else { Img.Dispose(); } ProcessImageMutex.ReleaseMutex(); if (StopLiveViewEvent.WaitOne(0, true)) { break; } } return; }
private void CamParamsChanged(object sender, EventArgs e) { double gainValue = 0, exposureValue = 0; //------------------------------------------------------------ // Cập nhật giá trị Gain //------------------------------------------------------------ try { gainValue = Double.Parse(txtGainValue.Text); MainFrameGrabber.SetFramegrabberParam(new HTuple("Gain"), new HTuple(gainValue)); } catch { } //------------------------------------------------------------ // Cập nhật giá trị Exposure //------------------------------------------------------------ try { exposureValue = Double.Parse(txtExposureValue.Text); MainFrameGrabber.SetFramegrabberParam(new HTuple("ExposureTime"), new HTuple(exposureValue)); } catch { } //------------------------------------------------------------ // Chụp ảnh mới theo thay đổi //------------------------------------------------------------ GrabMutex.WaitOne(); HImage Img; Img = MainFrameGrabber.GrabImage(); Img.DispObj(MainWindow); Img.Dispose(); GrabMutex.ReleaseMutex(); //------------------------------------------------------------ // Cập nhật CameraSet //------------------------------------------------------------ CurrentCameraSet.Gain = gainValue; CurrentCameraSet.Exposure = exposureValue; }
void ReleaseDesignerOutlets() { if (Img != null) { Img.Dispose(); Img = null; } if (LabelDosage != null) { LabelDosage.Dispose(); LabelDosage = null; } if (LabelLast != null) { LabelLast.Dispose(); LabelLast = null; } if (LabelName != null) { LabelName.Dispose(); LabelName = null; } if (LabelNext != null) { LabelNext.Dispose(); LabelNext = null; } if (LabelStock != null) { LabelStock.Dispose(); LabelStock = null; } }
private void btnConnect_Click(object sender, EventArgs e) { //------------------------------------------------------------ // Kiểm tra lệnh kết nối hay ngắt kết nối //------------------------------------------------------------ if (CameraConnected) { MainFrameGrabber.Dispose(); btnConnect.Text = " Connect"; CameraConnected = false; return; } //------------------------------------------------------------ // Lấy giá trị device và generic cho hàm kết nối camera //------------------------------------------------------------ bool isFileInterface = false; string regexDevicePattern = @"(device:)(.+?)(\s\|)"; string regexGenericPattern = @"(suggestion:)(.+)(\s\|)"; string deviceInfo = cbDevices.SelectedItem.ToString(); string device = Regex.Match(deviceInfo, regexDevicePattern).Groups[2].Value; if (device.Length < 3) { device = "default"; } HTuple generic; if (deviceInfo.Contains("misconfigured")) { generic = Regex.Match(deviceInfo, regexGenericPattern).Groups[2].Value; } else { generic = new HTuple(-1); } //------------------------------------------------------------ // Check if is File Interface //------------------------------------------------------------ string interfaceName = cbInterfaces.SelectedItem.ToString(); if (interfaceName == "File") { isFileInterface = true; } if (!isFileInterface) { try { MainFrameGrabber = new HFramegrabber(interfaceName, 1, 1, 0, 0, 0, 0, "default", new HTuple(-1), new HTuple("default"), generic, "default", new HTuple("default"), new HTuple(device), new HTuple(-1), new HTuple(-1)); } catch { return; } try { //------------------------------------------------------------ // Lấy giá trị Gain, Exposure từ Camera //------------------------------------------------------------ HTuple gain = MainFrameGrabber.GetFramegrabberParam("Gain"); HTuple exposureTime = MainFrameGrabber.GetFramegrabberParam("ExposureTime"); //------------------------------------------------------------ // Hiển thị lên ô cài đặt //------------------------------------------------------------ txtGainValue.Text = gain.D.ToString(); txtExposureValue.Text = exposureTime.D.ToString(); //------------------------------------------------------------ // Thay đổi trạng thái kết nối //------------------------------------------------------------ btnConnect.Text = " Connected"; CameraConnected = true; //------------------------------------------------------------ // Cập nhật CameraSet //------------------------------------------------------------ CurrentCameraSet.Device = device; CurrentCameraSet.Generic = generic; } catch (Exception ex) { } } else { MainFrameGrabber = null; } //------------------------------------------------------------ // Set Window display image //------------------------------------------------------------ string ImgType; int ImgWidth, ImgHeight; HImage Img; Img = MainFrameGrabber.GrabImageAsync(1); Img.GetImagePointer1(out ImgType, out ImgWidth, out ImgHeight); MainWindow.SetPart(0, 0, ImgHeight - 1, ImgWidth - 1); Img.DispObj(MainWindow); Img.Dispose(); }
public void TearDown() { Img.Dispose(); }