Monthly Archives: February 2013

The System Monitor – Part II

In a previous post we looked at some the enhancements to the version 10 System Monitor to make it a more user-friendly tool.  However, one of the features we didn’t mention was the addition of a Basic+ property API so you can interact with it from your own programs and tools if you wish.  This API is exposed via the new SYSTEMMONITOR object, which supports the following properties:

  • HANDLE
  • RESULTS
  • SIZE
  • TEXT
  • VISIBLE

And the following method:

  • RUN

HANDLE property

This property returns the window handle (HWND) of the System Monitor window.

RESULTS property

This property returns the contents of the results edit box in the System Monitor.

SIZE property

This property gets and sets the size and position of the System Monitor window.  It has the same format as the normal OpenInsight WINDOW SIZE property.

TEXT property

This property gets and sets the caption text of the System Monitor window.

VISIBLE property

This property gets and sets the visibility of the System Monitor window.  It has the same format as the normal OpenInsight WINDOW VISIBLE property

RUN method

This method executes a system monitor command.

(Disclaimer: This article is based on preliminary information and may be subject to change in the final release version of OpenInsight 10).

The Image API

As promised in our last post this time we’re going to cover the new properties we’ve added to the Presentation Server to support the enhanced image capability:

  • IMAGEALIGN
  • IMAGECOLORKEY
  • IMAGEFRAMECOUNT
  • IMAGEFRAMENUMBER
  • IMAGESIZE
  • IMAGESTYLE
  • IMAGETRANSLUCENCY

We have also added the following new method:

  • SETIMAGE

IMAGEALIGN property

This property specifies how a clipped or scaled image is aligned within a client area.  It can be one of the following values:

  • “0” Top-Left
  • “1” Top-Center
  • “2” Top-Right
  • “3” Middle-Left
  • “4” Centered
  • “5” Middle-Right
  • “6” Bottom-Left
  • “7” Bottom-Center
  • “8” Bottom-Right

Examples:

IMAGEALIGN 4 (Centered)

IMAGEALIGN 6 (Bottom-Left)

IMAGEALIGN 6 (Bottom-Left)

IMAGESTYLE property

This property specifies how the image is rendered onto the window’s client area.  The following property values are supported:

  • “0” Clip – the image is not resized and is simply rendered onto the client area according to the IMAGEALIGN property (Note that the IMAGEORIGIN property will override the image alignment).
  • “1” Stretch – the image is resized to cover the entire client area of the window.
  • “2” Tile – the image is tiled across the entire client area.
  • “3” Scale – the image is resized but it’s proportions are kept constant: e.g. if the image is taller than it is wide the image height will be resized to the height of the client area, and it’s width scaled to keep the same proportions.  It will also respect the IMAGEALIGN property.

Examples:

IMAGESTYLE 1 (Tiled)

IMAGESTYLE 1 (Tiled)

IMAGESTYLE 2 (Stretched)

IMAGESTYLE 2 (Stretched)

IMAGESTYLE 3 (Scaled), IMAGEALIGN 5 (Center-Right)

IMAGESTYLE 3 (Scaled), IMAGEALIGN 5 (Center-Right)

IMAGECOLORKEY property

This property specifies the color to use as the transparent color when rendering the image as described in this post.  It basically replaces the current (and undocumented) IMAGETRANSPARENT and TRANSPARENTCOLOR properties, both of which have been deprecated with this release.

This property should be a valid RGB color value or one of the following special values:

  • “-1” Use the color of the top left pixel as the color-key.
  • “-2” Use the color of the top-right pixel as the color-key.
  • “-3” Use the color of the bottom-left pixel as the color-key.
  • “-4” Use the color of the bottom-right pixel as the color-key.
  • “-5” Do not use any color-keying.

IMAGEFRAMECOUNT property

Some image formats such a GIF and TIFF files can contain more than one image, held in series of frames.  This read-only property returns the number of frames in the image file.  Note that this is not the same as the IMAGECOUNT property, which applies to a single frame only.

Example:

Animated GIF with 12 frames

Animated GIF with 12 frames

IMAGEFRAMENUMBER property

This property gets or sets the current display frame for the image and could be used with a TIMER event to display an animated GIF file for example.  Note that this property is not the same as the IMAGENUMBER property which applies to a single frame only.

Examples:

Animated GIF with IMAGEFRAMENUMBER of 2

Animated GIF with IMAGEFRAMENUMBER of 2

Animated GIF with IMAGEFRAMENUMBER of 10

