static ShadowWindow() { ActiveBottomImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/ActiveBottom.png")); ActiveBottomImage.Freeze(); ActiveBottomLeftImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/ActiveBottomLeft.png")); ActiveBottomLeftImage.Freeze(); ActiveBottomRightImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/ActiveBottomRight.png")); ActiveBottomRightImage.Freeze(); ActiveLeftImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/ActiveLeft.png")); ActiveLeftImage.Freeze(); ActiveRightImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/ActiveRight.png")); ActiveRightImage.Freeze(); ActiveTopImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/ActiveTop.png")); ActiveTopImage.Freeze(); ActiveTopLeftImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/ActiveTopLeft.png")); ActiveTopLeftImage.Freeze(); ActiveTopRightImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/ActiveTopRight.png")); ActiveTopRightImage.Freeze(); InactiveBottomImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/InactiveBottom.png")); InactiveBottomImage.Freeze(); InactiveBottomLeftImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/InactiveBottomLeft.png")); InactiveBottomLeftImage.Freeze(); InactiveBottomRightImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/InactiveBottomRight.png")); InactiveBottomRightImage.Freeze(); InactiveLeftImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/InactiveLeft.png")); InactiveLeftImage.Freeze(); InactiveRightImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/InactiveRight.png")); InactiveRightImage.Freeze(); InactiveTopImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/InactiveTop.png")); InactiveTopImage.Freeze(); InactiveTopLeftImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/InactiveTopLeft.png")); InactiveTopLeftImage.Freeze(); InactiveTopRightImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/InactiveTopRight.png")); InactiveTopRightImage.Freeze(); }
/// <summary> /// Constructor with parameters /// </summary> public MediaSource(string srcName, string srcPath, string relativeThumbnailUrl) { name = srcName; path = srcPath; //thumbnail = new BitmapImage(new Uri(@"C:\Users\William\Documents\Software Projects\Carputer\Media\folder-music.png")); thumbnail = new BitmapImage(new Uri(@"pack://siteoforigin:,,," + relativeThumbnailUrl)); }
static PracticeModel() { BmpsError32 = WPFUtils.GetPngImageSource("Grammar", "Status", "Error", 32); BmpsQuestion32 = WPFUtils.GetPngImageSource("Grammar", "Status", "Question", 32); BmpsInfo32 = WPFUtils.GetPngImageSource("Grammar", "Status", "Info", 32); BmpsOK32 = WPFUtils.GetPngImageSource("Grammar", "Status", "OK", 32); }
public EditorConfigCompletionSource(ITextBuffer buffer, IClassifierAggregatorService classifier, ITextStructureNavigatorSelectorService navigator, ImageSource glyph) { _buffer = buffer; _classifier = classifier.GetClassifier(buffer); _navigator = navigator; _glyph = glyph; }
public void ResetColor() { if (!AllowRecolor) return; InnerImage = null; InnerImageSource = null; IsRecolored = false; }
public GalleryItemViewModel(GalleryItem aModel, Action<GalleryItem> aOnClick) { _model = aModel; _onClick = aOnClick; OnClickCommand = new RelayCommand(wasClicked); _source = ImageSourceFromFile(_model.MediaPath); }
public AbstractMenuItem(string header, int priority, ImageSource icon = null, ICommand command = null, KeyGesture gesture = null, bool isCheckable = false) { Priority = priority; IsSeparator = false; Header = header; Key = header; Command = command; IsCheckable = isCheckable; Icon = icon; if (gesture != null && command != null) { Application.Current.MainWindow.InputBindings.Add(new KeyBinding(command, gesture)); InputGestureText = gesture.DisplayString; } if (isCheckable) { IsChecked = false; } if (Header == "SEP") { Key = "SEP" + sepCount.ToString(); Header = ""; sepCount++; IsSeparator = true; } }
// Метод задаёт изображение для отдельного поля вывода public void SetImage(System.Drawing.Image newImage) { ImageSource imgSourceOld = img.Source; imgSource = GetImageStream(newImage); img.Source = imgSource; img.RenderTransform = new ScaleTransform(1.0, 1.0, 0, 0); this.Width = imgSource.Width; this.Height = imgSource.Height; rubber.Init( rubber.GetClientRect(), new Size(this.Width, this.Height)); m_IsOpened = true; // Ждем освобождения всей памяти GC.Collect(); //GC.WaitForPendingFinalizers(); //GC.Collect(); // Выходим из неактивного режима if (m_mode == DisplayCanvasModeID.Disabled) { SetMode(DisplayCanvasModeID.Passive); } }
private static Completion EmojiCompletion(string emoji, ImageSource emojiImage) { // Map a completion object for each Emoji to the appropriate image var formattedEmoji = $":{emoji}:"; // Build a completion for each Emoji return new Completion(formattedEmoji, formattedEmoji, formattedEmoji, emojiImage, formattedEmoji); }
public CachedBitmap() { dispatcher = Dispatcher.CurrentDispatcher; _url = ""; _source = null; _workItem = null; }
public Calculator() { using (var stream = AssemblyHelper.GetEmbeddedResource(typeof(Calculator).Assembly, "calculate.png")) { this._icon = ImageSourceHelper.StreamToImageSource(stream); } }
public ICompletionSource TryCreateCompletionSource(ITextBuffer textBuffer) { if (_glyph == null) _glyph = GlyphService.GetGlyph(StandardGlyphGroup.GlyphGroupProperty, StandardGlyphItem.GlyphItemPublic); return new EditorConfigCompletionSource(textBuffer, ClassifierAggregatorService, NavigatorService, _glyph); }
public static ObjectAnimationUsingKeyFrames GetAnimation(ImageSource source, RepeatBehavior repeatBehavior) { var key = new CacheKey(source, repeatBehavior); ObjectAnimationUsingKeyFrames animation; _animationCache.TryGetValue(key, out animation); return animation; }
public MoreInfo(string appTitle, string filePath, ImageSource imgSource) { InitializeComponent(); txtAppTitle.Text = appTitle; txtAppFileName.Text = System.IO.Path.GetFileName(filePath); txtAppFilePath.Text = filePath; imgProgramIcon.Source = imgSource; }
private static System.Windows.Media.ImageSource _CalculateImage(DicomImage image, ref double scale, int maxW, int maxH) { if (image.Width > image.Height) { if (image.Width > maxW) { scale = (double)maxW / (double)image.Width; } } else { if (image.Height > maxH) { scale = (double)maxH / (double)image.Height; } } if (scale != 1.0) { image.Scale = scale; } //convert System.Drawing.Image to WPF image System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(image.RenderImage()); IntPtr hBitmap = bmp.GetHbitmap(); System.Windows.Media.ImageSource WpfBitmap = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); return(WpfBitmap); }
public MapImageWPF(MapImageType type, byte[] data) : base(type, data) { if ((data == null) || (data.Length == 0)) { _Image = null; return; } try { MemoryStream stream = new MemoryStream(Data); BitmapImage image = new BitmapImage(); image.BeginInit(); image.StreamSource = stream; image.EndInit(); _Image = image; } catch (InvalidOperationException ex) { throw new InvalidDataException("Invalid image data", ex); } catch (NotSupportedException ex) { throw new InvalidDataException("Invalid image data", ex); } }
public void addPlugin(string name, string description, System.Windows.Media.ImageSource image, Action <object> enable, bool isEnable, Action <object> uninstall, object tag = null) { var elem = new PluginListItem(); elem.title.Text = name; elem.description.Text = description; elem.image.Source = image; elem.uninstall.Click += (object sender, RoutedEventArgs e) => { uninstall(tag); }; elem.disable.Click += (object sender, RoutedEventArgs e) => { enable(tag); }; elem.settings.Click += (object sender, RoutedEventArgs e) => { PluginSettings settingsWindow = new PluginSettings(); settingsWindow.pluginName = (string)tag; settingsWindow.ShowDialog(); }; elem.disable.Content = (isEnable ? "Disable" : "Enable"); elem.tag = tag; elem.itemClick += () => { for (int i = 0; i < list.Children.Count; i++) { if (list.Children[i] is PluginListItem) { ((PluginListItem)list.Children[i]).Collapse(); } } ((PluginListItem)elem).Show(); }; list.Children.Add(elem); }
internal static FrameworkElement CreateCellRenderer(TreeNode node, CellView view) { if (view is TextCellView) { DataField field = ((TextCellView)view).TextField; int index = field.Index; SWC.TextBlock label = new SWC.TextBlock(); label.Text = (node.Values[index] ?? "null").ToString(); label.Padding = new Thickness(2); return(label); } else if (view is ImageCellView) { DataField field = ((ImageCellView)view).ImageField; int index = field.Index; SWM.ImageSource image = (SWM.ImageSource)WidgetRegistry.GetBackend(node.Values[index]); SWC.Image imageCtrl = new SWC.Image { Source = image, Width = image.Width, Height = image.Height }; return(imageCtrl); } throw new NotImplementedException(); }
public FieldInitializerItem(string name, string sortText, ImageSource displayGlyph, IEnumerable<CallHierarchyDetail> details) { _name = name; _sortText = sortText; _displayGlyph = displayGlyph; _details = details; }
public CompletionData(string text, ImageSource bmp,string description,TokenType tokenType) { this.Text = text; this.Image = bmp; this.Description = description; this.TokenType = tokenType; }
/// <summary> /// Captures a image and renders it into the view /// </summary> private void CaptureImage() { // get image Image <Bgr, byte> tempFrame = CameraManager.GetImage(); // rotate image if (rotation != 0) { tempFrame = tempFrame.Rotate(rotation, new Bgr(0, 0, 0), true); } // transform into bitmap frame = tempFrame.ToBitmap(tempFrame.Width, tempFrame.Height); // transform into UIComponent System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(frame); IntPtr hBitmap = bmp.GetHbitmap(); System.Windows.Media.ImageSource WpfBitmap = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); UIFrame = new Image(); UIFrame.Source = WpfBitmap; if (imageBox.Children.Contains(UIFrame)) { imageBox.Children.Remove(UIFrame); } imageBox.Children.Add(UIFrame); }
static SpringCompletion() { using (Stream stream = typeof(SpringCompletion).Assembly.GetManifestResourceStream("Spring.Resources.SpringGlyph.ico")) { SpringLeafGlyph = BitmapFrame.Create(stream); } }
public TouchTarget(double x, double y, double width, double height, ImageSource image, String characters, int dx, int dy) { X = x; Y = y; Width = width; Height = height; this.image = image; ROutside = (width / 2.0) * 0.9; RInside = ROutside * 1.2; this.callback = null; this.lastState = State.outside; this.characters = characters; this.timeInside = 0.0; this.selection = ' '; this.selectionTime = 0.0; this.dx = dx; this.dy = dy; this.CX = this.X + this.Width / 2.0; this.CY = this.Y + this.Height / 2.0; }
protected override void OnRefresh() { ImageDecoration profileImage = Visual as ImageDecoration; if (profileImage != null) { _image = ConfigManager.ImageManager.LoadImage(profileImage.Image); _imageRect.Width = profileImage.Width; _imageRect.Height = profileImage.Height; if (profileImage.BorderThickness > 0d) { _borderPen = new Pen(new SolidColorBrush(profileImage.BorderColor), profileImage.BorderThickness); } else { _borderPen = null; } if (_image == null) { _image = ConfigManager.ImageManager.LoadImage("{Helios}/Controls/missing_image.png"); _imageBrush = new ImageBrush(_image); _imageBrush.Stretch = Stretch.Fill; _imageBrush.TileMode = TileMode.None; _imageBrush.Viewport = new Rect(0d, 0d, 1d, 1d); _imageBrush.ViewportUnits = BrushMappingMode.RelativeToBoundingBox; } else { _imageBrush = new ImageBrush(_image); switch (profileImage.Alignment) { case ImageAlignment.Centered: _imageBrush.Stretch = Stretch.None; _imageBrush.TileMode = TileMode.None; _imageBrush.Viewport = new Rect(0d, 0d, 1d, 1d); _imageBrush.ViewportUnits = BrushMappingMode.RelativeToBoundingBox; break; case ImageAlignment.Stretched: _imageBrush.Stretch = Stretch.Fill; _imageBrush.TileMode = TileMode.None; _imageBrush.Viewport = new Rect(0d, 0d, 1d, 1d); _imageBrush.ViewportUnits = BrushMappingMode.RelativeToBoundingBox; break; case ImageAlignment.Tiled: _imageBrush.Stretch = Stretch.None; _imageBrush.TileMode = TileMode.Tile; _imageBrush.Viewport = new Rect(0d, 0d, _image.Width, _image.Height); _imageBrush.ViewportUnits = BrushMappingMode.Absolute; break; } } } else { _image = null; } }
public void SetPreviewElement(FrameworkElement element) { double x = 0; double y = 0; GetCurrentDPI(out x, out y); // Does the DrawingBrush thing seem a little hacky? Yeah, it's a necessary hack. See: // http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=364041 Rect bounds = VisualTreeHelper.GetDescendantBounds(element); RenderTargetBitmap r = new RenderTargetBitmap((int)(element.ActualWidth * x / 96), (int)(element.ActualHeight * y / 96), (int)x, (int)y, PixelFormats.Pbgra32); DrawingVisual dv = new DrawingVisual(); using (DrawingContext ctx = dv.RenderOpen()) { VisualBrush vb = new VisualBrush(element); ctx.DrawRectangle(vb, null, new Rect(new Point(), bounds.Size)); } r.Render(dv); DragImage = r; InvalidateMeasure(); }
public static ImageSource Convert(ImageSource imageSource, ColorConversion conversion) { ImageSource result = null; BitmapSource bitmapSource = imageSource as BitmapSource; if (bitmapSource != null) { PixelFormat format = PixelFormats.Default; switch (conversion) { case ColorConversion.BlackAndWhite: format = PixelFormats.BlackWhite; break; case ColorConversion.GrayScale: format = PixelFormats.Gray32Float; break; } if (format != PixelFormats.Default) { result = Convert(bitmapSource, format); } } return result; }
public FileManagerResult GetFileIcon(string filePath) { result = new FileManagerResult(); try { if (icon == null && System.IO.File.Exists(filePath)) { using (System.Drawing.Icon sysicon = System.Drawing.Icon.ExtractAssociatedIcon(filePath)) { icon = System.Windows.Interop.Imaging.CreateBitmapSourceFromHIcon( sysicon.Handle, System.Windows.Int32Rect.Empty, System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions()); } result.ImageSourceObj = icon; return(result); } else { result.ImageSourceObj = null; result.Errors.Add(string.Empty); return(result); } } catch (Exception e) { result.Exceptions.Add(e); } return(result); }
public static void DrawImage (this ConsoleBuffer @this, ImageSource imageSource, int x, int y, int width, int height) { var bmp = imageSource as BitmapSource; if (bmp == null) throw new ArgumentException("Only rendering of bitmap source is supported."); @this.OffsetX(ref x).OffsetY(ref y); int x1 = x, x2 = x + width, y1 = y, y2 = y + height; if ([email protected](ref x1, ref y1, ref x2, ref y2)) return; if (width != bmp.PixelWidth || height != bmp.PixelHeight) bmp = new TransformedBitmap(bmp, new ScaleTransform((double)width / bmp.PixelWidth, (double)height / bmp.PixelHeight)); if (bmp.Format != PixelFormats.Indexed4) bmp = new FormatConvertedBitmap(bmp, PixelFormats.Indexed4, BitmapPalettes.Halftone8Transparent, 0.5); const int bitsPerPixel = 4; int stride = 4 * (bmp.PixelWidth * bitsPerPixel + 31) / 32; byte[] bytes = new byte[stride * bmp.PixelHeight]; bmp.CopyPixels(bytes, stride, 0); for (int iy = y1, py = 0; iy < y2; iy++, py++) { ConsoleChar[] charsLine = @this.GetLine(iy); for (int ix = x1, px = 0; ix < x2; ix++, px++) { int byteIndex = stride * py + px / 2; int bitOffset = px % 2 == 0 ? 4 : 0; SetColor(ref charsLine[ix], bmp.Palette, (bytes[byteIndex] >> bitOffset) & 0xF); } } }
private static Uri GetUri(ImageSource image) { var bmp = image as BitmapImage; if (bmp != null && bmp.UriSource != null) { if (bmp.UriSource.IsAbsoluteUri) return bmp.UriSource; if (bmp.BaseUri != null) return new Uri(bmp.BaseUri, bmp.UriSource); } var frame = image as BitmapFrame; if (frame != null) { string s = frame.ToString(); if (s != frame.GetType().FullName) { Uri fUri; if (Uri.TryCreate(s, UriKind.RelativeOrAbsolute, out fUri)) { if (fUri.IsAbsoluteUri) return fUri; if (frame.BaseUri != null) return new Uri(frame.BaseUri, fUri); } } } return null; }
static MoveUpObject() { //use this code for *.ico files loading //IconBitmapDecoder ibd = new IconBitmapDecoder(new Uri(@"pack://*****:*****@"pack://application:,,/Icons/up.png", UriKind.RelativeOrAbsolute)); icon = Utility.LoadImageSource("UpIcon"); }
public AsyncHttpImage(Func<string> loading) { this.loading = loading; _asyncSource = AsyncImageQueue._HourGlass; AsyncImageQueue.Enqueue(this); }
public VideoScreenViewModel() { var bmp = new BitmapImage(); bmp.BeginInit(); bmp.UriSource = new Uri(@"/PlaybackPlugin;component/Images/iconwattermarkone.png", UriKind.RelativeOrAbsolute); bmp.EndInit(); ImageSource = bmp; }
public TaskRunner() { if (_icon == null) { string folder = GetExecutableFolder(); _icon = new BitmapImage(new Uri(Path.Combine(folder, "Resources\\logo.png"))); } }
public ImageBrushTool(ImageSource i, TileMode m, Rect v, BrushMappingMode u, double o = 1) : this() { Image = i; Mode = m; Viewport = v; ViewportUnits = u; Opacity = o; }
private void ChangeNodeIcon(TreeViewIconsItem node, ImageSource newIcon) { if (node == null || newIcon == null) { return; } node.Icon = newIcon; }
public AttachedImageViewModel(AttachedImage attachedAlbumModel, ImageSource image) { _attachedAlbumModel = attachedAlbumModel; _linkUrl = attachedAlbumModel.LinkUrl; _image = image; _width = image.Width; _height = image.Height; }
public static Icon ToEtoIcon(this swm.ImageSource bitmap) { if (bitmap == null) { return(null); } return(null); }
private void layoutTestFive(List<String> _temporary, int item_num)//题目 { mImagecontrol = new PaperImageControl(); mhImages = new List<Image>(); //载入题目 if (item_num == 2 ) //偶数个题目 { himageleft = 105 + layleft + (330 - (180 - 82) / 2) - 82; //330 是分割线的长度1/2 85是分割线位移 82图宽 180图片间距 } else if (item_num == 4) { himageleft = 105 + layleft + (330 - (180 - 82) / 2) - 82 - 180; } else//奇数个题目 { himageleft = 105 + layleft + (330 - 41) - 180; //330 是分割线的长度1/2 85是分割线位移 } for (int i = 0; i < item_num; i++)//item_num 题目的个数 { him = new Image(); // him = mImagecontrol.GetImage(82, 74); him.Stretch = Stretch.Fill; System.Drawing.Image pic = System.Drawing.Image.FromFile("Paper\\PaperRes\\Test\\Pa\\" + _temporary[0] + ".bmp"); System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(pic); IntPtr hBitmap = bmp.GetHbitmap(); System.Windows.Media.ImageSource WpfBitmap = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(82, 74));//FromEmptyOptions() 源图像大小 him.Source = WpfBitmap; //BitmapImage bitim = new BitmapImage(); //bitim.BeginInit(); //bitim.UriSource = new Uri("\\PCAT;component\\Images\\" + _temporary[0] + ".bmp", UriKind.Relative); //bitim.EndInit(); //him.Stretch = Stretch.Fill; //him.Source = bitim; mhImages.Add(him); PapertestCanvas.Children.Add(him); Canvas.SetTop(him, actual_y + himagetop);// Canvas.SetLeft(him, actual_x + himageleft);// himageleft = himageleft + himageadd; _temporary.RemoveAt(0); } _inputOpt = _temporary; }
public static System.Drawing.Image ImageWpfToGDI(this System.Windows.Media.ImageSource image) { MemoryStream ms = new MemoryStream(); var encoder = new System.Windows.Media.Imaging.BmpBitmapEncoder(); encoder.Frames.Add(System.Windows.Media.Imaging.BitmapFrame.Create(image as System.Windows.Media.Imaging.BitmapSource)); encoder.Save(ms); ms.Flush(); return(System.Drawing.Image.FromStream(ms)); }
public NewFallUC() { InitializeComponent(); CurrentVM = new FallsVM(); this.DataContext = CurrentVM; SaveButton.IsEnabled = true; TimeDatePicker.Text = DateTime.Now.ToString(); defaultPath = Image.Source; PredictionAndRealFalls = PredictionAndRealFallsVM.Instance; }
public test() { InitializeComponent(); System.Drawing.Image img = Properties.Resource1.LoginBackground; System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(img); IntPtr hBitmap = bmp.GetHbitmap(); System.Windows.Media.ImageSource WpfBitmap = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); backgroundImage.Source = WpfBitmap; }
private void Image_MouseDown(object sender, MouseButtonEventArgs e) { Image image = (Image)sender; System.Windows.Media.ImageSource path = image.Source; ImageWpf imageWpf = new ImageWpf(path); var thisMap = MainWindow.Instance.secondMapElement; UpdateAll(image.ToolTip.ToString(), thisMap); imageWpf.Show(); }
public static System.Drawing.Image AsGdiPlusImage(this System.Windows.Media.ImageSource image) { using (MemoryStream memoryStream = new MemoryStream()) { var encoder = new System.Windows.Media.Imaging.BmpBitmapEncoder(); encoder.Frames.Add(System.Windows.Media.Imaging.BitmapFrame.Create(image as System.Windows.Media.Imaging.BitmapSource)); encoder.Save(memoryStream); memoryStream.Flush(); return(System.Drawing.Image.FromStream(memoryStream)); } }
private async Task <byte[]> GetImageAsPngAsync(GetImageAsPngArgs args) { System.Windows.Media.ImageSource source = Control.Source; WriteableBitmap bitmap = source as WriteableBitmap; if (bitmap != null) { return(await bitmap.AsPngBytesAsync()); } return(null); }
public Task <System.Windows.Media.ImageSource> LoadImageAsync(ImageSource imagesoure, CancellationToken cancelationToken = new CancellationToken()) { System.Windows.Media.ImageSource image = null; FileImageSource filesource = imagesoure as FileImageSource; if (filesource != null) { string file = filesource.File; image = new BitmapImage(new Uri(file, UriKind.RelativeOrAbsolute)); } return(Task.FromResult(image)); }
private async void FindAlbumImages() { try { AlbumImageListBox.Items.Clear(); var client = new System.Net.Http.HttpClient(); var queryString = HttpUtility.ParseQueryString(string.Empty); client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "d01da6c28e184030be164f4d4f9a9236"); // Request parameters queryString["q"] = string.Format("{0}", textSearch.Text.Trim()); queryString["count"] = textResult.Text; queryString["offset"] = "0"; queryString["mkt"] = "en-us"; queryString["safeSearch"] = "Moderate"; queryString["size"] = "medium"; var uri = "https://api.cognitive.microsoft.com/bing/v5.0/images/search?" + queryString; var response = await client.GetAsync(uri); string content = await response.Content.ReadAsStringAsync(); var responseType = new { value = new[] { new { contentUrl = "", width = 300, height = 300 } } }; var results = JsonConvert.DeserializeAnonymousType(content, responseType); for (int i = 0; i < results.value.Count(); i++) { var firstResult = results.value[i].contentUrl; var request = WebRequest.Create(firstResult); using (var response2 = request.GetResponse()) using (var stream = response2.GetResponseStream()) { System.Drawing.Image image = System.Drawing.Image.FromStream(stream); System.Windows.Controls.Image img = new System.Windows.Controls.Image(); System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(image); IntPtr hBitmap = bmp.GetHbitmap(); System.Windows.Media.ImageSource WpfBitmap = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); img.Source = WpfBitmap; AlbumImageListBox.Items.Add(img); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void getImage(System.Drawing.Image getimg) { System.Windows.Controls.Image img = new System.Windows.Controls.Image(); System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(getimg); IntPtr hBitmap = bmp.GetHbitmap(); System.Windows.Media.ImageSource wpfBitmap = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); img1.Source = wpfBitmap; // img1.Width = 150; // img1.Height = 200; img1.Stretch = System.Windows.Media.Stretch.Fill; }
private void BtnFullImages_Click(ref int v, ref int Ho) { ViewboxWidth = imgEndoso.Width; ViewboxHeight = imgEndoso.Height; BitmapSource displayImage = new CroppedBitmap(srcEndoso, new Int32Rect(0, 0, 0, 0)); Source_image = displayImage; _sv.ScrollToVerticalOffset(v); _sv.ScrollToHorizontalOffset(Ho); _sv.UpdateLayout(); }
protected void _DisplayImage(object state) { var image = (DicomImage)state; double scale = 1.0; Size max = this.RenderSize; int maxW = (int)(max.Width - (Width - ctr_Image_RV.Width)); int maxH = (int)(max.Height - (Height - ctr_Image_RV.Height)); System.Windows.Media.ImageSource WpfBitmap = _CalculateImage(image, ref scale, maxW, maxH); CreateDynamicWPFGrid(WpfBitmap); }
protected void _DisplayOverviewImage(object state) { var image = (DicomImage)state; double scale = 1.0; Size max = this.RenderSize; int maxW = (int)(max.Width - (Width - ctr_Image_HDR.Width)); int maxH = (int)(max.Height - (Height - ctr_Image_HDR.Height)); System.Windows.Media.ImageSource WpfBitmap = _CalculateImage(image, ref scale, maxW, maxH); ctr_Image_HDR.Source = WpfBitmap; }
private async Task UpdateSymbolPreview(Symbol symbolToShow) { if (symbolToShow == null) { return; } // Create a swatch from the symbol with a white background. RuntimeImage swatch = await symbolToShow.CreateSwatchAsync(80, 80, 96, Color.White); // Convert the swatch to an image source and show it in the Image control. WinMedia.ImageSource symbolImage = await swatch.ToImageSourceAsync(); SymbolPreviewImage.Source = symbolImage; }
LoadPNGImageFromResource(string imageResourceName) { System.Reflection.Assembly dotNetAssembly = System.Reflection.Assembly.GetExecutingAssembly(); System.IO.Stream iconStream = dotNetAssembly.GetManifestResourceStream(imageResourceName); System.Windows.Media.Imaging.PngBitmapDecoder bitmapDecoder = new System.Windows.Media.Imaging.PngBitmapDecoder(iconStream, System.Windows.Media.Imaging.BitmapCreateOptions. PreservePixelFormat, System.Windows.Media.Imaging. BitmapCacheOption.Default); System.Windows.Media.ImageSource imageSource = bitmapDecoder.Frames[0]; return(imageSource); }
private System.Windows.Media.ImageSource ConvertImgControl(System.Drawing.Image _img) //method to convert Image type from Drawing.Image to Windows.Controls.Image { System.Windows.Controls.Image img = new System.Windows.Controls.Image(); //convert System.Drawing.Image to WPF image System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(_img); IntPtr hBitmap = bmp.GetHbitmap(); System.Windows.Media.ImageSource WpfBitmap = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); return(WpfBitmap); }
private System.Windows.Controls.Image ConvertDrawingImageToWPFImage(System.Drawing.Image gdiImg) { System.Windows.Controls.Image img = new System.Windows.Controls.Image(); //convert System.Drawing.Image to WPF image System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(gdiImg); IntPtr hBitmap = bmp.GetHbitmap(); System.Windows.Media.ImageSource WpfBitmap = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); img.Source = WpfBitmap; img.Width = 500; img.Height = 600; img.Stretch = System.Windows.Media.Stretch.Fill; return(img); }
/// <summary> /// カードをひっくり返す。 /// </summary> public void ReverseCard() { if (side == Side.front) { side = Side.back; IntPtr hbitmap = backImageBitmap.GetHbitmap(); imageSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hbitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); DeleteObject(hbitmap); } else { side = Side.front; IntPtr hbitmap = ImageBitmap.GetHbitmap(); imageSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hbitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); DeleteObject(hbitmap); } }
void BtnCrop_Click() { double factorX, factorY; factorX = srcEndoso.PixelWidth / srcEndoso.Width; factorY = srcEndoso.PixelHeight / srcEndoso.Height; BitmapSource displayImage = new CroppedBitmap(srcEndoso, new Int32Rect(_MyX, _MyY, (int)(_MyW), (int)(_MyH))); // new CroppedBitmap(original, crop); ViewboxWidth = (int)_MyW + 10; ViewboxHeight = (int)_MyH + 10; Source_image = displayImage; _sv.ScrollToVerticalOffset(0); _sv.ScrollToHorizontalOffset(0); }
/// <summary> /// Metodo que carga los botones de tipos de productos /// </summary> private void cargarTiposProductos() { foreach (tipos_de_productos tiposProd in mVTiposProds.listaTiposProds) { System.Drawing.Image imgProd = obtenerImgTipoProd(tiposProd); //Pasar de System.Drawing.Image a imagen para el componente System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(imgProd); IntPtr hBitmap = bmp.GetHbitmap(); System.Windows.Media.ImageSource WpfBitmap = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); Image imgBtn = new Image(); //imgBtn.Source = new BitmapImage(new Uri("pack://application:,,/Recursos/Iconos/" + "iconApp4Black.png")); imgBtn.Source = WpfBitmap; imgBtn.Height = 70; TextBlock textoBtn = new TextBlock() { Text = tiposProd.tipo_de_producto, Margin = new Thickness(0, 5, 0, 0), FontSize = 12 }; StackPanel stkPanelBtn = new StackPanel(); stkPanelBtn.Children.Add(imgBtn); stkPanelBtn.Children.Add(textoBtn); BtnTipoProd btnTProd = new BtnTipoProd() { Width = 200, //160 Height = 120, BorderBrush = Brushes.Black, Background = Brushes.Transparent, Margin = new Thickness(10, 10, 10, 10), Content = stkPanelBtn, tipoProdBtn = tiposProd, }; btnTProd.Click += new RoutedEventHandler(botonTipoProducto_Click); wrapTiposProd.Children.Add(btnTProd); } }
public static Bitmap backImageBitmap;//裏面のビットマップ。裏面は共通なのでクラス変数にする。 /// <summary> /// コンストラクタで画像イメージを設定する。 /// 全絵柄の1枚絵をクラス変数に保持して部分イメージを切り出して割り当てる。 /// </summary> /// <param name="suit"></param> /// <param name="number"></param> public Card(Suit suit, int number) { this.suit = suit; this.number = number; this.side = Side.back; const int width = 60; //カード1枚の幅 const int hidth = 90; //カード1枚の高さ if (originalBitmap == null) { originalBitmap = new Bitmap(480, 630); var originalImage = Image.FromFile(imgURL); originalBitmap = (Bitmap)originalImage; backImageBitmap = ImageRoi(originalBitmap, new Rectangle(7 * width, 6 * hidth, width, hidth)); } int x; int y; if (suit.Equals(Suit.jocker)) { x = 4; y = 6; } else { if (number < 8) { x = (int)suit; y = number - 1; } else { //元画像が8から次の列になっているので読み込み位置をずらす x = (int)suit + 4; y = number - 8; } } ImageBitmap = ImageRoi(originalBitmap, new Rectangle(x * width, y * hidth, width, hidth));//一枚あたりの大きさ IntPtr hbitmap = ImageBitmap.GetHbitmap(); imageSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hbitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); DeleteObject(hbitmap); }
private void layoutImage()//Canvas.Left="85" Canvas.Top="95"<Image Height="395" Name="portrailImage" Stretch="Fill" Width="250" /> { portrailImage = new Image(); portrailImage.Stretch = Stretch.Fill; System.Drawing.Image img = System.Drawing.Image.FromFile("PortraitMemory\\PortraitMemory_image\\" + _imageName + ".jpg"); System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(img); IntPtr hBitmap = bmp.GetHbitmap(); System.Windows.Media.ImageSource WpfBitmap = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(imagewith, imageheight));//FromEmptyOptions() 源图像大小 portrailImage.Source = WpfBitmap; MemoryCanvas.Children.Add(portrailImage); Canvas.SetLeft(portrailImage, 150); Canvas.SetTop(portrailImage, 120); }
private void layoutPortrailtImage(String path) { portrailImage = new Image(); portrailImage.Stretch = Stretch.Fill; System.Drawing.Image img = System.Drawing.Image.FromFile("PortraitMemory\\PortraitMemory_image\\" + path + ".jpg"); System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(img); IntPtr hBitmap = bmp.GetHbitmap(); System.Windows.Media.ImageSource WpfBitmap = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(imagewith, imageheight));//FromEmptyOptions() 源图像大小 portrailImage.Source = WpfBitmap; picturecanvas.Children.Add(portrailImage); Canvas.SetLeft(portrailImage, 0); //横向 Canvas.SetTop(portrailImage, 0); //纵向 475 FEITStandard.PAGE_BEG_Y +30 }