C#实现jpg转MemoryStream,再转成bmp保存
Java中应该思路差不多。staticvoidMain(string[]args){stringpicPath=@"D:\download\Pic.jpg";//Orig...
Java中应该思路差不多。
static void Main(string[] args)
{
string picPath = @"D:\download\Pic.jpg";//Origin picture path as jpg
string destPath = @"D:\download\Pic2.bmp";//Destination picture as bmp(or any type u like)
Image img = Image.FromFile(picPath);//load origin picture
File.Create(destPath);//create dest picture as path u want
using(MemoryStream memStream=new MemoryStream())//create a instance of memorystream
{
img.Save(memStream, ImageFormat.Bmp);//save stream from origin pic as format bmp
Bitmap destBmp = new Bitmap(memStream);//create bmp instance from stream above
destBmp.Save(destPath);//save bmp to the path you want
}
Console.WriteLine("**********Done**************");
Console.ReadKey();
} 展开
static void Main(string[] args)
{
string picPath = @"D:\download\Pic.jpg";//Origin picture path as jpg
string destPath = @"D:\download\Pic2.bmp";//Destination picture as bmp(or any type u like)
Image img = Image.FromFile(picPath);//load origin picture
File.Create(destPath);//create dest picture as path u want
using(MemoryStream memStream=new MemoryStream())//create a instance of memorystream
{
img.Save(memStream, ImageFormat.Bmp);//save stream from origin pic as format bmp
Bitmap destBmp = new Bitmap(memStream);//create bmp instance from stream above
destBmp.Save(destPath);//save bmp to the path you want
}
Console.WriteLine("**********Done**************");
Console.ReadKey();
} 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励30(财富值+成长值)
4个回答
展开全部
兄弟,没有看懂哦
来自:求助得到的回答
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这段代码有问题吗?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
jpg图片的内容是如何交给memoryStream对象的?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这代码应该可以用,你要问什么?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询