123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313 |
- #ifndef __IMAGESTONE_STANDARD_DEFINE_HEADER_H__
- #define __IMAGESTONE_STANDARD_DEFINE_HEADER_H__
- #ifdef _MSC_VER
- #pragma once
- #pragma warning (disable : 4786)
- #endif
- #ifdef IMAGESTONE_USE_NAMESPACE
- #define IMAGESTONE_NAMESPACE_START namespace IMAGESTONE{
- #define IMAGESTONE_NAMESPACE_END }
- #else
- #define IMAGESTONE_NAMESPACE_START
- #define IMAGESTONE_NAMESPACE_END
- #endif
- template<class T> inline const T& FMax (const T& _X, const T& _Y) {return (_X < _Y ? _Y : _X);}
- template<class T> inline const T& FMin (const T& _X, const T& _Y) {return (_Y < _X ? _Y : _X);}
- template<class T> inline void FSwap (T& t1, T& t2) { const T tmp=t1 ; t1=t2 ; t2=tmp ;}
- template<class T> inline T FSquare (const T& nValue) {return nValue*nValue ;}
- template<class T> inline T FClamp (const T& tValue, const T& tLow, const T& tHigh) {return FMax (tLow, FMin (tHigh, tValue)) ;}
- inline int FClamp0255 (int nValue) {return FClamp (nValue, 0, 0xFF) ;}
- inline int FRound (const double& x)
- {
- if (x > 0.0)
- return (int)(x + 0.5) ;
- else
- return (int)(x - 0.5) ;
- }
- #define LIB_PI 3.1415926535897932384626433832795
- #define LIB_2PI (2.0*LIB_PI)
- inline double AngleToRadian (int nAngle) {return LIB_PI * nAngle / 180.0;}
- inline int RadianToAngle (double dRadian) {return (int)(180.0 * dRadian / LIB_PI);}
- template<class T> inline T FHypot (const T& x, const T& y) {
- return (T)sqrt (double(x*x) + double(y*y)) ;
- }
- #ifdef WIN32
- #include <windows.h>
- #include <comdef.h>
- #include <TCHAR.H>
- #ifdef PCL_3RD_LIBRARY_USE_GDIPLUS
-
- #if _MSC_VER > 1200
-
- #include <GdiPlus.h>
- #pragma comment (lib, "GdiPlus.lib")
- #else
-
- #define ULONG_PTR ULONG
- #include "../lib/gdiplus/Include/gdiplus.h"
- #endif
- #endif
- #else
- #include "FLib_Macro.h"
- #endif
- #ifdef PCL_3RD_LIBRARY_USE_FREEIMAGE
- #include "../lib/FreeImage/Dist/FreeImage.h"
- #endif
- #include <stdlib.h>
- #include <stdio.h>
- #include <math.h>
- #include <float.h>
- #include <memory.h>
- #include <string.h>
- #include <string>
- #include <sstream>
- #include "PCL_array.h"
- #include "PCL_TT_Convertor.h"
- #include "PCL_interface_composite.h"
- #include "PCL_interface_lazyobj.h"
- #include "PCL_interface_undo.h"
- #include "FTimeCount.h"
- #include "ObjProgress.h"
- #define PCL_R(p) (((RGBQUAD*)(p))->rgbRed)
- #define PCL_G(p) (((RGBQUAD*)(p))->rgbGreen)
- #define PCL_B(p) (((RGBQUAD*)(p))->rgbBlue)
- #define PCL_A(p) (((RGBQUAD*)(p))->rgbReserved)
- template<class T> inline RGBQUAD PCL_RGBA (T r, T g, T b, T a=0xFF)
- {
- RGBQUAD cr ;
- PCL_R(&cr)=r ; PCL_G(&cr)=g ; PCL_B(&cr)=b ; PCL_A(&cr)=a ;
- return cr ;
- }
- struct POINT_F // 浮点数POINT
- {
- double x ;
- double y ;
- };
- inline long RECTWIDTH(const RECT & fRect) {return fRect.right - fRect.left;}
- inline long RECTHEIGHT(const RECT & fRect) {return fRect.bottom - fRect.top;}
- inline int FSquarePointDistance (const POINT& pt1, const POINT& pt2) {
- return FSquare(pt1.x - pt2.x) + FSquare(pt1.y - pt2.y) ;
- }
- inline double FPointAngle (const POINT& pt1, const POINT& pt2, const POINT& ptCenter) {
- const int nPt1 = FSquarePointDistance (pt1, ptCenter),
- nPt2 = FSquarePointDistance (pt2, ptCenter) ;
- if ((nPt1 == 0) || (nPt2 == 0))
- return -LIB_2PI ;
- const int nTemp = nPt1 + nPt2 - FSquarePointDistance (pt1, pt2) ;
- return acos (nTemp / (2.0*sqrt((double)nPt1)*sqrt((double)nPt2))) ;
- }
- inline double FPointAngleClockwise (const POINT &pt1, const POINT &pt2, const POINT &ptCenter) {
- const double fAngle = FPointAngle (pt1, pt2, ptCenter) ;
- if (fAngle < 0.0)
- return fAngle ;
- if (pt1.x == ptCenter.x)
- return (pt2.x >= ptCenter.x) ? fAngle : (LIB_PI - fAngle) ;
-
- const double yLine = ptCenter.y + (pt2.x - ptCenter.x) * (ptCenter.y - pt1.y) / (double)(ptCenter.x - pt1.x) ;
- if (pt2.y > yLine)
- return (pt1.x >= ptCenter.x) ? fAngle : (LIB_2PI - fAngle) ;
- return (pt1.x >= ptCenter.x) ? (LIB_2PI - fAngle) : fAngle ;
- }
- inline POINT FClockwisePoint (POINT pt1, POINT_F ptCenter, double fAngle)
- {
- double dx = pt1.x - ptCenter.x, dy = -pt1.y + ptCenter.y,
- cost = cos(fAngle), sint = sin(fAngle) ;
- POINT pt = {FRound(ptCenter.x + (dx*cost + dy*sint)),
- FRound(ptCenter.y - (dy*cost - dx*sint))} ;
- return pt ;
- }
- inline POINT FClockwisePoint (POINT pt1, POINT ptCenter, double fAngle) {
- POINT_F ptCen = {ptCenter.x, ptCenter.y} ;
- return FClockwisePoint (pt1, ptCen, fAngle) ;
- }
- inline bool IsRectInRect (const RECT & rcOut, const RECT & rcIn) {
- return (rcIn.left >= rcOut.left) && (rcIn.top >= rcOut.top) && (rcIn.right <= rcOut.right) && (rcIn.bottom <= rcOut.bottom) ;
- }
- enum AXIS_SYS
- {
- AXIS_X,
- AXIS_Y,
- AXIS_Z,
- };
- enum DIRECT_SYS
- {
- DIRECT_TOP_LEFT,
- DIRECT_TOP,
- DIRECT_TOP_RIGHT,
- DIRECT_LEFT,
- DIRECT_RIGHT,
- DIRECT_BOTTOM_LEFT,
- DIRECT_BOTTOM,
- DIRECT_BOTTOM_RIGHT,
- };
- enum REPEAT_MODE
- {
- REPEAT_NONE = 0,
- REPEAT_SAWTOOTH = 1,
- REPEAT_TRIANGULAR = 2,
- };
- enum INTERPOLATION_TYPE
- {
- INTERPOLATION_NONE,
- INTERPOLATION_BILINEAR,
- };
- enum LOGICAL_OP
- {
- LOGI_AND,
- LOGI_OR,
- LOGI_XOR,
- LOGI_ADD,
- LOGI_SUB,
- LOGI_MUL,
- LOGI_DIV,
- LOGI_LOG,
- LOGI_EXP,
- LOGI_SQRT,
- LOGI_TRIG,
- LOGI_INVERT,
- LOGI_SEL_ADD,
- LOGI_SEL_SUB,
- };
- #define MASK16_RED_565 0xF800
- #define MASK16_GREEN_565 0x07E0
- #define MASK16_BLUE_565 0x001F
- #define MASK16_RED_555 0x7C00
- #define MASK16_GREEN_555 0x03E0
- #define MASK16_BLUE_555 0x001F
- enum IMAGE_TYPE
- {
- IMG_UNKNOW,
- IMG_BMP,
- IMG_PCX,
- IMG_JPG,
- IMG_GIF,
- IMG_TGA,
- IMG_TIF,
- IMG_PNG,
- IMG_PSD,
- IMG_ICO,
- IMG_XPM,
- IMG_PHOXO,
- IMG_CUSTOM,
- };
- enum IMAGE_CHANNEL
- {
- CHANNEL_RED = 1 << 0,
- CHANNEL_GREEN = 1 << 1,
- CHANNEL_BLUE = 1 << 2,
- CHANNEL_ALPHA = 1 << 3,
- CHANNEL_RGB = CHANNEL_RED|CHANNEL_GREEN|CHANNEL_BLUE,
- CHANNEL_RGBA = CHANNEL_RGB|CHANNEL_ALPHA,
- CHANNEL_GRAY = 1 << 4,
- };
- enum LINE_STYLE
- {
- LINE_STYLE_SOLID = 0,
- LINE_STYLE_DASH = 1,
- LINE_STYLE_DOT = 2,
- };
- enum TONE_REGION
- {
-
- TONE_SHADOWS = 0,
-
- TONE_MIDTONES = 1,
-
- TONE_HIGHLIGHTS = 2,
- };
- struct SHADOWDATA
- {
- int nSmooth ;
- RGBQUAD crShadow ;
- int nAlpha ;
- int nOffsetX ;
- int nOffsetY ;
- SHADOWDATA()
- {
- nOffsetX = nOffsetY = 5 ;
- crShadow = PCL_RGBA(75,75,75) ;
- nAlpha = 75 ;
- nSmooth = 5 ;
- }
- };
- #endif
|