DEV Community

Peter + AI
Peter + AI

Posted on

πŸ–ΌοΈ Understanding Uniface 10.4 Image Data Types: A Simple Guide

Note: This blog post was created with the assistance of AI to help make Uniface documentation more accessible.

πŸ“š Introduction

If you're working with Uniface 10.4 and need to handle images in your application, you might wonder which data type to use. Uniface offers several image data type variants, each optimized for different image sources. Let's break them down in simple terms! πŸš€

🎯 The Five Image Data Types

Uniface provides five different image data types, all based on the core Image type. Each one tells Uniface where to expect the image data from:

1. I or Image - The Universal Type 🌐

What it does: This is the most flexible option. Uniface automatically detects the image format and handles it accordingly.

When to use: When you're not sure where the image will come from, or when your image sources vary.

Example:

field MYFIELD : I  ; Generic image field
Enter fullscreen mode Exit fullscreen mode

2. I# - Database Images πŸ’Ύ

What it does: Tells Uniface the image comes from a database occurrence (stored as a BLOB - Binary Large Object).

When to use: When images are stored directly in your database tables.

Example:

field EMPLOYEE_PHOTO : I#  ; Photo stored in database
Enter fullscreen mode Exit fullscreen mode

3. I@ - Disk File Images πŸ“

What it does: Assumes the image is stored as a file on your disk.

When to use: When working with image files from the file system.

Example:

field PRODUCT_IMAGE : I@  ; Image from disk file
; You only need to specify the filename like "product123.jpg"
Enter fullscreen mode Exit fullscreen mode

4. I^ - Glyph Images 🎨

What it does: Retrieves images from a glyph library (pre-loaded image collections).

When to use: For icons, buttons, and other UI elements stored in resource libraries.

Example:

field TOOLBAR_ICON : I^  ; Icon from glyph library
; Just specify the glyph name like "save_icon"
Enter fullscreen mode Exit fullscreen mode

5. I& - URL Images 🌍

What it does: Expects the image to be served by a web server via URL.

When to use: Only in server pages when images are hosted on web servers.

Example:

field WEB_BANNER : I&  ; Image from web server
; Specify URL like "https://example.com/banner.png"
Enter fullscreen mode Exit fullscreen mode

πŸ’‘ Key Advantages

The beauty of I^ (glyph) and I@ (disk file) data types is their simplicity! You only need to specify the image name or filename, and Uniface handles the loading automatically. No need to write complex code to retrieve and display images. ✨

πŸŽ“ Practical Tips

  • Choose the right type: Using the specific data type (I#, I@, I^, I&) helps Uniface optimize performance.
  • Use I for flexibility: When in doubt, the generic I type provides maximum flexibility.
  • Database vs. Files: Consider whether storing images in the database (I#) or as files (I@) better suits your application needs.
  • Web applications: For web-based Uniface apps, I& is your friend for external images.

🏁 Conclusion

Understanding these five image data types helps you write cleaner, more efficient Uniface code. Each type is designed for a specific use case, making image handling in Uniface both powerful and straightforward. Choose the right type based on your image source, and let Uniface do the heavy lifting! πŸ’ͺ

Happy coding! πŸ‘¨β€πŸ’»πŸ‘©β€πŸ’»

Top comments (0)