mirror of
https://github.com/ShareX/ShareX.git
synced 2024-06-30 12:11:07 +12:00
#5055: Also handle bigger cursor in region capture
This commit is contained in:
parent
b2896cec47
commit
546c95c6b1
|
@ -142,5 +142,32 @@ public void DrawCursor(Image img, Point offset)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Bitmap ToBitmap()
|
||||
{
|
||||
Size cursorSize;
|
||||
|
||||
if (Size.IsEmpty)
|
||||
{
|
||||
cursorSize = new Size(32, 32);
|
||||
}
|
||||
else
|
||||
{
|
||||
cursorSize = Size;
|
||||
}
|
||||
|
||||
Bitmap bmp = new Bitmap(cursorSize.Width, cursorSize.Height);
|
||||
|
||||
using (Graphics g = Graphics.FromImage(bmp))
|
||||
{
|
||||
IntPtr hdcDest = g.GetHdc();
|
||||
|
||||
NativeMethods.DrawIconEx(hdcDest, 0, 0, Handle, cursorSize.Width, cursorSize.Height, 0, IntPtr.Zero, NativeConstants.DI_NORMAL);
|
||||
|
||||
g.ReleaseHdc(hdcDest);
|
||||
}
|
||||
|
||||
return bmp;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -810,11 +810,11 @@ public WindowInfo GetWindowInfo()
|
|||
return ShapeManager.FindSelectedWindowInfo(CurrentPosition);
|
||||
}
|
||||
|
||||
public void AddCursor(IntPtr cursorHandle, Point position)
|
||||
public void AddCursor(Bitmap bmpCursor, Point position)
|
||||
{
|
||||
if (ShapeManager != null)
|
||||
{
|
||||
ShapeManager.AddCursor(cursorHandle, position);
|
||||
ShapeManager.AddCursor(bmpCursor, position);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,11 +35,15 @@ public class CursorDrawingShape : ImageDrawingShape
|
|||
|
||||
public void UpdateCursor(IntPtr cursorHandle, Point position)
|
||||
{
|
||||
Dispose();
|
||||
|
||||
Icon icon = Icon.FromHandle(cursorHandle);
|
||||
Image = icon.ToBitmap();
|
||||
Bitmap bmpCursor = icon.ToBitmap();
|
||||
UpdateCursor(bmpCursor, position);
|
||||
}
|
||||
|
||||
public void UpdateCursor(Bitmap bmpCursor, Point position)
|
||||
{
|
||||
Dispose();
|
||||
Image = bmpCursor;
|
||||
Rectangle = new Rectangle(position, Image.Size);
|
||||
}
|
||||
|
||||
|
|
|
@ -1750,10 +1750,10 @@ private void PasteFromClipboard(bool insertMousePosition)
|
|||
}
|
||||
}
|
||||
|
||||
public void AddCursor(IntPtr cursorHandle, Point position)
|
||||
public void AddCursor(Bitmap bmpCursor, Point position)
|
||||
{
|
||||
CursorDrawingShape shape = (CursorDrawingShape)CreateShape(ShapeType.DrawingCursor);
|
||||
shape.UpdateCursor(cursorHandle, position);
|
||||
shape.UpdateCursor(bmpCursor, position);
|
||||
Shapes.Add(shape);
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ protected TaskMetadata ExecuteRegionCapture(TaskSettings taskSettings)
|
|||
{
|
||||
if (cursorData != null && cursorData.IsVisible)
|
||||
{
|
||||
form.AddCursor(cursorData.Handle, form.PointToClient(cursorData.DrawPosition));
|
||||
form.AddCursor(cursorData.ToBitmap(), form.PointToClient(cursorData.DrawPosition));
|
||||
}
|
||||
|
||||
form.ShowDialog();
|
||||
|
|
Loading…
Reference in a new issue