| #pragma once |
| |
| #ifndef WARP_H |
| #define WARP_H |
| |
| #include "tfxparam.h" |
| #include "trop.h" |
| #include "trasterfx.h" |
| |
| |
| |
| struct WarpParams { |
| int m_shrink; |
| double m_warperScale; |
| double m_intensity; |
| bool m_sharpen; |
| }; |
| |
| struct LPoint { |
| TPointD s; |
| TPointD d; |
| }; |
| |
| struct Lattice { |
| int m_width; |
| int m_height; |
| LPoint *coords; |
| |
| Lattice() : coords(0) {} |
| ~Lattice() { |
| if (coords) delete[] coords; |
| } |
| }; |
| |
| namespace |
| { |
| inline int myCeil(double x) { |
| return ((x - (int)(x)) > TConsts::epsilon ? (int)(x) + 1 : (int)(x)); |
| } |
| |
| inline TRect convert(const TRectD &r, TPointD &dp) { |
| TRect ri(tfloor(r.x0), tfloor(r.y0), myCeil(r.x1), myCeil(r.y1)); |
| dp.x = r.x0 - ri.x0; |
| dp.y = r.y0 - ri.y0; |
| assert(dp.x >= 0 && dp.y >= 0); |
| return ri; |
| } |
| } |
| |
| |
| |
| inline double getWarpRadius(const WarpParams ¶ms) { |
| return 2.55 * 1.5 * 1.5 * fabs(params.m_intensity); |
| } |
| |
| |
| |
| inline double getWarperEnlargement(const WarpParams ¶ms) { |
| |
| |
| |
| |
| |
| int enlargement = 3; |
| if (!params.m_sharpen) enlargement += 6; |
| return enlargement; |
| } |
| |
| |
| |
| void getWarpComputeRects(TRectD &outputComputeRect, TRectD &warpedComputeRect, |
| const TRectD &warpedBox, const TRectD &requestedRect, |
| const WarpParams ¶ms); |
| |
| |
| |
| |
| void warp(TRasterP &tileRas, const TRasterP &rasIn, TRasterP &warper, |
| TPointD rasInPos, TPointD warperPos, const WarpParams ¶ms); |
| |
| #endif |