ImageGear .NET v24.12 - Updated
ImGearPageDisplay Class
User Guide > How to Work with... > Common Operations > Viewing > Image Display Using ImGearPage > ImGearPageDisplay Class

To work with the ImGearPageDisplay Class, your application must create an ImGearPage Class object first, and load an image into it. The following example shows the use of the ImGearFileFormats.LoadPage Method, but any of the techniques could be used: 

C#
Copy Code
// declared somewhere in you application
public ImGearPage m_igPage = null;

....

C#
Copy Code
using (FileStream stream = new FileStream(
    "test1.tif", FileMode.Open,
    FileAccess.Read, FileShare.Read))
{
    m_igPage = ImGearFileFormats.LoadPage(stream, 0);
}

Next, your application must create an ImGearPageDisplay Class object for the ImGearPage Class. This is done by declaring a respective variable and initializing it:

C#
Copy Code
// declared somewhere in you application
public ImGearPageDisplay m_igPageDisplay = null;

....

C#
Copy Code
m_igPageDisplay = new ImGearPageDisplay(m_igPage);

By itself, the ImGearPageDisplay Class object does not cause the image to appear on the computer screen. For that to happen, .NET provides a construct of type Graphics. There are many .NET API  functions that can be used to obtain a Graphics for ImGearPageDisplay Class to use. A simple case instance of Graphics is provided as part of the Paint event.

To simplify programming, ImageGear provides a .NET control called ImGearPageView Class that automatically performs image drawing according to settings stored in ImGearPageDisplay Class. The application programmer simply places the ImGearPageView Class onto a dialog or other window, and then adds a line of code to the application to associate the ImGearPageView Class with the ImGearPageDisplay Class object.

ImGearPageDisplay Class offers the following options for rendering the image:

When the ImGearPageDisplay Class is created, ImageGear creates the structures needed to render the image. When the ImGearPageDisplay Class is associated with an ImGearPageView Class, and the ImGearPageView.Update Method is called, then the image is rendered into the Graphics defined by the ImGearPageView Class.

There are a host of display setting properties in ImGearPageDisplay Class. They can be altered to change the way that the image is rendered a those properties will be discussed below. After setting any of the ImGearPageDisplay Class properties, or modifying the image in the ImGearPage Class object, the application must call ImGearPageView.Update Method once again to re-render the image:

C#
Copy Code
imGearPageView.Display = m_igPageDisplay;
imGearPageView.Update();

Neither changes to the display settings (e.g., changes to ImGearPageDisplay Class properties), nor changes to the ImGearPage Class object associated with the ImGearPageDisplay Class will cause an automatic redraw of the ImGearPageView Class a the application must call the ImGearPageView.Update Method to have it regenerate the DIB for the image. Continuing our example, assume that the application loads a different image into the ImGearPage Class object:

C#
Copy Code
using (FileStream stream = new FileStream(
    "photo.jpg", FileMode.Open,
    FileAccess.Read, FileShare.Read))
{
    m_igPage = ImGearFileFormats.LoadPage(stream, 0);
}
m_igPageDisplay.Page = m_igPage;

ImGearPage Class is changed, but the image is not yet rendered:

C#
Copy Code
imGearPageView.Update();