#include "BIDIB.H"
HDIB CALLBACK CropDIB( HDIB hDib,
long LeftPosition,
long TopPosition,
long RightPosition,
long BottomPosition)
Description
The CropDIB method crops a part of the image specified by the hDib parameter. The size of new (cropped) image is set by the 4 parameters. The values of the parameters can be from 0 to the size of the original image. LeftPosition must not be higher than RightPosition and TopPosition must not be higher than BottomPosition. (The smallest image that you can crop from an original image is 1 pixel x 1 pixel)
The (0;0) point of the image is located at the left upper corner of the image.
This function works for bitmaps with 1, 2, 4 , 8, 16, 24 or 32 bits per pixel.
Parameters
|
HDIB |
hDib |
Handle of the DIB. |
|
long |
LeftPosition |
Left position of the rectangle of cropping value: from: 0 to width of the original image - 1 |
|
long |
TopPosition |
Top position of rectangle of the cropping value: from: 0 to height of the original image - 1 |
|
long |
RightPosition |
Left position of the rectangle of cropping value: from: 0 to width of the original image - 1 |
|
long |
BottomPosition |
Left position of the rectangle of cropping value: from: 0 to height of the original image - 1 |
Return values
Handle of the DIB. NULL on error.
Requirements
Header : Declared in BiDIB.h; include BiDIB.h.
Library : Use BiDIB.lib.
DLLs : BiDIB.dll.
Code example
#include "BIDIB.H"
TCHAR szMessage[250];
…
BeginWaitCursor();
HDIB hDibNew = CropDIB(hDib, 0, 0, 300, 200);
EndWaitCursor();
if(hDibNew ) {
GlobalFree(pDocument->hDib);
SetNewDib(hDibNew ,FALSE);
}
else {
_stprintf(szMessage,TEXT("Error in Cropping Image !"));
AfxMessageBox(szMessage,MB_OK,0);
}//hDib is the HANDLE of the original DIB.
…