public MainWindow() { InitializeComponent(); this.paragraph = new Paragraph(); LogTextBox.Document = new FlowDocument(paragraph); Logger.mainTextBoxBase = paragraph; Logger.richTextBox = LogTextBox; this.DataContext = this; RenessansLogo.Background = new ImageBrush { ImageSource = Imaging.CreateBitmapSourceFromHBitmap( Properties.Resources.white_500.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(Properties.Resources.white_500.Width, Properties.Resources.white_500.Height)) }; SourceInitialized += (s, e) => { IntPtr handle = (new WindowInteropHelper(this)).Handle; HwndSource.FromHwnd(handle)?.AddHook(new HwndSourceHook(WindowProc)); }; MinimizeButton.Click += (sender, args) => WindowState = WindowState.Minimized; CloseButton.Click += (sender, args) => Close(); RenessansLogo.MouseDown += (sender, args) => Process.Start("https://github.com/RDIL/Destroy-Windows-10-Spying"); CheckSystemStatus(); AboutInfo.Text = "Destroy Windows Spying (DWS) - a free utility that prevents tracking of your activity in Windows 10 and enhances the security and privacy settings of the operating system from Microsoft.\r\n\r\n\r"; }
public ImageSource CreateText(string text) { if (imgs.ContainsKey(text)) { return(imgs[text]); } var bmp = new System.Drawing.Bitmap(CellWidth, CellHeight); var g = System.Drawing.Graphics.FromImage(bmp); g.SmoothingMode = SmoothingMode.AntiAlias; g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; var fontOjb = new System.Drawing.Font(font, 12); var size = g.MeasureString(text, fontOjb); var spanWidth = (CellWidth - size.Width) / 2; var spanHeight = (CellHeight - size.Height) / 2; g.DrawString(text, fontOjb, System.Drawing.Brushes.Black, new System.Drawing.PointF(spanWidth, spanHeight)); g.Dispose(); var img = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(bmp.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(bmp.Width, bmp.Height)); imgs.Add(text, img); return(img); }
public BusinessWeatherForecast Make(WeatherForecast weatherForecast) { var bitmap = Resources.ResourceManager.GetObject(weatherForecast.CurrentForecast.Icon) as Bitmap; var bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( bitmap.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(100, 100)); BusinessWeatherForecast forecast = new BusinessWeatherForecast { Date = formatter.GetNumberAndMonth(weatherForecast.CurrentForecast.Time), Time = formatter.GetTime(weatherForecast.CurrentForecast.Time), Temperature = Convert.ToInt32(((weatherForecast.CurrentForecast.Temperature - 32) * 5 / 9)).ToString(), WindSpeed = weatherForecast.CurrentForecast.WindSpeed.ToString(), CloudCover = weatherForecast.CurrentForecast.Summary, Icon = bitmapSource, WeekForecast = weatherForecast.WeekForecast.WeekForecasts.Select(df => new BusinessDailyForecast { DayWeek = formatter.GetWeekDay(df.Time), Date = formatter.GetShortDate(df.Time), RangeTemperature = df.TemperatureMin.ToString() + "-" + df.TemperatureMax.ToString(), WindSpeed = df.WindSpeed.ToString(), Icon = Application.Current.Resources[df.Icon] }).ToList(), }; return(forecast); }
private void DataGridAns_SelectionChanged(object sender, SelectionChangedEventArgs e) { var select = template.AnsData.Count != 0 && DataGridAns.SelectedIndex >= 0; System.Drawing.Bitmap preview2; if (!select) { preview2 = preview; } else { int x = template.AnsData[DataGridAns.SelectedIndex].StartX; int y = template.AnsData[DataGridAns.SelectedIndex].StartY; int c = template.AnsData[DataGridAns.SelectedIndex].Count; int l = template.AnsData[DataGridAns.SelectedIndex].Length; var o = template.AnsData[DataGridAns.SelectedIndex].OrderType; var pointList = Helper.AreaToPointList(x, y, o == AnswerSheetChecker.Template.TemplateData.Type.Horizontal ? c : l, o == AnswerSheetChecker.Template.TemplateData.Type.Horizontal ? l : c, template); preview2 = OMR.ImageDrawing.Draw(OMR.ImageDrawing.Mode.Cross, preview, pointList, System.Drawing.Color.Blue, 3); } ImagePreview.Source = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( preview2.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(preview2.Width, preview2.Height)); }
public static BitmapSource GetBitmapSource(Bitmap bmp, out IntPtr exDelete) { exDelete = bmp.GetHbitmap(); return(System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( exDelete, IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(bmp.Width, bmp.Height))); }
public static System.Windows.Media.Imaging.BitmapSource GetIconDll(string fileName) { BitmapSource myIcon = null; Boolean validDrive = false; foreach (DriveInfo D in System.IO.DriveInfo.GetDrives()) { //D.DriveType. if (fileName == D.Name) { validDrive = true; } } if ((File.Exists(fileName)) || (Directory.Exists(fileName)) || (validDrive)) { using (System.Drawing.Icon sysIcon = ShellIcon.GetLargeIcon(fileName)) { try { myIcon = System.Windows.Interop.Imaging.CreateBitmapSourceFromHIcon( sysIcon.Handle, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(34, 34)); } catch { myIcon = null; } } } return(myIcon); }
public ResHolderDigitSymbol() { Bitmap bitmapO = FiveElementsIntTest.Properties.Resources.rightimg;//替换原来的circle mImageO = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( bitmapO.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(bitmapO.Width, bitmapO.Height)); Bitmap bitmapX = FiveElementsIntTest.Properties.Resources.X; mImageX = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( bitmapX.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(bitmapX.Width, bitmapX.Height)); Bitmap bitmapBar = FiveElementsIntTest.Properties.Resources.BAR; mImageBar = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( bitmapBar.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(bitmapBar.Width, bitmapBar.Height)); Bitmap bitmapArrow = FiveElementsIntTest.Properties.Resources.arrow; mImageArrow = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( bitmapArrow.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(bitmapArrow.Width, bitmapArrow.Height)); }
private void MaskEvent() { Nullable <bool> result = file.ShowDialog(); if (result == true) { maskImage = factory.Load(file.FileName).Image; ImageLayer layer = new ImageLayer(); layer.Image = targetImage; var resultImage = factory.Mask(layer).Image; bitmap = new Bitmap(resultImage); var hbitmap = bitmap.GetHbitmap(); var option = BitmapSizeOptions.FromWidthAndHeight(targetImage.Width, targetImage.Height); TargetSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( hbitmap, IntPtr.Zero, Int32Rect.Empty, option ); } }
protected override void OnExecute(object parameter) { var s = new Bitmap(Properties.Resources.png_undo_16_16); var w = new TestWindow { Background = Brushes.Green, Grid = { Margin = new Thickness(50), Background = Brushes.Red } }; var b = ImageThemingUtilities.GetThemedBitmap(s, ImageThemingUtilities.GetImageBackgroundColor(w.Grid).ToRgba()); BitmapSource bs = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( b.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(b.Width, b.Height)); w.Icon = bs; w.ShowDialog(); //new FolderBrowserDialog().ShowDialog(); }
public static BitmapSource ImgViewAtN(System.Drawing.Image imgsrc, int X, int Y, int spriteWidth, int spriteHeight) { Bitmap imgdst = new Bitmap(spriteWidth, spriteHeight); // Bitmap drawing_surface = new Bitmap(500, 500); Graphics GFX = Graphics.FromImage(imgdst); GFX.DrawImage(imgsrc, new System.Drawing.RectangleF(0, 0, imgdst.Width, imgdst.Height), new System.Drawing.RectangleF(X, Y, spriteWidth, spriteHeight), GraphicsUnit.Pixel); // Create Image Element //System.Windows.Controls.Image myImage = new System.Windows.Controls.Image(); //myImage.Width = 200; BitmapSource bs = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( imgdst.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(imgdst.Width, imgdst.Height)); return(bs); //} //else //{ // return null; //} }
public WindowColorPick() { InitializeComponent(); // Determine the size of the "virtual screen" which includes all monitors int screenLeft = (int)SystemParameters.VirtualScreenLeft; int screenTop = (int)SystemParameters.VirtualScreenTop; int screenWidth = (int)SystemParameters.VirtualScreenWidth; int screenHeight = (int)SystemParameters.VirtualScreenHeight; // Expand the window to all monitors this.Top = 0; this.Left = 0; this.Width = screenWidth; this.Height = screenHeight; // Take a screenshot of all monitors using (Bitmap bmp = new Bitmap(screenWidth, screenHeight)) { // Draw the screenshot into our bitmap. using (Graphics g = Graphics.FromImage(bmp)) { g.CopyFromScreen(screenLeft, screenTop, 0, 0, bmp.Size); } // Convert Bitmap to ImageBrush and set as background BSSceenshot = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( bmp.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(bmp.Width, bmp.Height)); } }
private void AddDataGroupInit(Type type, Template template, Template.TemplateData data, Action <Template.TemplateData> f) { this.type = type; this.template = template; callback = f; InitializeComponent(); if (type == Type.Info) { TextBlockNumberChoice.Text = ""; TextBoxNumberChoice.IsEnabled = false; TextBoxNumberChoice.Text = "10"; } else { TextBlockName.Text = "เริ่มข้อที่"; TextBoxName.Text = (data.Offset + data.Count + 1).ToString(); TextBoxName.IsEnabled = false; TextBlockNumberAns.Text = "จำนวนข้อ"; } preview = OMR.ImageDrawing.Draw(OMR.ImageDrawing.Mode.Circle, template.Image.Width, template.Image.Height, template.PointsList, System.Drawing.Color.Black, 2); ImagePreview.Source = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( preview.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(preview.Width, preview.Height)); }
public static ImageSource GetSystemIcon(string path, IconSize iconSize, IconType iconType, FileAttributes fileAttributes = new FileAttributes()) { Size size = GetImageSize(iconSize); SHGFI flags = SHGFI.SHGFI_SYSICONINDEX | (iconSize == IconSize.Small ? SHGFI.SHGFI_SMALLICON : SHGFI.SHGFI_LARGEICON); switch (iconType) { case IconType.System: flags |= SHGFI.SHGFI_USEFILEATTRIBUTES; break; case IconType.File: flags |= SHGFI.SHGFI_ICON; break; default: break; } SHFILEINFO shfi = new SHFILEINFO(); IntPtr iconHandle = IntPtr.Zero; ImageSource imageSource = null; try { SHGetFileInfo(path, fileAttributes, ref shfi, SHFILEINFO.Size, flags); IImageList imageList = null; Guid guid = new Guid(IID_IImageList); SHGetImageList((int)iconSize, ref guid, ref imageList); imageList.GetIcon(shfi.iIcon, (int)(IMAGELISTDRAWFLAGS.ILD_TRANSPARENT | IMAGELISTDRAWFLAGS.ILD_IMAGE), ref iconHandle); using (Icon icon = (Icon)Icon.FromHandle(iconHandle).Clone()) { imageSource = Imaging.CreateBitmapSourceFromHIcon( icon.Handle, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(size.Width, size.Height)); } } catch (Exception) { } finally { if (shfi.hIcon != IntPtr.Zero) { DestroyIcon(shfi.hIcon); } if (iconHandle != IntPtr.Zero) { DestroyIcon(iconHandle); } } return(imageSource); }
private void WebBrowser_DocumentTitleChanged(object sender, EventArgs e) { var webBrowser = (WebBrowser)sender; if (webBrowser.DocumentTitle != "done") { return; } //webBrowser.Width = 600; //webBrowser.Height = 900; var newSize = webBrowser.Document.Body.ScrollRectangle.Size; newSize.Height = newSize.Height + 20; newSize.Width = newSize.Width + 20; webBrowser.Size = newSize; using (Bitmap bitmap = new Bitmap( webBrowser.Width, webBrowser.Height)) { webBrowser.DrawToBitmap(bitmap, new Rectangle(0, 0, bitmap.Width, bitmap.Height)); currentImage = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( bitmap.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(webBrowser.Width, webBrowser.Height)); bitmap.Save(rootDir + @"\Reklamer\lvlUp.jpg", System.Drawing.Imaging.ImageFormat.Jpeg); } }
private void m_timer_Tick(object sender, EventArgs e) { if (m_currIndex < m_animationIcons.Length) { var bitmap = m_animationIcons[m_currIndex].ToBitmap(); m_notifyIcon.Icon = Imaging.CreateBitmapSourceFromHBitmap(bitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight( bitmap.Width, bitmap.Height)); m_currIndex++; } else { m_currIndex = 0; if (m_loopCount <= 0) { m_timer.Stop(); m_notifyIcon.Icon = m_DefaultIcon; } else { --m_loopCount; } } }
private void ButtonTestImage_OnClick(object sender, RoutedEventArgs e) { var backgroundImage = new Bitmap(@"Assets\dial.png"); //Compass circle System.Drawing.Size finalSize = backgroundImage.Size; var foregroundImage = new Bitmap(@"Assets\arrow.png");//Compass needle foregroundImage = new Bitmap(foregroundImage, 13, 65); var finalImage = new Bitmap(finalSize.Width, finalSize.Height); using (var graphics = Graphics.FromImage(finalImage)) { graphics.DrawImage(backgroundImage, 0, 0, backgroundImage.Width, backgroundImage.Height); graphics.TranslateTransform(backgroundImage.Width / 2f, backgroundImage.Height / 2f); graphics.RotateTransform(_angle); graphics.TranslateTransform(foregroundImage.Width / -2f, foregroundImage.Height / -2f); graphics.DrawImage(foregroundImage, Point.Empty); } var image = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(finalImage.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(finalSize.Width, finalSize.Height)); ImageTest.Source = image; _angle += 20; if (_angle >= 360) { _angle = 0; } }
public static BitmapSource GetIconForFile(string filename) { BitmapSource resultIcon = null; //var driveInfo = DriveInfo.GetDrives().First(p => p.Name == filename); //bool valid = DriveInfo.GetDrives().First(p => p.Name == filename).IsReady; if (File.Exists(filename) || Directory.Exists(filename)) { using (Icon windowsIcon = ShellIcon.GetLargeIcon(filename)) { try { resultIcon = Imaging.CreateBitmapSourceFromHIcon( windowsIcon.Handle, Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(34, 34)); } catch (Exception e) { resultIcon = null; } } } return(resultIcon); }
private static BitmapSource getShellThumbnail(object fileName) { int pixelWidth = 150; int pixelHeight = 120;//todo: sta thread try { using (var st = new ShellThumbnail { DesiredSize = new System.Drawing.Size(pixelWidth, pixelHeight) }) { using (var pic = st.GetThumbnail(fileName.ToString())) { return(Imaging.CreateBitmapSourceFromHBitmap( pic.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(pixelWidth, pixelHeight))); } } } catch (Exception ex) { //todo: log ... } return(null); }
protected ImageSource RenderImage(int imageWidth, int imageHeight, Action <Graphics> renderObject) { BitmapSource bmpSource; using (var bmp = new Bitmap(imageWidth, imageHeight)) { using (var g = Graphics.FromImage(bmp)) { renderObject(g); } var hBitmap = bmp.GetHbitmap(); try { bmpSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(bmp.Width, bmp.Height)); } finally { DeleteObject(hBitmap); } } bmpSource.Freeze(); return(bmpSource); }
public TextPointer AddFlag(TextRange range, string name) { range.ApplyPropertyValue(TextElement.BackgroundProperty, Brushes.PaleGreen); var tempImage = Properties.Resources.romb; var ScreenCapture = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( tempImage.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(20, 20)); var image = new Image(); image.Source = ScreenCapture; image.Stretch = Stretch.Fill; image.Cursor = Cursors.Hand; image.Height = 14; image.Width = 14; image.Tag = name; image.MouseUp += Image_MouseUp; // TextPointer p = TextBox.MainControl.Selection.Start; TextBox.MainControl.BeginChange(); InlineUIContainer imageContainer = new InlineUIContainer(image, range.Start); imageContainer.Unloaded -= BrowseProject.Element_Unloaded; imageContainer.Unloaded += BrowseProject.Element_Unloaded; TextBox.MainControl.EndChange(); TextBox.MainControl.Focus(); return(imageContainer.ContentStart); // TextBox.MainControl.CaretPosition = imageContainer.ElementEnd; }
public QRCode(string data, string roomId, string title) { InitializeComponent(); //textBox.Text = data; if (roomId != null && roomId.Length == 5) { // 设置label的逻辑 added by vincentsong 0512 label1.Content = roomId.Substring(0, 1); label2.Content = roomId.Substring(1, 1); label3.Content = roomId.Substring(2, 1); label4.Content = roomId.Substring(3, 1); label5.Content = roomId.Substring(4, 1); } Title = title; var qrCodeEncoder = new QRCodeEncoder(); qrCodeEncoder.QRCodeScale = 16; var image = qrCodeEncoder.Encode(data, Encoding.UTF8); var imageSrc = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( image.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(image.Width, image.Height)); imgBox.Source = imageSrc; }
public GraphicToken(TokenType type, GraphControl control) { InitializeComponent(); mType = type; mControl = control; Bitmap bmp = null; switch (type) { case TokenType.DARKCIRCLE: bmp = FiveElementsIntTest.Properties.Resources.CSDarkblueCircle; break; case TokenType.LIGHTCIRCLE: bmp = FiveElementsIntTest.Properties.Resources.CSLightblueCircle; break; case TokenType.TRIANGLE: bmp = FiveElementsIntTest.Properties.Resources.CSTriangle; break; } amImage.Source = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(bmp.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(bmp.Width, bmp.Height)); HALF_WIDHT = bmp.Width / 2; HALF_HEIGHT = bmp.Height / 2; setAsIdle(); }
private PageContent generatePageContent(System.Drawing.Bitmap bmp, int top, int bottom, double pageWidth, double PageHeight, System.Printing.PrintCapabilities capabilities) { FixedPage printDocumentPage = new FixedPage(); printDocumentPage.Width = pageWidth; printDocumentPage.Height = PageHeight; int newImageHeight = bottom - top; System.Drawing.Bitmap bmpPage = bmp.Clone(new System.Drawing.Rectangle(0, top, bmp.Width, newImageHeight), System.Drawing.Imaging.PixelFormat.Format32bppArgb); // Create a new bitmap for the contents of this page Image pageImage = new Image(); BitmapSource bmpSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( bmpPage.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(bmp.Width, newImageHeight)); pageImage.Source = bmpSource; pageImage.VerticalAlignment = VerticalAlignment.Top; // Place the bitmap on the page printDocumentPage.Children.Add(pageImage); PageContent pageContent = new PageContent(); ((System.Windows.Markup.IAddChild)pageContent).AddChild(printDocumentPage); FixedPage.SetLeft(pageImage, capabilities.PageImageableArea.OriginWidth); FixedPage.SetTop(pageImage, capabilities.PageImageableArea.OriginHeight); pageImage.Width = capabilities.PageImageableArea.ExtentWidth; pageImage.Height = capabilities.PageImageableArea.ExtentHeight; return(pageContent); }
//put the given image into the right image view and set this output image for further work private void SetOutputImage(Bitmap outputBitmap) { var hBitmap = outputBitmap.GetHbitmap(); var imgOut = ((System.Windows.Controls.Image) this.FindName("OutputImage")); if (imgOut.Source != null) { imgOut.Source = null; } try { var imageSource = Imaging.CreateBitmapSourceFromHBitmap( hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(outputBitmap.Width, outputBitmap.Height)); imageSource.Freeze(); imgOut.Source = imageSource; } finally { DeleteObject(hBitmap); imgOut.Width = outputBitmap.Width; imgOut.Height = outputBitmap.Height; var outputInfoLabel = ((System.Windows.Controls.Label) this.FindName("OutputInfoLabel")); outputInfoLabel.Content = $"x:{outputBitmap.Width} y:{outputBitmap.Height}"; } }
//put the bitmap as input image and set it for next steps private void SetInputImage(Bitmap inputBitmap) { var hBitmap = inputBitmap.GetHbitmap(); var imgIn = ((System.Windows.Controls.Image) this.FindName("InputImage")); if (imgIn.Source != null) { imgIn.Source = null; } try { var imageSource = Imaging.CreateBitmapSourceFromHBitmap( hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(inputBitmap.Width, inputBitmap.Height)); imageSource.Freeze(); imgIn.Source = imageSource; } finally { DeleteObject(hBitmap); imgIn.Width = inputBitmap.Width; imgIn.Height = inputBitmap.Height; var inputInfoLabel = ((System.Windows.Controls.Label) this.FindName("InputInfoLabel")); inputInfoLabel.Content = $"x:{inputBitmap.Width} y:{inputBitmap.Height}"; inputImage = FilterImageConvert.FilterImageFromBitmap(inputBitmap); } }
/// <summary> /// Create UI on StartUp /// </summary> /// <param name="application"></param> /// <returns></returns> public Result OnStartup(UIControlledApplication application) { RibbonPanel grevitPanel = null; foreach (RibbonPanel rpanel in application.GetRibbonPanels()) { if (rpanel.Name == "Grevit") { grevitPanel = rpanel; } } if (grevitPanel == null) { grevitPanel = application.CreateRibbonPanel("Grevit"); } PushButton commandButton = grevitPanel.AddItem(new PushButtonData("GrevitCommand", "Grevit", path, "Grevit.Revit.GrevitCommand")) as PushButton; commandButton.LargeImage = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( Properties.Resources.paper_airplane.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(32, 32)); commandButton.SetContextualHelp(new ContextualHelp(ContextualHelpType.Url, "http://grevit.net/")); PushButton parameterButton = grevitPanel.AddItem(new PushButtonData("ParameterNames", "Parameter names", path, "Grevit.Revit.ParameterNames")) as PushButton; parameterButton.LargeImage = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( Properties.Resources.tag_hash.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(32, 32)); parameterButton.SetContextualHelp(new ContextualHelp(ContextualHelpType.Url, "http://grevit.net/")); PushButton getFaceRefButton = grevitPanel.AddItem(new PushButtonData("GetFaceReference", "Face Reference", path, "Grevit.Revit.GrevitFaceReference")) as PushButton; getFaceRefButton.LargeImage = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( Properties.Resources.radio_button.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(32, 32)); getFaceRefButton.SetContextualHelp(new ContextualHelp(ContextualHelpType.Url, "http://grevit.net/")); PushButton speckleButton = grevitPanel.AddItem(new PushButtonData("Speckle Client", "Speckle Client", path, "Grevit.Revit.GrevitFaceReference")) as PushButton; speckleButton.LargeImage = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( Properties.Resources.speckle.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(32, 32)); speckleButton.SetContextualHelp(new ContextualHelp(ContextualHelpType.Url, "https://github.com/speckleworks/Grevit")); return(Result.Succeeded); }
public static BitmapSource ConvertBitmap(Bitmap source) { return(System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( source.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(1920, 1080))); }
public static ImageSource GetImageSource(this Bitmap bitMap) { return(System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( bitMap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(bitMap.Width, bitMap.Height))); }
private static BitmapSource ConvertToBitmapSource(MandelBrotArgs args, Bitmap pic) { return(Imaging.CreateBitmapSourceFromHBitmap(pic.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight((int)args.Size.Width, (int)args.Size.Height))); }
public static BitmapSource GetBitmapSourceFromBitmap(Bitmap bitmap) { return(Imaging.CreateBitmapSourceFromHBitmap( bitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(bitmap.Width, bitmap.Height))); }