From cbf2fae360c6ad754eebc11e55809a8b01cadaf0 Mon Sep 17 00:00:00 2001 From: RKrom Date: Fri, 10 Feb 2012 13:26:49 +0000 Subject: [PATCH] (forgotten checkin) Added a getter to the bitmap git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1649 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4 --- GreenshotPlugin/Core/BitmapBuffer.cs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/GreenshotPlugin/Core/BitmapBuffer.cs b/GreenshotPlugin/Core/BitmapBuffer.cs index 4132941dc..79f6a3fdc 100644 --- a/GreenshotPlugin/Core/BitmapBuffer.cs +++ b/GreenshotPlugin/Core/BitmapBuffer.cs @@ -34,6 +34,25 @@ namespace GreenshotPlugin.Core { private bool clone; private Bitmap bitmap; + /// + /// Get the bitmap, you will always need to dispose the returned bitmap!! + /// Only works, and makes sense, if cloned and not locked! + /// + public Bitmap Bitmap { + get { + if (bitsLocked) { + throw new NotSupportedException("Can't get a locked bitmap!"); + } + if (!clone) { + throw new NotSupportedException("Can't return a not cloned bitmap!"); + } else { + // Make sure the bitmap isn't disposed when this object is closed + clone = false; + return bitmap; + } + } + } + [NonSerialized] private BitmapData bmData; [NonSerialized] @@ -201,7 +220,7 @@ namespace GreenshotPlugin.Core { /** * Unlock the System Memory */ - private void Unlock() { + public void Unlock() { if (bitsLocked) { bitmap.UnlockBits(bmData); bitsLocked = false; @@ -301,7 +320,7 @@ namespace GreenshotPlugin.Core { int a = (aIndex==-1) ? 255 : (int)pointer[aIndex+offset]; return new int[]{a, pointer[rIndex+offset], pointer[gIndex+offset], pointer[bIndex+offset]}; } else { - return new int[]{255,255,255,255}; + return new int[]{0,0,0,0}; } }