熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

C#轉換圖片文件格式

2022-06-13   來源: .NET編程 

  將圖片轉換為另一種格式的圖像時需要使用ImageFormat類該類主要用來指定圖像的格式代碼如下

  privatevoidbutton_Click(objectsenderEventArgse)

  {

  //轉換圖像文件

  if(MyBitmap==null)

  {

  MessageBoxShow(請首先選擇一幅圖像!信息提示);

  return;

  }

  SaveFileDialogsaveDlg=newSaveFileDialog();

  if(saveDlgShowDialog()==DialogResultCancel)

  return;

  stringfileName=saveDlgFileName;

  try

  {

  if(boBoxSelectedIndex==)

  {

  MyBitmapSave(fileName+bmpSystemDrawingImagingImageFormatBmp);

  }

  if(boBoxSelectedIndex==)

  {

  MyBitmapSave(fileName+jpgSystemDrawingImagingImageFormatGif);

  }

  if(boBoxSelectedIndex==)

  {

  MyBitmapSave(fileName+pngSystemDrawingImagingImageFormatJpeg);

  }

  if(boBoxSelectedIndex==)

  {

  MyBitmapSave(fileName+gifSystemDrawingImagingImageFormatPng);

  }

  if(boBoxSelectedIndex==)

  {

  MyBitmapSave(fileName+tifSystemDrawingImagingImageFormatTiff);

  }

  if(boBoxSelectedIndex==)

  {

  MyBitmapSave(fileName+wmfSystemDrawingImagingImageFormatWmf);

  }

  }

  catch(Exceptionex)

  {

  MessageBoxShow(exMessage信息提示);

  }

  }


From:http://tw.wingwit.com/Article/program/net/201311/11428.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.