C\#그림 형식 변환 인 스 턴 스 코드
지식 에 관련되다
그림 변환기 의 예제 효과 도 는 다음 과 같다.
핵심 코드
그림 열기
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnOpen_Click(object sender, EventArgs e)
{
this.fileDialog.Filter = fileFilter;
this.fileDialog.Multiselect = true;
this.fileDialog.CheckFileExists = true;
if (fileDialog.ShowDialog() == DialogResult.OK)
{
string[] fileNames = this.fileDialog.FileNames;
foreach(string fileName in fileNames)
{
Bitmap bmp = new Bitmap(fileName);
//
bmp.Tag = Path.GetFileNameWithoutExtension(fileName);
PictureBox box = new PictureBox();
box.Image = bmp;
box.Width = 105;
box.Height = 150;
box.BorderStyle = BorderStyle.FixedSingle;
box.Padding = new Padding(2);
this.flowPnl.Controls.Add(box);
}
this.txtFile.Text = Path.GetDirectoryName(fileNames[0]);
}
}
그림 형식 변환
/// <summary>
///
/// </summary>
private void convertImage(string dir, string filter,Bitmap bmp)
{
string filePath = Path.Combine(dir, string.Format("{0}.{1}", bmp.Tag.ToString(), filter.ToLower()));
switch (filter)
{
case "JPG":
bmp.Save(filePath, ImageFormat.Jpeg);
break;
case "PNG":
bmp.Save(filePath, ImageFormat.Png);
break;
case "GIF":
bmp.Save(filePath, ImageFormat.Gif);
break;
case "BMP":
bmp.Save(filePath, ImageFormat.Bmp);
break;
case "ICO":
Stream stream = File.Create(filePath);
Icon icon = Icon.FromHandle(bmp.GetHicon());
icon.Save(stream); // save the icon
stream.Close();
break;
}
}
예제 의 소스 코드 가 필요 하 다 면 링크 를 클릭 하여 다운로드 할 수 있 습 니 다.소스 코드 링크
이상 은 C\#그림 형식 변환 의 인 스 턴 스 코드 에 대한 상세 한 내용 입 니 다.c\#그림 형식 변환 에 관 한 자 료 는 다른 관련 글 을 주목 하 십시오!
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
C#Task를 사용하여 비동기식 작업을 수행하는 방법라인이 완성된 후에 이 라인을 다시 시작할 수 없습니다.반대로 조인(Join)만 결합할 수 있습니다 (프로세스가 현재 라인을 막습니다). 임무는 조합할 수 있는 것이다. 연장을 사용하여 그것들을 한데 연결시키는 것이...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.