FFView
full featured image display

Prototype

Put the following prototype in the prototypes section of the application program header file:

int  ( __stdcall *pfnFFView)( HWND, void*, int, int, void*, void* );

Purpose

Color and b&w image full screen display with pan, zoom, rotation, print.

Description and use

Well, I don't want to be immodest, but I haven't ever seen a better display routine than this. It takes its steps from DirectDraw to display a 256 colours bitmap image (one byte per pixel).

When displaying the image, the following actions can be taken:

  • Alt+Tab: switch between applications in memory (as soon as you switch back, the image is automatically restored, wow !)
  • ESC: exit and return 1 to the application (1 would mean "abandone")
  • Page Up: exit, and return 2 to the application (2 would mean "pass me the preceeding image")
  • Page Down: exit, and return 3 to the application (3 whould mean "pass me the next image")
  • mouse right button click: exit, and return the coordinates of the cursor to the application (see the return value below for the format of the coordinates)
  • plus: zoom in
  • minus: zoom out
  • arrow keys: pan
  • p: print the image on the default printer
  • r: rotate the image counterclockwise
Additionally when you move the mouse cursor across the screen it changes its shape and, if you press the left mouse button, an action will be taken according to the shape of the cursor.

I've generally been using this display function from within my optical storage and retrieval systems, to display images in black and white (being 0x00 the black and 0xFF the white in the colour lookup table). Try the first example given below to display a TIFF image file.

In 2001 I added the feature to return the coordinate of the cursor at the mouse right button click. This because I was developing a very simple bitmap based GIS, millions of light years far from a normal vectorial GIS but, from a coreographical standpoint, much more pleasant. Try the colour bitmap display example below and see.

The last example in the examples section below illustrates how to display an uncompressed colour bitmap. This has been sufficient for my applications, but if you want to display JPEG, GIF, and other image formats you should be provided with the proper routine to fill the memory area that will be passed to this display routine.

Specification

The image should have been loaded in memory at one byte per pixel. The video display adapter card should support DirectDraw. The calling application window should be minimized (wsMinimized) before calling this function, and should be restored (wsNormal) on return.

Parameters
  • HWND window handle to the application program
  • void* pointer to the memory area that contains the raster image
  • int image width in pixel/8: be careful to pass an integer value; in other words the image width in pixel should be an *exact* multiple of 8 !!!
  • int image length in lines
  • void* pointer to the colour palette, or zero if black&white image
  • void* set to zero (it's an undeveloped feature)

Return value

The function returns a 32 bit integer. The 8 least significant bits are the true return code:
  • 0: mouse right button click, cursor coordinates returned (see below)
  • 1: ESC pressed
  • 2: Page Up pressed
  • 3: Page Down pressed
When the return code is 0 the cursor coordinates are returned in the 24 most significant bits of the return value. The first 12 bit are the X coordinate, and the remaining 12 bit are the Y coordinate. These coordinates are given in pixels from the top left corner. For bitmaps larger than 4096x4096 pixels the coordinates are not valid (but it is also rare to display a bitmap more than 4096x4096 pixels...).

Application examples

See also
  • FFTiffServices: single image TIFF file management
  • FFBmpServices: single image BMP file management
  • FFScan: SCSI scanner single page scan
  • FFDec: CCITT group 4 bidimensional decompression
  • FFOMR: OMR (Optical Mark Recognition)

Notes

A subset of the source code of this function is given in another section of my web pages.

Any error you receive after calling this function is due to bad DirectDraw installation in your PC. Reinstall DirectDraw and retry.

If the displayed image looks strange (skewed or so) check that the image width in pixels is an actual multiple of 8.

If the colors look strange check that the proper palette has been passed.