The Future Is Now – Advanced Support for Images

SRPPicture Shortly after Revelation released news of their support for alpha channel images, they released a companion article documenting other improvements to their image API. This introduced seven new properties (IMAGEALIGN, IMAGECOLORKEY, IMAGEFRAMECOUNT, IMAGEFRAMENUMBER, IMAGESIZE, IMAGESTYLE, and IMAGETRANSLUCENCY) and one new method (SETIMAGE). In like fashion we will explore some of the more advanced features of the SRP Picture control and compare them to these new properties and new method that will be introduced in OpenInsight 10.

Alignment property

This property performs the equivalent functionality of OpenInsight’s new IMAGEALIGN property. It provides developers with alignment control over images which are clipped or scaled. The image can be placed in any corner, the middle of any side, or directly in the center – nine positions in total. Whereas the IMAGEALIGN property uses a single integer to represent one of the nine alignment options, the Alignment property uses an @FM delimited array. Attribute 1 contains the vertical alignment value (T or Top, C or Center, B or Bottom) and attribute 2 contains the horizontal alignment value (L or Left, C or Center, R or Right). For example:

 

AlignmentTL

Set_Property(@Window : ‘.OLE_PICTURE’, ‘OLE.Alignment’, ‘T’ : @FM : ‘L’)

 

TransparentColor property

We already documented this property in our previous article. We are mentioning it again here because it serves the same purpose as OpenInsight’s IMAGECOLORKEY property.

 

ImageSize property

Not only is the spelling the same OpenInsight’s IMAGESIZE property, they work exactly the same as well. Both properties return a dynamic array with attribute 1 containing the image width and attribute 2 containing the image height.

 

Layout property

By default images are displayed in a clipped format. That is, the image is displayed in its original size, but if the image is larger than the dimensions of the SRP Picture control, this outer area appears cut off, like an old photograph trimmed to fit into a small picture frame. However, developers sometimes prefer to display the entire image regardless of the size of the SRP Picture control, or perhaps another layout option is needed. OpenInsight 10 will support various layout preferences through the IMAGESTYLE property. Developers will be able to choose clipped, stretched, tiled, or scaled options. The SRP Picture control supports all four of these options within the Layout property with Clip, Stretch, Tile, and Thumbnail values (respectively.)

 

LayoutTile

Set_Property(@Window : ‘.OLE_PICTURE’, ‘OLE.Layout’, ‘Tile’)

 

There is a fifth value, Pan, which opens up two very useful features: zooming and scrolling . A panned image can be zoomed in or out interactively using a mouse (Double-Click or Ctrl+Mouse Wheel Up to zoom in, Shift+Double-Click or Ctrl+Mouse Wheel Down to zoom out) or via the Zoom property. Zoomed images (or ones that are naturally larger than the size of the SRP Picture control) can be dragged around with a mouse or moved around using the scroll bars that will automatically appear in the SRP Picture control:

 

LayoutPan

Set_Property(@Window : ‘.OLE_PICTURE’, ‘OLE.Layout’, ‘Pan’)

 

Supported Image Formats

At present, SRP image technology does not yet handle multiple frames from GIF or TIFF images. Only the first frame will load. Thus, there are no equivalent properties for IMAGEFRAMECOUNT and IMAGEFRAMENUMBER. Our Frame and FrameCount properties, however, behave exactly like OpenInsight’s IMAGECOUNT and IMAGENUMBER properties. Furthermore, our Animated and AnimationDelay properties provide a flexible and rich animation experience without the need to rely on the TIMER event.

It should also be noted that vector formats (.WMF, .EMF) are supported. We make sure that the aspect ratio is preserved so that these images scale perfectly when zoomed.

 

LoadRawImage method

Applications do not always have the luxury of storing images as local files. Sensitive images are sometimes stored directly within the database itself. For this reason, the LoadRawImage method was created so that developers can read the binary data directly from the database and populate the SRP Picture control. The OpenInsight SETIMAGE method was added to the API for the exact same reason.

 

ControlPart property

We will end this post with one of the oldest and probably most underrated properties of the SRP Picture control: ControlPart. This special property, which has no OpenInsight counterpart as of this writing, provides developers a way to add theme friendly widgets such as vertical bars, horizontal dividers, and toolbar grippers. These visual objects are far better than graphic images because they can resize with the control smoothly and they will draw perfectly for the theme and color scheme. They are also better than group box controls because they offer more flexibility. These have been a staple in our primary SRP FrameWorks MDI Frame for many years, giving our toolbars a contemporary look and feel.

 ControlPart

Toolbar using a menu divider and several vertical dividers

One of the ControlPart values, Divider, also provides UI developers a cleaner, contemporary, and lighter weight alternative to the group box control. Here is an example of the two types of controls side by side:

ControlPartDiv

Leave a Reply

Subscribe to Blog

Enter your email address to sign up for email notifications of new posts.