Get an Area of A DIB

Q:  How can I select an area from a device independent bitmap?

A:  You can select an area from a DIB with the CropDIB function. This function is available in the BiDIB.dll. The CropDIB works with monochrome 2, 4, 8, 16, 24 and 32 bit per pixel images. You must specify the handle of the device independent bitmap, and the coordinates of the area, and then the function retrieves the selected area as a DIB. . You can have obtain the handle to the DIB by loading from files, databases etc.

Code example:

     #include “BiDib.h”

     HANDLE hDib = LoadDIBFromFile(szFileName);

     if (hDib)

     {

            int left, top, right, bottom;

`           HANDLE hArea;

            …

            hArea = CropDIB(hDib, left, top, right, bottom);

            if (hArea)

            {

                        …

            }

     }