Objectmix
Tags Register Mark Forums Read

Saving a Bitmap or Image type to a Byte() in a database - SQL Server 2005 : DOTNET

This is a discussion on Saving a Bitmap or Image type to a Byte() in a database - SQL Server 2005 within the DOTNET forums in Framework and Interface Programming category; Thanks Bob for previous link. The problem now is that the images are stored in the database as a Byte( ) , ie a Byte array. So I am having trouble converting the System.Drawing.Bitmap type into a Byte( ). CType won't do this. Can anyone help me do this with Visual Basic 2005. Thanks Jason...


Object Mix > Framework and Interface Programming > DOTNET > Saving a Bitmap or Image type to a Byte() in a database - SQL Server 2005

DOTNET Discussion forums related to Microsoft Dot net technologies, CSharp and other related items

Reply

 

LinkBack Thread Tools
  #1  
Old 10-17-2006, 11:20 PM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Saving a Bitmap or Image type to a Byte() in a database - SQL Server 2005

Thanks Bob for previous link.
The problem now is that the images are stored in the database as a Byte( ) ,
ie a Byte array. So I am having trouble converting the System.Drawing.Bitmap
type into a Byte( ). CType won't do this. Can anyone help me do this with
Visual Basic 2005.
Thanks
Jason


  #2  
Old 10-17-2006, 11:25 PM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: Saving a Bitmap or Image type to a Byte() in a database - SQL Server 2005

<jason.smart@email.cs.nsw.gov.au> wrote in message
news:OnJSzym8GHA.4012@TK2MSFTNGP04.phx.gbl...
> Thanks Bob for previous link.
> The problem now is that the images are stored in the database as a Byte( )
> , ie a Byte array. So I am having trouble converting the
> System.Drawing.Bitmap type into a Byte( ). CType won't do this. Can anyone
> help me do this with


Create a memory stream from the byte array and then create the image from
the stream.

> Visual Basic 2005.
> Thanks
> Jason
>



  #3  
Old 10-18-2006, 12:13 AM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: Saving a Bitmap or Image type to a Byte() in a database - SQL Server 2005

Thanks Michael,
This is what I used and it works fine, note that bitmap is of type
System.Drawing.Bitmap

Dim memoryStream As New MemoryStream()

bitmap.Save(memoryStream, bitmap.RawFormat)

Dim imgArray() As Byte = memoryStream.GetBuffer

memoryStream.Close()



"Michael C" <nospam@nospam.com> wrote in message
news:u0%238w0m8GHA.3552@TK2MSFTNGP03.phx.gbl...
> <jason.smart@email.cs.nsw.gov.au> wrote in message
> news:OnJSzym8GHA.4012@TK2MSFTNGP04.phx.gbl...
>> Thanks Bob for previous link.
>> The problem now is that the images are stored in the database as a
>> Byte( ) , ie a Byte array. So I am having trouble converting the
>> System.Drawing.Bitmap type into a Byte( ). CType won't do this. Can
>> anyone help me do this with

>
> Create a memory stream from the byte array and then create the image from
> the stream.
>
>> Visual Basic 2005.
>> Thanks
>> Jason
>>

>
>



Managed by Infnx Pvt Ltd.