Available in the LEADTOOLS Imaging toolkit. |
Loading and Displaying an Image (Access 2.0)
Take the following steps to start a project and to add some code that positions, scales, and displays an image on a form:
1. Start Microsoft Access 2.0.
2. On the File pull-down menu, use the New Database option to create a new database.
3. In the Database window, select the Module tab, and click the New button.
4. On the File pull-down menu, use the Load Text option to load the L_ACCESS.BAS file from LEAD's INCLUDE directory. (Use the Merge option when loading the file.)
5. Close the file, and save it as the Global Constants module.
6. In the Database window, select the Form tab, and click the New button.
7. In the New Form window, click the Blank Form Button.
8. Click and drag the form's detail area to make it large enough to hold an image and some command buttons.
9. On the Edit pull-down menu, use the Insert Object option to select the Lead Control (12).
10. Click the OK button. The lead control appears on the form.
11. Size and position the control as you want it to appear at run time, and change the name of the control to Lead1.
12. Add a command button to your form and name it as follows. (Cancel the Command Button Wizard when it appears.)
Name |
Caption |
LoadLead |
Load Image |
13. Click the Code Window icon on the toolbar.
14. Select the Load procedure for Form1, and add the following code. In online help, you can use the Edit pull-down menu to copy the block of code.
Sub Form_Load ()
'Set defaults for displaying the image.
'These are all persistent properties that can be set in the properties box.
Me![Lead1].Object.BorderStyle = 1
Me![Lead1].Object.BackColor = RGB(255, 255, 125)
Me![Lead1].Object.PaintDither = PAINTDITHER_DIFFUSION
Me![Lead1].Object.PaintPalette = PAINTPALETTE_AUTO
Me![Lead1].Object.AutoRepaint = True
Me![Lead1].Object.AutoSize = False
Me![Lead1].Object.AutoSetRects = True
Me![Lead1].Object.PaintSizeMode = PAINTSIZEMODE_FIT
Me![Lead1].Object.ForePalette = True
End Sub
15. Code the LoadLead button's click procedure as follows:
Sub LoadLead_Click ()
Me![Lead1].Object.Load "c:\lead\images\image1.cmp", 0, 0, 1
End Sub
16. Close the code window.
17. Click the Form View icon on the toolbar to test the form.
Note: For 256-color mode, you can improve the image quality as explained in Palette Usage in Microsoft Access.