Chapter III Pictures in Database
Section 1 processing blobs, store pictures in Access
Now developing database applications only need to handle text or digital data. For example, if you are developing an Internet / IntraN or multimedia-based application, like the text in the database, the images in the database must be displayed frequently.
In the third chapter of this tutorial, we will understand how to remove graphics data in the Access database via ADO. Don't worry that the database programming techniques you need to handle images in the Access database are more than this tutorial to now. Let us assume that we have known more than you have already got.
If you learn from the beginning of this tutorial (especially Chapter 2), you will know how to connect the database and display the Applications table in DBGRID (from our AboutDelphi.mdb database). Remember, we need three data components: DBGRID, ADOTABLE and DATASOURCE to get and display the data of the Applications table.
Back to Chapter Chapter Chapter When we create a database, we have an empty in the last field of the Applications table (other fields we fill in dumb data). The field name of the final field is Picture, the type of OLE object type.
If you roll to the last column of DBGRID, you will see the situation as shown:
When using MS Access, we can store images (and other big data objects, such as sound or video) in the field of OLE object types. This type of data is considered a binary large object bitmap (blob) large binary object bitmap.
Of course, when processing images, several types of image formats are available. The most commonly used JPEG, GIF, and BMP. Among them, JPEG has been widely accepted by web designers because the amount of data stored is small (in other words, JPEGS is less than BMPS).
Of course, Delphi has methods for processing BMP, GIF, and JPEG graphics formats. The next section of this chapter will handle the JPEG file format.
Storage Pictures in Access (Storing Pictures in Access)
Before discussing images in the Delphi form, we need to add some graphical data in the database.
Run Access to open the AboutDelphi.mdb library. Open Applications table (it should have a line of data) and select the Picture field.
Add an image by following the steps below:
1. Select INSERT | Object ... An Insert Object dialog box will appear.
2. Click the Browse button to open the Browse open dialog box. Note: There may be some .jpg files on your computer, so you can use these files, or if you have Win98 and updated versions, MS Paint will save images in this format - many other tools can also complete the same functionality . Find the directory where the image is stored and select a picture.
Note: The text on the Picture Image field has an executable name to handle the name of the JPEG file on your computer. Of course, you won't see pictures on your table. In order to really see pictures, you can double-click this field, which will carry out images associated with the application in JPG format.
Now, we already have pictures in the database, let us see how to display it in the Delphi form. From the second chapter, we have a Delphi form with a data component.