将图像保存在文件夹中 [英] Save Image in a Folder

查看:83
本文介绍了将图像保存在文件夹中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Helloo!
我正在为wpf创建拼图,我需要一些帮助将图片片段保存在特定的文件夹中,以便在用户请求时重新加载它们..
1.我检查目录是否存在
2.如果没有,我写道:

Helloo!
I''m working on creating a puzzle on wpf and I need some help in saving pieces of a picture in a specific folder to reload them if the user requested..
1. I checked if the directory exists
2. if not, I wrote:

if (!Directory.Exists(path1))
              {
                  Directory.CreateDirectory(path1);}



3.我需要将片段保存到先前的文件夹中!我从打开的文件对话框中获取了原始图像,然后在运行时将其切成100张

反正
有人可以帮我将图像保存到文件夹吗?



3. I need to save pieces into the previous folder! I got the Original Image from an open file dialog then I cut it into 100 pieces at run time

Anyway
Can Anyone help me saving an image in a folder?

推荐答案

Image类直接具有您可以使用的Save方法.请参阅: http://msdn.microsoft.com/en-us/library/ktx83wah.aspx [ ^ ]
The Image class directly has a Save method you can use. See:http://msdn.microsoft.com/en-us/library/ktx83wah.aspx[^]


尝试
http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapencoder.aspx [ ^ ]
将BitmapFrame对象的集合编码到图像流.
Try
http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapencoder.aspx[^]
to Encodes a collection of BitmapFrame objects to an image stream.
FileStream stream = new FileStream("empty.tif", FileMode.Create);
TiffBitmapEncoder encoder = new TiffBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(image));
encoder.Save(stream);



您可以使用给定的功能



as you can use given function

public static void SaveClipboardImageToFile(string filePath)
{
    var image = Clipboard.GetImage();
    using (var fileStream = new FileStream(filePath, FileMode.Create))
    {
        BitmapEncoder encoder = new PngBitmapEncoder();
        encoder.Frames.Add(BitmapFrame.Create(image));
        encoder.Save(fileStream);
    }
}


检查这些博客
http://www.dotnetspark.com/links/26147-save-image-new- folder.aspx [ ^ ]
http://www .redmondpie.com/how-to-save-and-retrieve-images-in-c-wpf-application-from-sql-server-database/ [
check these blogs
http://www.dotnetspark.com/links/26147-save-image-new-folder.aspx[^]
http://www.redmondpie.com/how-to-save-and-retrieve-images-in-c-wpf-application-from-sql-server-database/[^]
--NDK


这篇关于将图像保存在文件夹中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