Pictures inside a database
Page 1: Working with BLOBs. Storing pictures in Access
More of this Feature
• Page 2: DBImage.NOT
• Page 3: Streaming JPG
• Page 4: JPG SOI marker
• Page 5: Project's Code Join the Discussion
"Post your views and
comments to this chapter of the free Delphi database Programming Course"
Discuss!
Related Resources
• free DB Course.TOC
• Delphi DB articles
Elsewhere on the Web
• BMP in Access/ADO
These days developing database applications requires more than just operating with textual or numeric data. If you are, for example, developing an Internet/intranet or multimedia based application,
frequently there is a need to display pictures along with text from a database.
In this third chapter of the Delphi database course, we'll see how to pull out and display the graphical data (images) inside an Access database with ADO. Don't be worried with the fact that working with images inside an Access database requires more database programming skills than this course has provided so far. Let's
pretend that we know more to get more.
If you have followed this course from the beginning (specially the second chapter), you know how to connect to a database and display the Applications (from our working aboutdelphi.mdb
http://delphi.about.com/library/weekly/aa030601a.htm (1 of 5) [24.11.2002 16:56:50]
in this topic
Game Programming Graphics
Internet/Intranet Mathematics Multimedia
Delphi Pascal/IDE Screen saver dev.
VCL Using
VCL Write/Enhance Web Services Windows/Shell/API Kylix (D on Linux)
Coding standards Books/Publications Dev. Utilities
FAQs/Tips/Tricks Free Code Projects Humor and Fun Icons and Glyphs Jobs and Offers Training/CD/Video VCL & Tools
Subject Library All articles on this topic
database) table in a DBGrid. Remember, we used 3 data components: DBGrid, ADOTable and DataSource to get and display the data from the Applications table.
Back in the first chapter when we created our database, the last filed in the Applications table was left blank (after filling our database with some dummy data). The last field has the name Picture and is of the OLE object type.
If you scroll right to the last column of the DBGrid you'll see something like:
When using MS Access, we can store images (and other large data objects such as sound or video) in a field that has the OLE object type. This type of data is referred to as a Binary Large Object Bitmap (BLOB).
Naturally when working with images, several types of picture formats are available. The most commonly used include JPEG, GIF and BMP. JPEG format has proven to be widely accepted by Web masters because of the small amount of storage required (in other words JPEGs are smaller than BMPs in bytes).
Delphi, of course, has means of handling BMP, GIF and JPEG graphic formats. The rest of this article will deal with JPEG file formats.
Storing pictures in Access
Before going on to discussion about displaying the image inside a table within a Delphi form, we need to add some graphical data to our database.
Start Access and open the aboutdelphi.mdb database. Open the Applications table (it should have one row of data) and select the Picture field.
http://delphi.about.com/library/weekly/aa030601a.htm (2 of 5) [24.11.2002 16:56:50]
Stay up-to-date!
Subscribe to our newsletter.
Advertising
> Free Credit Report
> Free Psychics To add an image do the following:
1. Select Insert|Object... this will display the Insert Object dialog box.
2. Click on the Browse button, this pops up the Browse open dialog. Note: you probably have some .jpg files on your computer, so you could use those, or if you have Win 98 and newer, MS Paint will save pictures in this format, as will many other programs. Navigate to a directory where your pictures are stored and select one.
Note: the text in the Picture field holds the name of an
executable used to work with JPEG files on your computer. Of course you don't see the picture in a table grid. To actually see the graphics double click that field. This will load the image within the JPG type associated application.
Now, when we have a picture inside a database, let's see how to display it inside a Delphi form. We already have a Delphi form with data components on it from the second chapter of this course.
Next page > Pulling the Jpeg with DBImage - the wrong way >
Page 1, 2, 3, 3, 5
http://delphi.about.com/library/weekly/aa030601a.htm (3 of 5) [24.11.2002 16:56:50]
Enter Email Go!
All graphics (if any) in this feature created by Zarko Gajic.
More Delphi
· Learn another routine every day - RTL Quick Reference.
· Download free source code applications and components.
· Talk about Delphi Programming, real time. Start a chat now!
· Link to the Delphi Programming site from your Web pages.
· Tutorials, articles, tech. tips by date: 2001|2000|1999|1998 or by TOPIC.
· NEXT ARTICLE: Owner and Parent.
The differences between a component Owner and its Parent - briefly explained.
Stay informed with all new and interesting things about Delphi (for free).
Subscribe to the About Programming Newsletter
Name Email
Got some code to share? Got a question? Need some help?
Recent Discussions
Delphi Programming
Join these forum conversations Extracting digital audio from cd
Delphi disadvantages compared to VS.Net Keep An Application Always On Top Delphi7 adoblob problem
Searching in a text file or wide string
Email this page!
http://delphi.about.com/library/weekly/aa030601a.htm (4 of 5) [24.11.2002 16:56:50]
subscribe
Explore More on the About Network!
Related Sites
C/C++
Focus on Java Focus on Linux Focus on Windows HTML/XML
Brand New Malibu
Auto Buying Guide Philip Powell takes a closer look at
Chevrolet's sexy new 2004 Malibu.
Road Radio
Driving this Thanksgiving?
Radio Guide Corey Deitz explains how to find the right station.
Weird Science
Paranormal Guide
Steven Wagner looks at strange scientific experiments throughout history.
Search About
About Us | Advertise on This Site | User Agreement | Privacy Policy | Kids' Privacy Policy | Help
Copyright © 2002 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.
http://delphi.about.com/library/weekly/aa030601a.htm (5 of 5) [24.11.2002 16:56:50]
Explore more...
About > Computing & Technology > Delphi Programming
with Zarko Gajic Your Guide to one of hundreds of sites
Home · Articles · Forums · Chat · Classifieds · Newsletters · Help
Shop for Holiday Gifts from merchants like Old Navy, Eddie Bauer, Spiegel, and more!
ADO DB programming·
Delphi for .NET·
Free code APPs &VCL
·
A-Z Site Index BUYER'S GUIDEWhat's New and Hot Top Picks-Tool/VCL
Beginners Here COM/OLE/ActiveX Database
Distrubuted comp.
RTL reference|Glossary|Tips/Tricks|FREE App/VCL|Best'O'Net|Books|Link To