(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
This commit is contained in:
RKrom 2012-02-10 13:26:49 +00:00
parent dede5cf292
commit cbf2fae360

View file

@ -34,6 +34,25 @@ namespace GreenshotPlugin.Core {
private bool clone; private bool clone;
private Bitmap bitmap; private Bitmap bitmap;
/// <summary>
/// Get the bitmap, you will always need to dispose the returned bitmap!!
/// Only works, and makes sense, if cloned and not locked!
/// </summary>
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] [NonSerialized]
private BitmapData bmData; private BitmapData bmData;
[NonSerialized] [NonSerialized]
@ -201,7 +220,7 @@ namespace GreenshotPlugin.Core {
/** /**
* Unlock the System Memory * Unlock the System Memory
*/ */
private void Unlock() { public void Unlock() {
if (bitsLocked) { if (bitsLocked) {
bitmap.UnlockBits(bmData); bitmap.UnlockBits(bmData);
bitsLocked = false; bitsLocked = false;
@ -301,7 +320,7 @@ namespace GreenshotPlugin.Core {
int a = (aIndex==-1) ? 255 : (int)pointer[aIndex+offset]; int a = (aIndex==-1) ? 255 : (int)pointer[aIndex+offset];
return new int[]{a, pointer[rIndex+offset], pointer[gIndex+offset], pointer[bIndex+offset]}; return new int[]{a, pointer[rIndex+offset], pointer[gIndex+offset], pointer[bIndex+offset]};
} else { } else {
return new int[]{255,255,255,255}; return new int[]{0,0,0,0};
} }
} }