Hrlregion *region; Hkey obj_key; ... HCkP(HAllocRLTmp(proc_handle,®ion)); HGetObj(proc_handle,par_num,obj_num,&obj_key); HGetDRL(proc_handle,obj_key,region); /* processing (in general this should be done calling an action proc.) */ area = 0; for (i=0; i<region->num; i++) area += region->rl[i].ce - region->rl[i].cb + 1; HCkP(HFreeRLTmp(proc_handle,region));
Figure 5.10: Application of HGetDRL.
HGetDRL (see figure 5.9) combines HGetComp (section “HGetComp”) and HGetRL (section “HGetRL”). It reads the runlength encoding of a region (type: Hrlregion, see section “Region Data (Hrlregion)”) specified by the database key obj_key of an image object. The region data is copied to region, which must have been allocated before with a suitable size (e.g., by using HAllocRLTmp, see section “Temporary Data”). Therefore, this region data can be overwritten without side effects. On the other hand, the memory must be deallocated at the end of the supply procedure (e.g., by using HFreeRLTmp). Figure 5.10 shows an example application of HGetDRL.
Note that HGetDRL automatically checks the result state of the underlying procedure with the macro HCkP (see section “HCkP”). Thus, you must not use HCkP on HGetDRL yourself.