I have a question that I can not solve and I am looking for your help ...
I comment, I have a datagrid which has a column type image in which I use as a preview of my image that is loaded from a database.
Often I have a button type column which I use to see the image in a PictureBox, all this works correctly I can see all the images in the picturebox when I click the View button.
Then I have a button type column to delete the image, that works correctly.
Then I have a column type button which has a button that is to download the image that has the picturebox and here is the problem.
Here the image of datagrid
Here I have the code of how to press the button see 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, but when I open it, the image is not displayed, just like this name.jpeg and when I give it a double cilck to see the image, nothing is seen.
They can guide me on how to do it.
Thanks.
Note: The image is loaded from the database, I NEVER PASS THE IMAGE PATH TO THE PICTUREBOX, do not get confused.