# BasicWPF

| Support            | ![](assets/images/sample_programs/applies_to/cpp.svg)   |
|--------------------|---------------------------------------------------------|
| Required licenses  | Any                                                     |
| Recommended images | Any                                                     |
| Location           | `Image Processing/Basic`                                |

## Purpose

This sample program demonstrates how to:

* Display an image in a WPF context.
* Display and graphically interact with an ROI.

![](assets/images/sample_programs/image_processing-basic.webp)

## Code highlights

1. Load an image file from the disk into an `EImage` object.
   ```c++
   image.Load(...);
   ```
2. Attach (associate) an ROI to the image.

The ROI gives access to the selected part of the image content.

```none
```c++
roi.Attach(image);
```
```

1. Position and size the attached ROI on the image.
   ```c++
   roi.SetPlacement(orgX, orgY, width, height);
   ```
2. Draw the image in a graphical device context.
   ```c++
   image.Draw(drawAdapter);
   ```
3. Draw the frame (the external rectangle) of the ROI in a graphical device context.

The second parameter enables the handles to manually manipulate the ROI position and size.

```none
```c++
roi.DrawFrame(context, true);
```
```

1. Retrieve the cursor coordinates after clicking.
   ```c++
   handle = roi.HitTest(x, y);
   ```
2. Move the handle to its new retrieved position and modify the ROI accordingly.
   ```c++
   roi.Drag(handle, x, y);
   ```
