public Image GetNetImage(int sizeIfResource = 32) { // once the image is created it is not disposed at the moment. If it is being drawn on-screen it will be needed repeatedly if (!string.IsNullOrEmpty(m_ResourceName)) { return(GUIUtilities.VariableSizeImage(m_ResourceName, "", sizeIfResource)); // RM.GetObject(m_strResourceName) } return(m_Image.GetNetImage()); }
public void btnChangeActivityIcon_Click(object sender, EventArgs e) { string filename = FileDialog.ShowOpen(FileDialog.Context.Image); if (string.IsNullOrEmpty(filename)) { return; } m_Image = new MemoryImage(filename); m_Image.ChangeToBitmap(new Size(144, 144)); pnlPreviewActivityIcon.Image = m_Image.GetNetImage(); EnableOK(); Globals.OnAvailableActivitiesChanged(); // We should also raise this if the text changes; but that's more complicated if we don't want to raise numerous events, and I'm not sure it's worth the effort }
/// <summary>Adds the given file to the displayed list</summary> private void ShowPicture(DisplayedImage image) { PictureBox ctr = new PictureBox(); MemoryImage memory = new MemoryImage(image.Filename); // this is used for its SVG handling. We don't really need the memory buffer overhead! ctr.Image = memory.GetNetImage(); ctr.Tag = image; ctr.Size = new Size(100, 100); ctr.SizeMode = PictureBoxSizeMode.Zoom; ctr.Margin = new Padding(10, 10, 10, 10); ctr.Padding = new Padding(10, 10, 10, 10); ctr.Click += Image_Click; ctr.DoubleClick += Image_DoubleClick; pnlImages.Controls.Add(ctr); }
private string PrepareMemoryImage(MemoryImage img, int imageKey, RectangleF source) { if (!img.IsSVG) { return(PrepareImage((Bitmap)img.GetNetImage(true), imageKey, source)); } // rest for SVG only, which partially repeats PrepareImage (above) string ID = "img" + imageKey.ToString("x"); RectangleF bounds = new RectangleF(PointF.Empty, img.Size); if (!source.IsEmpty && !source.Equals(bounds)) { ID += "_" + source.GetHashCode(); } if (!m_Images.Contains(ID)) { // for SVG images can just retrieve the data directly from the memory image (no need to worry about formats) Debug.Assert(img.Buffer != null); AddImageToDefinitions(img.Buffer, ID, img.Size, "svg+xml"); } return(ID); }