Placing Bitmap and JPEG Image Fields

Description

Alpha Anywhere lets you add images to your database in two ways.

  •  Bitmap and JPEG Image fields

    store Windows Bitmap (.BMP) or JPEG (.JPG) images in the database. The images are stored in .FPT memo files.

  •  Image File Reference fields

    store the paths and filenames of Windows Bitmap (.BMP) or JPEG (.JPG) images in the database, while the images are stored independently in Windows folders. For many applications this is a more efficient way of storing images, and it can result in much smaller databases.

 Creating a Bitmap Image Field

  1. Display the Table/Sets tab of the Control Panel.

  2. Select the table that will contain the field and select Design > Table Structure.

  3. In the resulting Restructure Table dialog box create a field of type "Bitmap". Its width automatically defaults to 10 characters.

 Creating a JPEG Image Field

  1. Display the Table/Sets tab of the Control Panel.

  2. Select the table that will contain the field and select Design > Table Structure.

  3. In the resulting Restructure Table dialog box create a field of type "JPEG Image". Its width automatically defaults to 10 characters.

 Placing a Bitmap or JPEG Image Field

  1. Select the image file reference field on the Drag and Drop List.

  2. Drag the field onto the form.

  3. Resize and reposition the field (which will display the image) as necessary.

  4. Right click on the field and select Properties > Setup.

  5. Select the image display mode to use. The options are:

    • "Absolute" - the image is not stretched or scaled and may be bigger or smaller than the form field.

    • "Best Fit" - the image is scaled without distortion to fit the form field

    • "Stretch" - the image is scaled with possible distortion to fit the form field

    • "Tiled" - the image is repeated as many times as necessary both vertically and horizontally to fill the form field

 Adding an Image to the Table

When you insert a picture into a .JPG Picture field, you are not restricted to selecting only .JPG files. For example, you can select a .BMP file and insert it into the .JPG field. Alpha Five will automatically convert the .BMP format file to a .JPG format and store the picture in the field. The same is true of storing a .JPG format file in a .BMP field. Alpha Five automatically converts from the .JPG format to the .BMP format.

  1. Put the form into view mode.

  2. Right click the image file reference field and select Import Image.

  3. In the resulting Filename dialog box, optionally enter the path and filename of an image file in the File name field.

  4. Optionally,

    • 1. Click the 'open folder' icon to select a disk drive and directory in the Look in field.

    • 2. Select the file from the File Names list.

    • 3. Optionally, click the 'heart' icon to save the current folder as the default folder when adding other images.

  5. Select the preview display mode by clicking Best Fit, Absolute, or Stretch. This does not affect the form's image's display properties.

    • "Absolute" - does not stretch the image. This option may cause the image to appear as a different size when printed.

    • "Stretch" - stretches the image both horizontally and vertically to cover the form's background. This option may distort the image.

    • "Best fit" - scales the image to the maximum size that will fit on the form background without clipping the image.

  6. Click OK to select the image or Cancel to quit.

 Adding Data to a Bitmap or JPEG Image Field with Xbasic

The following script was placed under the OnPush event of a button on a form. The form displays a field named thumbnail, which is a Bitmap Image field. This script works equally well for JPEG Image fields.

There is no automatic format conversion, so you must select a Windows Bitmap for a bitmap image field and a JPEG image for a JPEG image field.
dim img as C
dim tbl as P
tbl = table.current()
img = ui_get_image_filename()
tbl.enter_begin(.t.)
tbl.thumbnail.memo_read_from_file(img, MEMO_APPEND)
tbl.enter_end(.t.)
thumbnail.refresh()

 Deleting an Image

  1. Put the form into view mode.

  2. Right click the image field and select Delete Image.

 Exporting the Image

  1. Put the form into view mode.

  2. Right click the image field and select Export Image.

  3. Optionally, in the resulting Save As dialog select Bitmap (.BMP) or JPEG (.JPG) from the Save as type list.

  4. Navigate to the target folder, enter a filename in the File name field, and click OK.

See Also