Image Table
CREATE TABLE [dbo].[Image_Table]
(
[Img_ID] [bigint] IDENTITY(1,1) NOT NULL,
[Image_Name] [image] NULL,
)
How To Convert Byte Array To Image
When you want to take image from database.It must change byte array to image to show it.
The next function convert byte array to image :
public Image byteArrayToImage(byte[] bArray)
{
MemoryStream ms = new MemoryStream(bArray);
Image Img = Image.FromStream(ms);
return Img;
}
How To Show Image
call the function:
pictureBox1.Image=byteArrayToImage((byte[])dr["Image_Name"]);
dr["Image_Name"]: is a data reader .it takes values from database.
9 Aug 2009
Convert ByteArray To Image
Posted by
Hayfa
Convert Image To ByteArray
Posted by
Hayfa
Image Table
CREATE TABLE [dbo].[Image_Table]
(
[Img_ID] [bigint] IDENTITY(1,1) NOT NULL,
[Image_Name] [image] NULL,
)
How To Convert Image To Byte Array
When you want to save image in database.It must save it as byte array.
The next function convert image to byte array:
public byte[] imageToByteArray(System.Drawing.Image img)
{
MemoryStream ms = new MemoryStream();
img.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
return ms.ToArray();
}
Subscribe to:
Posts (Atom)