Print a Region of an Image

You can print a region of an image in two steps:

  1. Crop an area from the DIB.

  2. Print the DIB.

 

For cropping see the Cropping an Image section. You can crop a rectangle from the DIB with the CropDIB function. This function retrieves the cropped DIB. And then you have to use the PrintDIBPage function to print the DIB. For details on the usage of the PrintDIBPage see the Single and Multipage Printing section.

 

[C++]

 

#include “BiDib.h”

#include “BiPrint.h”

 

HDIB hDibCropped;

 

hDibCropped = CropDIB(hDib, 0, 0, 50, 50);

 

if (hDibCropped)

            // Print DIB

            PrintCroppedImg(hDibCropped);

 

[VB]

 

Dim hDibCropped As Long

Dim BiDIBobj as Object

 

Set BiDIBobj = CreateObject("BIDIB.BIDIBCtrl.1")

 

hDibCropped = BiDIBobj.CropDIB(hDib, 0, 0, 50, 50)

 

Set BIDIBObj = Nothing

 

If hDibCropped > 0 Then

            PrintCroppedImg (hDibCropped)

End If

 

[C#]

 

int hDibCropped;

 

hDibCropped = BiDIB.CropDIB(hDib, 0, 0, 50, 50);

 

if (hDibCropped > 0)

            PrintCroppedImg(hDibCropped);