• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Windows.Int32Rect类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Windows.Int32Rect的典型用法代码示例。如果您正苦于以下问题:C# Int32Rect类的具体用法?C# Int32Rect怎么用?C# Int32Rect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Int32Rect类属于System.Windows命名空间,在下文中一共展示了Int32Rect类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Window_Loaded

        private void Window_Loaded( object sender, RoutedEventArgs e )
        {
            try {
                kinect = KinectSensor.GetDefault();
                if ( kinect == null ) {
                    throw new Exception("Kinectを開けません");
                }

                kinect.Open();

                // 表示のためのデータを作成
                depthFrameDesc = kinect.DepthFrameSource.FrameDescription;

                // 表示のためのビットマップに必要なものを作成
                depthImage = new WriteableBitmap( depthFrameDesc.Width, depthFrameDesc.Height,
                    96, 96, PixelFormats.Gray16, null );
                depthBuffer = new ushort[depthFrameDesc.LengthInPixels];
                depthRect = new Int32Rect( 0, 0, depthFrameDesc.Width, depthFrameDesc.Height );
                depthStride = (int)(depthFrameDesc.Width * depthFrameDesc.BytesPerPixel);

                ImageDepth.Source = depthImage;

                // 初期の位置表示座標
                depthPoint = new Point( depthFrameDesc.Width / 2, depthFrameDesc.Height / 2 );

                // Depthリーダーを開く
                depthFrameReader = kinect.DepthFrameSource.OpenReader();
                depthFrameReader.FrameArrived += depthFrameReader_FrameArrived;
            }
            catch ( Exception ex ) {
                MessageBox.Show( ex.Message );
                Close();
            }
        }
开发者ID:kaorun55,项目名称:Kinect-for-Windows-SDK-v2.0-Samples,代码行数:34,代码来源:MainWindow.xaml.cs


示例2: MainWindow

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <remarks>
        /// Created by default automatically.
        /// </remarks>
        public MainWindow()
        {
            InitializeComponent();

            int width = (int)Math.Ceiling(Math.Sqrt(sn_range));
            int height = width;

            m_shuffledBuffer = new WriteableBitmap(width, height, 96, 96, PixelFormats.Cmyk32, null);
            m_sortedBuffer = new WriteableBitmap(width, height, 96, 96, PixelFormats.Cmyk32, null);
            m_rect = new Int32Rect(0, 0, m_sortedBuffer.PixelWidth, m_sortedBuffer.PixelHeight);
            m_bpp = (m_sortedBuffer.Format.BitsPerPixel + 7) / 8;
            m_stride = m_sortedBuffer.PixelWidth * m_bpp;
            m_arraySize = m_stride * m_sortedBuffer.PixelHeight;

            imgSorted.Source = m_sortedBuffer;
            imgShuffled.Source = m_shuffledBuffer;

            imgShuffled.Width = width;
            imgShuffled.Height = height;

            imgSorted.Width = width;
            imgSorted.Height = height;

            txtOutput.IsReadOnly = true;
        }
开发者ID:jrbirchall,项目名称:jbirchall-pandell-git,代码行数:31,代码来源:MainWindow.xaml.cs


示例3: CardPack

        public CardPack()
        {
            _pack = new List<Card>();
            Uri uri = new Uri("./Images/cards.png", UriKind.Relative);
            source = new BitmapImage(uri);
            _cardFronts = new List<CroppedBitmap>();
            CardBack = new Image();

            int w = source.PixelWidth / 13;
            int h = source.PixelHeight/5;

            for (int s = 0; s < 4; s++)
            {
                for (int v = 0; v < 13; v++)
                {
                    int imageIndex = (s*13) + v;

                    int fx = imageIndex % 13;
                    int fy = imageIndex / 13;

                    Int32Rect sourceRect = new Int32Rect(fx * w, fy * h, w, h);
                    CroppedBitmap front = new CroppedBitmap(source, sourceRect);

                    sourceRect = new Int32Rect(2 * w, 4 * h, w, h);
                    CroppedBitmap back = new CroppedBitmap(source, sourceRect);

                    Image frontImage = new Image {Source = front};
                    Image backImage = new Image { Source = back };

                    Card card = new Card((CardSuit)s, (CardValue)v, frontImage, backImage);
                    _pack.Add(card);
                }
            }
        }
开发者ID:RedHobbit,项目名称:ClockPatience,代码行数:34,代码来源:CardPack.cs


示例4: Draw

        public void Draw(List<Cell> alives)
        {
            int width = Cells.GetLength(0);
            int height = Cells.GetLength(1);

            // Reserve the back buffer for updates
            WriteableBitmap bitmap = _bitmap;
            bitmap.Lock();

            // Clear to white
            var rect = new Int32Rect(0, 0, width, height);
            bitmap.WritePixels(rect, _whiteBitmap, bitmap.BackBufferStride, 0);

            unsafe
            {
                // Get a pointer to the back buffer
                int pBackBuffer = (int)bitmap.BackBuffer;
                foreach (Cell cell in alives)
                {
                    // Find the address of the pixel to draw
                    int p = pBackBuffer + (cell.Y * bitmap.BackBufferStride);
                    p += cell.X * 4;
                    *((int*)p) = 0;
                }
            }

            // Specify the area of the bitmap that changed
            bitmap.AddDirtyRect(new Int32Rect(0, 0, width, height));

            // Release the back buffer and make it available for display
            bitmap.Unlock();
        }
开发者ID:hanscho,项目名称:GameOfLife,代码行数:32,代码来源:GameBoard.cs


示例5: Show

        public void Show(Int32Rect rpRect)
        {
            var rMainWindowHandle = new WindowInteropHelper(App.Current.MainWindow).Handle;

            if (r_HwndSource == null)
            {
                var rParam = new HwndSourceParameters(nameof(ScreenshotToolOverlayWindow))
                {
                    Width = 0,
                    Height = 0,
                    PositionX = 0,
                    PositionY = 0,
                    WindowStyle = 0,
                    UsesPerPixelOpacity = true,
                    HwndSourceHook = WndProc,
                    ParentWindow = rMainWindowHandle,
                };

                r_HwndSource = new HwndSource(rParam) { SizeToContent = SizeToContent.Manual, RootVisual = this };
            }

            var rBrowserWindowHandle = ServiceManager.GetService<IBrowserService>().Handle;

            NativeStructs.RECT rBrowserWindowRect;
            NativeMethods.User32.GetWindowRect(rBrowserWindowHandle, out rBrowserWindowRect);

            var rHorizontalRatio = rBrowserWindowRect.Width / GameConstants.GameWidth;
            var rVerticalRatio = rBrowserWindowRect.Height / GameConstants.GameHeight;
            rpRect.X = (int)(rpRect.X * rHorizontalRatio);
            rpRect.Y = (int)(rpRect.Y * rVerticalRatio);
            rpRect.Width = (int)(rpRect.Width * rHorizontalRatio);
            rpRect.Height = (int)(rpRect.Height * rVerticalRatio);

            NativeMethods.User32.SetWindowPos(r_HwndSource.Handle, IntPtr.Zero, rBrowserWindowRect.Left + rpRect.X, rBrowserWindowRect.Top + rpRect.Y, rpRect.Width, rpRect.Height, NativeEnums.SetWindowPosition.SWP_NOZORDER | NativeEnums.SetWindowPosition.SWP_NOACTIVATE | NativeEnums.SetWindowPosition.SWP_SHOWWINDOW);
        }
开发者ID:amatukaze,项目名称:IntelligentNavalGun,代码行数:35,代码来源:ScreenshotToolOverlayWindow.cs


示例6: RenderPages

        /// <summary>
        /// Generates an image of each page in the year book
        /// and saves it to the src folder
        /// </summary>
        /// <param name="bv"></param>
        /// <param name="folderloc"></param>
        private static void RenderPages(BookViewer bv, string folderloc)
        {
            int currentpage = bv.ViewIndex;
            //loops though each page
            foreach (Page p in bv.CurrentBook.Pages)
            {
                bv.ViewIndex = p.PageNumber;
                //forces the canvas to re-render
                BookViewer.DesignerCanvas.UpdateLayout();
                //takes a picture of the canvas
                RenderTargetBitmap rtb = new RenderTargetBitmap(PaperSize.Pixel.PaperWidth, PaperSize.Pixel.PaperHeight, 96, 96, PixelFormats.Default);
                rtb.Render(BookViewer.DesignerCanvas);
                //getting the bleed margin
                Int32Rect bleedmargin = new Int32Rect((PaperSize.Pixel.PaperWidth - PaperSize.Pixel.BleedWidth) / 2, (PaperSize.Pixel.PaperHeight - PaperSize.Pixel.BleedHeight) / 2, PaperSize.Pixel.BleedWidth, PaperSize.Pixel.BleedHeight);
                //cropping the image
                CroppedBitmap cb = new CroppedBitmap(rtb, bleedmargin);
                //encodes the image in png format
                PngBitmapEncoder pbe = new PngBitmapEncoder();
                pbe.Frames.Add(BitmapFrame.Create(cb));
                //saves the resulting image
                FileStream fs = File.Open(folderloc + "\\src\\" + (p.PageNumber+1) + ".png", FileMode.Create);
                pbe.Save(fs);
                fs.Flush();
                fs.Close();

            }
            bv.ViewIndex = currentpage;
        }
开发者ID:rakuza,项目名称:YBM2012,代码行数:34,代码来源:WebPublisher.cs


示例7: MainWindow

        public MainWindow()
        {
            InitializeComponent();
            try
            {

                CompositionTarget.Rendering += CompositionTarget_Rendering;

                //_kC.InitialCalibration();
                this._colorImageBitmapRect = new Int32Rect(0, 0, 640, 480);
                this._colorImageStride = 640 * 4;

                this._colorImageBitmap1 = new WriteableBitmap(640, 480, 96, 96, PixelFormats.Bgr32, null);
                this._colorImageBitmap2 = new WriteableBitmap(640, 480, 96, 96, PixelFormats.Bgr32, null);
                this._colorImageBitmap3 = new WriteableBitmap(640, 480, 96, 96, PixelFormats.Bgr32, null);
                this._colorImageBitmap4 = new WriteableBitmap(640, 480, 96, 96, PixelFormats.Bgr32, null);
                this._colorImageBitmap5 = new WriteableBitmap(640, 480, 96, 96, PixelFormats.Bgr32, null);

                this.ColorImageElement1.Source = this._colorImageBitmap1;
                this.ColorImageElement2.Source = this._colorImageBitmap2;
                this.ColorImageElement3.Source = this._colorImageBitmap3;
                this.ColorImageElement4.Source = this._colorImageBitmap4;
                this.ColorImageElement5.Source = this._colorImageBitmap5;

                //this.ColorImageElement1.Source = kC.GetDifferenceBitmap();

                //this.ColorImageElement3.Source = kC.GetPic2Bitmap();

            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.StackTrace);
            }
        }
开发者ID:eluechin,项目名称:KinectAutoCalibration,代码行数:34,代码来源:MainWindow.xaml.cs


示例8: Initialize

        public void Initialize(KinectSensor sensor)
        {
            this.sensor = sensor;
            coordinateMapper = new CoordinateMapper(sensor);

            //Prepare for RGB image information receive
            sensor.ColorStream.Enable(ColorImageFormat.RgbResolution1280x960Fps12);
            imageSize = new Int32Rect(0, 0, sensor.ColorStream.FrameWidth, sensor.ColorStream.FrameHeight);
            stride = imageSize.Width * 4; // blue, green, red, empty
            colorData = new byte[sensor.ColorStream.FramePixelDataLength];
            ColorBitmap = new WriteableBitmap(imageSize.Width, imageSize.Height, 96, 96, PixelFormats.Bgr32, null);

            TransformSmoothParameters smooth = new TransformSmoothParameters()
            {
                Smoothing = Parameters.Kinect.Smoothing,
                Correction = Parameters.Kinect.Correction,
                Prediction = Parameters.Kinect.Prediction,
                JitterRadius = Parameters.Kinect.JitterRadius,
                MaxDeviationRadius = Parameters.Kinect.MaxDeviationRadius
            };
            sensor.SkeletonStream.TrackingMode = Parameters.Kinect.TrackingMode;
            sensor.SkeletonStream.Enable(smooth);

            sensor.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(sensor_SkeletonFrameReady);
            sensor.ColorFrameReady += new EventHandler<ColorImageFrameReadyEventArgs>(sensor_ColorFrameReady);
            sensor.Start();
            Initialized = true;
        }
开发者ID:pentlandfirth,项目名称:PongForKinect,代码行数:28,代码来源:Kinect.cs


示例9: CalculateLuminanceRGB

      private void CalculateLuminanceRGB(BitmapSource bitmap)
      {
         var width = bitmap.PixelWidth;
         var height = bitmap.PixelHeight;
         var stepX = (bitmap.Format.BitsPerPixel + 7) / 8;
         var bufferSize = width * stepX;
         var buffer = new byte[bufferSize];
         var rect = new Int32Rect(0, 0, width, 1);
         var luminanceIndex = 0;

         luminances = new byte[width * height];

         for (var curY = 0; curY < height; curY++)
         {
            bitmap.CopyPixels(rect, buffer, bufferSize, 0);
            for (var curX = 0; curX < bufferSize; curX += stepX)
            {
               var r = buffer[curX];
               var g = buffer[curX + 1];
               var b = buffer[curX + 2];
               luminances[luminanceIndex] = (byte)
                  (0.3 * r + 0.59 * g + 0.11 * b + 0.01);
               luminanceIndex++;
            }
            rect.Y++;
         }
      }
开发者ID:Bogdan-p,项目名称:ZXing.Net,代码行数:27,代码来源:BitmapSourceLuminanceSource.cs


示例10: EncodeColorAsync

        public async Task EncodeColorAsync(byte[] colorData, BinaryWriter writer)
        {
            if (this.Width == this.OutputWidth && this.Height == this.OutputHeight)
            {
                // Header
                writer.Write(this.Width);
                writer.Write(this.Height);
                writer.Write(colorData.Length);

                // Data
                writer.Write(colorData);
            }
            else
            {
                WriteableBitmap bmp = BitmapFactory.New(this.Width, this.Height);
                int stride = this.Width * 4; // 4 bytes per pixel in BGRA
                var dirtyRect = new Int32Rect(0, 0, this.Width, this.Height);
                bmp.WritePixels(dirtyRect, colorData, stride, 0);
                var newBytes = await Task.FromResult(bmp.Resize(this.OutputWidth, this.OutputHeight, WriteableBitmapExtensions.Interpolation.NearestNeighbor).ToByteArray());

                // Header
                writer.Write(this.OutputWidth);
                writer.Write(this.OutputHeight);
                writer.Write(newBytes.Length);
                writer.Write(newBytes);

            }
        }
开发者ID:tonyly,项目名称:Kinect,代码行数:28,代码来源:RawCodec.cs


示例11: AddFrame

        public void AddFrame(string path, Int32Rect rect, int delay = 66)
        {
            //TODO: If global color is used, get all colors from all frames and write only 1 color table.
            GeneratePalette(path);

            CalculateColorTableSize();

            if (IsFirstFrame)
            {
                FullSize = rect;

                WriteLogicalScreenDescriptor(rect);

                //Global color table.
                if (UseGlobalColorTable)
                    WritePalette();

                if (RepeatCount > -1)
                    WriteApplicationExtension();
            }

            WriteGraphicControlExtension(delay);
            WriteImageDescriptor(rect);

            //TODO: If it has Global color table, no need to use local.
            //if uses global, all colors should be added to that palette.

            //Local color table.
            if (!UseGlobalColorTable)
                WritePalette();

            WriteImage();

            IsFirstFrame = false;
        }
开发者ID:dbremner,项目名称:ScreenToGif,代码行数:35,代码来源:GifFile.cs


示例12: KinectImage

        //セットアップ
        public KinectImage()
        #region
        {
            //キネクト
            this.kinect = KinectSensor.GetDefault();
            
            //bodyIndexFrameの処理
            this.bodyIndexFrameDes = this.kinect.BodyIndexFrameSource.FrameDescription;
            this.bodyIndexFrameReader = this.kinect.BodyIndexFrameSource.OpenReader();
            this.bodyIndexFrameReader.FrameArrived += this.BodyIndexFrame_Arrived;
            //画像情報
            this.kinectImgPackage = new ShadowPackage();
            this.imageWidth =  this.bodyIndexFrameDes.Width;  // imgW;
            this.imageHeight = this.bodyIndexFrameDes.Height; // imgH;

            this.imageBytePerPixel = (int)this.bodyIndexFrameDes.BytesPerPixel;
            this.bitmapRec = new Int32Rect(0, 0, this.imageWidth, this.imageHeight);
            this.bitmapStride = (int)(this.imageWidth * this.imageBytePerPixel);
           
            this.bodyIndexBuffer = new byte[this.imageWidth *
                                                this.imageHeight * this.imageBytePerPixel];
            this.kinectImage = new Mat(this.imageHeight, this.imageWidth, MatType.CV_8UC1);
            //キネクト開始
            this.kinect.Open();
            
        }
开发者ID:mahoo168,项目名称:mahoo,代码行数:27,代码来源:KinectImage.cs


示例13: GetPixelColor

        public Color GetPixelColor(int x, int y) {
            Color color;
            var bytesPerPixel = (_screenSource.Format.BitsPerPixel + 7) / 8;
            var bytes = new byte[bytesPerPixel];
            var rect = new Int32Rect(x, y, 1, 1);

            _screenSource.CopyPixels(rect, bytes, bytesPerPixel, 0);
            
            if (_screenSource.Format == PixelFormats.Pbgra32) {
                color = Color.FromArgb(bytes[3], bytes[2], bytes[1], bytes[0]);
            } else if (_screenSource.Format == PixelFormats.Bgr32) {
                color = Color.FromArgb(0xFF, bytes[2], bytes[1], bytes[0]);
            } else if (_screenSource.Format == PixelFormats.Bgra32) {
                color = Color.FromArgb(bytes[3], bytes[2], bytes[1], bytes[0]);
            } else {
                if (!_hasBeenWarned) {
                    Logging.Warning("Unsupported format: " + _screenSource.Format);
                    _hasBeenWarned = true;
                }

                color = Colors.Black;
            }

            return color;
        }
开发者ID:gro-ove,项目名称:actools,代码行数:25,代码来源:ScreenColorPickerDialog.xaml.cs


示例14: RenderMaterial

        public void RenderMaterial()
        {
            int width = (int)Width;
            int height = (int)Height;

            byte[] pixels = new byte[4 * height * width];
            WriteableBitmap writeableBitmap = new WriteableBitmap(width, height, 96, 96, PixelFormats.Bgra32, null);

            for (int p=0; p<width*height; p++)
            {
                Colour fillColour = _Material._DiffuseColour;
                fillColour.Clamp(0, 1);
                pixels[p*4] = (byte)(fillColour._Blue * 255.99f);
                pixels[p*4+1] = (byte)(fillColour._Green * 255.99f); 
                pixels[p*4+2] = (byte)(fillColour._Red * 255.99f); 
                pixels[p*4+3] = 255;
            }

            Int32Rect rect = new Int32Rect(0, 0, width, height);

            writeableBitmap.WritePixels(rect, pixels, width * 4, (int)0);

            MaterialImage.Source = writeableBitmap;

        }
开发者ID:dom767,项目名称:woofractal,代码行数:25,代码来源:MaterialControl.xaml.cs


示例15: CreateUVImage

        private void CreateUVImage()
        {
            this.Bitmap.Lock();

            var rect = new Int32Rect(0, 0, Bitmap.PixelWidth, Bitmap.PixelHeight);
            var bytesPerPixel = (Bitmap.Format.BitsPerPixel + 7) / 8; // 1 ピクセル当たりのバイト数(4 になるはず)
            var stride = Bitmap.PixelWidth * bytesPerPixel; // 幅方向のバイト数
            var arraySize = stride * Bitmap.PixelHeight;

            pixelEntity = new byte[arraySize];

            int index; // 左上隅からのバイトのインデックス

            for (int y = 0; y < Bitmap.PixelHeight; ++y)
            {
                for (int x = 0; x < Bitmap.PixelWidth; ++x)
                {
                    index = x * bytesPerPixel + y * stride;

                    var r = (byte)(((double)x / Bitmap.PixelWidth) * 255);
                    var g = (byte)(((double)y / Bitmap.PixelHeight) * 255);

                    pixelEntity[index] = 0;
                    pixelEntity[index + 1] = g;
                    pixelEntity[index + 2] = r;
                    pixelEntity[index + 3] = 255;
                }
            }
            Bitmap.WritePixels(rect, pixelEntity, stride, 0);

            this.Bitmap.Unlock();
        }
开发者ID:IrisTechnica,项目名称:Iris-Engine,代码行数:32,代码来源:UVNodeViewModel.cs


示例16: Convert

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var exposure = value as Exposure;

            if (exposure != null)
            {
                if (_exposureBitmap == null ||
                    ((int)_exposureBitmap.Width != exposure.Width || (int)_exposureBitmap.Height != exposure.Height))
                {
                    _exposureBitmap = new WriteableBitmap(exposure.Width, exposure.Height, 96, 96,
                        PixelFormats.Gray8, null);

                }
                var fullRect = new Int32Rect(0, 0, (int) _exposureBitmap.Width, (int) _exposureBitmap.Height);

                GCHandle pinnedExposureBuf = GCHandle.Alloc(exposure.Pixels8Bit, GCHandleType.Pinned);
                IntPtr exposureBufPtr = pinnedExposureBuf.AddrOfPinnedObject();

                for (int i = 0; i < exposure.Height; i++)
                {
                    int skip = i*_exposureBitmap.BackBufferStride;
                    int ppos = i*exposure.Width;
                    CopyMemory(_exposureBitmap.BackBuffer + skip, exposureBufPtr + ppos, (uint)exposure.Width);
                }

                _exposureBitmap.Lock();
                _exposureBitmap.AddDirtyRect(fullRect);
                _exposureBitmap.Unlock();

                return _exposureBitmap;

            }

            return null;
        }
