473,409 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,409 software developers and data experts.

How to extract an OLE Object (Bitmap Image) from JET?

I have a Windows Forms app that connects to an Access database. One of the
tables in the database contains a bunch of pictures stored in OLE Object
fields.

What I need to do is extract those pictures to the file system so the user
can do stuff with the image. For example, the user would select the name of
the image from a combo box and then somePicture.bmp would be extracted from
the Access database to the temp directory.

Is there an easy way to do this? Examples? Other suggestions?

Thanks in advance.
Nov 17 '05 #1
3 6610
The OLE Object header added by Access has never been documented by MS;
however, its observed length seems to be 78 bytes in all cases that I seen
so far; so, all you have to do is to strip the first 78 bytes and kept the
remaining.

--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
"deko" <de**@nospam.com> wrote in message
news:dC***************@newssvr13.news.prodigy.com. ..
I have a Windows Forms app that connects to an Access database. One of the
tables in the database contains a bunch of pictures stored in OLE Object
fields.

What I need to do is extract those pictures to the file system so the user
can do stuff with the image. For example, the user would select the name
of the image from a combo box and then somePicture.bmp would be extracted
from the Access database to the temp directory.

Is there an easy way to do this? Examples? Other suggestions?

Thanks in advance.

Nov 17 '05 #2
> The OLE Object header added by Access has never been documented by MS;
however, its observed length seems to be 78 bytes in all cases that I seen
so far; so, all you have to do is to strip the first 78 bytes and kept the
remaining.


Sounds good. Thanks for the tip. But I really have no idea how to do
that... could you provide an example?
Nov 17 '05 #3
I found the below code at http://sastools.com/b2/post/79394244

But I'm not sure what the class definition for MemoryStream is. My guess is
it's something well-known since the author left it out - still, I have no
idea with it is.

private void Page_Load(object sender,
System.EventArgs e)
{
SqlConnection cn;
cn = new SqlConnection
("DATABASE=northwind;SERVER=localhost;UID=sa;") ;
String cmdText = "SELECT photo FROM Employees WHERE employeeid=" +
Request["id"].ToString();
SqlCommand cmd = new SqlCommand(cmdText, cn);

MemoryStream ms = new MemoryStream();

// 78 is the size of the OLE header for Northwind images.
// There's no header in PUBS as PUBS
// just contains the raw image bits.
int offset = 78;

cn.Open();
byte [] img = (byte[]) cmd.ExecuteScalar();
ms.Write(img, offset, img.Length-offset);
cn.Close();

Bitmap bmp = null;
bmp = new Bitmap(ms);
Response.ContentType = "image/gif";
bmp.Save(Response.OutputStream, ImageFormat.Gif);
ms.Close();
}
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: deko | last post by:
I have a table that contains a bunch of pictures. When the user selects a particular image in a form, I need a way to extract the selected bitmap image (stored in an OLE Object table field) to the...
0
by: gana | last post by:
I'm converting an EMF to BMP. Image is coming properly except that background color of the bMP is set to black. I'm saving EMF to a stream and craeting BMP from stream. One more thing I tried is...
1
by: Joseff | last post by:
I have this Bitmap object declared and outputted to the browswer this way: invoiceBMP.Save(Response.OutputStream, ImageFormat.Gif); However, the result is that the existing static controls of...
3
by: Niels Jensen | last post by:
I have a bitmap image that's around 640 x 480 pixels. I want to add some ..gif or .png files to the image before displaying it in my application. Is there a way of doing this? Cheers Niels
1
by: makdtripper | last post by:
I create a bitmap image. I can draw and save it successfulyl...i need to know how to resize the bitmap when i add more and more drawings...or how to add scroll bars to a large created bitmap. My...
2
by: ajay_itbhu | last post by:
Hi everyone, I want to read the pixel values of 2 similar images in bitmap format like 2 continuous frame of a video for calculating the median. But i dont know how to read the pixel values of...
8
by: JEO | last post by:
I have a Visual basic 3 App that I am converting to VBA in Microsoft Access 2003. The VB3 app successfully recolors a bitmap image with code using pixel locations when clicking on option buttons...
1
by: icepick72 | last post by:
On an academic note, I want to copy a Graphic to an Image (Bitmap). I have the Graphic object but not the origin image from which it originates; this is because I'm overriding the PrintDocument...
1
by: swetha | last post by:
HI, I am very new to C++.Using C++ I am reading one bitmap image.Now,I am trying to zooming that image.Can any one tell me which function have to use for this.Or can any one send some sample code...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.