-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KitopiaEx新增 置顶截图
- Loading branch information
Showing
10 changed files
with
165 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<u:UrsaWindow xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:u="https://irihi.tech/ursa" | ||
|
||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" | ||
x:Class="KitopiaEx.ImagePin.ImagePin" | ||
|
||
Topmost="True" | ||
IsManagedResizerVisible="False" | ||
IsFullScreenButtonVisible="False" | ||
IsMinimizeButtonVisible="False" | ||
IsRestoreButtonVisible="False" | ||
BorderBrush="Transparent" | ||
Background="Transparent" | ||
CanResize="False" | ||
Title="ImagePin"> | ||
<Image x:Name="Image" PointerPressed="Image_OnPointerPressed"></Image> | ||
</u:UrsaWindow> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using Avalonia; | ||
using Avalonia.Controls; | ||
using Avalonia.Input; | ||
using Avalonia.Markup.Xaml; | ||
using Avalonia.Media.Imaging; | ||
using Ursa.Controls; | ||
|
||
|
||
namespace KitopiaEx.ImagePin; | ||
|
||
public partial class ImagePin : UrsaWindow | ||
{ | ||
public ImagePin() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
protected override void OnClosed(EventArgs e) | ||
{ | ||
base.OnClosed(e); | ||
if (Image.Source is Bitmap bitmap) | ||
{ | ||
bitmap.Dispose(); | ||
} | ||
} | ||
|
||
private void Image_OnPointerPressed(object? sender, PointerPressedEventArgs e) | ||
{ | ||
BeginMoveDrag(e); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using System; | ||
using Avalonia; | ||
using Avalonia.Media.Imaging; | ||
using Avalonia.Platform; | ||
using Avalonia.Threading; | ||
using PluginCore; | ||
using PluginCore.Attribute; | ||
|
||
namespace KitopiaEx.ImagePin; | ||
|
||
public class ScreenCaptureEx | ||
{ | ||
[Capture("置顶图片", 0xf602)] | ||
public void Pin(ScreenCaptureResult dResult) | ||
{ | ||
if (dResult.Bytes is null&& dResult.Source is null) | ||
{ | ||
throw new Exception("无图像数据"); | ||
} | ||
|
||
Dispatcher.UIThread.Invoke((() => | ||
{ | ||
if (dResult.Source is null) | ||
{ | ||
|
||
var writeableBitmap = new WriteableBitmap( | ||
new PixelSize(dResult.Info.Width, dResult.Info.Height), | ||
new Vector(96, 96), PixelFormat.Bgra8888); | ||
using (var l = writeableBitmap.Lock()) | ||
{ | ||
unsafe | ||
{ | ||
var destinationSizeInBytes = dResult.Info.Width * 4 * dResult.Info.Height; | ||
fixed (byte* srcPtr = dResult.Bytes) | ||
{ | ||
Buffer.MemoryCopy(srcPtr, (void*)l.Address, destinationSizeInBytes, destinationSizeInBytes); | ||
} | ||
|
||
} | ||
} | ||
|
||
dResult.Source = writeableBitmap; | ||
|
||
} | ||
|
||
var imagePin = new ImagePin(); | ||
imagePin.Image.Source = dResult.Source; | ||
imagePin.Width = dResult.Info.Width; | ||
imagePin.Height = dResult.Info.Height; | ||
imagePin.Show(); | ||
})); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters