1

An OLE Object column contains images but the image type (jpg/gif/tiff) is unknown. These images need to be extracted from the DB and saved to disk. The application is primarily using VB.NET but C# examples are welcome too.

thanks Rahul

2 Answers 2

3

Try using the System.Drawing.Image.FromStream to load the image. You can make a stream from a byte array using System.IO.MemoryStream foo = new System.IO.MemoryStream(MyByteArray);

Once you've loaded the image, you can use whatever GDI stuff you want to save it (e.g. ImageInstance.Save(FileName);)

Sign up to request clarification or add additional context in comments.

Comments

3

Create a byte array large enough to hold the OLE object:

Dim bArr(Len(<OLE Object Field>)) as Byte

Read in the first row of your OLE Object column and place it in the Byte array.

For a GIF file, bytes 0 through 2 will have the ASCII value "GIF". For a JPEG file, bytes 6 through 9 will typically have the value "JFIF". For a PNG file, bytes 1 through 3 will have the ASCII value "PNG".

TIFF is more difficult since there are so many different TIFF standards.

Once you have determined the file type, you can use Brian's method to save the file

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.