mirror of
https://github.com/greenshot/greenshot
synced 2025-08-14 02:37:03 -07:00
Fixed an issue with the FastBitmap, renamed methods in the BitmapBuffer to be equal to the FastBitmap implementation. In general it's now very easy to switch from the BitmapBuffer to the FastBitmap implementation, but one should consider that the BitmapBuffer checks the x,y if they are inside... and supports a "apply rectangle". Had to "refactor" the CreateBlur for this. Changed the CreateShadow to work with the BoxBlur, this changes the time to create a shadow of a 1280x1024 from ~2.6 to ~1.2 seconds on my PC... which is still slow. The resulting effect seems to be extremely similar... good enough for me.
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2480 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
c9e1ef30e4
commit
3f4d93f2b6
3 changed files with 315 additions and 215 deletions
|
@ -64,6 +64,11 @@ namespace GreenshotPlugin.Core {
|
|||
}
|
||||
}
|
||||
|
||||
public Bitmap UnlockAndReturnBitmap() {
|
||||
Unlock();
|
||||
return Bitmap;
|
||||
}
|
||||
|
||||
public PixelFormat PixelFormat {
|
||||
get {
|
||||
return bitmap.PixelFormat;
|
||||
|
@ -208,9 +213,9 @@ namespace GreenshotPlugin.Core {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlock the System Memory
|
||||
*/
|
||||
/// <summary>
|
||||
/// Unlock the System Memory
|
||||
/// </summary>
|
||||
public void Unlock() {
|
||||
if (bitsLocked) {
|
||||
bitmap.UnlockBits(bmData);
|
||||
|
@ -218,24 +223,31 @@ namespace GreenshotPlugin.Core {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the stored bitmap to the destionation bitmap at the supplied point
|
||||
*/
|
||||
/// <summary>
|
||||
/// Draw the stored bitmap to the destionation bitmap at the supplied point
|
||||
/// </summary>
|
||||
/// <param name="graphics"></param>
|
||||
/// <param name="destination"></param>
|
||||
public void DrawTo(Graphics graphics, Point destination) {
|
||||
DrawTo(graphics, null, destination);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the stored Bitmap on the Destination bitmap with the specified rectangle
|
||||
* Be aware that the stored bitmap will be resized to the specified rectangle!!
|
||||
*/
|
||||
/// <summary>
|
||||
/// Draw the stored Bitmap on the Destination bitmap with the specified rectangle
|
||||
/// Be aware that the stored bitmap will be resized to the specified rectangle!!
|
||||
/// </summary>
|
||||
/// <param name="graphics"></param>
|
||||
/// <param name="destinationRect"></param>
|
||||
public void DrawTo(Graphics graphics, Rectangle destinationRect) {
|
||||
DrawTo(graphics, destinationRect, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* private helper to draw the bitmap
|
||||
*/
|
||||
/// <summary>
|
||||
/// private helper to draw the bitmap
|
||||
/// </summary>
|
||||
/// <param name="graphics"></param>
|
||||
/// <param name="destinationRect"></param>
|
||||
/// <param name="destination"></param>
|
||||
private void DrawTo(Graphics graphics, Rectangle? destinationRect, Point? destination) {
|
||||
if (destinationRect.HasValue) {
|
||||
// Does the rect have any pixels?
|
||||
|
@ -288,10 +300,13 @@ namespace GreenshotPlugin.Core {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the color at location x,y
|
||||
* Before the first time this is called the Lock() should be called once!
|
||||
*/
|
||||
/// <summary>
|
||||
/// Set the color at location x,y
|
||||
/// Before the first time this is called the Lock() should be called once!
|
||||
/// </summary>
|
||||
/// <param name="x"></param>
|
||||
/// <param name="y"></param>
|
||||
/// <param name="color"></param>
|
||||
public void SetColorAt(int x, int y, Color color) {
|
||||
if(x>=0 && y>=0 && x<rect.Width && y<rect.Height) {
|
||||
int offset = x*bytesPerPixel+y*stride;
|
||||
|
@ -302,10 +317,13 @@ namespace GreenshotPlugin.Core {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the color at location x,y to a byte[]
|
||||
* Before the first time this is called the Lock() should be called once!
|
||||
*/
|
||||
/// <summary>
|
||||
/// Retrieve the color at location x,y to a byte[]
|
||||
/// Before the first time this is called the Lock() should be called once!
|
||||
/// </summary>
|
||||
/// <param name="x"></param>
|
||||
/// <param name="y"></param>
|
||||
/// <param name="color"></param>
|
||||
public void GetUncheckedColorIn(int x, int y, byte[] color) {
|
||||
int offset = x * bytesPerPixel + y * stride;
|
||||
color[0] = (aIndex == -1) ? (byte)255 : (byte)pointer[aIndex + offset];
|
||||
|
@ -314,11 +332,14 @@ namespace GreenshotPlugin.Core {
|
|||
color[3] = pointer[bIndex + offset];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the color at location x,y to a byte[]
|
||||
* Before the first time this is called the Lock() should be called once!
|
||||
*/
|
||||
public void GetColorIn(int x, int y, byte[] color) {
|
||||
/// <summary>
|
||||
/// Retrieve the color at location x,y to a byte[]
|
||||
/// Before the first time this is called the Lock() should be called once!
|
||||
/// </summary>
|
||||
/// <param name="x"></param>
|
||||
/// <param name="y"></param>
|
||||
/// <param name="color"></param>
|
||||
public void GetColorAt(int x, int y, byte[] color) {
|
||||
if (x >= 0 && y >= 0 && x < rect.Width && y < rect.Height) {
|
||||
int offset = x * bytesPerPixel + y * stride;
|
||||
color[0] = (aIndex == -1) ? (byte)255 : (byte)pointer[aIndex + offset];
|
||||
|
@ -333,11 +354,14 @@ namespace GreenshotPlugin.Core {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the color at location x,y as an array
|
||||
* Before the first time this is called the Lock() should be called once!
|
||||
*/
|
||||
public void SetColorArrayAt(int x, int y, byte[] colors) {
|
||||
/// <summary>
|
||||
/// Set the color at location x,y as an array
|
||||
/// Before the first time this is called the Lock() should be called once!
|
||||
/// </summary>
|
||||
/// <param name="x"></param>
|
||||
/// <param name="y"></param>
|
||||
/// <param name="colors"></param>
|
||||
public void SetColorAt(int x, int y, byte[] colors) {
|
||||
if(x>=0 && y>=0 && x<rect.Width && y<rect.Height) {
|
||||
int offset = x*bytesPerPixel+y*stride;
|
||||
if(aIndex!=-1) pointer[aIndex+offset] = (byte)colors[0];
|
||||
|
@ -346,20 +370,10 @@ namespace GreenshotPlugin.Core {
|
|||
pointer[bIndex+offset] = (byte)colors[3];
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Set the color at location x,y as an array
|
||||
* Before the first time this is called the Lock() should be called once!
|
||||
*/
|
||||
public void SetUncheckedColorArrayAt(int x, int y, byte[] colors) {
|
||||
int offset = x * bytesPerPixel + y * stride;
|
||||
if (aIndex != -1) pointer[aIndex + offset] = (byte)colors[0];
|
||||
pointer[rIndex + offset] = (byte)colors[1];
|
||||
pointer[gIndex + offset] = (byte)colors[2];
|
||||
pointer[bIndex + offset] = (byte)colors[3];
|
||||
}
|
||||
/**
|
||||
* Set some internal values for accessing the bitmap according to the PixelFormat
|
||||
*/
|
||||
|
||||
/// <summary>
|
||||
/// Set some internal values for accessing the bitmap according to the PixelFormat
|
||||
/// </summary>
|
||||
private void PrepareForPixelFormat() {
|
||||
// aIndex is only set if the pixel format supports "A".
|
||||
aIndex = -1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue