сохраните файлы изображений в C#

Как мы можем сохранить файлы изображений (типы, такие как jpg или png) в C#?

15
задан masoud ramezani 3 April 2010 в 10:21
поделиться

3 ответа

в C # используется метод Image.Save с этими параметрами (строка Filename, ImageFormat)

http://msdn.microsoft.com/en-us/library/9t4syfhh.aspx

Это все, что вам нужно ?

// Construct a bitmap from the button image resource.
Bitmap bmp1 = new Bitmap(typeof(Button), "Button.bmp");

// Save the image as a GIF.
bmp1.Save("c:\\button.gif", System.Drawing.Imaging.ImageFormat.Gif);
22
ответ дан 1 December 2019 в 00:59
поделиться
Image bitmap = Image.FromFile("C:\\MyFile.bmp");
bitmap.Save("C:\\MyFile2.bmp");  

Вы должны иметь возможность использовать метод сохранения из класса изображения , и все будет в порядке, как показано выше. У метода сохранения есть 5 различных вариантов или перегрузок ...

  //Saves this Image  to the specified file or stream.
  img.Save(filePath);

  //Saves this image to the specified stream in the specified format.
  img.Save(Stream, ImageFormat);

  //Saves this Image to the specified file in the specified format.
  img.Save(String, ImageFormat);

  //Saves this image to the specified stream, with the specified encoder and image encoder parameters.
  img.Save(Stream, ImageCodecInfo, EncoderParameters);

  //Saves this Image to the specified file, with the specified encoder and image-encoder parameters.
  img.Save(String, ImageCodecInfo, EncoderParameters);
18
ответ дан 1 December 2019 в 00:59
поделиться

Если вам нужна более обширная обработка изображений, чем предоставляет .NET Framework «из коробки», ознакомьтесь с проектом FreeImage

0
ответ дан 1 December 2019 в 00:59
поделиться
Другие вопросы по тегам:

Похожие вопросы: