mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 17:56:51 +13:00
Proof of concept Torn Edges effect on cut
This commit is contained in:
parent
32cae726e8
commit
ac0cfcd4ec
3 changed files with 69 additions and 4 deletions
|
@ -212,4 +212,13 @@ public enum StepType // Localized
|
||||||
RomanNumeralsUppercase,
|
RomanNumeralsUppercase,
|
||||||
RomanNumeralsLowercase
|
RomanNumeralsLowercase
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum CutOutEffectType // Localized (probably)
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
ZigZag,
|
||||||
|
TornEdge,
|
||||||
|
Wave,
|
||||||
|
Gradient
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -223,7 +223,7 @@ public static Bitmap CropBitmap(Bitmap bmp, Rectangle rect)
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Bitmap CutOutBitmapMiddleHorizontal(Bitmap bmp, int x, int width)
|
public static Bitmap CutOutBitmapMiddleHorizontal(Bitmap bmp, int x, int width, CutOutEffectType effectType, int effectSize)
|
||||||
{
|
{
|
||||||
if (bmp != null && width > 0)
|
if (bmp != null && width > 0)
|
||||||
{
|
{
|
||||||
|
@ -231,11 +231,39 @@ public static Bitmap CutOutBitmapMiddleHorizontal(Bitmap bmp, int x, int width)
|
||||||
if (x > 0)
|
if (x > 0)
|
||||||
{
|
{
|
||||||
leftPart = CropBitmap(bmp, new Rectangle(0, 0, Math.Min(x, bmp.Width), bmp.Height));
|
leftPart = CropBitmap(bmp, new Rectangle(0, 0, Math.Min(x, bmp.Width), bmp.Height));
|
||||||
|
switch (effectType)
|
||||||
|
{
|
||||||
|
case CutOutEffectType.None:
|
||||||
|
break;
|
||||||
|
case CutOutEffectType.ZigZag:
|
||||||
|
break;
|
||||||
|
case CutOutEffectType.TornEdge:
|
||||||
|
leftPart = TornEdges(leftPart, effectSize, effectSize * 2, AnchorStyles.Right, false);
|
||||||
|
break;
|
||||||
|
case CutOutEffectType.Wave:
|
||||||
|
break;
|
||||||
|
case CutOutEffectType.Gradient:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (x + width < bmp.Width)
|
if (x + width < bmp.Width)
|
||||||
{
|
{
|
||||||
int x2 = Math.Max(x + width, 0);
|
int x2 = Math.Max(x + width, 0);
|
||||||
rightPart = CropBitmap(bmp, new Rectangle(x2, 0, bmp.Width - x2, bmp.Height));
|
rightPart = CropBitmap(bmp, new Rectangle(x2, 0, bmp.Width - x2, bmp.Height));
|
||||||
|
switch (effectType)
|
||||||
|
{
|
||||||
|
case CutOutEffectType.None:
|
||||||
|
break;
|
||||||
|
case CutOutEffectType.ZigZag:
|
||||||
|
break;
|
||||||
|
case CutOutEffectType.TornEdge:
|
||||||
|
rightPart = TornEdges(rightPart, effectSize, effectSize * 2, AnchorStyles.Left, false);
|
||||||
|
break;
|
||||||
|
case CutOutEffectType.Wave:
|
||||||
|
break;
|
||||||
|
case CutOutEffectType.Gradient:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (leftPart != null && rightPart != null)
|
if (leftPart != null && rightPart != null)
|
||||||
|
@ -255,7 +283,7 @@ public static Bitmap CutOutBitmapMiddleHorizontal(Bitmap bmp, int x, int width)
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Bitmap CutOutBitmapMiddleVertical(Bitmap bmp, int y, int height)
|
public static Bitmap CutOutBitmapMiddleVertical(Bitmap bmp, int y, int height, CutOutEffectType effectType, int effectSize)
|
||||||
{
|
{
|
||||||
if (bmp != null && height > 0)
|
if (bmp != null && height > 0)
|
||||||
{
|
{
|
||||||
|
@ -263,11 +291,39 @@ public static Bitmap CutOutBitmapMiddleVertical(Bitmap bmp, int y, int height)
|
||||||
if (y > 0)
|
if (y > 0)
|
||||||
{
|
{
|
||||||
topPart = CropBitmap(bmp, new Rectangle(0, 0, bmp.Width, Math.Min(y, bmp.Height)));
|
topPart = CropBitmap(bmp, new Rectangle(0, 0, bmp.Width, Math.Min(y, bmp.Height)));
|
||||||
|
switch (effectType)
|
||||||
|
{
|
||||||
|
case CutOutEffectType.None:
|
||||||
|
break;
|
||||||
|
case CutOutEffectType.ZigZag:
|
||||||
|
break;
|
||||||
|
case CutOutEffectType.TornEdge:
|
||||||
|
topPart = TornEdges(topPart, effectSize, effectSize * 2, AnchorStyles.Bottom, false);
|
||||||
|
break;
|
||||||
|
case CutOutEffectType.Wave:
|
||||||
|
break;
|
||||||
|
case CutOutEffectType.Gradient:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (y + height < bmp.Height)
|
if (y + height < bmp.Height)
|
||||||
{
|
{
|
||||||
int y2 = Math.Max(y + height, 0);
|
int y2 = Math.Max(y + height, 0);
|
||||||
bottomPart = CropBitmap(bmp, new Rectangle(0, y2, bmp.Width, bmp.Height - y2));
|
bottomPart = CropBitmap(bmp, new Rectangle(0, y2, bmp.Width, bmp.Height - y2));
|
||||||
|
switch (effectType)
|
||||||
|
{
|
||||||
|
case CutOutEffectType.None:
|
||||||
|
break;
|
||||||
|
case CutOutEffectType.ZigZag:
|
||||||
|
break;
|
||||||
|
case CutOutEffectType.TornEdge:
|
||||||
|
bottomPart = TornEdges(bottomPart, effectSize, effectSize * 2, AnchorStyles.Top, false);
|
||||||
|
break;
|
||||||
|
case CutOutEffectType.Wave:
|
||||||
|
break;
|
||||||
|
case CutOutEffectType.Gradient:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (topPart != null && bottomPart != null)
|
if (topPart != null && bottomPart != null)
|
||||||
|
|
|
@ -1931,12 +1931,12 @@ public void CutOut(RectangleF rect)
|
||||||
if (isHorizontal && cropRect.Width > 0)
|
if (isHorizontal && cropRect.Width > 0)
|
||||||
{
|
{
|
||||||
CollapseAllHorizontal(rect.X, rect.Width);
|
CollapseAllHorizontal(rect.X, rect.Width);
|
||||||
UpdateCanvas(ImageHelpers.CutOutBitmapMiddleHorizontal(Form.Canvas, cropRect.X, cropRect.Width));
|
UpdateCanvas(ImageHelpers.CutOutBitmapMiddleHorizontal(Form.Canvas, cropRect.X, cropRect.Width, CutOutEffectType.TornEdge, 5));
|
||||||
}
|
}
|
||||||
else if (!isHorizontal && cropRect.Height > 0)
|
else if (!isHorizontal && cropRect.Height > 0)
|
||||||
{
|
{
|
||||||
CollapseAllVertical(rect.Y, rect.Height);
|
CollapseAllVertical(rect.Y, rect.Height);
|
||||||
UpdateCanvas(ImageHelpers.CutOutBitmapMiddleVertical(Form.Canvas, cropRect.Y, cropRect.Height));
|
UpdateCanvas(ImageHelpers.CutOutBitmapMiddleVertical(Form.Canvas, cropRect.Y, cropRect.Height, CutOutEffectType.TornEdge, 5));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue