public static BitmapSource MakeFrame(System.Drawing.Size fullSize, BitmapSource rawFrame, FrameMetadata metadata, BitmapSource baseFrame) { //I removed this, so I could save the same as 32bpp //if (baseFrame == null && IsFullFrame(metadata, fullSize)) //{ // // No previous image to combine with, and same size as the full image // // Just return the frame as is // return rawFrame; //} DrawingVisual visual = new DrawingVisual(); using (var context = visual.RenderOpen()) { if (baseFrame != null) { var fullRect = new Rect(0, 0, fullSize.Width, fullSize.Height); context.DrawImage(baseFrame, fullRect); } var rect = new Rect(metadata.Left, metadata.Top, metadata.Width, metadata.Height); context.DrawImage(rawFrame, rect); } //TODO: Test, DPI was hardcoded to 96. var bitmap = new RenderTargetBitmap(fullSize.Width, fullSize.Height, rawFrame.DpiX, rawFrame.DpiY, PixelFormats.Pbgra32); bitmap.Render(visual); if (bitmap.CanFreeze && !bitmap.IsFrozen) { bitmap.Freeze(); } return(bitmap); }
public static bool IsFullFrame(FrameMetadata metadata, System.Drawing.Size fullSize) { return(metadata.Left == 0 && metadata.Top == 0 && metadata.Width == fullSize.Width && metadata.Height == fullSize.Height); }
public SaveImageWindows(ImageSource imageSource, List <Contour <System.Drawing.Point> > contours, double strokeThickness, Size size) { InitializeComponent(); _imageSource = imageSource; _contours = contours; _strokeThickness = strokeThickness; _size = size; }
public VideoControlWrapper() { ClientSize = new System.Drawing.Size(1, 1); BitmapImage src = new BitmapImage(); src.BeginInit(); src.UriSource = new Uri(@"pack://application:,,,/VATRP.Linphone.VideoWrapper;component/Resources/camera_mute.png", UriKind.Absolute); src.EndInit(); _cameraBitmap = BitmapSourceToBitmap(src); }
private Image CutEllipse(Image img, Rectangle rec, System.Drawing.Size size) { Bitmap bitmap = new Bitmap(size.Width, size.Height); using (Graphics g = Graphics.FromImage(bitmap)) { using (TextureBrush br = new TextureBrush(img, System.Drawing.Drawing2D.WrapMode.Clamp, rec)) { br.ScaleTransform(bitmap.Width / (float)rec.Width, bitmap.Height / (float)rec.Height); g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; g.FillEllipse(br, new Rectangle(System.Drawing.Point.Empty, size)); } } return(bitmap); }
private void ScaleImageSizeToPrintRect(RectangleF printRect, System.Drawing.Size imageSize, out System.Drawing.Size scaledSize) { double width, height; double ratio; // fit the width of the image inside the width of the print Rectangle ratio = printRect.Width / imageSize.Width; width = imageSize.Width * ratio; height = imageSize.Height * ratio; // fit the other dimension if (height > printRect.Height) { ratio = printRect.Height / height; width *= ratio; height *= ratio; } scaledSize = new System.Drawing.Size((int)width, (int)height); }
public void Start(Size simulationSize) { _simulationSize = simulationSize; _loadedSettings = new WaveSettings(simulationSize); _additionalSettings = new WaveSettings(simulationSize); _waveEngineRef.Settings = _loadedSettings; }
private SharpImage(Image image, SharpImageFormat format) { _image = image; _format = format; SourceSize = new System.Drawing.Size(image.Width, image.Height); }
//internal string prevName = ""; protected override void OnLoad(EventArgs e) { window.Size = window.DefaultSize; ClientSize = new System.Drawing.Size(window.Size.DPoint()); frame.Position = this.PointToScreen(new DPoint(0, 0)).PxVector(); frame.Size = new PxVector(ClientSize.Width, ClientSize.Height); frame.SetWindowDims(); RemakeTarget(); }
public static void Execute() { List <Bitmap> bitmaps = new List <Bitmap>(); IntPtr tmpPtr = FindWindow("Notepad", null); if (tmpPtr.Equals(IntPtr.Zero)) { MessageBox.Show("Target application is not open", "Error"); return; } IntPtr intPtr = FindWindowEx(tmpPtr, IntPtr.Zero, "Edit", null); if (intPtr.Equals(IntPtr.Zero)) { MessageBox.Show("Target application is not open", "Error"); return; } SetActiveWindow(tmpPtr); Point defaultPnt = default; SCROLLINFO VScrInfo = new SCROLLINFO(); VScrInfo.cbSize = (uint)Marshal.SizeOf(VScrInfo); VScrInfo.fMask = (int)ScrollInfoMask.SIF_ALL; // GetScrollInfo GetScrollInfo(intPtr, (int)ScrollBarDirection.SB_VERT, ref VScrInfo); double pageCount = Math.Truncate((double)VScrInfo.nMax / VScrInfo.nPage); int finalScrPos = 0; for (int i = 0; i < pageCount + 1; i++) { Point origin = default; int operationInt; if (i == 0) { operationInt = SB_PAGETOP; } else { operationInt = SB_PAGEDOWN; } PostMessage(intPtr, 0x115, operationInt, 0); System.Threading.Thread.Sleep(100); ClientToScreen(intPtr, ref origin); GetClientRect(intPtr, out RECT rect); int height; int margin = 0; if (i == pageCount - 1) { GetScrollInfo(intPtr, (int)ScrollBarDirection.SB_VERT, ref VScrInfo); finalScrPos = VScrInfo.nPos; } if (i == pageCount) { GetScrollInfo(intPtr, (int)ScrollBarDirection.SB_VERT, ref VScrInfo); margin = (int)(rect.Height * (VScrInfo.nPos - finalScrPos) / VScrInfo.nPage); height = margin; } else { height = rect.Height; } using (var bmp = new Bitmap(rect.Width, height)) { using (var g = Graphics.FromImage(bmp)) { Size size = rect.Size; if (i == pageCount) { size = new System.Drawing.Size(rect.Width, margin); g.CopyFromScreen(new Point(origin.X + rect.Left, origin.Y + rect.Top + rect.Height - margin), defaultPnt, size); } else { g.CopyFromScreen(new Point(origin.X + rect.Left, origin.Y + rect.Top), defaultPnt, size); } bitmaps.Add((Bitmap)bmp.Clone()); } } } var hBitmap = ImageCombineV(bitmaps).GetHbitmap(); try { var bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions() ); Clipboard.SetImage(bitmapSource); } finally { DeleteObject(hBitmap); } }