Victor Image Processing Library How-to Tips

Displaying Multiple Images

Use the Victor Library function viewimageex to place each image in the window at a specified (x,y) window location.

When the system display is using 256 (or fewer) colors all images have to be displayed with a common palette. In the example below the VIEWSCATTER and COLORSCATTER256 are defined constants that tell the Victor functions to use the standard rainbow palette with diffusion scatter for the best rendition of multiple images.


Display Two Images - the Source Code

Requires Victor Image Processing Library for Windows v 4.1x or higher.
// Display 2 images side by side in a single window
void display2(HWND hWnd, imgdes far* image1, imgdes far* image2)
{
   PAINTSTRUCT ps;   // Holds PAINT info
   HDC hdc;
   int rcode, wndx, spacing=5, mode=VIEWSCATTER;
   HPALETTE hpal1, hpal2;
   imgdes tempimage1, tempimage2;
   int displaybpp;

   hdc = BeginPaint(hWnd, &ps);
   displaybpp = GetDeviceCaps(hdc, BITSPIXEL); // Bits/pixel of current display mode

   // Display any 8-bit image with the colorscatter method using rainbow palette
   if(displaybpp == 8 & image1->bmh->biBitCount==8) {
      allocimage(&tempimage1, image1->bmh->biWidth, image1->bmh->biHeight, 8);
      colorscatter(image1, &tempimage1, COLORSCATTER256);
      rcode = viewimageex(hWnd, hdc, &hpal1, 0, 0, &tempimage1, 0, 0, mode);
      freeimage(&tempimage1);
      }
   else
      rcode = viewimageex(hWnd, hdc, &hpal1, 0, 0, image1, 0, 0, mode);

   // Display second image beside first one with some space between them
   wndx = image1->bmh->biWidth + spacing;

   if(displaybpp == 8 & image1->bmh->biBitCount==8) {
      allocimage(&tempimage2, image2->bmh->biWidth, image2->bmh->biHeight, 8);
      colorscatter(image2, &tempimage2, COLORSCATTER256);
      rcode = viewimageex(hWnd, hdc, &hpal2, 0, 0, &tempimage2, wndx, 0, mode);
      freeimage(&tempimage2);
      }
   else
      rcode = viewimageex(hWnd, hdc, &hpal2, 0, 0, image2, wndx, 0, mode);

   DeletePalette(hpal1);
   DeletePalette(hpal2);

   EndPaint(hWnd, &ps);
   // Handle any errors, error_handler defined in VicDemo
   if(rcode != NO_ERROR)
      error_handler(hWnd, rcode);
}


Copyright © 1997 Catenary Systems Inc. All rights reserved. Victor Image Processing Library is a trademark of Catenary Systems.


Victor Image Processing Library homepage | Victor Product Summary | more source code