/// <summary> /// Returns an ImageSource with the given file's icon /// </summary> /// <param name="file"></param> /// <returns></returns> public static ImageSource GetFileIcon(FileSystemInfo file) { // If it's already in the cache, just return it from there string ext = file.Extension.ToLower(); if (fileIconCache.ContainsKey(ext)) { return(fileIconCache[ext]); } // It's not in the cache, so load it. ImageSource imageSource; System.Drawing.Icon icon = System.Drawing.Icon.ExtractAssociatedIcon(file.FullName); using (System.Drawing.Bitmap bmp = icon.ToBitmap()) { MemoryStream stream = new MemoryStream(); bmp.Save(stream, System.Drawing.Imaging.ImageFormat.Png); imageSource = BitmapFrame.Create(stream); } // Add it to the cache and return it fileIconCache.Add(ext, imageSource); return(imageSource); }
/// <summary> /// This event gets called when an item is dropped on the dock /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DisplayGrid_Drop(object sender, System.Windows.DragEventArgs e) { //TODO : We could make it so you are able to add multiple icons at the same time var files = (string[])e.Data.GetData(DataFormats.FileDrop); FileInfo fileInfo = new FileInfo(files[0]); //Create the image of the Icon System.Drawing.Icon icon = System.Drawing.Icon.ExtractAssociatedIcon(files[0]); //Create the name that this icon image is going to be stored under var newIconImageName = fileInfo.Name.Replace(fileInfo.Extension.ToString(), "") + ".png"; string startupPath = Environment.CurrentDirectory; if (!File.Exists(startupPath + "\\icons\\" + newIconImageName)) { icon.ToBitmap().Save(startupPath + "\\icons\\" + newIconImageName); } // instantiate a new shortcut object temporarily with enough information to generate an XML fragment var button = new Bauble.Buttons.Shortcut("icons/" + newIconImageName, fileInfo.Name, files[0]) as IBaubleButton; // have the settings object create a fully instantiated button object button = _settings.AddShortcut(button); // load the button onto the current dock DisplayButton(DisplayGrid.ColumnDefinitions.Count + 1, button); // Allow the IconFlow to initialize the button for any animations it uses _settings.IconFlow.Initialize(button); // save the new button list out to the file system _settings.SaveButtonList(); }
public static Image LoadImageFromIcon(this ResourceManager resourceManager, string cacheKey, System.Drawing.Icon icon) { return(resourceManager.LoadImage(cacheKey, textureLoader => new LazyImage(resourceManager.DefaultImage, () => { var _log = Log.Get <ResourceManager>(); try { _log.Info($"Loading image from icon..."); using (var bmpStream = new MemoryStream()) { // Convert to bitmap icon.ToBitmap().Save(bmpStream, System.Drawing.Imaging.ImageFormat.Bmp); // Convert to texture return textureLoader.Load(bmpStream.ToArray()); } } catch (Exception ex) { _log.Error($"Could not load image from icon: '{ex.Message}'.", ex); return ResourceManager.Instance.DefaultImage; } }))); }
/* * static System.Drawing.Bitmap CaptureCursor() //ref int x, ref int y) * { * System.Drawing.Bitmap bmp; * IntPtr hicon; * CURSORINFO ci = new CURSORINFO(); * aICONINFO icInfo; * ci.cbSize = Marshal.SizeOf(ci); * if (GetCursorInfo(out ci)) * { * if (ci.flags == CURSOR_SHOWING) * { * hicon = CopyIcon(ci.hCursor); * if (GetIconInfo(hicon, out icInfo)) * { * //x = ci.ptScreenPos.x - ((int)icInfo.xHotspot); * //y = ci.ptScreenPos.y - ((int)icInfo.yHotspot); * System.Drawing.Icon ic = System.Drawing.Icon.FromHandle(hicon); * bmp = ic.ToBitmap(); * DestroyIcon(hicon); * return bmp; * } * } * } * return null; * }*/ static BitmapSource CaptureCursor() //ref int x, ref int y) { IntPtr hicon; CURSORINFO ci = new CURSORINFO(); aICONINFO icInfo; ci.cbSize = Marshal.SizeOf(ci); if (GetCursorInfo(out ci)) { if (ci.flags == CURSOR_SHOWING) { hicon = CopyIcon(ci.hCursor); if (GetIconInfo(hicon, out icInfo)) { System.Drawing.Icon ic = System.Drawing.Icon.FromHandle(hicon); System.Drawing.Bitmap bmp = ic.ToBitmap(); BitmapSource retVal = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(bmp.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); DestroyIcon(hicon); return(retVal); } } } return(null); }
private void AsIsInfoShown(object sender, EventArgs e) { SystemSounds.Asterisk.Play(); var myIcon = new System.Drawing.Icon(System.Drawing.SystemIcons.Information, 32, 32); lblIcon.Image = myIcon.ToBitmap(); }
public AWindow(IWindow owner) : base(owner, Core.settings) { TabItem from_me = new TabItem(); from_me.BeginInit(); from_me.EndInit(); this.Background = from_me.Background; ProgressBar from_color = new ProgressBar(); default_progress_color = from_color.Foreground; // Taskbar progress setup TaskbarItemInfo = new TaskbarItemInfo(); // var uriSource = new Uri(System.IO.Path.Combine(Core.ExecutablePath, "masgau.ico"), UriKind.Relative); System.Drawing.Icon ico = Properties.Resources.MASGAUIcon; this.Icon = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( ico.ToBitmap().GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); if (owner != null) { this.Owner = owner as System.Windows.Window; this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner; } else { this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen; } }
protected static void ImgToShowSourcePropertyChange(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d.GetType() == typeof(AGImage)) { try { AGImage ag = d as AGImage; System.Drawing.Icon ic = (System.Drawing.Icon)LaserControl.Properties.Resources.ResourceManager.GetObject(e.NewValue.ToString()); System.Drawing.Bitmap bmp = ic.ToBitmap(); System.Drawing.Bitmap bmpD = MakeGrayscale3(bmp); ag.ImgEnabled = BitmapToImageSource(bmp); ag.ImgDisabled = BitmapToImageSource(bmpD); ag.Source = ag.IsEnabled ? ag.ImgEnabled : ag.ImgDisabled; ic.Dispose(); } catch { //Mache nichts } } }
//itemで指定したフルパスの先にあるファイルorフォルダのフルパスと名前と対応するアイコンを追加する。 private ImageList returnImageList(string item) { Image img = new Image(); ITEM_TYPE type; if (!Directory.Exists(item)) { System.Drawing.Icon appIcon = System.Drawing.Icon.ExtractAssociatedIcon(item); img.Source = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( appIcon.ToBitmap().GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); type = ITEM_TYPE.file; } else { BitmapImage folIcon = new BitmapImage(); MemoryStream data = new MemoryStream(File.ReadAllBytes(@"../../img/folder.png")); WriteableBitmap wbmp = new WriteableBitmap(BitmapFrame.Create(data)); data.Close(); img.Source = wbmp; type = ITEM_TYPE.folder; } return(new ImageList(item, img.Source, type)); }
protected static void ImgToShowSourcePropertyChange(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d.GetType() == typeof(ImgButton)) { try { ImgButton ib = d as ImgButton; // Console.WriteLine("Tada: {0} -> {1} ", e.NewValue, ib.IsEnabled); System.Drawing.Icon ic = (System.Drawing.Icon)LaserControl.Properties.Resources.ResourceManager.GetObject(e.NewValue.ToString()); System.Drawing.Bitmap bmp = ic.ToBitmap(); System.Drawing.Bitmap bmpD = MakeGrayscale3(bmp); ib.ImgEnabled = BitmapToImageSource(bmp); ib.ImgDisabled = BitmapToImageSource(bmpD); if (ib.IsEnabled) { ib.Data.ImageToDisplay = ib.ImgEnabled; } else { ib.Data.ImageToDisplay = ib.ImgDisabled; } ic.Dispose(); } catch { //Mache nichts } } }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(VerInfoForm)); this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.label1 = new System.Windows.Forms.Label(); this.button1 = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.SuspendLayout(); // // pictureBox1 // System.Drawing.Icon ico = new System.Drawing.Icon(Properties.Resources.Icon, 64, 64); System.Drawing.Bitmap bmp = ico.ToBitmap(); this.pictureBox1.Image = bmp; this.pictureBox1.Location = new System.Drawing.Point(12, 12); this.pictureBox1.Name = "pictureBox1"; this.pictureBox1.Size = new System.Drawing.Size(64, 64); this.pictureBox1.TabIndex = 0; this.pictureBox1.TabStop = false; // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(82, 12); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(0, 12); this.label1.TabIndex = 1; // // button1 // this.button1.DialogResult = System.Windows.Forms.DialogResult.OK; this.button1.Location = new System.Drawing.Point(247, 53); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(75, 23); this.button1.TabIndex = 2; this.button1.Text = "OK"; this.button1.UseVisualStyleBackColor = true; // // VerInfoForm // this.AcceptButton = this.button1; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(334, 92); this.Controls.Add(this.button1); this.Controls.Add(this.label1); this.Controls.Add(this.pictureBox1); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "VerInfoForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "バージョン情報"; this.Load += new System.EventHandler(this.VerInfoForm_Load); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); }
public DrawingTree() { InitializeComponent(); System.Drawing.Icon icon = Properties.Resources.dollar; System.Drawing.Bitmap bitmap = icon.ToBitmap(); this.Icon = bitmap.ToImageSource(); this.ResizeMode = ResizeMode.NoResize; FontSize = 12.5; }
public MainWindow() { InitializeComponent(); string filename = "C:/Program Files/Internet Explorer/iexplore.exe"; System.Drawing.Icon icon = System.Drawing.Icon.ExtractAssociatedIcon(filename); System.Drawing.Bitmap iconBitmap = icon.ToBitmap(); }
public CmdCommit() : base(null, CAPTION, 0, null, MESSAGE, NAME, TOOLTIP) { System.Drawing.Icon icon = new System.Drawing.Icon(GetType().Assembly. GetManifestResourceStream("ISDUTLib.tm.ui.images.commitTrans.ico")); if(icon!=null) { base.m_bitmap = icon.ToBitmap(); } }
public static string Icon2Base64String(System.Drawing.Icon I) { MemoryStream ms = new MemoryStream(); if (I != null) { I.ToBitmap().Save(ms, ImageFormat.Png); } byte[] arr = ms.GetBuffer(); return(Convert.ToBase64String(arr)); }
/// <summary>Save a Windows icon to cache</summary> /// <param name="sdi">The System.Drawing.Icon, which needs to be saved</param> /// <param name="name">The icon name</param> /// <param name="size">The icon size</param> public static void SaveIconToCache(System.Drawing.Icon sdi, string name, int size = 16) { if (!Directory.Exists(PathToIcons + Path.DirectorySeparatorChar + size)) { Directory.CreateDirectory(PathToIcons + Path.DirectorySeparatorChar + size); } string IconPath = PathToIcons + Path.DirectorySeparatorChar + size + Path.DirectorySeparatorChar + name + ".png"; sdi.ToBitmap().Save(IconPath); }
public ImageSource ImageSourceFromIcon(System.Drawing.Icon ico) { ImageSource imageSource; using (System.Drawing.Bitmap bmp = ico.ToBitmap()) { var stream = new MemoryStream(); bmp.Save(stream, System.Drawing.Imaging.ImageFormat.Png); imageSource = BitmapFrame.Create(stream); return(imageSource); } }
private void buttonSavePng_Click(object sender, EventArgs e) { using (var saveFileDialog = new SaveFileDialog { Filter = "PNG image files|*.png|All files|*.*" }) { if (saveFileDialog.ShowDialog(this) == DialogResult.OK) { _icon.ToBitmap().Save(saveFileDialog.FileName, ImageFormat.Png); } } }
private void ShowFtpClientDirectories(string cmd, string currentDirectory) { System.Drawing.Icon icon = FileHelp.GetDirectoryIcon(); //清空区域 localDirectoryList.Items.Clear(); var directories = Directory.GetDirectories(currentDirectory); foreach (var directory in directories) { DirectoryInfo di = new DirectoryInfo(directory); StackPanel sp = new StackPanel(); sp.Orientation = Orientation.Horizontal; sp.Tag = di.Name; Image img = new Image(); img.Source = BitmapToBitmapSource(icon.ToBitmap()); Label lb = new Label(); lb.FontSize = 16; lb.Content = di.Name; sp.Children.Add(img); sp.Children.Add(lb); localDirectoryList.Items.Add(sp); } var files = Directory.GetFiles(currentDirectory); foreach (var file in files) { System.Drawing.Icon fileIcon = FileHelp.GetFileIcon(file); FileInfo fi = new FileInfo(file); StackPanel sp = new StackPanel(); sp.Orientation = Orientation.Horizontal; sp.Tag = fi.Name; Image img = new Image(); img.Source = BitmapToBitmapSource(fileIcon.ToBitmap()); Label lb = new Label(); lb.FontSize = 16; lb.Content = fi.Name; sp.Children.Add(img); sp.Children.Add(lb); localDirectoryList.Items.Add(sp); } }
public static System.Windows.Media.ImageBrush createImageBrushFromIcon(System.Drawing.Icon i_theIcon) { ImageSource imageSource; using (System.Drawing.Bitmap bmp = i_theIcon.ToBitmap()) { var stream = new MemoryStream(); bmp.Save(stream, System.Drawing.Imaging.ImageFormat.Png); imageSource = System.Windows.Media.Imaging.BitmapFrame.Create(stream); } return(new ImageBrush(imageSource)); }
private void button4_Click(object sender, System.EventArgs e) { OpenFileDialog od = new OpenFileDialog(); od.Filter = "Icon files (*.ico)|*.ico"; if (od.ShowDialog() == DialogResult.OK) { System.Drawing.Icon ic = new System.Drawing.Icon(od.FileName); pictureBox1.Image = ic.ToBitmap(); icon = od.FileName; makeChanges(); } }
public static System.Windows.Media.ImageSource ToImageSource(this System.Drawing.Icon icon) { System.Drawing.Bitmap bitmap = icon.ToBitmap(); IntPtr hBitmap = bitmap.GetHbitmap(); ImageSource wpfBitmap = Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); if (!DeleteObject(hBitmap)) { throw new System.ComponentModel.Win32Exception(); } return(wpfBitmap); }
public static ImageSource ToImageSource(System.Drawing.Icon toConvert) { if (toConvert == null) { return(null); } ImageSource imageSource = null; using (System.Drawing.Bitmap bitmap = toConvert.ToBitmap()) { imageSource = ToImageSource(bitmap); } return(imageSource); }
public static BitmapImage ToBitmapImage(System.Drawing.Icon toConvert) { if (toConvert == null) { return(null); } BitmapImage bitmapImage = new BitmapImage(); using (System.Drawing.Bitmap bitmap = toConvert.ToBitmap()) { bitmapImage = ToBitmapImage(bitmap); } return(bitmapImage); }
public static Sprite GetSpriteFromIcon(string fileName) { int index = TextureFileNames.IndexOf(fileName); if (index >= 0) { // Texture Already Exists // move it to the end of the array and return it Texture texture = Textures[index]; string name = TextureFileNames[index]; Textures.RemoveAt(index); TextureFileNames.RemoveAt(index); Textures.Add(texture); TextureFileNames.Add(name); return(new Sprite(Textures[Textures.Count - 1])); } else { // New Texture (from .ico) try { System.Drawing.Icon icon = new System.Drawing.Icon(fileName, 256, 256); System.Drawing.Bitmap iconImage = ExtractVistaIcon(icon); if (iconImage == null) { iconImage = icon.ToBitmap(); } Sprite iconSprite; using (MemoryStream iconStream = new MemoryStream()) { iconImage.Save(iconStream, System.Drawing.Imaging.ImageFormat.Png); Texture iconTexture = new Texture(iconStream); Textures.Add(iconTexture); TextureFileNames.Add(fileName); iconSprite = new Sprite(new Texture(iconTexture)); } return(iconSprite); } catch (Exception) { } } return(null); }
private ImageSource getIconSource(string iconPath) { ImageSource imageSource; System.Drawing.Icon testIcon = System.Drawing.Icon.ExtractAssociatedIcon(iconPath); using (System.Drawing.Bitmap bmp = testIcon.ToBitmap()) { var stream = new MemoryStream(); bmp.Save(stream, System.Drawing.Imaging.ImageFormat.Png); imageSource = BitmapFrame.Create(stream); } return(imageSource); }
public NewWindow(AViewWindow owner) : base(owner, Core.settings) { this.Owner = owner; // var uriSource = new Uri(System.IO.Path.Combine(Core.ExecutablePath, "masgau.ico"), UriKind.Relative); // this.Icon = new BitmapImage(uriSource); System.Drawing.Icon ico = Properties.Resources.MASGAUIcon; this.Icon = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( ico.ToBitmap().GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); }
/// <summary> /// MIcon: Display MyIcon on the message box. /// </summary> static public System.Windows.Forms.DialogResult Show(string Message, string Title, MyButtons MButtons, MyIcon MIcon, bool isChsLanguage) { lock (olock) { BuildMessageBox(Title); frmTitle.Text = Title; frmMessage.Text = Message; ButtonStatements(MButtons, isChsLanguage); IconStatements(MIcon); System.Drawing.Image imageIcon = new System.Drawing.Bitmap(frmIcon.ToBitmap(), 38, 38); pIcon.Image = imageIcon; newMessageBox.ShowDialog(); return(CYReturnButton); } }
private void iconPage_Initialize(object sender, WizardPageInitEventArgs e) { var windowsExe = _feedBuilder.MainCandidate as WindowsExe; if (windowsExe == null) { pictureBoxIcon.Visible = buttonSaveIco.Enabled = buttonSavePng.Enabled = false; } else { _icon = windowsExe.ExtractIcon(); pictureBoxIcon.Image = _icon.ToBitmap(); pictureBoxIcon.Visible = buttonSaveIco.Enabled = buttonSavePng.Enabled = true; } }
private void AddProfile_MouseDown(object sender, MouseButtonEventArgs e) { Microsoft.Win32.OpenFileDialog exe_filedlg = new Microsoft.Win32.OpenFileDialog(); exe_filedlg.DefaultExt = ".exe"; exe_filedlg.Filter = "Executable Files (*.exe)|*.exe;"; Nullable <bool> result = exe_filedlg.ShowDialog(); if (result.HasValue && result == true) { string filename = System.IO.Path.GetFileName(exe_filedlg.FileName.ToLowerInvariant()); if (Global.LightingStateManager.Events.ContainsKey(filename)) { if (Global.LightingStateManager.Events[filename] is GameEvent_Aurora_Wrapper) { Global.LightingStateManager.Events.Remove(filename); } else { MessageBox.Show("Profile for this application already exists."); return; } } GenericApplication gen_app_pm = new GenericApplication(filename); gen_app_pm.Initialize(); ((GenericApplicationSettings)gen_app_pm.Settings).ApplicationName = Path.GetFileNameWithoutExtension(filename); System.Drawing.Icon ico = System.Drawing.Icon.ExtractAssociatedIcon(exe_filedlg.FileName.ToLowerInvariant()); if (!System.IO.Directory.Exists(gen_app_pm.GetProfileFolderPath())) { System.IO.Directory.CreateDirectory(gen_app_pm.GetProfileFolderPath()); } using (var icon_asbitmap = ico.ToBitmap()) { icon_asbitmap.Save(Path.Combine(gen_app_pm.GetProfileFolderPath(), "icon.png"), System.Drawing.Imaging.ImageFormat.Png); } ico.Dispose(); Global.LightingStateManager.RegisterEvent(gen_app_pm); ConfigManager.Save(Global.Configuration); GenerateProfileStack(filename); } }
public static System.Drawing.Bitmap GetIcon(CloudFiles item) { SHFILEINFO sfi = new SHFILEINFO(); if (item.Item.Extention != null) { IntPtr img1 = img1 = SHGetFileInfo("." + item.Item.Extention.ToUpper(), FILE_ATTRIBUTE_NORMAL, ref sfi, (uint)Marshal.SizeOf(sfi), SHGFI_ICON | SHGFI_LARGEICON | SHGFI_USEFILEATTRIBUTES | SHGFI_TYPENAME | SHGFI_SYSICONINDEX); } else { IntPtr img1 = img1 = SHGetFileInfo("Doesn't matter", FILE_ATTRIBUTE_DIRECTORY, ref sfi, (uint)Marshal.SizeOf(sfi), SHGFI_ICON | SHGFI_LARGEICON | SHGFI_USEFILEATTRIBUTES | SHGFI_OPENICON | SHGFI_TYPENAME); } System.Drawing.Icon icon = (System.Drawing.Icon)System.Drawing.Icon.FromHandle(sfi.hIcon).Clone(); DestroyIcon(sfi.hIcon); return(icon.ToBitmap()); }
//--------------------------------------------------------------------------------------------------------- /// <summary> /// Получение иконки файла связанного с типом файла /// </summary> /// <param name="file_name">Имя файла</param> /// <returns>Изображение</returns> //--------------------------------------------------------------------------------------------------------- public static BitmapSource GetIconFromFileTypeFromShell(String file_name) { IntPtr icon_small = XNative.SHGetFileInfo(file_name, 0, ref XNative.ShellFileInfoDefault, (UInt32)Marshal.SizeOf(XNative.ShellFileInfoDefault), XNative.SHGFI_ICON | XNative.SHGFI_LARGEICON); //The icon is returned in the hIcon member of the shinfo struct System.Drawing.Icon icon = System.Drawing.Icon.FromHandle(XNative.ShellFileInfoDefault.IconHandle); var h_bitmap = icon.ToBitmap().GetHbitmap(); var result = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(h_bitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); XNative.DeleteObject(h_bitmap); return(result); }
public CmdActivate() : base(null, CAPTION, 0, null, MESSAGE, NAME, TOOLTIP) { try { base.m_bitmap = new System.Drawing.Bitmap(GetType().Assembly.GetManifestResourceStream("ISDUTLib.tm.ui.images.redlight.png")); } catch (Exception e) { System.Drawing.Icon icon = new System.Drawing.Icon(GetType().Assembly. GetManifestResourceStream("ISDUTLib.tm.ui.images.database.ico")); if (icon != null) { base.m_bitmap = icon.ToBitmap(); } } }
private SharpMap.Styles.VectorStyle LoadStyle(string filename) { SharpMap.Styles.VectorStyle style = new SharpMap.Styles.VectorStyle(); if (System.IO.File.Exists(filename)) { string fileExtension = System.IO.Path.GetExtension(filename).ToLower(); switch (fileExtension) { case ".png": case ".jpg": case ".gif": case ".bmp": style.Symbol = new System.Drawing.Bitmap(filename, true); break; case ".ico": System.Drawing.Icon icon = new System.Drawing.Icon(filename); style.Symbol = icon.ToBitmap(); break; default: style.Line.Color = System.Drawing.Color.Black; break; } } else { style.Line.Color = System.Drawing.Color.Black; } return style; }
private void iconPage_Initialize(object sender, WizardPageInitEventArgs e) { var windowsExe = _feedBuilder.MainCandidate as WindowsExe; if (windowsExe == null) pictureBoxIcon.Visible = buttonSaveIco.Enabled = buttonSavePng.Enabled = false; else { _icon = windowsExe.ExtractIcon(); pictureBoxIcon.Image = _icon.ToBitmap(); pictureBoxIcon.Visible = buttonSaveIco.Enabled = buttonSavePng.Enabled = true; } }
public static bool ConvertGifIcoToPng(byte[] aInput, int nImageFormat, out byte[] aOutput) { aOutput = null; bool bRes = false; if (FileFormats.AVS_OFFICESTUDIO_FILE_IMAGE_GIF == nImageFormat) { using (MemoryStream ms = new MemoryStream(aInput)) { System.Drawing.Image oImage = System.Drawing.Image.FromStream(ms); using (MemoryStream ms2 = new MemoryStream()) { oImage.Save(ms2, System.Drawing.Imaging.ImageFormat.Png); aOutput = ms2.ToArray(); bRes = true; } } } else if (FileFormats.AVS_OFFICESTUDIO_FILE_IMAGE_ICO == nImageFormat) { using (MemoryStream ms = new MemoryStream(aInput)) { System.Drawing.Icon oIcon = new System.Drawing.Icon(ms, new System.Drawing.Size(256, 256)); using (MemoryStream ms2 = new MemoryStream()) { oIcon.ToBitmap().Save(ms2, System.Drawing.Imaging.ImageFormat.Png); aOutput = ms2.ToArray(); bRes = true; } } } return bRes; }
public void CopyAsImage() { Thread thread = new Thread(() => { try { System.Drawing.Bitmap bitmap; if (File.IndexOf(".ico") == File.Length - 4) { // If .ico - copy largest version System.Drawing.Icon icon = new System.Drawing.Icon(File, 256, 256); bitmap = Graphics.ExtractVistaIcon(icon); if (bitmap == null) bitmap = icon.ToBitmap(); } else bitmap = new System.Drawing.Bitmap(File); Clipboard.SetImage(bitmap); } catch (Exception) { } }); thread.SetApartmentState(ApartmentState.STA); thread.Start(); }
private void button4_Click(object sender, System.EventArgs e) { OpenFileDialog od = new OpenFileDialog(); od.Filter = "Icon files (*.ico)|*.ico"; if (od.ShowDialog() == DialogResult.OK) { System.Drawing.Icon ic=new System.Drawing.Icon(od.FileName); pictureBox1.Image = ic.ToBitmap(); icon = od.FileName; makeChanges(); } }
private static byte[] IconAsSizedPng(byte[] iconBytes, int iSize) { System.Drawing.Icon icon; using (System.IO.MemoryStream ms = new System.IO.MemoryStream(iconBytes)) icon = new System.Drawing.Icon(ms, iSize, iSize); using (icon) { using (System.Drawing.Bitmap bmp = icon.ToBitmap()) { //bmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Png); using (var ms = new System.IO.MemoryStream()) { bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png); return ms.ToArray(); } } } }
public static Sprite GetSpriteFromIcon(string fileName) { try { System.Drawing.Icon icon = new System.Drawing.Icon(fileName, 256, 256); System.Drawing.Bitmap iconImage = ExtractVistaIcon(icon); if (iconImage == null) iconImage = icon.ToBitmap(); Sprite iconSprite; using (MemoryStream iconStream = new MemoryStream()) { iconImage.Save(iconStream, System.Drawing.Imaging.ImageFormat.Png); iconSprite = new Sprite(new Texture(iconStream)); } return iconSprite; } catch (Exception) { } return null; }