#604 closed defect (fixed)
psRegionForImage incompletely implemented
| Reported by: | eugene | Owned by: | |
|---|---|---|---|
| Priority: | high | Milestone: | |
| Component: | mathtypes | Version: | 0.8.0 |
| Severity: | normal | Keywords: | |
| Cc: |
Description
the SDRS was not very clear about how to handle sub-images. The implementation
of psRegionForImage was inconsistent between subimage pixels and parent image
pixels. It also returned an error in too many conditions which should have
resulted in a valid psRegion.
I've reimplemented this function in the eam_rel8_b2 branch
set actual region based on image parameters:
- compensate for negative upper limits
- force range to be on this image
- saturate on upper and lower limits of image
- flip x0,x1 if x0>x1
- flip y0,y1 if y0>y1
psRegion in refers to coordinates in the
psRegion psRegionForImage(psImage *image,
psRegion in)
{
if (image == NULL) {
return in;
}
convert non-positive upper-limits
in.x1 = (in.x1 <= 0) ? (image->numCols + in.x1) : in.x1;
in.y1 = (in.y1 <= 0) ? (image->numRows + in.y1) : in.y1;
force the upper-limits to be on the image
in.x1 = PS_MIN(image->numCols, in.x1);
in.y1 = PS_MIN(image->numRows, in.y1);
force the lower-limits to be on the image
in.x0 = PS_MAX(0, in.x0);
in.y0 = PS_MAX(0, in.y0);
in.x0 = PS_MIN(image->numCols, in.x0);
in.y0 = PS_MIN(image->numRows, in.y0);
flip start and end if out of order
if (in.x0 > in.x1) {
PS_SWAP (in.x0, in.x1);
}
if (in.y0 > in.y1) {
PS_SWAP (in.y0, in.y1);
}
return (in);
}
---
Change History (2)
comment:1 by , 21 years ago
| Owner: | changed from to |
|---|
comment:2 by , 21 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |

branch joined with cvs trunk