Showing posts with label ImageViewer. Show all posts
Showing posts with label ImageViewer. Show all posts

Tuesday, June 15, 2010

Image Render Transformations

Image binding to Viewmodel :

  • ImageData (bitmap data)
  • ZOOM (zooming)
  • TX / TY (translation)
<Image Stretch="None" Source="{Binding Path=ImageData, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" > 
<Image.LayoutTransform>
<ScaleTransform ScaleX="{Binding Path=ZOOM}" ScaleY="{Binding Path=ZOOM}" />
</Image.LayoutTransform>
<Image.RenderTransform>
<TransformGroup>
<TranslateTransform X="{Binding Path=TX}" Y="{Binding Path=TY}"/>
</TransformGroup>
</Image.RenderTransform>
</Image>

WPF - Multiple Display

The Method

Use the System.Windows.Forms.Screen API to setup the displays.

The PrimaryScreen Property is the primary display, Other Displays are given by the AllScreens Property (System.Windows.Forms.Screen[])

Example with three windows (ImageViewer Application)

1)Take the StartUri element out of App.xaml and add the Startup event

<Application x:Class="DicomImageViewer.App"
             xmlns="
http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="MainWindow.xaml"
             Startup="Application_Startup">
    <Application.Resources>

    </Application.Resources>
</Application>

2)Add the Startup event handler

private void Application_Startup(object sender, StartupEventArgs e)
{
    setDisplayRects(MainDisplayWindow, ImageBox1, ImageBox2);
}

2)This is an example of the ImageViewer for triple display
(note if 1 or 2 displays it subdivides the displays)

public void setDisplayRects(MainWindow main, ImageWindow img1, ImageWindow img2)
{
    System.Windows.Forms.Screen s0;
    System.Windows.Forms.Screen s1;
    System.Windows.Forms.Screen s2;
    switch (System.Windows.Forms.Screen.AllScreens.Count())
    {
        case 3:
            s0 = System.Windows.Forms.Screen.PrimaryScreen;
            main.Top = s0.WorkingArea.Top;
            main.Left = s0.WorkingArea.Left;
            main.WindowState = WindowState.Maximized;
            main.Show();

            s1 = System.Windows.Forms.Screen.AllScreens[1];
            img1.Top = s1.WorkingArea.Top;
            img1.Left = s1.WorkingArea.Left;
            img1.WindowState = WindowState.Maximized;
            img1.Show();
            img1.Owner = main;

            s2 = System.Windows.Forms.Screen.AllScreens[2];
            img2.Top = s2.WorkingArea.Top;
            img2.Left = s2.WorkingArea.Left;
            img2.WindowState = WindowState.Maximized;
            img2.Show();
            img2.Owner = main;

            break;

        case 2:
            s0 = System.Windows.Forms.Screen.PrimaryScreen;
            main.Top = s0.WorkingArea.Top;
            main.Left = s0.WorkingArea.Left;
            main.Show();

            s1 = System.Windows.Forms.Screen.AllScreens[1];
            img1.Top = s1.WorkingArea.Top;
            img1.Left = s1.WorkingArea.Left;
            img1.Width = s1.WorkingArea.Width;
            img1.Height = s1.WorkingArea.Height / 2;
            img1.Show();
            img1.Owner = main;

            img2.Top = s1.WorkingArea.Top + s1.WorkingArea.Height / 2;
            img2.Left = s1.WorkingArea.Left;
            img2.Width = s1.WorkingArea.Width;
            img2.Height = s1.WorkingArea.Height / 2;
            img2.Show();
            img2.Owner = main;

            break;

        case 1:
            s0 = System.Windows.Forms.Screen.PrimaryScreen;
            main.Top = s0.WorkingArea.Top;
            main.Left = s0.WorkingArea.Left;
            main.Width = s0.WorkingArea.Width;
            main.Height = s0.WorkingArea.Height / 3;
            main.Show();

            img1.Top = s0.WorkingArea.Top + s0.WorkingArea.Height / 3;
            img1.Left = s0.WorkingArea.Left;
            img1.Width = s0.WorkingArea.Width;
            img1.Height = s0.WorkingArea.Height / 3;
            img1.Show();
            img1.Owner = main;

            img2.Top = s0.WorkingArea.Top + (2 * s0.WorkingArea.Height / 3);
            img2.Left = s0.WorkingArea.Left;
            img2.Width = s0.WorkingArea.Width;
            img2.Height = s0.WorkingArea.Height / 3;
            img2.Show();
            img2.Owner = main;

            break;
    }
}

Wednesday, June 9, 2010

DICOM Image Viewer – Useful Links

 

Imaging Overview - http://msdn.microsoft.com/en-us/library/ms748873.aspx

Optimizing Performance: 2D Graphics and Imaging - http://msdn.microsoft.com/en-us/library/bb613591.aspx

WPF Graphics Rendering Overview - http://msdn.microsoft.com/en-us/library/ms748373.aspx

Optimizing WPF Application Performance - http://msdn.microsoft.com/en-us/library/aa970683.aspx

Medical Display Specs - http://www.slideshare.net/PlanarEmbedded/trends-in-medical-displays-planar-systems-adi-abileah

WriteableBitmap - http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.writeablebitmap.aspx The new WriteableBitmap has much more performance than the original.  It provides tear-free, raster updates of a bitmap, which you can use an <Image> to display.