When I try to insert an image to the MySQL database everything works normal, but when I run a function that makes the size of my image smaller and try to insert it, it shows me an error that says
this is the code to select the image:
private void pbImagen_DoubleClick(object sender, EventArgs e)
{
try {
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "choose Image(*.JPG;*.PNG)|*.jpg;*.png";
if (ofd.ShowDialog() == DialogResult.OK)
{
convertir conv = new convertir()
pbImagen.Image = conv.RedimensionarImage(Bitmap.FromFile(ofd.FileName));
pbImagen.SizeMode = PictureBoxSizeMode.CenterImage;
pbImagen.SizeMode = PictureBoxSizeMode.StretchImage;
}
}
catch {
MessageBox.Show("No Ingresaste Ninguna Imagen");
}
}
then we have the code that reduces the size of the image:
public Bitmap RedimensionarImage(Image imgO)
{
var redimencion = new Bitmap(100, 100);
Graphics.FromImage(redimencion).DrawImage(imgO, 0, 0, 100, 100);
Bitmap ImagenFinal = new Bitmap(redimencion);
return ImagenFinal;
}
and then I try to insert it into the database but it tells me that the value is null. if this I try without reducing the image if it works. someone to help me please