2个回答
展开全部
private void Form1_Load(object sender, EventArgs e)
{
//this.BackColor = Color.Honeydew;
FileStream NewFileStream = File.Open(@"D:\1.jpg", FileMode.Open);
MessageBox.Show(NewFileStream.Length.ToString());
byte[] NewByte = new byte[Convert.ToInt32(NewFileStream.Length)];
NewFileStream.Read(NewByte, 0, Convert.ToInt32(NewFileStream.Length));
MemoryStream memdefault = new MemoryStream();
BinaryWriter savewriter = new BinaryWriter(memdefault);
savewriter.Write(NewByte);
Image NewImage = Image.FromStream(memdefault);
NewImage.Save(@"D:\2.jpg");
//Image NewImage = Image.FromStream(NewFileStream);
//NewImage.Save(@"D:\2.jpg");
}
private void button1_Click(object sender, EventArgs e)
{
Bitmap myBitmap = new Bitmap(250, 261);
Rectangle DrawRect = new Rectangle(0, 0, 250, 261);
webBrowser1.DrawToBitmap(myBitmap, DrawRect);
System.Drawing.Image imgOutput = myBitmap;
System.Drawing.Image oThumbNail = new Bitmap(250, 261, imgOutput.PixelFormat);
Graphics g = Graphics.FromImage(oThumbNail);
g.CompositingQuality = CompositingQuality.HighSpeed;
g.SmoothingMode = SmoothingMode.HighSpeed;
g.InterpolationMode = InterpolationMode.HighQualityBilinear;
Rectangle oRectangle = new Rectangle(0, 0, 250, 261);
g.DrawImage(imgOutput, oRectangle);
pictureBox1.Image = oThumbNail;
imgOutput.Dispose();
imgOutput = null;
}
{
//this.BackColor = Color.Honeydew;
FileStream NewFileStream = File.Open(@"D:\1.jpg", FileMode.Open);
MessageBox.Show(NewFileStream.Length.ToString());
byte[] NewByte = new byte[Convert.ToInt32(NewFileStream.Length)];
NewFileStream.Read(NewByte, 0, Convert.ToInt32(NewFileStream.Length));
MemoryStream memdefault = new MemoryStream();
BinaryWriter savewriter = new BinaryWriter(memdefault);
savewriter.Write(NewByte);
Image NewImage = Image.FromStream(memdefault);
NewImage.Save(@"D:\2.jpg");
//Image NewImage = Image.FromStream(NewFileStream);
//NewImage.Save(@"D:\2.jpg");
}
private void button1_Click(object sender, EventArgs e)
{
Bitmap myBitmap = new Bitmap(250, 261);
Rectangle DrawRect = new Rectangle(0, 0, 250, 261);
webBrowser1.DrawToBitmap(myBitmap, DrawRect);
System.Drawing.Image imgOutput = myBitmap;
System.Drawing.Image oThumbNail = new Bitmap(250, 261, imgOutput.PixelFormat);
Graphics g = Graphics.FromImage(oThumbNail);
g.CompositingQuality = CompositingQuality.HighSpeed;
g.SmoothingMode = SmoothingMode.HighSpeed;
g.InterpolationMode = InterpolationMode.HighQualityBilinear;
Rectangle oRectangle = new Rectangle(0, 0, 250, 261);
g.DrawImage(imgOutput, oRectangle);
pictureBox1.Image = oThumbNail;
imgOutput.Dispose();
imgOutput = null;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
FileStream fs = null;
byte[] buffer = null;
try
{
if (File.Exists(filePath)) //图片文件的全路径字符串
{
fs = new FileStream(filePath, FileMode.Open);
buffer = new byte[fs.Length];
fs.Read(buffer, 0, int.Parse(fs.Length.ToString()));
fs.Close();
fs.Dispose();
}
}
catch
{
fs.Close();
fs.Dispose();
}
return buffer;//图片文件的流
通过以上方法就得到了指定图片文件的流
以下是从流中保存文件到本地
FileStream fs = new FileStream(fileName, FileMode.Create);//fileName是要保存到的文件路径
fs.Write(buffer, 0, buffer.Length);
fs.Dispose();
byte[] buffer = null;
try
{
if (File.Exists(filePath)) //图片文件的全路径字符串
{
fs = new FileStream(filePath, FileMode.Open);
buffer = new byte[fs.Length];
fs.Read(buffer, 0, int.Parse(fs.Length.ToString()));
fs.Close();
fs.Dispose();
}
}
catch
{
fs.Close();
fs.Dispose();
}
return buffer;//图片文件的流
通过以上方法就得到了指定图片文件的流
以下是从流中保存文件到本地
FileStream fs = new FileStream(fileName, FileMode.Create);//fileName是要保存到的文件路径
fs.Write(buffer, 0, buffer.Length);
fs.Dispose();
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询