ImageGear for C and C++ on Windows v20.5 - Updated
Using Clipboard Operations
User Guide > How to Work with ... > Common Operations > Viewing > Scanning > Using Clipboard Operations

The "clipboard" functions provide the ability to cut, copy, and paste to and from the clipboard. With this function group, you can cut or copy all or a portion of an image to the system clipboard, paste the contents of the clipboard into a new HIGEAR image, or even "paste-merge" the contents of the system clipboard into a pre-existing image. You can also check for the existence of data in the clipboard, and check the size of an image in the clipboard. For separate descriptions of each clipboard function and additional sample code, please refer to the Clipboard Functions section in the Core Component API Function Reference.

This section provides information about the following:

Copying/Cutting to the Clipboard

You may cut or copy the entire HIGEAR image, or just a specified rectangular portion of the image, to the clipboard. To copy to the clipboard, call the function IG_clipboard_copy() with the image's HIGEAR handle, and the coordinates of the AT_RECT rectangle that you would like to save to the clipboard. Pass NULL as the rectangle's value to if you want to copy the entire image to the clipboard.

To cut to the clipboard, call IG_clipboard_cut(). The only difference in the prototype of these functions is that IG_clipboard_cut() contains an extra argument for specifying what color pixel to use to replace the pixels that are "cut away". This pixel color argument is usually set to black or white.

Checking the Contents of the Clipboard

ImageGear provides two functions for examining the contents of the clipboard:

Pasting an Image from the Clipboard

There are two ImageGear functions for pasting the image from the clipboard:

Before you call IG_clipboard_paste_merge_ex(), you can call the function IG_clipboard_paste_op_set() to specify the kind of arithmetic operation you want to apply to the pixels of the two bitmaps that intersect during the paste-merge. IG_clipboard_paste_op_set() takes an AT_MODE constant (defined in accucnst.h) that has a prefix of IG_ARITH_. The full group of arithmetic constants is listed under the function description for IG_clipboard_paste_op_set(). ImageGear also supplies a companion reading function IG_clipboard_paste_op_get() to read the current setting for the paste-merge arithmetic operation. See Example code below:

 
Copy Code
AT_DIMENSION nWi, nHi;
UINT nBpp;
BOOL bPasteAvail;
AT_ERRCOUNT nErrcount;
HIGEAR hIGear, hIGear2;
AT_RECT rcClipRect;
nErrcount = IG_load_file("picture.bmp", &hIGear);
if (nErrcount == 0)
{
        nErrcount = IG_image_dimensions_get ( hIGear, &nWid, &nHi, &nBpp );*/
        if ( nErrcount == 0 ) /* If valid image dimensions */
        {/* send the bottom half of the image*/
                rcClipRect.top = nHi/2; /* to the clipboard */
                rcClipRect.left = 0; 
                rcClipRect.right = nWi - 1;
                rcClipRect.bottom = nHi - 1;
                nErrcount = IG_clipboard_copy (hIGear, &rcClipRect);
        }
if (nErrcount == 0)
{
/*load a second image into which to merge the clipboard contents*/
                nErrcount = IG_load_file("picture2.bmp", &hIGear2);
}
if (nErrcount == 0)
{
        nErrcount = IG_clipboard_paste_available_ex(&bPasteAvail);
        if (bPasteAvail == TRUE)
        {
        /* set the paste-merge arithmetic operation to Img1^Img2 */
        nErrcount = IG_clipboard_paste_op_set(hIGear, 
                                IG_ARITH_XOR);
        /* merge clipboard's rectangular contents with upper left
         corner at position 0,0                 */
                nErrcount = IG_clipboard_paste_merge_ex(hIGear2, 0 , 0);
                }
}
Is this page helpful?
Yes No
Thanks for your feedback.