public byte[] GetAsPngBytes(bool canUseImage = true) { //TODO: not sure why without this lock can be null later if (this._lock == null) { this._lock = new object(); } lock (this._lock) { if (this._pngBytes != null) { return(this._pngBytes); } else { if (canUseImage && this._image != null) { this._pngBytes = CompressibleImage.CompressToPng(this._image); return(this._pngBytes); } else { return(null); } } } }
public void Compress() { lock (this._lock) { if (this._image != null) { if (this._pngBytes == null) { this._pngBytes = CompressibleImage.CompressToPng(this._image); } this._image.Dispose(); this._image = null; } } }