From 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 Mon Sep 17 00:00:00 2001 From: Joe Hunkeler Date: Tue, 11 Aug 2015 16:51:37 -0400 Subject: Repatch (from linux) of OSX IRAF --- pkg/images/tv/imedit/epgdata.x | 70 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 pkg/images/tv/imedit/epgdata.x (limited to 'pkg/images/tv/imedit/epgdata.x') diff --git a/pkg/images/tv/imedit/epgdata.x b/pkg/images/tv/imedit/epgdata.x new file mode 100644 index 00000000..163d7478 --- /dev/null +++ b/pkg/images/tv/imedit/epgdata.x @@ -0,0 +1,70 @@ +include +include "epix.h" + +# EP_GDATA -- Get input and output image subrasters with boundary checking. +# Null pointer are returned if entirely out of bounds. + +procedure ep_gdata (ep, x1, x2, y1, y2) + +pointer ep # EPIX pointer +int x1, x2, y1, y2 # Subraster limits + +int nc, nl +pointer im, imgs2r(), imps2r() + +begin + im = EP_IM(ep) + nc = IM_LEN(im,1) + nl = IM_LEN(im,2) + + if (x2 < 1 || x1 >= nc || y2 < 1 || y1 >= nl) { + call eprintf ("Pixel out of bounds\n") + EP_INDATA(ep) = NULL + EP_OUTDATA(ep) = NULL + return + } + + EP_X1(ep) = max (1, x1) + EP_X2(ep) = min (nc, x2) + EP_Y1(ep) = max (1, y1) + EP_Y2(ep) = min (nl, y2) + EP_NX(ep) = EP_X2(ep) - EP_X1(ep) + 1 + EP_NY(ep) = EP_Y2(ep) - EP_Y1(ep) + 1 + EP_NPTS(ep) = EP_NX(ep) * EP_NY(ep) + EP_OUTDATA(ep) = imps2r (im, EP_X1(ep), EP_X2(ep), EP_Y1(ep), EP_Y2(ep)) + EP_INDATA(ep) = imgs2r (im, EP_X1(ep), EP_X2(ep), EP_Y1(ep), EP_Y2(ep)) + call amovr (Memr[EP_INDATA(ep)], Memr[EP_OUTDATA(ep)], EP_NPTS(ep)) +end + + +# EP_GINDATA -- Get input image data only with boundary checking. +# A null pointer is returned if entirely out of bounds. + +procedure ep_gindata (ep, x1, x2, y1, y2) + +pointer ep # EPIX pointer +int x1, x2, y1, y2 # Subraster limits + +int nc, nl +pointer im, imgs2r() + +begin + im = EP_IM(ep) + nc = IM_LEN(im,1) + nl = IM_LEN(im,2) + + if (x2 < 1 || x1 >= nc || y2 < 1 || y1 >= nl) { + call eprintf ("Pixel out of bounds\n") + EP_INDATA(ep) = NULL + return + } + + EP_X1(ep) = max (1, x1) + EP_X2(ep) = min (nc, x2) + EP_Y1(ep) = max (1, y1) + EP_Y2(ep) = min (nl, y2) + EP_NX(ep) = EP_X2(ep) - EP_X1(ep) + 1 + EP_NY(ep) = EP_Y2(ep) - EP_Y1(ep) + 1 + EP_NPTS(ep) = EP_NX(ep) * EP_NY(ep) + EP_INDATA(ep) = imgs2r (im, EP_X1(ep), EP_X2(ep), EP_Y1(ep), EP_Y2(ep)) +end -- cgit