不太明白楼主的意思。 以下代码是msdn中Image类Save方法的例子。Bitmap image1;private void Button1_Click(System.Object sender, System.EventArgs e) { try { // Retrieve the image. image1 = new Bitmap(@"C:\Documents and Settings\All Users\" + @"Documents\My Music\music.bmp", true); int x, y; // Loop through the images pixels to reset color. for(x=0; x<image1.Width; x++) { for(y=0; y<image1.Height; y++) { Color pixelColor = image1.GetPixel(x, y); Color newColor = Color.FromArgb(pixelColor.R, 0, 0); image1.SetPixel(x, y, newColor); } } // Set the PictureBox to display the image. PictureBox1.Image = image1; // Display the pixel format in Label1. Label1.Text = "Pixel format: "+image1.PixelFormat.ToString(); } catch(ArgumentException) { MessageBox.Show("There was an error." + "Check the path to the image file."); } } private void Button5_Click(System.Object sender, System.EventArgs e) { try { if (image1 != null) { image1.Save("c:\\myBitmap.bmp"); Button5.Text = "Saved file."; } } catch(Exception) { MessageBox.Show("There was a problem saving the file." + "Check the file permissions."); }}
保存路径是可以设置的。 以下是msdn中Image类Save方法的调用例子。Bitmap image1;private void Button1_Click(System.Object sender, System.EventArgs e) { try { // Retrieve the image. image1 = new Bitmap(@"C:\Documents and Settings\All Users\" + @"Documents\My Music\music.bmp", true); int x, y; // Loop through the images pixels to reset color. for(x=0; x<image1.Width; x++) { for(y=0; y<image1.Height; y++) { Color pixelColor = image1.GetPixel(x, y); Color newColor = Color.FromArgb(pixelColor.R, 0, 0); image1.SetPixel(x, y, newColor); } } // Set the PictureBox to display the image. PictureBox1.Image = image1; // Display the pixel format in Label1. Label1.Text = "Pixel format: "+image1.PixelFormat.ToString(); } catch(ArgumentException) { MessageBox.Show("There was an error." + "Check the path to the image file."); } }private void Button5_Click(System.Object sender, System.EventArgs e) { try { if (image1 != null) { image1.Save("c:\\myBitmap.bmp"); Button5.Text = "Saved file."; } } catch(Exception) { MessageBox.Show("There was a problem saving the file." + "Check the file permissions."); }}
Image image = Image.FromFile("图片文件全路径");
image.Save("保存全路径", System.Drawing.Imaging.ImageFormat.Bmp);//第二个参数是保存格式,根据自己需要修改
保存全路径可以替换成当前项目的文件夹吗?
以下代码是msdn中Image类Save方法的例子。Bitmap image1;private void Button1_Click(System.Object sender, System.EventArgs e)
{ try
{
// Retrieve the image.
image1 = new Bitmap(@"C:\Documents and Settings\All Users\"
+ @"Documents\My Music\music.bmp", true); int x, y; // Loop through the images pixels to reset color.
for(x=0; x<image1.Width; x++)
{
for(y=0; y<image1.Height; y++)
{
Color pixelColor = image1.GetPixel(x, y);
Color newColor = Color.FromArgb(pixelColor.R, 0, 0);
image1.SetPixel(x, y, newColor);
}
} // Set the PictureBox to display the image.
PictureBox1.Image = image1; // Display the pixel format in Label1.
Label1.Text = "Pixel format: "+image1.PixelFormat.ToString(); }
catch(ArgumentException)
{
MessageBox.Show("There was an error." +
"Check the path to the image file.");
}
}
private void Button5_Click(System.Object sender, System.EventArgs e)
{
try
{
if (image1 != null)
{
image1.Save("c:\\myBitmap.bmp");
Button5.Text = "Saved file.";
}
}
catch(Exception)
{
MessageBox.Show("There was a problem saving the file." +
"Check the file permissions.");
}}
以下是msdn中Image类Save方法的调用例子。Bitmap image1;private void Button1_Click(System.Object sender, System.EventArgs e)
{ try
{
// Retrieve the image.
image1 = new Bitmap(@"C:\Documents and Settings\All Users\"
+ @"Documents\My Music\music.bmp", true); int x, y; // Loop through the images pixels to reset color.
for(x=0; x<image1.Width; x++)
{
for(y=0; y<image1.Height; y++)
{
Color pixelColor = image1.GetPixel(x, y);
Color newColor = Color.FromArgb(pixelColor.R, 0, 0);
image1.SetPixel(x, y, newColor);
}
} // Set the PictureBox to display the image.
PictureBox1.Image = image1; // Display the pixel format in Label1.
Label1.Text = "Pixel format: "+image1.PixelFormat.ToString(); }
catch(ArgumentException)
{
MessageBox.Show("There was an error." +
"Check the path to the image file.");
}
}private void Button5_Click(System.Object sender, System.EventArgs e)
{
try
{
if (image1 != null)
{
image1.Save("c:\\myBitmap.bmp");
Button5.Text = "Saved file.";
}
}
catch(Exception)
{
MessageBox.Show("There was a problem saving the file." +
"Check the file permissions.");
}}
http://topic.csdn.net/u/20081206/09/9a28f8b3-48de-499c-83b7-54e0b4499b93.html
this.pictureBox.Image.Save(@"c:\xxx.bmp");我这样用的能行吗
this.pictureBox.Image.Save(pictureopenFileDialog.FileName);