Improving the display of large image files in your applications

This Tech Tip appeared in Imaging News August 2004.
When working with large image files, display quality problems often occur in areas of detailed content, such as small text or thin lines. In order to achieve the best display of a large images that contain small detailed elements, create an image buffer in the form of a temporary snowbound object. The reduced image will match your screen resolution and size thus resulting in a greatly improved display. Here's how:

********************** IN JAVA (Java Imaging Toolkit ) *************************

public class SnowPanel extends Panel

{

....

....

public void paint(Graphics g)

{

if (wereDisplayChangesMade)

displayImage = getNewDisplayImage(mainImage);

//Do rest of painting with new displayImage object......

}

private Snowbnd getNewDisplayImage(Snowbnd sourceImage)

{

if (mainImage != null)

{

//Create Copy - Copy will contain all the current settings

Snowbnd display_image = new Snowbnd(sourceImage);

//Calculate the reduces width and height of the new image

int width = (display_image.getWidth() / 2);

int height = (display_image.getHeight() / 2);

//Create the reduced image and return

displayImage.IMG_create_thumbnail(width,height);

return displayImage;

}

return null;

}

......

......

}

*********************** IN C/C++ (Windows Imaging Toolkit) *********************

int getNewDisplayImage(int srcImgHandle)

{

if (srcImgHandle != 0)

{

int width,height,bpp;

LPDIB_HEADER lpbi =

IMG_bitmap_info(srcImgHandle,&width,&height,&bpp);

int newImgHandle =0;

if (two_ways_to_create_a_duplicate_image)

{

newImgHandle = IMG_create_handle_shell(lpbi);

if (bpp == 1)

IMG_dib_to_runs(newImgHandle);

IMG_merge_bitmap_handle(newImgHandle,nHandle,0,0,0);

}

else //Or this way

{

newImgHandle =

IMG_decompress_bitmap_mem((char*)lpbi,0);

}

///Set gamma, contrast, brightness, aliasing, etc...

//Calculate the reduces width and height of the new image

width = (width / 2);

height = (height / 2);

//Create the reduced image and return

IMG_create_thumbnail(newImgHandle,width,height);

return newImgHandle;

}

return 0;

}

*Note: Printing and manipulation functions should be performed on the original image.

Learn More
In addition to our Tech Tips section, our document and image Solutions Section provides business application and industry-specific examples.

Category:

Online Demo