- 전체
- Form
- Image/Picture/Icon
- Enviroment
- string
- File/Directory
- Menu
- windows
- Net
- DataBase
- LINQ
- Event
- DateTime
- General
- 에러해결
- 그외
- 정리예정
Image/Picture/Icon 이미지를 아이콘으로 저장
2013.01.15 14:33
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; namespace ImageToIcon { public partial class ImageToIcon
: Form { Stream myStream; public ImageToIcon() {
InitializeComponent(); } // 파일을 열어서 // 썸네일 추출 private void
btnOpenImage_Click(object sender, EventArgs e) { if (ofdPicture.ShowDialog() == DialogResult.OK) { if ((myStream = ofdPicture.OpenFile()) != null) { Image
image = Image.FromFile(ofdPicture.FileName); Image
newImage = image.GetThumbnailImage(32, 32, null,
new IntPtr());
txtImagePath.Text = ofdPicture.FileName;
pbImage.Image = newImage; } } } // 썸네일을 아이콘으로 저장 private void
btnSaveAsIcon_Click(object sender, EventArgs e) { if (sfdPicture.ShowDialog() == DialogResult.OK) { String fileName = sfdPicture.FileName; Stream IconStream = System.IO.File.OpenWrite(fileName); Bitmap
bitmap = new Bitmap(pbImage.Image);
bitmap.SetResolution(72, 72); Icon icon =
System.Drawing.Icon.FromHandle(bitmap.GetHicon()); this.Icon = icon;
icon.Save(IconStream); } } } } 출처: http://code.msdn.microsoft.com/windowsdesktop/Convert-Image-file-to-Icon-c927d9f7
- [2016/09/24] XML 으로 환경설정 저장하기 ( \n,엔터값 포함, NewLine) (9668)
- [2013/08/29] int array to string (10278)
- [2013/08/29] byte array to Hexa String (13026)
- [2013/03/17] C#, 16진수 TEXT => 10 진수 변환 (23502)
- [2013/01/06] byte array to string (13915)
- [2013/01/06] string to byte array (13750)
- [2010/10/10] 프로그램을 트레이 아이콘으로 보내기, tray ()
- [2010/09/05] EXE 파일 아이콘 읽어서 ListView에 출력하기 ()