GdPicture.NET Reference Guide
SetROI Method (GdPictureImaging)
Example 





GdPicture14 Namespace > GdPictureImaging Class : SetROI Method
The horizontal (X) coordinate of the top left position of the ROI, in pixels.
The vertical (Y) coordinate of the top left position of the ROI, in pixels.
The required width of the ROI, in pixels.
The required height of the ROI, in pixels.
Defines the current region of interest (ROI) for further processing with this GdPictureImaging object by specifying its coordinates and dimensions. You can use the ResetROI method to clear the previously defined region of interest.
Syntax
'Declaration
 
Public Sub SetROI( _
   ByVal Left As Integer, _
   ByVal Top As Integer, _
   ByVal Width As Integer, _
   ByVal Height As Integer _
) 
public void SetROI( 
   int Left,
   int Top,
   int Width,
   int Height
)
public procedure SetROI( 
    Left: Integer;
    Top: Integer;
    Width: Integer;
    Height: Integer
); 
public function SetROI( 
   Left : int,
   Top : int,
   Width : int,
   Height : int
);
public: void SetROI( 
   int Left,
   int Top,
   int Width,
   int Height
) 
public:
void SetROI( 
   int Left,
   int Top,
   int Width,
   int Height
) 

Parameters

Left
The horizontal (X) coordinate of the top left position of the ROI, in pixels.
Top
The vertical (Y) coordinate of the top left position of the ROI, in pixels.
Width
The required width of the ROI, in pixels.
Height
The required height of the ROI, in pixels.
Remarks
Please note, that the coordinates of the upper left corner of the processed image are set to (0, 0).

Be aware that this method does not reset the previously set error status.

Example
How to set a required ROI to specify an area of the processed image for adding noise.
Dim caption As String = "Example: SetROI"
Using oImage As GdPictureImaging = New GdPictureImaging()
    Dim imageID As Integer = oImage.CreateGdPictureImageFromFile("image.png")
    If oImage.GetStat() = GdPictureStatus.OK Then
        oImage.SetROI(50, 50, 100, 100)
        oImage.FxAddNoise(imageID)
        oImage.SetROI(150, 50, 100, 100)
        oImage.FxAddNoise(imageID)
        oImage.ResetROI()
        If oImage.SaveAsPNG(imageID, "image with noise.png") = GdPictureStatus.OK Then
            MessageBox.Show("The image has been saved successfully.", caption)
        Else
            MessageBox.Show("The image can't be saved. Status: " + oImage.GetStat().ToString(), caption)
        End If
        oImage.ReleaseGdPictureImage(imageID)
    Else
        MessageBox.Show("The image can't be created. Status: " + oImage.GetStat().ToString(), caption)
    End If
End Using
string caption = "Example: SetROI";
using (GdPictureImaging oImage = new GdPictureImaging())
{
    int imageID = oImage.CreateGdPictureImageFromFile("image.png");
    if (oImage.GetStat() == GdPictureStatus.OK)
    {
        oImage.SetROI(50, 50, 100, 100);
        oImage.FxAddNoise(imageID);
        oImage.SetROI(150, 50, 100, 100);
        oImage.FxAddNoise(imageID);
        oImage.ResetROI();
        if (oImage.SaveAsPNG(imageID, "image with noise.png") == GdPictureStatus.OK)
            MessageBox.Show("The image has been saved successfully.", caption);
        else
            MessageBox.Show("The image can't be saved. Status: " + oImage.GetStat().ToString(), caption);
        oImage.ReleaseGdPictureImage(imageID);
    }
    else
        MessageBox.Show("The image can't be created. Status: " + oImage.GetStat().ToString(), caption);
}
See Also

Reference

GdPictureImaging Class
GdPictureImaging Members
ResetROI Method