HPutRect (see figure 6.8) inserts a rectangular region in an already existing output object with database key obj_key. It is mostly used in connection with operators that create new image objects like in the example in figure 6.10.
Note that HPutRect automatically checks the result state of the underlying procedure with the macro HCkP (see section “HCkP”). Thus, you must not use HCkP on HPutRect yourself.
Herror CIOGrabImage(Hproc_handle proc_handle) { Hkey obj_key,image_key; Himage image; HCrObj(proc_handle,1,&obj_key); HCkP(HNewImage(proc_handle,&image,BYTE_IMAGE,640,480)); /* grab an NTSC image 640 x 480 pixel, 8 bit */ HCkP(IOBGrabImage(&image)); HPutDImage(proc_handle,obj_key,1,&image,false,&image_key); HPutRect(proc_id,obj_key,image.width,image.height); return(H_MSG_TRUE); }
Figure 6.10: A typical application of HPutRect: Grabbing an image.
Note, that HCrObj (see section “HCrObj”) creates an object with empty region. In many situations the default domain (area of definition) for a new image will be the full image domain, which is a rectangle. In this situation the use of HPutRect is very convenient.