/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> public void Dispose() { if (this.isDisposed) { return; } this.UnPinPixels(); // Note disposing is done. this.isDisposed = true; // This object will be cleaned up by the Dispose method. // Therefore, you should call GC.SuppressFinalize to // take this object off the finalization queue // and prevent finalization code for this object // from executing a second time. GC.SuppressFinalize(this); if (this.PooledMemory) { PixelPool <TColor> .ReturnPixels(this.pixelBuffer); this.pixelBuffer = null; } }
/// <summary> /// Returns the rented pixel array back to the pool. /// </summary> private void ReturnPixels() { PixelPool <TColor> .ReturnPixels(this.pixelBuffer); this.pixelBuffer = null; }
/// <summary> /// Rents the pixel array from the pool. /// </summary> private void RentPixels() { this.pixelBuffer = PixelPool <TColor> .RentPixels(this.Width *this.Height); }
/// <summary> /// Initializes a new instance of the <see cref="PixelAccessor{TColor}"/> class. /// </summary> /// <param name="width">The width of the image represented by the pixel buffer.</param> /// <param name="height">The height of the image represented by the pixel buffer.</param> public PixelAccessor(int width, int height) : this(width, height, PixelPool <TColor> .RentPixels(width * height), true) { }