ImGearPresentationPageDisplay Class is an advanced version of ImGearPageDisplay Class that requires Windows Presentation Framework.
This class implements the IImGearPageDisplay interface and implements a set of display API for rendering an image specified by the Page Property and annotations specified by the ARTPage Property in the WPF environment. The ImGearPresentationPageDisplay class derives from the System.Windows.DependencyObject class, allowing the Page, ARTPage, Channels, DICOMDisplaySettings, LUT, Orientation, Contrast, Brightness, and Gamma properties of this class to serve as the source or target of a binding. Note that since DependencyObject’s have thread affinity, the ImGearPresentationPageDisplay class should only be accessed from the thread on which it is created.
It is recommended that you use ImGearPresentationPageDisplay Class for Silverlight applications.
C# | ![]() |
---|---|
ImGearPresentationPageDisplay newDisplay = new ImGearPresentationPageDisplay(); ImGearPage page = ImGearFormats.LoadPage(...); newDisplay.Page = page; ImGearARTPage artPage = new ImGearARTPage(); newDisplay.ARTPage = artPage; |
To work with the ImGearPresentationPageDisplay 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# | ![]() |
---|---|
// declared somewhere in you application public ImGearPage m_igPage = null; |
....
C# | ![]() |
---|---|
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 ImGearPresentationPageDisplay Class object for the ImGearPage Class. This is done by declaring a respective variable and initializing it:
C# | ![]() |
---|---|
// declared somewhere in you application public ImGearPageDisplay m_igPageDisplay = null; |
....
C# | ![]() |
---|---|
m_igPageDisplay = new ImGearPageDisplay(m_igPage); |
By itself, the ImGearPresentationPageDisplay 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 ImGearPresentationPageDisplay 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 PageView Class that automatically performs image drawing according to settings stored in ImGearPageDisplay Class. The application programmer simply places the PageView Class onto a dialog or other window, and then adds a line of code to the application to associate the PageView Class with the ImGearPresentationPageDisplay Class object.
ImGearPresentationPageDisplay Class offers the following options for rendering the image:
- Using a PageView Class, as shown above.
- Directly into Graphics. The application program must obtain the Graphics for this purpose (e.g., from HDC handle returned by Windows GDI GetDC() function). The image is rendered by calling the ImGearPresentationPageDisplay.Draw Method.
When the ImGearPresentationPageDisplay Class is created, ImageGear creates the structures needed to render the image. When the ImGearPresentationPageDisplay Class is associated with a PageView Class, and the PageView.Update Method is called, then the image is rendered into the Graphics defined by the PageView Class. There are a host of display setting properties in ImGearPresentationPageDisplay Class. They can be altered to change the way that the image is rendered - those properties will be discussed below. After setting any of the ImGearPresentationPageDisplay Class properties, or modifying the image in the ImGearPage Class object, the application must call PageView.Update Method once again to re-render the image:
C# | ![]() |
---|---|
pageView.Display = m_igPageDisplay; pageView.Update(); |
Neither changes to the display settings (e.g., changes to ImGearPresentationPageDisplay Class properties), nor changes to the ImGearPage Class object associated with the ImGearPresentationPageDisplay Class will cause an automatic redraw of the PageView Class - the application must call the PageView.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# | ![]() |
---|---|
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 image is not yet rendered:
C# | ![]() |
---|---|
pageView.Update(); |