欧美free性护士vide0shd,老熟女,一区二区三区,久久久久夜夜夜精品国产,久久久久久综合网天天,欧美成人护士h版

目錄

柚子快報(bào)激活碼778899分享:wpf放大鏡

柚子快報(bào)激活碼778899分享:wpf放大鏡

http://yzkb.51969.com/

using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes;

namespace ControlStudy { ? ? ///

? ? /// Magnifier.xaml 的交互邏輯 ? ? /// ? ? public partial class Magnifier : UserControl ? ? { ? ? ? ? public Magnifier() ? ? ? ? { ? ? ? ? ? ? InitializeComponent(); ? ? ? ? }

? ? ? ? private double Zoom = 1.0d;

? ? ? ? public bool ImgVisZoom ? ? ? ? { ? ? ? ? ? ? get { return (bool)GetValue(ImgVisZoomProperty); } ? ? ? ? ? ? set { SetValue(ImgVisZoomProperty, value); } ? ? ? ? }

? ? ? ? // Using a DependencyProperty as the backing store for ImgVisZoom. ?This enables animation, styling, binding, etc... ? ? ? ? public static readonly DependencyProperty ImgVisZoomProperty = ? ? ? ? ? ? DependencyProperty.Register("ImgVisZoom", typeof(bool), typeof(Magnifier), new PropertyMetadata(false));

? ? ? ? public BitmapSource ImgSource ? ? ? ? { ? ? ? ? ? ? get { return (BitmapSource)GetValue(ImgSourceProperty); } ? ? ? ? ? ? set { SetValue(ImgSourceProperty, value); } ? ? ? ? }

? ? ? ? // Using a DependencyProperty as the backing store for bitmapSource. ?This enables animation, styling, binding, etc... ? ? ? ? public static readonly DependencyProperty ImgSourceProperty = ? ? ? ? ? ? DependencyProperty.Register("ImgSource", typeof(BitmapSource), typeof(Magnifier));

? ? ? ? private void Ellipse_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) ? ? ? ? { ? ? ? ? ? ? Zoom = 1.0f; ? ? ? ? ? ? ImgVisZoom = false; ? ? ? ? }

? ? ? ? private void Grid_MouseMove(object sender, MouseEventArgs e) ? ? ? ? { ? ? ? ? ? ? if (!ImgVisZoom) return; ? ? ? ? ? ? double Zwidth = ImgSource.Width / ActualWidth; ? ? ? ? ? ? double Zheight = ImgSource.Height / ActualHeight; ? ? ? ? ? ? System.Windows.Point point = Mouse.GetPosition(gridMagnifier); ? ? ? ? ? ? ellipse.Margin = new Thickness ? ? ? ? ? ? { ? ? ? ? ? ? ? ? Left = point.X - ellipse.Width / 2, ? ? ? ? ? ? ? ? Top = point.Y - ellipse.Height / 2 ? ? ? ? ? ? }; ? ? ? ? ? ? double CenterX = point.X * Zwidth; ? ? ? ? ? ? double CenterY = point.Y * Zheight; ? ? ? ? ? ? double CutWidth = ellipse.Width * Zwidth / Zoom; ? ? ? ? ? ? double CutHeight = ellipse.Height * Zheight / Zoom; ? ? ? ? ? ? Int32Rect CutRect = new Int32Rect ? ? ? ? ? ? { ? ? ? ? ? ? ? ? Width = (int)CutWidth, ? ? ? ? ? ? ? ? Height = (int)CutHeight, ? ? ? ? ? ? ? ? X = (int)(CenterX - CutWidth / 2), ? ? ? ? ? ? ? ? Y = (int)(CenterY - CutHeight / 2) ? ? ? ? ? ? }; ? ? ? ? ? ? ImageZoom.ImageSource = ImgClipRect(CutRect); ? ? ? ? }

? ? ? ? private void Ellipse_MouseWheel(object sender, MouseWheelEventArgs e) ? ? ? ? { ? ? ? ? ? ? Zoom = Math.Round(Zoom, 2); ? ? ? ? ? ? if (e.Delta > 0 && Zoom >= 1) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? Zoom += 0.2; ? ? ? ? ? ? } ? ? ? ? ? ? if (e.Delta < 0 && Zoom >= 1.1) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? Zoom -= 0.2; ? ? ? ? ? ? } ? ? ? ? ? ? Grid_MouseMove(null, null); ? ? ? ? }

? ? ? ? ///

