画像をマウスカーソルの下に拡大表示させるプログラムを何とか作ることができました
参考にしたサイト
https://thinkit.co.jp/story/2013/11/11/4674
この拡大している画像を魚眼レンズ風の画像に変えたいです
どなたか知恵を貸してください
XAML
1<Window x:Class="MainWindow" 2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 4 Title="MainWindow" Height="1080" Width="1920" WindowState="Maximized"> 5 <Canvas Margin="0,0,0,0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="1920" Height="1080"> 6 <Image x:Name="sourceImage" HorizontalAlignment="Stretch" Height="1080" VerticalAlignment="Stretch" Width="1920" Canvas.Top="0" Source="Image/S__82993161.jpg" Canvas.Left="0"/> 7 <Image x:Name="zoomImage" Stretch="Uniform" IsHitTestVisible="False" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="1900" Height="1085" Source="Image/S__82993161.jpg" Canvas.Left="10" Canvas.Top="-15"> 8 <Image.RenderTransform> 9 <ScaleTransform ScaleX="3" ScaleY="3"/> 10 </Image.RenderTransform> 11 <Image.Clip> 12 <EllipseGeometry x:Name="Lens" RadiusX="30" RadiusY="30" Center="0.0,0.0"> 13 <EllipseGeometry.Transform> 14 <TransformGroup> 15 <ScaleTransform ScaleX="1" ScaleY="1"/> 16 <SkewTransform /> 17 <RotateTransform/> 18 <TranslateTransform/> 19 </TransformGroup> 20 </EllipseGeometry.Transform> 21 </EllipseGeometry> 22 </Image.Clip> 23 </Image> 24 <InkPresenter Name="paintCanvas"/> 25 </Canvas> 26</Window>
vb
1Imports Leap 2Imports System.Windows.Ink 3Imports System 4Imports System.Windows 5Imports System.Windows.Input 6Imports System.Windows.Media.Imaging 7Imports System.Windows.Interop 8 9 10 11 12 13 14Class MainWindow 15 Private Declare Function SetCursorPos Lib "user32" (x As Integer, y As Integer) As Boolean 16 Private Declare Function apimouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Int32, ByVal dx As Int32, ByVal dy As Int32, ByVal cButtons As Int32, ByVal dwExtraInfo As Int32) As Boolean 17 Private Const MOUSEEVENTF_LEFTDOWN = &H2 18 Private Const MOUSEEVENTF_LEFTUP = &H4 19 Private Const MOUSEEVENTF_MOVE = &H1 20 Private leap As New Controller 21 Private touchIndicator As New DrawingAttributes 22 Private touchPoint As StylusPoint 23 Private tx As Double 24 Private ty As Double 25 Private x As Integer 26 Private y As Integer 27 Private ImageX As Double 28 Private ImageY As Double 29 'Private Index As Integer 30 Private windowWidth As Double = 1920 31 Private windowHeight As Double = 1080 32 33 'Private no As Integer 34 Private FingersCount As Integer 35 36 37 38 39 Private Sub sourceImage_MouseLeftButtonDown(sender As Object, e As MouseButtonEventArgs) Handles sourceImage.MouseLeftButtonDown 40 zoomImage.Visibility = Windows.Visibility.Visible 41 ImageX = e.GetPosition(sourceImage).X 42 ImageY = e.GetPosition(sourceImage).Y 43 LensPosition(ImageX, ImageY) 44 End Sub 45 46 Private Sub sourceImage_MouseMove(sender As Object, e As MouseEventArgs) Handles sourceImage.MouseMove 47 ImageX = e.GetPosition(sourceImage).X 48 ImageY = e.GetPosition(sourceImage).Y 49 LensPosition(ImageX, ImageY) 50 End Sub 51 52 Private Sub sourceImage_MouseLeftButtonUp(sender As Object, e As MouseButtonEventArgs) Handles sourceImage.MouseLeftButtonUp 53 zoomImage.Visibility = Windows.Visibility.Collapsed 54 End Sub 55 56 57 Private Sub LensPosition(x As Double, y As Double) 58 Lens.Center = New Point(ImageX, ImageY) 59 zoomImage.SetValue(Canvas.LeftProperty, ImageX - (ImageX * 3)) 60 zoomImage.SetValue(Canvas.TopProperty, ImageY - (ImageY * 3)) 61 62 End Sub 63 64 65End Class 66
回答1件
あなたの回答
tips
プレビュー