Animated GIF with IMAGEFRAMENUMBER of 10

IMAGESIZE property

This read-only property returns a dynamic array containing the size of the image in pixels:

<1> Width
<2> Height

Note that for a multi-frame image format it returns the size of a single frame, not all the frames combined.

IMAGETRANSLUCENCY property

This property specifies the transparency of the entire image as it is rendered onto the window. It is based on simple percentage amount, “0″ being fully opaque and “100″ being fully transparent (and therefore not visible).

Example:

IMAGETRANSLUCENCY of 70 with IMAGEORIGIN of 90,60

IMAGETRANSLUCENCY of 70 with IMAGEORIGIN of 90,60

SETIMAGE method

This method supersedes the existing IMAGE property and allows a image to be set by passing the raw image data rather than by passing a file or resource name as per the BITMAP property.  The OpenInsight property interface is text-based and does not support passing binary data with embedded null characters, whereas the method interface does, hence the reason for this change.

Other image-related properties

The following current image-related properties remain the same:

  • BITMAP
  • IMAGECOUNT
  • IMAGENUMBER
  • IMAGEOFFSET
  • IMAGEORIGIN

Deprecated properties

The following properties have been deprecated or removed in OpenInsight 10:

  • IMAGE – this property has been superseded by the SETIMAGE method.  It is now a synonym for the BITMAP property.
  • IMAGECLIP – this property has been superseded by the IMAGESTYLE property.
  • IMAGETRANSPARENT – this property has been superseded by the IMAGECOLORKEY property.
  • TRANSPARENTCOLOR – this property has been superseded by the IMAGECOLORKEY property.

(Disclaimer: This article is based on preliminary information and may be subject to change in the final release version of OpenInsight 10).

Image transparency – Color-keying and Alpha-blending

Earlier versions of OpenInsight have supported basic image transparency via a method called “color-keying”, where a specific color in the image is nominated as the transparent color (by default the color of the top-left pixel).  When the image is drawn to screen the pixels that match the transparent color are not rendered so the background pixels show through instead.  Whilst this can be effective in simple cases it is sub-optimal for images that have smooth curves and shadows as these tend to appear very pixelated: You can see this in the example from OpenInsight 9.3 below, where a bitmap with a white background and a slight shadow is rendered to a non-white background:

Orignal bitmap

Color-Keyed bitmap showing pixelated edges

Color-Keyed bitmap showing pixelated edges

A much better alternative is to use an image format that supports an “alpha channel” such as a PNG file*. Basically this means that each pixel in the image has an extra byte that describes it’s transparency – a value of 0 means that the pixel is totally transparent, while a value of 255 means that the pixel is totally opaque, Values in between are used to calculate how the image pixel is combined with the background pixel when drawn, so that it gives the appearance of being translucent, allowing the background pixel to show through to some degree.  This is a technique known as Alpha-blending.

With version 10 we’ve taken the opportunity to re-visit OpenInsight’s image handling so it respects the alpha channel properly – you can see this in the example below, where the same image is loaded from a PNG file rather than a standard BMP file:

Alpha-blended source bitmap

Alpha-blended PNG bitmap with smooth edges and shadow

Alpha-blended PNG bitmap with smooth edges and shadow

We have also take this one step further and provided the ability to specify a transparency setting for the entire image when it is rendered, so you can create an effect like a watermark:

Alpha-blended translucent image on a gradient background

Alpha-blended translucent image on a gradient background

Note that this effect also applies to color-keyed and non-transparent bitmaps too, which of course are still fully supported so you won’t need to change your existing applications unless you want to. In the next post we’ll take a look at some of the new image-specific properties that support this functionality.

* (PNG image files have always been supported in OpenInsight but the alpha-channel has never been respected, thereby limiting them to basic color-keying for transparency effects).

(Disclaimer: This article is based on preliminary information and may be subject to change in the final release version of OpenInsight 10).

Subject to change…

Those of you reading to the end of the posts in this blog may have noticed a small disclaimer we put at the bottom of each article explaining that things might change between now and the final release.  This post is just a small example of that in action as we’ve recently renamed a couple of properties in the interests of clarity and usability:

  • The WINDOW TRANSPARENCY property has been renamed to TRANSLUCENCY
  • The WINDOW APPUSERMODELID property has been renamed to TASKBARID (along with it’s switch in the RXI file)

More news as it happens …

(Disclaimer: This article is based on preliminary information and may be subject to change in the final release version of OpenInsight 10).