I have a question that I cannot solve and I am looking for your help...
I tell you, I have a datagrid which has an image type column in which I use as a preview of my image that is loaded from a database.
Next I have a button type column which helps me to See the image in a PictureBox, all this works correctly I can see all the images in the picturebox when I press the View button.
Then I have a button type column to remove the image, that works correctly.
Then I have a button type column which has a button that is to Download the image that has the picturebox and here is the problem.
Here is the datagrid image
Here I have the code of how when pressing the view button the image goes to the picturebox
DataGridViewImageCell cell =
dataGridView2.Rows[e.RowIndex].Cells["vistaprev"] as DataGridViewImageCell;
Bitmap bmpbt;
bmpbt = (Bitmap)cell.Value;
using (MemoryStream ms = new MemoryStream())
{
bmpbt.Save(ms, ImageFormat.Jpeg);
base64dgv = Convert.ToBase64String(ms.ToArray());
MemoryStream msm = new MemoryStream(Convert.FromBase64String(base64dgv));
pictureBox2.Image = Bitmap.FromStream(ms);
pictureBox2.SizeMode = PictureBoxSizeMode.StretchImage;
}
So I'm trying to download the images...
SaveFileDialog newsave = new SaveFileDialog();
newsave.FileName ="Name";
newsave.Filter = "JPEG(*.JPEG)|*.JPEG";
if (newsave.ShowDialog() == DialogResult.OK)
{
pictureBox2.Image.Save(newsave.FileName,ImageFormat.Jpeg);
}
This downloads an image for me but when I open it the image is not displayed, only like this name.jpeg and when I double click it to see the image nothing is seen.
Can you guide me on how to do it.
Thanks.
Note: The image is loaded from the database, I NEVER PASS THE PATH OF THE IMAGE TO THE PICTUREBOX, let's not get confused.
I would recommend that you do not take so many steps, if you have the image in
Bitmap
there you can already save the image to a fileBitmap.Save(String, ImageFormat)