This function crops the image to the specified rectangle.
Copy Code
|
|
---|---|
AT_ERRCOUNT ACCUAPI IG_IP_crop( HIGEAR hIGear, LPAT_RECT lpCropRect ); |
Name | Type | Description |
---|---|---|
hIGear | HIGEAR | HIGEAR handle of image. |
lpCropRect | LPAT_RECT | Pointer to an AT_RECT struct specifying the rectangular portion of the image to keep. The remainder of the image is removed and discarded. |
All pixel formats supported by ImageGear for C and C++.
Copy Code
|
|
---|---|
HIGEAR hIGear; // HIGEAR handle of the image AT_ERRCOUNT nErrcount; // Count of errs on stack upon ret from func AT_DIMENSION nWidth, nHeight; // Dimensions of the image AT_RECT rcRect; // Crop rectangle // Load image file "picture.bmp" from working directory nErrcount = IG_load_file("picture.bmp", &hIGear); if(nErrcount == 0) { // Get dimensions of the image and initialize the crop rectangle IG_image_dimensions_get(hIGear, &nWidth, &nHeight, NULL); rcRect.left = 0; rcRect.top = 0; rcRect.right = nWidth / 2; rcRect.bottom = nHeight / 2; nErrcount = IG_IP_crop(hIGear, &rcRect); // ... // Destroy the image IG_image_delete(hIGear); } |
Only pixels that fall on or inside the lpCropRect rectangle will be kept in the resulting image. The dimensions of the resulting image are then same as that of the lpCropRect. The removed parts of the image are discarded.
If right or bottom bound of the rectangle falls beyond the image dimensions, the rectangle is clipped to the image bounds. The resulting image dimensions cannot be larger than the dimensions of the source image. Use IG_IP_resize_canvas to extend the image bounds without scaling the image.