# Basic

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

## Purpose

This sample program demonstrates how to:

* Display an image.
* 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.
   ```c++
   roi.Attach(image);
   ```
3. Position and size the attached ROI on the image.
   ```c++
   roi.SetPlacement(orgX, orgY, width, height);
   ```
4. Draw the image in a graphical device context.
   ```c++
   image.Draw(drawAdapter);
   ```
5. 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.
   ```c++
   roi.DrawFrame(&drawAdapter, true);
   ```
6. Retrieve the cursor coordinates after clicking.
   ```c++
   handle = roi.HitTest(x, y);
   ```
7. Move the handle to its new retrieved position and modify the ROI accordingly.
   ```c++
   roi.Drag(handle, x, y);
   ```