开发者ID:Jusas,项目名称:DSImager,代码行数:35,代码来源:ExposureToImageConverter.cs


示例17: Figure

 public Figure(int figureIdx, int pageIdx, Int32Rect figRect, string[] triggerTxt)
 {
     this.PageIndex = pageIdx;
       this.FigureIndex = figureIdx;
       this.FigureRect = figRect;
       this.TriggerText = triggerTxt;
 }
开发者ID:hcilab-um,项目名称:tPad,代码行数:7,代码来源:Figures.cs


示例18: CreateImage

        public unsafe void CreateImage(WriteableBitmap target, IntPtr pointer)
        {
            Int32Rect rectangle = default(Int32Rect);
            target.Dispatcher.Invoke(new Action(() =>
            {
                rectangle = new Int32Rect(0, 0, target.PixelWidth, target.PixelHeight);
            }));

            this.CreateHistogram(pointer, rectangle.Width, rectangle.Height);
            var pixelcount = rectangle.Width * rectangle.Height;
            var buffer = new byte[pixelcount * 3];
            try
            {
                ushort* pDepth = (ushort*)pointer;
                for (int index = 0; index < pixelcount; index++)
                {
                    byte pixel = (byte)histogram.GetValue(*pDepth);
                    buffer[index * 3] = pixel;
                    buffer[index * 3 + 1] = pixel;
                    buffer[index * 3 + 2] = pixel;
                    pDepth++;
                }
            }
            catch (AccessViolationException)
            { }
            catch (SEHException)
            { }

            target.Dispatcher.Invoke(new Action(() =>
                {
                    target.Lock();
                    target.WritePixels(rectangle, buffer, rectangle.Width * 3, 0);
                    target.Unlock();
                }));
        }
开发者ID:aabrohi,项目名称:kinect-kollage,代码行数:35,代码来源:DepthImageSourceFactory.cs


示例19: CreateScreenshot

        /// <summary>Creates the screenshot of entire plotter element</summary>
        /// <returns></returns>
        internal static BitmapSource CreateScreenshot(UIElement uiElement, Int32Rect screenshotSource)
        {
            Window window = Window.GetWindow(uiElement);
            if (window == null)
            {
                return CreateElementScreenshot(uiElement);
            }
            Size size = window.RenderSize;

            //double dpiCoeff = 32 / SystemParameters.CursorWidth;
            //int dpi = (int)(dpiCoeff * 96);
            double dpiCoeff = 1;
            int dpi = 96;

            RenderTargetBitmap bmp = new RenderTargetBitmap(
                (int)(size.Width * dpiCoeff), (int)(size.Height * dpiCoeff),
                dpi, dpi, PixelFormats.Default);

			// white background
			Rectangle whiteRect = new Rectangle { Width = size.Width, Height = size.Height, Fill = Brushes.White };
			whiteRect.Measure(size);
			whiteRect.Arrange(new Rect(size));
			bmp.Render(whiteRect);
			// the very element
            bmp.Render(uiElement);

            CroppedBitmap croppedBmp = new CroppedBitmap(bmp, screenshotSource);
            return croppedBmp;
        }
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:31,代码来源:ScreenshotHelper.cs


示例20: UpdateBitmap

 /// <summary>
 /// Update the bitmap with the given byte array.
 /// </summary>
 /// <param name="data">the length of the data must be equal to this.width * this.height</param>
 public void UpdateBitmap(byte[] data, WriteableBitmap bitmap)
 {
     var stride = bitmap.PixelWidth * bitmap.Format.BitsPerPixel / 8;
       var rect = new Int32Rect(0, 0, bitmap.PixelWidth, bitmap.PixelHeight);
       bitmap.WritePixels(rect, data, stride, 0);
       RaisePropertyChanged(() => bitmap);
 }
开发者ID:ushadow,项目名称:handinput,代码行数:11,代码来源:DebugDisplayManager.cs



注:本文中的System.Windows.Int32Rect类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Windows.Point类代码示例发布时间:2022-05-26
下一篇:
C# Windows.GiveFeedbackEventArgs类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap