En C# ,hay que convertir la imagen a un array de bytes para grabarlo en bytea,
quizá esto te pueda servir.
saludos.
public static byte[] Image2Bytes(Image img)
{
string sTemp = Path.GetTempFileName();
FileStream fs = new FileStream(sTemp, FileMode.OpenOrCreate,
FileAccess.ReadWrite);
img.Save(fs, System.Drawing.Imaging.ImageFormat.Png);
fs.Position = 0;
//
int imgLength = Convert.ToInt32(fs.Length);
byte[] bytes = new byte[imgLength];
fs.Read(bytes, 0, imgLength);
fs.Close();
return bytes;
}
public static byte[] ImagenABytes(Image Imagen)
{
Bitmap bmp = new Bitmap(Imagen);
MemoryStream mm = new MemoryStream();
bmp.Save(mm, System.Drawing.Imaging.ImageFormat.Jpeg);
ImageConverter converter = new ImageConverter();
byte[] Array = (byte[])converter.ConvertTo(bmp, typeof(byte[]));
return Array;
}
public static Image Bytes2Image(byte[] bytes)
{
if (bytes == null) return null;
//
MemoryStream ms = new MemoryStream(bytes);
Bitmap bm = null;
try
{
bm = new Bitmap(ms);
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
return bm;
}
----- Original Message -----
From: cesar florez
To: [email protected]
Sent: Monday, December 28, 2009 1:53 PM
Subject: [pgsql-es-ayuda] imagenes en postgres
estoy desarrollando una aplicacion en Visual c++ 6.0 y la version de
postgresql que estoy utilizando es la 8.4 bajo windows he tratado de insertar
una imagen en base de datos y he intentado por todos los medios pero sin nungun
resultado, he probado con el tipo de datao bytea, y con el oid con el oid
funciona pero no con el resultado esperado, donde tengo entendido el tipo oid
guarda un identificador donde se encuentra la imagen mas no insertera el
contenido a la tabla.
Nota.
me conecto con el servidor usando las api de postgres que viene
libreria pqlib.lib
les agradeceria muchisimo cual quier informacion que me pueda ayudar..
Gracias...
Att. Cesar Flórez