? ? ? ? /// 裁剪圖片 ? ? ? ? /// ? ? ? ? /// 裁剪范圍? ? ? ? ? /// ? ? ? ? public BitmapSource ImgClipRect(Int32Rect CutRect) ? ? ? ? { ? ? ? ? ? ? List ListBytes = new List(); ? ? ? ? ? ? //byte[] bufOrignal = new byte[(int)(ImgSource.Width * ImgSource.Height)]; ? ? ? ? ? ? Int32Rect rect = new Int32Rect ? ? ? ? ? ? { ? ? ? ? ? ? ? ? X = 0, ? ? ? ? ? ? ? ? Y = 0, ? ? ? ? ? ? ? ? Height = (int)ImgSource.Height, ? ? ? ? ? ? ? ? Width = (int)ImgSource.Width, ? ? ? ? ? ? }; ? ? ? ? ? ? var stride = ImgSource.Format.BitsPerPixel * rect.Width / 8;//計(jì)算Stride ? ? ? ? ? ? byte[] bufOrignal = new byte[rect.Height * stride]; ? ? ? ? ? ? ImgSource.CopyPixels(rect, bufOrignal, stride, 0); //像素值拷貝

? ? ? ? ? ? int cutRectX_Temp = ImgSource.Format.BitsPerPixel * CutRect.X / 8; ? ? ? ? ? ? int cutRectWidth_Temp = ImgSource.Format.BitsPerPixel * CutRect.Width / 8;

? ? ? ? ? ? for (int row = CutRect.Y; row < CutRect.Y + CutRect.Height; row++) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? //for (int col = CutRect.X; col < CutRect.X + CutRect.Width; col++) ? ? ? ? ? ? ? ? for (int col = cutRectX_Temp; col < cutRectX_Temp + cutRectWidth_Temp; col++) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? if (row < 0 || row >= ImgSource.Height || col < 0 || col >= stride) ? ? ? ? ? ? ? ? ? ? //(row < 0 || row >= ImgSource.Height || col < 0 || col >= ImgSource.Width) ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? ListBytes.Add(0); ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? else ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? //int Index = (int)(row * ImgSource.Width + col); ? ? ? ? ? ? ? ? ? ? ? ? int Index = (int)(row * stride + col); ? ? ? ? ? ? ? ? ? ? ? ? ListBytes.Add(bufOrignal[Index]); ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? } ? ? ? ? ? ? } ? ? ? ? ? ? IntPtr pData = Marshal.AllocHGlobal(ListBytes.Count); ? ? ? ? ? ? BitmapSource source = null; ? ? ? ? ? ? try ? ? ? ? ? ? { ? ? ? ? ? ? ? ? Marshal.Copy(ListBytes.ToArray(), 0, pData, ListBytes.Count); ? ? ? ? ? ? ? ? string strTImgType = ImgSource.Format.ToString(); ? ? ? ? ? ? ? ? if (strTImgType.Contains("Rgb24")) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? source = BitmapSource.Create(CutRect.Width, CutRect.Height, 0, 0, PixelFormats.Rgb24, null, pData, cutRectWidth_Temp * CutRect.Height, cutRectWidth_Temp); //bgr24 血流圖像 ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? else ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? source = BitmapSource.Create(CutRect.Width, CutRect.Height, 96, 96, PixelFormats.Gray8, BitmapPalettes.Gray256, pData, CutRect.Width * CutRect.Height, CutRect.Width); //gray8 ? ? ? ? ? ? ? ? } ? ? ? ? ? ? } ? ? ? ? ? ? catch (Exception ex) ? ? ? ? ? ? { ? ? ? ? ? ? } ? ? ? ? ? ? finally ? ? ? ? ? ? { ? ? ? ? ? ? ? ? Marshal.FreeHGlobal(pData); ? ? ? ? ? ? } ? ? ? ? ? ? return source; ? ? ? ? } ? ? } } ?

? ? ? ? ? ?

本文內(nèi)容根據(jù)網(wǎng)絡(luò)資料整理,出于傳遞更多信息之目的,不代表金鑰匙跨境贊同其觀點(diǎn)和立場(chǎng)。

轉(zhuǎn)載請(qǐng)注明,如有侵權(quán),聯(lián)系刪除。

本文鏈接:http://gantiao.com.cn/post/19103848.html

發(fā)布評(píng)論

您暫未設(shè)置收款碼

請(qǐng)?jiān)谥黝}配置——文章設(shè)置里上傳

掃描二維碼手機(jī)訪問(wèn)

文章目錄