mirror of
https://github.com/greenshot/greenshot
synced 2025-07-16 10:03:44 -07:00
Removed "rotate" leftovers. Also implemented transform in the ImageContainer, be aware: scaling will probably cause artefakts if we "undo"...
This commit is contained in:
parent
4b8ec88aaf
commit
621cc7fd0c
3 changed files with 42 additions and 20 deletions
|
@ -93,7 +93,8 @@ namespace Greenshot.Drawing {
|
|||
public Image Image {
|
||||
set {
|
||||
// Remove all current bitmaps
|
||||
DisposeImages();
|
||||
DisposeImage();
|
||||
DisposeShadow();
|
||||
image = ImageHelper.Clone(value);
|
||||
bool shadow = GetFieldValueAsBool(FieldType.SHADOW);
|
||||
CheckShadow(shadow);
|
||||
|
@ -118,24 +119,42 @@ namespace Greenshot.Drawing {
|
|||
/// <param name="disposing"></param>
|
||||
protected override void Dispose(bool disposing) {
|
||||
if (disposing) {
|
||||
DisposeImages();
|
||||
DisposeImage();
|
||||
DisposeShadow();
|
||||
}
|
||||
image = null;
|
||||
_shadowBitmap = null;
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void DisposeImages() {
|
||||
private void DisposeImage() {
|
||||
if (image != null) {
|
||||
image.Dispose();
|
||||
}
|
||||
image = null;
|
||||
}
|
||||
private void DisposeShadow() {
|
||||
if (_shadowBitmap != null) {
|
||||
_shadowBitmap.Dispose();
|
||||
}
|
||||
image = null;
|
||||
_shadowBitmap = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Make sure the content is also transformed.
|
||||
/// </summary>
|
||||
/// <param name="matrix"></param>
|
||||
public override void Transform(Matrix matrix) {
|
||||
base.Transform(matrix);
|
||||
LOG.DebugFormat("Rotating element with {0} degrees.", CalculateAngle(matrix));
|
||||
DisposeShadow();
|
||||
using (var tmpMatrix = new Matrix()) {
|
||||
using (image) {
|
||||
image = ImageHelper.ApplyEffect(image, new RotateEffect(CalculateAngle(matrix)), tmpMatrix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
|
@ -157,7 +176,9 @@ namespace Greenshot.Drawing {
|
|||
/// <param name="shadow"></param>
|
||||
private void CheckShadow(bool shadow) {
|
||||
if (shadow && _shadowBitmap == null) {
|
||||
_shadowBitmap = ImageHelper.ApplyEffect(image, new DropShadowEffect(), new Matrix());
|
||||
using (var matrix = new Matrix()) {
|
||||
_shadowBitmap = ImageHelper.ApplyEffect(image, new DropShadowEffect(), matrix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue