From 686a2bcf8b3374f2e194c97b578303438863daeb Mon Sep 17 00:00:00 2001 From: pointertobios Date: Sun, 13 Jul 2025 21:09:02 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E6=8A=8A=E4=B8=80=E9=83=A8=E5=88=86?= =?UTF-8?q?=E6=AF=94=E8=BE=83=E7=8B=AC=E7=AB=8B=E7=9A=84=E5=86=85=E9=83=A8?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=94=B9=E8=BF=9B=E5=88=B0=E7=8E=B0=E4=BB=A3?= =?UTF-8?q?C++=E5=BD=A2=E5=BC=8F=EF=BC=8C=E8=BF=98=E6=9C=89=E4=B8=80?= =?UTF-8?q?=E4=BA=9B=E6=A0=BC=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/ege.h | 1921 +++++++++++++++++++++--------------------- include/ege/stdint.h | 80 +- src/array.h | 26 +- src/color.cpp | 69 +- src/color.h | 98 ++- src/compress.cpp | 26 +- src/console.cpp | 37 +- src/ege_common.h | 2 - src/ege_math.h | 22 +- src/egegapi.cpp | 746 ++++++++-------- src/encodeconv.h | 2 +- src/image.cpp | 664 +++++++-------- src/utils.h | 46 +- 13 files changed, 1854 insertions(+), 1885 deletions(-) diff --git a/include/ege.h b/include/ege.h index f3cea5c9..b88a02b9 100644 --- a/include/ege.h +++ b/include/ege.h @@ -20,12 +20,12 @@ // Easy Graphics Engine Version // Calendar Versioning, format: YY.0M.PatchNumber (If the PatchNumber equals 0, the YY.0M format is used.) -#define EGE_VERSION "24.04" -#define EGE_VERSION_MAJOR 24 -#define EGE_VERSION_MINOR 4 -#define EGE_VERSION_PATCH 0 -#define EGE_MAKE_VERSION_NUMBER(major, minor, patch) ((major) * 10000L + (minor) * 100L + (patch)) -#define EGE_VERSION_NUMBER EGE_MAKE_VERSION_NUMBER(EGE_VERSION_MAJOR, EGE_VERSION_MINOR, EGE_VERSION_PATCH) +#define EGE_VERSION "24.04" +#define EGE_VERSION_MAJOR 24 +#define EGE_VERSION_MINOR 4 +#define EGE_VERSION_PATCH 0 +#define EGE_MAKE_VERSION_NUMBER(major, minor, patch) ((major) * 10000L + (minor) * 100L + (patch)) +#define EGE_VERSION_NUMBER EGE_MAKE_VERSION_NUMBER(EGE_VERSION_MAJOR, EGE_VERSION_MINOR, EGE_VERSION_PATCH) #ifndef __cplusplus #error You must use a C++ compiler and ensure that your source files is named with the '.cpp' suffix. @@ -36,26 +36,25 @@ #endif #if defined(_MSC_VER) -# pragma warning(disable: 4355) -# ifndef _ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH -# define _ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH -# endif -# ifndef _ALLOW_RUNTIME_LIBRARY_MISMATCH -# define _ALLOW_RUNTIME_LIBRARY_MISMATCH -# endif +#pragma warning(disable : 4355) +#ifndef _ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH +#define _ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH +#endif +#ifndef _ALLOW_RUNTIME_LIBRARY_MISMATCH +#define _ALLOW_RUNTIME_LIBRARY_MISMATCH +#endif #endif #if !defined(EGE_GRAPH_LIB_BUILD) && !defined(EGE_GRAPH_NO_LIB) -# ifdef _MSC_VER -# pragma comment(lib,"gdiplus.lib") -# ifdef _WIN64 // 64 bit libs -# pragma comment(lib,"graphics.lib") -# else // 32 bit libs -# pragma comment(lib,"graphics.lib") -# endif -# endif +#ifdef _MSC_VER +#pragma comment(lib, "gdiplus.lib") +#ifdef _WIN64 // 64 bit libs +#pragma comment(lib, "graphics.lib") +#else // 32 bit libs +#pragma comment(lib, "graphics.lib") +#endif +#endif #endif - #if !defined(EGE_GRAPH_LIB_BUILD) && !defined(EGE_GRAPH_NO_LIB) #ifndef _CRT_SECURE_NO_WARNINGS @@ -86,76 +85,87 @@ #endif #if defined(_MSC_VER) && _MSC_VER <= 1200 && !defined(SetWindowLongPtr) -# define SetWindowLongPtrW SetWindowLongW -# define GetWindowLongPtrW GetWindowLongW -# define GWLP_USERDATA GWL_USERDATA -# define GWLP_WNDPROC GWL_WNDPROC +#define SetWindowLongPtrW SetWindowLongW +#define GetWindowLongPtrW GetWindowLongW +#define GWLP_USERDATA GWL_USERDATA +#define GWLP_WNDPROC GWL_WNDPROC #endif #ifndef WM_MOUSEWHEEL -#define WM_MOUSEWHEEL 0x020A +#define WM_MOUSEWHEEL 0x020A #endif #ifndef EGE_CDECL -# if __STDC__ -# define EGE_CDECL __cdecl -# else -# define EGE_CDECL __cdecl -# endif +#if __STDC__ +#define EGE_CDECL __cdecl +#else +#define EGE_CDECL __cdecl +#endif #endif #ifdef _MSC_VER -# if defined(_WIN64) -# define EGEAPI -# else -# define EGEAPI EGE_CDECL -# endif +#if defined(_WIN64) +#define EGEAPI +#else +#define EGEAPI EGE_CDECL +#endif #else -# if defined(__WORDSIZE) -# if __WORDSIZE > 32 -# define EGEAPI -# else -# define EGEAPI EGE_CDECL -# endif -# else -# define EGEAPI -# endif +#if defined(__WORDSIZE) +#if __WORDSIZE > 32 +#define EGEAPI +#else +#define EGEAPI EGE_CDECL +#endif +#else +#define EGEAPI +#endif #endif #ifndef EGE_DEPRECATE -# ifdef _MSC_VER -# ifdef _CRT_DEPRECATE_TEXT -# define EGE_DEPRECATE(function, msg) _CRT_DEPRECATE_TEXT("This function is deprecated. " msg " For more information, visit https://xege.org .") -# else -# define EGE_DEPRECATE(function, msg) -# endif -# elif ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5))) -# define EGE_DEPRECATE(function, msg) __attribute__((deprecated(msg " For more information, visit https://xege.org ."))) -# else -# define EGE_DEPRECATE(function, msg) __attribute__((deprecated)) -# endif +#ifdef _MSC_VER +#ifdef _CRT_DEPRECATE_TEXT +#define EGE_DEPRECATE(function, msg) \ + _CRT_DEPRECATE_TEXT("This function is deprecated. " msg " For more information, visit https://xege.org .") +#else +#define EGE_DEPRECATE(function, msg) +#endif +#elif ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5))) +#define EGE_DEPRECATE(function, msg) __attribute__((deprecated(msg " For more information, visit https://xege.org ."))) +#else +#define EGE_DEPRECATE(function, msg) __attribute__((deprecated)) +#endif #endif #define EGE_GDIPLUS -#define EGERGBA(r, g, b, a) ((::ege::color_t)(((r) << 16) | ((g) << 8) | (b) | ((a) << 24))) -#define EGERGB(r, g, b) EGERGBA(r, g, b, 0xFF) -#define EGEARGB(a, r, g, b) EGERGBA(r, g, b, a) -#define EGEACOLOR(a, color) ((::ege::color_t)(((color) & 0xFFFFFF) | ((a) << 24))) -#define EGECOLORA(color, a) EGEACOLOR(a, color) -#define EGEGET_R(c) (((c) >> 16) & 0xFF) -#define EGEGET_G(c) (((c) >> 8) & 0xFF) -#define EGEGET_B(c) (((c)) & 0xFF) -#define EGEGET_A(c) (((c) >> 24) & 0xFF) -#define EGEGRAY(gray) EGERGB(gray, gray, gray) -#define EGEGRAYA(gray, a) EGERGBA(gray, gray, gray, a) -#define EGEAGRAY(a, gray) EGEGRAYA(gray, a) +#ifndef EGE_COLOR_T_TYPEDEF +#define EGE_COLOR_T_TYPEDEF + +namespace ege +{ +/// @brief Color type definition, uses 32-bit unsigned integer to represent ARGB color +typedef uint32_t color_t; +}; // namespace ege +#endif + +#define EGERGBA(r, g, b, a) ((::ege::color_t)(((r) << 16) | ((g) << 8) | (b) | ((a) << 24))) +#define EGERGB(r, g, b) EGERGBA(r, g, b, 0xFF) +#define EGEARGB(a, r, g, b) EGERGBA(r, g, b, a) +#define EGEACOLOR(a, color) ((::ege::color_t)(((color) & 0xFFFFFF) | ((a) << 24))) +#define EGECOLORA(color, a) EGEACOLOR(a, color) +#define EGEGET_R(c) (((c) >> 16) & 0xFF) +#define EGEGET_G(c) (((c) >> 8) & 0xFF) +#define EGEGET_B(c) (((c)) & 0xFF) +#define EGEGET_A(c) (((c) >> 24) & 0xFF) +#define EGEGRAY(gray) EGERGB(gray, gray, gray) +#define EGEGRAYA(gray, a) EGERGBA(gray, gray, gray, a) +#define EGEAGRAY(a, gray) EGEGRAYA(gray, a) /* you can also use 932 as shift-jis, 950 as big5 ... */ /* see https://learn.microsoft.com/en-us/windows/win32/intl/code-page-identifiers */ -#define EGE_CODEPAGE_GB2312 936 -#define EGE_CODEPAGE_UTF8 65001 -#define EGE_CODEPAGE_ANSI 0 +const int EGE_CODEPAGE_GB2312 = 936; +const int EGE_CODEPAGE_UTF8 = 65001; +const int EGE_CODEPAGE_ANSI = 0; namespace ege { @@ -165,10 +175,19 @@ const double PI = 3.1415926535897932384626; /* define graphics drivers */ enum graphics_drivers { - DETECT = 0, /* requests autodetection */ - CGA, MCGA, EGA, EGA64, EGAMONO, IBM8514,/* 1 - 6 */ - HERCMONO, ATT400, VGA, PC3270, /* 7 - 10 */ - TRUECOLOR, TRUECOLORSIZE, + DETECT = 0, /* requests autodetection */ + CGA, + MCGA, + EGA, + EGA64, + EGAMONO, + IBM8514, /* 1 - 6 */ + HERCMONO, + ATT400, + VGA, + PC3270, /* 7 - 10 */ + TRUECOLOR, + TRUECOLORSIZE, CURRENT_DRIVER = -1 }; @@ -208,16 +227,17 @@ enum graphics_modes enum initmode_flag { - INIT_DEFAULT = 0x0, ///< Default mode - INIT_NOBORDER = 0x1, ///< Borderless window - INIT_CHILD = 0x2, ///< Child window mode - INIT_TOPMOST = 0x4, ///< Topmost window - INIT_RENDERMANUAL = 0x8, ///< Manual rendering mode - INIT_NOFORCEEXIT = 0x10, ///< Don't force exit program when closing window, only set internal flag, is_run() can get the flag - INIT_UNICODE = 0x20, ///< Unicode character messages (equivalent to setunicodecharmessage(true)) - INIT_HIDE = 0x40, ///< Hidden window - INIT_WITHLOGO = 0x100, ///< Show EGE Logo animation on startup (not shown by default in Debug version) - INIT_ANIMATION = INIT_DEFAULT | INIT_RENDERMANUAL | INIT_NOFORCEEXIT ///< Animation mode + INIT_DEFAULT = 0x0, ///< Default mode + INIT_NOBORDER = 0x1, ///< Borderless window + INIT_CHILD = 0x2, ///< Child window mode + INIT_TOPMOST = 0x4, ///< Topmost window + INIT_RENDERMANUAL = 0x8, ///< Manual rendering mode + INIT_NOFORCEEXIT = + 0x10, ///< Don't force exit program when closing window, only set internal flag, is_run() can get the flag + INIT_UNICODE = 0x20, ///< Unicode character messages (equivalent to setunicodecharmessage(true)) + INIT_HIDE = 0x40, ///< Hidden window + INIT_WITHLOGO = 0x100, ///< Show EGE Logo animation on startup (not shown by default in Debug version) + INIT_ANIMATION = INIT_DEFAULT | INIT_RENDERMANUAL | INIT_NOFORCEEXIT ///< Animation mode }; /** @@ -226,137 +246,130 @@ enum initmode_flag */ enum rendermode_e { - RENDER_AUTO, ///< Automatic rendering - RENDER_MANUAL ///< Manual rendering + RENDER_AUTO, ///< Automatic rendering + RENDER_MANUAL ///< Manual rendering }; /** * @enum graphics_errors * @brief Graphics operation error codes - * + * * Defines various error codes that can be returned by graphics operations */ enum graphics_errors { - grOk = 0, ///< Operation successful - grNoInitGraph = -1, ///< Graphics system not initialized - grNotDetected = -2, ///< Graphics device not detected - grFileNotFound = -3, ///< File not found - grInvalidDriver = -4, ///< Invalid driver - grNoLoadMem = -5, ///< Memory loading failed - grNoScanMem = -6, ///< Scan memory failed - grNoFloodMem = -7, ///< Fill memory failed - grFontNotFound = -8, ///< Font not found - grNoFontMem = -9, ///< Insufficient font memory - grInvalidMode = -10, ///< Invalid mode - grError = -11, ///< General error - grIOerror = -12, ///< I/O error - grInvalidFont = -13, ///< Invalid font - grInvalidFontNum = -14, ///< Invalid font number - grInvalidVersion = -18, ///< Version incompatible - - grException = 16, ///< EGE exception - grParamError = 17, ///< Parameter error - grInvalidRegion = 18, ///< Invalid region - grOutOfMemory = 19, ///< Out of memory - grNullPointer = 20, ///< Null pointer - grAllocError = 21, ///< Allocation error - grInvalidFileFormat = 22, ///< Invalid file format - grUnsupportedFormat = 23, ///< Unsupported format - grInvalidMemory = 0xCDCDCDCD ///< Invalid memory(-842150451) + grOk = 0, ///< Operation successful + grNoInitGraph = -1, ///< Graphics system not initialized + grNotDetected = -2, ///< Graphics device not detected + grFileNotFound = -3, ///< File not found + grInvalidDriver = -4, ///< Invalid driver + grNoLoadMem = -5, ///< Memory loading failed + grNoScanMem = -6, ///< Scan memory failed + grNoFloodMem = -7, ///< Fill memory failed + grFontNotFound = -8, ///< Font not found + grNoFontMem = -9, ///< Insufficient font memory + grInvalidMode = -10, ///< Invalid mode + grError = -11, ///< General error + grIOerror = -12, ///< I/O error + grInvalidFont = -13, ///< Invalid font + grInvalidFontNum = -14, ///< Invalid font number + grInvalidVersion = -18, ///< Version incompatible + + grException = 16, ///< EGE exception + grParamError = 17, ///< Parameter error + grInvalidRegion = 18, ///< Invalid region + grOutOfMemory = 19, ///< Out of memory + grNullPointer = 20, ///< Null pointer + grAllocError = 21, ///< Allocation error + grInvalidFileFormat = 22, ///< Invalid file format + grUnsupportedFormat = 23, ///< Unsupported format + grInvalidMemory = 0xCDCDCDCD ///< Invalid memory(-842150451) }; /** * @enum message_event * @brief Message event types - * + * * Defines event types for mouse and keyboard messages, used for message handling */ enum message_event { - MSG_EVENT_UP = 0x00, ///< Key/mouse button release event - MSG_EVENT_DOWN = 0x01, ///< Key/mouse button press event - MSG_EVENT_CLICK = 0x01, ///< Mouse click event (equivalent to DOWN) - MSG_EVENT_DBCLICK = 0x02, ///< Mouse double-click event - MSG_EVENT_MOVE = 0x04, ///< Mouse move event - MSG_EVENT_WHEEL = 0x10 ///< Mouse wheel event + MSG_EVENT_UP = 0x00, ///< Key/mouse button release event + MSG_EVENT_DOWN = 0x01, ///< Key/mouse button press event + MSG_EVENT_CLICK = 0x01, ///< Mouse click event (equivalent to DOWN) + MSG_EVENT_DBCLICK = 0x02, ///< Mouse double-click event + MSG_EVENT_MOVE = 0x04, ///< Mouse move event + MSG_EVENT_WHEEL = 0x10 ///< Mouse wheel event }; /** * @enum message_mouse * @brief Mouse button identifiers - * + * * Defines different mouse buttons, can be combined using bitwise OR operations */ enum message_mouse { - MSG_MOUSE_LEFT = 0x01, ///< Left mouse button - MSG_MOUSE_RIGHT = 0x02, ///< Right mouse button - MSG_MOUSE_MID = 0x04 ///< Middle mouse button (wheel button) + MSG_MOUSE_LEFT = 0x01, ///< Left mouse button + MSG_MOUSE_RIGHT = 0x02, ///< Right mouse button + MSG_MOUSE_MID = 0x04 ///< Middle mouse button (wheel button) }; - -#ifndef EGE_COLOR_T_TYPEDEF -#define EGE_COLOR_T_TYPEDEF -/// @brief Color type definition, uses 32-bit unsigned integer to represent ARGB color -typedef uint32_t color_t; -#endif - /** * @enum alpha_type * @brief Alpha channel types - * + * * Defines different handling methods for image alpha channels */ enum alpha_type { - ALPHATYPE_STRAIGHT = 0, ///< Straight alpha (non-premultiplied alpha) - ALPHATYPE_PREMULTIPLIED = 1 ///< Premultiplied alpha + ALPHATYPE_STRAIGHT = 0, ///< Straight alpha (non-premultiplied alpha) + ALPHATYPE_PREMULTIPLIED = 1 ///< Premultiplied alpha }; /** * @struct ege_point * @brief Floating-point coordinate point structure - * + * * Used to represent a point in 2D space with floating-point coordinates */ struct ege_point { - float x; ///< x coordinate - float y; ///< y coordinate + float x; ///< x coordinate + float y; ///< y coordinate }; /** * @struct ege_rect * @brief Rectangle area structure - * + * * Used to represent a rectangular area, including position and size information */ struct ege_rect { - float x; ///< Rectangle top-left x coordinate - float y; ///< Rectangle top-left y coordinate - float w; ///< Rectangle width - float h; ///< Rectangle height + float x; ///< Rectangle top-left x coordinate + float y; ///< Rectangle top-left y coordinate + float w; ///< Rectangle width + float h; ///< Rectangle height }; /** * @struct ege_colpoint * @brief Coordinate point structure with color - * + * * Used to represent a 2D coordinate point with color information, commonly used for gradient effects */ struct ege_colpoint { - float x; ///< x coordinate - float y; ///< y coordinate - color_t color; ///< Color value of this point + float x; ///< x coordinate + float y; ///< y coordinate + color_t color; ///< Color value of this point }; /** * @enum COLORS * @brief Predefined color constants - * + * * Provides commonly used color constants, defined based on web-safe color standards * Color values use RGB format and can be used directly in drawing functions */ @@ -509,532 +522,539 @@ enum COLORS /** * @enum line_styles * @brief Line styles - * + * * Defines different styles that can be used when drawing lines */ enum line_styles { - SOLID_LINE = PS_SOLID, ///< Solid line - CENTER_LINE = PS_DASH, ///< Center line (dashed line) - DOTTED_LINE = PS_DOT, ///< Dotted line - DASHED_LINE = PS_DASHDOT, ///< Dash-dot line - NULL_LINE = PS_NULL, ///< Null line (no drawing) - USERBIT_LINE = PS_USERSTYLE ///< User-defined line style + SOLID_LINE = PS_SOLID, ///< Solid line + CENTER_LINE = PS_DASH, ///< Center line (dashed line) + DOTTED_LINE = PS_DOT, ///< Dotted line + DASHED_LINE = PS_DASHDOT, ///< Dash-dot line + NULL_LINE = PS_NULL, ///< Null line (no drawing) + USERBIT_LINE = PS_USERSTYLE ///< User-defined line style }; /** * @struct line_style_type * @brief Line style structure - * + * * Describes detailed style attributes of lines */ struct line_style_type { - int linestyle; ///< Line style - unsigned short upattern; ///< User-defined line pattern - int thickness; ///< Line thickness + int linestyle; ///< Line style + unsigned short upattern; ///< User-defined line pattern + int thickness; ///< Line thickness }; /** * @enum line_cap_type * @brief Line cap styles - * + * * Defines the drawing styles for line endpoints */ enum line_cap_type { - LINECAP_FLAT = 0, ///< Flat cap - LINECAP_SQUARE, ///< Square cap - LINECAP_ROUND ///< Round cap + LINECAP_FLAT = 0, ///< Flat cap + LINECAP_SQUARE, ///< Square cap + LINECAP_ROUND ///< Round cap }; /** * @enum line_join_type * @brief Line join styles - * + * * Defines the drawing styles for line connection points */ enum line_join_type { - LINEJOIN_MITER = 0, ///< Miter join - LINEJOIN_BEVEL, ///< Bevel join - LINEJOIN_ROUND ///< Round join + LINEJOIN_MITER = 0, ///< Miter join + LINEJOIN_BEVEL, ///< Bevel join + LINEJOIN_ROUND ///< Round join }; /** * @enum fill_patterns * @brief Fill patterns - * + * * Defines different pattern styles that can be used when filling geometric shapes */ enum fill_patterns { - EMPTY_FILL, ///< No fill - SOLID_FILL, ///< Solid fill (fill with fill color) - LINE_FILL, ///< Horizontal line fill --- - LTSLASH_FILL, ///< Light slash fill "///" - SLASH_FILL, ///< Heavy slash fill "///" - BKSLASH_FILL, ///< Heavy backslash fill "\\\" - LTBKSLASH_FILL, ///< Light backslash fill "\\\" - HATCH_FILL, ///< Light grid fill - XHATCH_FILL, ///< Heavy cross grid fill - INTERLEAVE_FILL, ///< Interleaved line fill - WIDE_DOT_FILL, ///< Sparse dot fill - CLOSE_DOT_FILL, ///< Dense dot fill - USER_FILL ///< User-defined fill + EMPTY_FILL, ///< No fill + SOLID_FILL, ///< Solid fill (fill with fill color) + LINE_FILL, ///< Horizontal line fill --- + LTSLASH_FILL, ///< Light slash fill "///" + SLASH_FILL, ///< Heavy slash fill "///" + BKSLASH_FILL, ///< Heavy backslash fill "\\\" + LTBKSLASH_FILL, ///< Light backslash fill "\\\" + HATCH_FILL, ///< Light grid fill + XHATCH_FILL, ///< Heavy cross grid fill + INTERLEAVE_FILL, ///< Interleaved line fill + WIDE_DOT_FILL, ///< Sparse dot fill + CLOSE_DOT_FILL, ///< Dense dot fill + USER_FILL ///< User-defined fill }; /** * @enum fill_mode * @brief Fill modes - * + * * Defines filling algorithms for complex graphics */ enum fill_mode { - FILLMODE_DEFAULT = 0, ///< Default fill mode - FILLMODE_ALTERNATE = 1, ///< Alternate fill mode - FILLMODE_WINDING = 2 ///< Winding fill mode + FILLMODE_DEFAULT = 0, ///< Default fill mode + FILLMODE_ALTERNATE = 1, ///< Alternate fill mode + FILLMODE_WINDING = 2 ///< Winding fill mode }; /** * @enum text_just * @brief Text alignment methods - * + * * Defines horizontal and vertical alignment methods for text */ enum text_just { - LEFT_TEXT = 0, ///< Left align - CENTER_TEXT = 1, ///< Center align - RIGHT_TEXT = 2, ///< Right align + LEFT_TEXT = 0, ///< Left align + CENTER_TEXT = 1, ///< Center align + RIGHT_TEXT = 2, ///< Right align - TOP_TEXT = 0, ///< Top align -/* CENTER_TEXT = 1, Already defined above */ - BOTTOM_TEXT = 2 ///< Bottom align + TOP_TEXT = 0, ///< Top align + /* CENTER_TEXT = 1, Already defined above */ + BOTTOM_TEXT = 2 ///< Bottom align }; /** * @struct textsettingstype * @brief Text settings structure - * + * * Contains text settings such as font, direction, size and alignment */ struct textsettingstype { - int font; ///< Font type - int direction; ///< Text direction - int charsize; ///< Character size - int horiz; ///< Horizontal alignment - int vert; ///< Vertical alignment + int font; ///< Font type + int direction; ///< Text direction + int charsize; ///< Character size + int horiz; ///< Horizontal alignment + int vert; ///< Vertical alignment }; /** * @enum font_styles * @brief Font styles - * + * * Defines various font styles, can be combined using bitwise OR operations */ enum font_styles { - FONTSTYLE_BOLD = 1, ///< Bold - FONTSTYLE_ITALIC = 2, ///< Italic - FONTSTYLE_UNDERLINE = 4, ///< Underline - FONTSTYLE_STRIKEOUT = 8 ///< Strikeout + FONTSTYLE_BOLD = 1, ///< Bold + FONTSTYLE_ITALIC = 2, ///< Italic + FONTSTYLE_UNDERLINE = 4, ///< Underline + FONTSTYLE_STRIKEOUT = 8 ///< Strikeout }; /** * @enum music_state_flag * @brief Music playback state flags - * + * * Defines various states of the music player */ enum music_state_flag { - MUSIC_MODE_NOT_OPEN = 0x0, ///< Not opened state - MUSIC_MODE_NOT_READY = 0x20C, ///< Not ready state - MUSIC_MODE_PAUSE = 0x211, ///< Paused state - MUSIC_MODE_PLAY = 0x20E, ///< Playing state - MUSIC_MODE_STOP = 0x20D, ///< Stopped state - MUSIC_MODE_OPEN = 0x212, ///< Opened state - MUSIC_MODE_SEEK = 0x210 ///< Seeking state + MUSIC_MODE_NOT_OPEN = 0x0, ///< Not opened state + MUSIC_MODE_NOT_READY = 0x20C, ///< Not ready state + MUSIC_MODE_PAUSE = 0x211, ///< Paused state + MUSIC_MODE_PLAY = 0x20E, ///< Playing state + MUSIC_MODE_STOP = 0x20D, ///< Stopped state + MUSIC_MODE_OPEN = 0x212, ///< Opened state + MUSIC_MODE_SEEK = 0x210 ///< Seeking state }; /// @brief Music operation error code -#define MUSIC_ERROR 0xFFFFFFFF +#define MUSIC_ERROR 0xFFFFFFFF /** * @enum key_msg_flag * @brief Key message flags - * + * * Defines types and state flags for key messages */ enum key_msg_flag { - KEYMSG_CHAR_FLAG = 2, ///< Character message flag - KEYMSG_DOWN_FLAG = 1, ///< Key down message flag - KEYMSG_UP_FLAG = 1, ///< Key up message flag - - KEYMSG_CHAR = 0x40000, ///< Character message - KEYMSG_DOWN = 0x10000, ///< Key down message - KEYMSG_UP = 0x20000, ///< Key up message - KEYMSG_FIRSTDOWN = 0x80000 ///< First key down message + KEYMSG_CHAR_FLAG = 2, ///< Character message flag + KEYMSG_DOWN_FLAG = 1, ///< Key down message flag + KEYMSG_UP_FLAG = 1, ///< Key up message flag + + KEYMSG_CHAR = 0x40000, ///< Character message + KEYMSG_DOWN = 0x10000, ///< Key down message + KEYMSG_UP = 0x20000, ///< Key up message + KEYMSG_FIRSTDOWN = 0x80000 ///< First key down message }; /** * @enum key_code_e * @brief Keyboard and mouse key codes - * + * * Defines key code values for all detectable keyboard keys and mouse buttons * Key code values are based on Windows Virtual Key Codes */ enum key_code_e { // Mouse buttons - key_mouse_l = 0x01, ///< Left mouse button - key_mouse_r = 0x02, ///< Right mouse button - key_mouse_m = 0x04, ///< Middle mouse button - key_mouse_x1 = 0x05, ///< Mouse X1 button - key_mouse_x2 = 0x06, ///< Mouse X2 button - + key_mouse_l = 0x01, ///< Left mouse button + key_mouse_r = 0x02, ///< Right mouse button + key_mouse_m = 0x04, ///< Middle mouse button + key_mouse_x1 = 0x05, ///< Mouse X1 button + key_mouse_x2 = 0x06, ///< Mouse X2 button + // Special function keys - key_back = 0x08, ///< Backspace key - key_tab = 0x09, ///< Tab key - key_enter = 0x0d, ///< Enter key - key_shift = 0x10, ///< Shift key - key_control = 0x11, ///< Ctrl key - key_menu = 0x12, ///< Alt key - key_pause = 0x13, ///< Pause key - key_capslock = 0x14, ///< Caps Lock key - key_esc = 0x1b, ///< Escape key - key_space = 0x20, ///< Space key + key_back = 0x08, ///< Backspace key + key_tab = 0x09, ///< Tab key + key_enter = 0x0d, ///< Enter key + key_shift = 0x10, ///< Shift key + key_control = 0x11, ///< Ctrl key + key_menu = 0x12, ///< Alt key + key_pause = 0x13, ///< Pause key + key_capslock = 0x14, ///< Caps Lock key + key_esc = 0x1b, ///< Escape key + key_space = 0x20, ///< Space key // Navigation keys - key_pageup = 0x21, ///< Page Up key - key_pagedown = 0x22, ///< Page Down key - key_end = 0x23, ///< End key - key_home = 0x24, ///< Home key + key_pageup = 0x21, ///< Page Up key + key_pagedown = 0x22, ///< Page Down key + key_end = 0x23, ///< End key + key_home = 0x24, ///< Home key // Arrow keys - key_left = 0x25, ///< Left arrow key - key_up = 0x26, ///< Up arrow key - key_right = 0x27, ///< Right arrow key - key_down = 0x28, ///< Down arrow key + key_left = 0x25, ///< Left arrow key + key_up = 0x26, ///< Up arrow key + key_right = 0x27, ///< Right arrow key + key_down = 0x28, ///< Down arrow key // Editing keys - key_print = 0x2a, ///< Print key - key_snapshot = 0x2c, ///< Print Screen key - key_insert = 0x2d, ///< Insert key - key_delete = 0x2e, ///< Delete key + key_print = 0x2a, ///< Print key + key_snapshot = 0x2c, ///< Print Screen key + key_insert = 0x2d, ///< Insert key + key_delete = 0x2e, ///< Delete key // Number keys (main keyboard) - key_0 = 0x30, ///< Number key 0 - key_1 = 0x31, ///< Number key 1 - key_2 = 0x32, ///< Number key 2 - key_3 = 0x33, ///< Number key 3 - key_4 = 0x34, ///< Number key 4 - key_5 = 0x35, ///< Number key 5 - key_6 = 0x36, ///< Number key 6 - key_7 = 0x37, ///< Number key 7 - key_8 = 0x38, ///< Number key 8 - key_9 = 0x39, ///< Number key 9 + key_0 = 0x30, ///< Number key 0 + key_1 = 0x31, ///< Number key 1 + key_2 = 0x32, ///< Number key 2 + key_3 = 0x33, ///< Number key 3 + key_4 = 0x34, ///< Number key 4 + key_5 = 0x35, ///< Number key 5 + key_6 = 0x36, ///< Number key 6 + key_7 = 0x37, ///< Number key 7 + key_8 = 0x38, ///< Number key 8 + key_9 = 0x39, ///< Number key 9 // Letter keys - key_A = 0x41, ///< Letter key A - key_B = 0x42, ///< Letter key B - key_C = 0x43, ///< Letter key C - key_D = 0x44, ///< Letter key D - key_E = 0x45, ///< Letter key E - key_F = 0x46, ///< Letter key F - key_G = 0x47, ///< Letter key G - key_H = 0x48, ///< Letter key H - key_I = 0x49, ///< Letter key I - key_J = 0x4a, ///< Letter key J - key_K = 0x4b, ///< Letter key K - key_L = 0x4c, ///< Letter key L - key_M = 0x4d, ///< Letter key M - key_N = 0x4e, ///< Letter key N - key_O = 0x4f, ///< Letter key O - key_P = 0x50, ///< Letter key P - key_Q = 0x51, ///< Letter key Q - key_R = 0x52, ///< Letter key R - key_S = 0x53, ///< Letter key S - key_T = 0x54, ///< Letter key T - key_U = 0x55, ///< Letter key U - key_V = 0x56, ///< Letter key V - key_W = 0x57, ///< Letter key W - key_X = 0x58, ///< Letter key X - key_Y = 0x59, ///< Letter key Y - key_Z = 0x5a, ///< Letter key Z - + key_A = 0x41, ///< Letter key A + key_B = 0x42, ///< Letter key B + key_C = 0x43, ///< Letter key C + key_D = 0x44, ///< Letter key D + key_E = 0x45, ///< Letter key E + key_F = 0x46, ///< Letter key F + key_G = 0x47, ///< Letter key G + key_H = 0x48, ///< Letter key H + key_I = 0x49, ///< Letter key I + key_J = 0x4a, ///< Letter key J + key_K = 0x4b, ///< Letter key K + key_L = 0x4c, ///< Letter key L + key_M = 0x4d, ///< Letter key M + key_N = 0x4e, ///< Letter key N + key_O = 0x4f, ///< Letter key O + key_P = 0x50, ///< Letter key P + key_Q = 0x51, ///< Letter key Q + key_R = 0x52, ///< Letter key R + key_S = 0x53, ///< Letter key S + key_T = 0x54, ///< Letter key T + key_U = 0x55, ///< Letter key U + key_V = 0x56, ///< Letter key V + key_W = 0x57, ///< Letter key W + key_X = 0x58, ///< Letter key X + key_Y = 0x59, ///< Letter key Y + key_Z = 0x5a, ///< Letter key Z + // Windows keys - key_win_l = 0x5b, ///< Left Windows key - key_win_r = 0x5c, ///< Right Windows key + key_win_l = 0x5b, ///< Left Windows key + key_win_r = 0x5c, ///< Right Windows key - key_sleep = 0x5f, ///< Sleep key + key_sleep = 0x5f, ///< Sleep key // Numeric keypad - key_num0 = 0x60, ///< Numeric keypad 0 - key_num1 = 0x61, ///< Numeric keypad 1 - key_num2 = 0x62, ///< Numeric keypad 2 - key_num3 = 0x63, ///< Numeric keypad 3 - key_num4 = 0x64, ///< Numeric keypad 4 - key_num5 = 0x65, ///< Numeric keypad 5 - key_num6 = 0x66, ///< Numeric keypad 6 - key_num7 = 0x67, ///< Numeric keypad 7 - key_num8 = 0x68, ///< Numeric keypad 8 - key_num9 = 0x69, ///< Numeric keypad 9 + key_num0 = 0x60, ///< Numeric keypad 0 + key_num1 = 0x61, ///< Numeric keypad 1 + key_num2 = 0x62, ///< Numeric keypad 2 + key_num3 = 0x63, ///< Numeric keypad 3 + key_num4 = 0x64, ///< Numeric keypad 4 + key_num5 = 0x65, ///< Numeric keypad 5 + key_num6 = 0x66, ///< Numeric keypad 6 + key_num7 = 0x67, ///< Numeric keypad 7 + key_num8 = 0x68, ///< Numeric keypad 8 + key_num9 = 0x69, ///< Numeric keypad 9 // Numeric keypad operators - key_multiply = 0x6a, ///< Numeric keypad multiply (*) - key_add = 0x6b, ///< Numeric keypad add (+) - key_separator = 0x6c, ///< Numeric keypad separator - key_subtract = 0x6d, ///< Numeric keypad subtract (-) - key_decimal = 0x6e, ///< Numeric keypad decimal point (.) - key_divide = 0x6f, ///< Numeric keypad divide (/) + key_multiply = 0x6a, ///< Numeric keypad multiply (*) + key_add = 0x6b, ///< Numeric keypad add (+) + key_separator = 0x6c, ///< Numeric keypad separator + key_subtract = 0x6d, ///< Numeric keypad subtract (-) + key_decimal = 0x6e, ///< Numeric keypad decimal point (.) + key_divide = 0x6f, ///< Numeric keypad divide (/) // Function keys - key_f1 = 0x70, ///< F1 function key - key_f2 = 0x71, ///< F2 function key - key_f3 = 0x72, ///< F3 function key - key_f4 = 0x73, ///< F4 function key - key_f5 = 0x74, ///< F5 function key - key_f6 = 0x75, ///< F6 function key - key_f7 = 0x76, ///< F7 function key - key_f8 = 0x77, ///< F8 function key - key_f9 = 0x78, ///< F9 function key - key_f10 = 0x79, ///< F10 function key - key_f11 = 0x7a, ///< F11 function key - key_f12 = 0x7b, ///< F12 function key + key_f1 = 0x70, ///< F1 function key + key_f2 = 0x71, ///< F2 function key + key_f3 = 0x72, ///< F3 function key + key_f4 = 0x73, ///< F4 function key + key_f5 = 0x74, ///< F5 function key + key_f6 = 0x75, ///< F6 function key + key_f7 = 0x76, ///< F7 function key + key_f8 = 0x77, ///< F8 function key + key_f9 = 0x78, ///< F9 function key + key_f10 = 0x79, ///< F10 function key + key_f11 = 0x7a, ///< F11 function key + key_f12 = 0x7b, ///< F12 function key // Lock keys - key_numlock = 0x90, ///< Num Lock key - key_scrolllock = 0x91, ///< Scroll Lock key + key_numlock = 0x90, ///< Num Lock key + key_scrolllock = 0x91, ///< Scroll Lock key // Left/right distinguished modifier keys - key_shift_l = 0xa0, ///< Left Shift key - key_shift_r = 0xa1, ///< Right Shift key - key_control_l = 0xa2, ///< Left Ctrl key - key_control_r = 0xa3, ///< Right Ctrl key - key_menu_l = 0xa4, ///< Left Alt key - key_menu_r = 0xa5, ///< Right Alt key + key_shift_l = 0xa0, ///< Left Shift key + key_shift_r = 0xa1, ///< Right Shift key + key_control_l = 0xa2, ///< Left Ctrl key + key_control_r = 0xa3, ///< Right Ctrl key + key_menu_l = 0xa4, ///< Left Alt key + key_menu_r = 0xa5, ///< Right Alt key // Punctuation keys - key_semicolon = 0xba, ///< Semicolon key (;) - key_plus = 0xbb, ///< Equals/plus key (=) - key_comma = 0xbc, ///< Comma key (,) - key_minus = 0xbd, ///< Minus/underscore key (-) - key_period = 0xbe, ///< Period key (.) - key_slash = 0xbf, ///< Slash key (/) - key_tilde = 0xc0, ///< Tilde key (~) - key_lbrace = 0xdb, ///< Left bracket key ([) - key_backslash = 0xdc, ///< Backslash key (\) - key_rbrace = 0xdd, ///< Right bracket key (]) - key_quote = 0xde, ///< Quote key (') - - key_ime_process = 0xe5 ///< IME process key + key_semicolon = 0xba, ///< Semicolon key (;) + key_plus = 0xbb, ///< Equals/plus key (=) + key_comma = 0xbc, ///< Comma key (,) + key_minus = 0xbd, ///< Minus/underscore key (-) + key_period = 0xbe, ///< Period key (.) + key_slash = 0xbf, ///< Slash key (/) + key_tilde = 0xc0, ///< Tilde key (~) + key_lbrace = 0xdb, ///< Left bracket key ([) + key_backslash = 0xdc, ///< Backslash key (\) + key_rbrace = 0xdd, ///< Right bracket key (]) + key_quote = 0xde, ///< Quote key (') + + key_ime_process = 0xe5 ///< IME process key }; /** * @enum key_msg_e * @brief Key message types - * + * * Defines specific types of key events */ enum key_msg_e { - key_msg_down = 1, ///< Key press message - key_msg_up = 2, ///< Key release message - key_msg_char = 4 ///< Character input message + key_msg_down = 1, ///< Key press message + key_msg_up = 2, ///< Key release message + key_msg_char = 4 ///< Character input message }; /** * @enum key_flag_e * @brief Key state flags - * + * * Defines modifier key states and special flags for key events */ enum key_flag_e { - key_flag_shift = 0x100, ///< Shift key is pressed - key_flag_ctrl = 0x200, ///< Ctrl key is pressed - key_flag_first_down = 0x80000 ///< First press flag + key_flag_shift = 0x100, ///< Shift key is pressed + key_flag_ctrl = 0x200, ///< Ctrl key is pressed + key_flag_first_down = 0x80000 ///< First press flag }; /** * @struct key_msg * @brief Key message structure - * + * * Contains complete key event information */ struct key_msg { - int key; ///< Key code - key_msg_e msg; ///< Message type - unsigned int flags; ///< State flags + int key; ///< Key code + key_msg_e msg; ///< Message type + unsigned int flags; ///< State flags }; /** * @enum mouse_msg_e * @brief Mouse message types - * + * * Defines specific types of mouse events */ enum mouse_msg_e { - mouse_msg_down = 0x10, ///< Mouse button press message - mouse_msg_up = 0x20, ///< Mouse button release message - mouse_msg_move = 0x40, ///< Mouse move message - mouse_msg_wheel = 0x80 ///< Mouse wheel message + mouse_msg_down = 0x10, ///< Mouse button press message + mouse_msg_up = 0x20, ///< Mouse button release message + mouse_msg_move = 0x40, ///< Mouse move message + mouse_msg_wheel = 0x80 ///< Mouse wheel message }; /** * @enum mouse_flag_e * @brief Mouse state flags - * + * * Defines the states of various mouse buttons and modifier keys in mouse events */ enum mouse_flag_e { - mouse_flag_left = 0x0001, ///< Left mouse button is pressed - mouse_flag_right = 0x0002, ///< Right mouse button is pressed - mouse_flag_mid = 0x0004, ///< Middle mouse button is pressed - mouse_flag_x1 = 0x0008, ///< Mouse X1 button is pressed - mouse_flag_x2 = 0x0010, ///< Mouse X2 button is pressed - mouse_flag_shift = 0x0100, ///< Shift key is pressed - mouse_flag_ctrl = 0x0200, ///< Ctrl key is pressed - mouse_flag_doubleclick = 0x1000 ///< Double click. + mouse_flag_left = 0x0001, ///< Left mouse button is pressed + mouse_flag_right = 0x0002, ///< Right mouse button is pressed + mouse_flag_mid = 0x0004, ///< Middle mouse button is pressed + mouse_flag_x1 = 0x0008, ///< Mouse X1 button is pressed + mouse_flag_x2 = 0x0010, ///< Mouse X2 button is pressed + mouse_flag_shift = 0x0100, ///< Shift key is pressed + mouse_flag_ctrl = 0x0200, ///< Ctrl key is pressed + mouse_flag_doubleclick = 0x1000 ///< Double click. }; /** * @struct mouse_msg * @brief Mouse message structure - * + * * Contains complete mouse event information with convenient state query methods */ struct mouse_msg { - int x; ///< Mouse x coordinate - int y; ///< Mouse y coordinate - mouse_msg_e msg; ///< Message type - unsigned int flags; ///< State flags - int wheel; ///< Wheel scroll delta + int x; ///< Mouse x coordinate + int y; ///< Mouse y coordinate + mouse_msg_e msg; ///< Message type + unsigned int flags; ///< State flags + int wheel; ///< Wheel scroll delta /// @brief Check if it's a left mouse button event - bool is_left() const {return (flags & mouse_flag_left) != 0;} + bool is_left() const { return (flags & mouse_flag_left) != 0; } + /// @brief Check if it's a right mouse button event - bool is_right() const {return (flags & mouse_flag_right) != 0;} + bool is_right() const { return (flags & mouse_flag_right) != 0; } + /// @brief Check if it's a middle mouse button event - bool is_mid() const {return (flags & mouse_flag_mid) != 0;} + bool is_mid() const { return (flags & mouse_flag_mid) != 0; } + /// @brief Check if it's a mouse X1 button event - bool is_x1() const {return (flags & mouse_flag_x1) != 0;} + bool is_x1() const { return (flags & mouse_flag_x1) != 0; } + /// @brief Check if it's a mouse X2 button event - bool is_x2() const {return (flags & mouse_flag_x2) != 0;} + bool is_x2() const { return (flags & mouse_flag_x2) != 0; } /// @brief Check if it's a button press event - bool is_down() const {return msg == mouse_msg_down; } + bool is_down() const { return msg == mouse_msg_down; } + /// @brief Check if it's a button release event - bool is_up() const {return msg == mouse_msg_up; } + bool is_up() const { return msg == mouse_msg_up; } + /// @brief Check if it's a mouse move event - bool is_move() const {return msg == mouse_msg_move; } + bool is_move() const { return msg == mouse_msg_move; } + /// @brief Check if it's a wheel event - bool is_wheel() const {return msg == mouse_msg_wheel;} + bool is_wheel() const { return msg == mouse_msg_wheel; } /// @brief Check if it's a double-click event - bool is_doubleclick() const {return (flags & mouse_flag_doubleclick) != 0;} + bool is_doubleclick() const { return (flags & mouse_flag_doubleclick) != 0; } }; /** * @struct MOUSEMSG * @brief Legacy mouse message structure (compatibility) - * + * * Provides mouse message format compatible with older versions */ struct MOUSEMSG { - UINT uMsg; ///< Windows message ID - bool mkCtrl; ///< Ctrl key state - bool mkShift; ///< Shift key state - bool mkLButton; ///< Left button state - bool mkMButton; ///< Middle button state - bool mkRButton; ///< Right button state - bool mkXButton1; ///< X1 button state - bool mkXButton2; ///< X2 button state - short x; ///< x coordinate - short y; ///< y coordinate - short wheel; ///< Wheel delta + UINT uMsg; ///< Windows message ID + bool mkCtrl; ///< Ctrl key state + bool mkShift; ///< Shift key state + bool mkLButton; ///< Left button state + bool mkMButton; ///< Middle button state + bool mkRButton; ///< Right button state + bool mkXButton1; ///< X1 button state + bool mkXButton2; ///< X2 button state + short x; ///< x coordinate + short y; ///< y coordinate + short wheel; ///< Wheel delta }; /** * @struct viewporttype * @brief Viewport type structure - * + * * Defines the boundary rectangle of the drawing viewport */ /** * @struct viewporttype * @brief Viewport type structure - * + * * Defines the boundary rectangle of the drawing viewport */ struct viewporttype { - int left; ///< Left boundary - int top; ///< Top boundary - int right; ///< Right boundary - int bottom; ///< Bottom boundary - int clipflag; ///< Clipping flag + int left; ///< Left boundary + int top; ///< Top boundary + int right; ///< Right boundary + int bottom; ///< Bottom boundary + int clipflag; ///< Clipping flag }; /** * @struct ege_transform_matrix * @brief 2D transformation matrix - * + * * 3x2 matrix for 2D graphics transformations, supports translation, rotation, scaling, etc. */ struct ege_transform_matrix { - float m11, m12; ///< First row: [m11, m12] - float m21, m22; ///< Second row: [m21, m22] - float m31, m32; ///< Third row: [m31, m32] translation components + float m11, m12; ///< First row: [m11, m12] + float m21, m22; ///< Second row: [m21, m22] + float m31, m32; ///< Third row: [m31, m32] translation components }; /** * @struct ege_path * @brief Graphics path - * + * * Used to define complex graphics paths, supporting combinations of lines, curves and other graphic elements */ struct ege_path { private: - void* m_data; ///< Internal data pointer + void* m_data; ///< Internal data pointer public: /// @brief Default constructor ege_path(); - + /// @brief Construct path from point array and type array /// @param points Point array /// @param types Path type array /// @param count Number of points ege_path(const ege_point* points, const unsigned char* types, int count); - + /// @brief Copy constructor /// @param path Path to copy ege_path(const ege_path& path); - + /// @brief Destructor virtual ~ege_path(); /// @brief Get read-only data pointer /// @return Constant data pointer const void* data() const; - + /// @brief Get writable data pointer /// @return Data pointer void* data(); - + /// @brief Assignment operator /// @param path Path to assign /// @return Path reference @@ -1044,29 +1064,29 @@ struct ege_path /** * @struct msg_createwindow * @brief Create window message structure - * + * * Message structure used to pass parameters when creating windows */ struct msg_createwindow { - HANDLE hEvent; ///< Event handle - HWND hwnd; ///< Window handle + HANDLE hEvent; ///< Event handle + HWND hwnd; ///< Window handle const wchar_t* classname; ///< Window class name - DWORD style; ///< Window style - DWORD exstyle; ///< Extended window style - size_t id; ///< Window ID - LPVOID param; ///< Parameter pointer + DWORD style; ///< Window style + DWORD exstyle; ///< Extended window style + size_t id; ///< Window ID + LPVOID param; ///< Parameter pointer }; /// @brief Generic callback function type -typedef void (CALLBACK_PROC)(); +typedef void(CALLBACK_PROC)(); /// @brief Keyboard message handler callback function type /// @param userdata User data pointer /// @param message Message type /// @param key Key code /// @return Processing result -typedef int (__stdcall MSG_KEY_PROC )(void*, unsigned, int); +typedef int(__stdcall MSG_KEY_PROC)(void*, unsigned, int); /// @brief Mouse message handler callback function type /// @param userdata User data pointer @@ -1075,14 +1095,14 @@ typedef int (__stdcall MSG_KEY_PROC )(void*, unsigned, int); /// @param y y coordinate /// @param flags Flag bits /// @return Processing result -typedef int (__stdcall MSG_MOUSE_PROC)(void*, unsigned, int, int, int); +typedef int(__stdcall MSG_MOUSE_PROC)(void*, unsigned, int, int, int); /// @brief Callback function pointer type -typedef CALLBACK_PROC * LPCALLBACK_PROC; +typedef CALLBACK_PROC* LPCALLBACK_PROC; /// @brief Keyboard message handler function pointer type -typedef MSG_KEY_PROC * LPMSG_KEY_PROC; +typedef MSG_KEY_PROC* LPMSG_KEY_PROC; /// @brief Mouse message handler function pointer type -typedef MSG_MOUSE_PROC * LPMSG_MOUSE_PROC; +typedef MSG_MOUSE_PROC* LPMSG_MOUSE_PROC; struct VECTOR3D; @@ -1104,21 +1124,22 @@ void EGEAPI rotate_point3d_z(VECTOR3D* point, float rad); /** * @struct VECTOR3D * @brief 3D vector structure - * + * * Represents vectors or points in 3D space, provides basic 3D graphics computation functionality */ struct VECTOR3D { - float x, y, z; ///< 3D coordinate components + float x, y, z; ///< 3D coordinate components /// @brief Default constructor, initialize to origin VECTOR3D() : x(0.0f), y(0.0f), z(0.0f) {} - + /// @brief Constructor /// @param x x coordinate /// @param y y coordinate /// @param z z coordinate (default 0) - VECTOR3D(float x, float y, float z = 0.0f) : x(x), y(y), z(z) {} /// @brief Assignment operator + VECTOR3D(float x, float y, float z = 0.0f) : x(x), y(y), z(z) {} /// @brief Assignment operator + /// @param vector Vector to assign /// @return Vector reference VECTOR3D& operator=(const VECTOR3D& vector) @@ -1134,23 +1155,23 @@ struct VECTOR3D /// @brief Vector subtraction assignment operator VECTOR3D& operator-=(const VECTOR3D& vector); /// @brief Vector addition operator - VECTOR3D operator+ (const VECTOR3D& vector) const; + VECTOR3D operator+(const VECTOR3D& vector) const; /// @brief Vector subtraction operator - VECTOR3D operator- (const VECTOR3D& vector) const; + VECTOR3D operator-(const VECTOR3D& vector) const; /// @brief Scalar multiplication assignment operator VECTOR3D& operator*=(float scale); /// @brief Scalar multiplication operator - VECTOR3D operator* (float scale) const; + VECTOR3D operator*(float scale) const; /// @brief Vector dot product operator - float operator* (const VECTOR3D& vector) const; + float operator*(const VECTOR3D& vector) const; /// @brief Vector cross product operator - VECTOR3D operator& (const VECTOR3D& vector) const; + VECTOR3D operator&(const VECTOR3D& vector) const; /// @brief Vector cross product assignment operator VECTOR3D& operator&=(const VECTOR3D& vector); - + /// @brief Get vector magnitude /// @return Vector magnitude - float GetModule() const; + float GetModule() const; /// @brief Get squared vector magnitude /// @return Squared vector magnitude @@ -1188,8 +1209,8 @@ struct VECTOR3D /// @param e End vector /// @param s Start vector (default to positive z-axis) /// @return Vector reference - VECTOR3D& Rotate (const VECTOR3D& e, const VECTOR3D& s = VECTOR3D(0.0f, 0.0f, 1.0f)); - + VECTOR3D& Rotate(const VECTOR3D& e, const VECTOR3D& s = VECTOR3D(0.0f, 0.0f, 1.0f)); + /// @brief Calculate angle between two vectors /// @param e First vector /// @param s Second vector (default to positive z-axis) @@ -1200,13 +1221,13 @@ struct VECTOR3D /// @brief Image object forward declaration class IMAGE; /// @brief Image object pointer type -typedef IMAGE *PIMAGE; +typedef IMAGE* PIMAGE; /// @brief Constant image object pointer type -typedef const IMAGE *PCIMAGE; +typedef const IMAGE* PCIMAGE; /** * @brief Set code page - * + * * Set character encoding, affects text processing and display * @param codepage Code page, should use EGE_CODEPAGE_XXX constants, default is EGE_CODEPAGE_ANSI */ @@ -1214,14 +1235,14 @@ void EGEAPI setcodepage(unsigned int codepage); /** * @brief Get current code page - * + * * @return Currently set code page */ unsigned int EGEAPI getcodepage(); /** * @brief Set whether to enable Unicode character messages - * + * * Control whether getkey() function uses UTF-16 encoded character messages * @param enable true enables UTF-16, false uses ANSI */ @@ -1229,20 +1250,21 @@ void EGEAPI setunicodecharmessage(bool enable); /** * @brief Get Unicode character message setting status - * + * * @return true indicates UTF-16 is enabled, false indicates ANSI is used */ bool EGEAPI getunicodecharmessage(); /** * @brief Set initialization mode - * + * * Set default parameters when creating windows * @param mode Initialization mode flags * @param x Initial window x coordinate (default CW_USEDEFAULT) * @param y Initial window y coordinate (default CW_USEDEFAULT) */ void EGEAPI setinitmode(initmode_flag mode, int x = CW_USEDEFAULT, int y = CW_USEDEFAULT); + inline void setinitmode(int mode, int x = CW_USEDEFAULT, int y = CW_USEDEFAULT) { setinitmode(static_cast(mode), x, y); @@ -1250,29 +1272,31 @@ inline void setinitmode(int mode, int x = CW_USEDEFAULT, int y = CW_USEDEFAULT) /** * @brief Get current initialization mode - * + * * @return Currently set initialization mode flags */ -initmode_flag EGEAPI getinitmode(); +initmode_flag EGEAPI getinitmode(); /** * @brief Create EGE graphics window and perform environment initialization - * - * This is the main initialization function of the EGE graphics library, creates and displays graphics window after execution - * + * + * This is the main initialization function of the EGE graphics library, creates and displays graphics window after + * execution + * * @param width Window width (pixels) * @param height Window height (pixels) * @param mode Initialization mode flags, controls various window attributes - * + * * @code * // Create an 800x600 default window * initgraph(800, 600, INIT_DEFAULT); - * + * * // Create a borderless topmost window * initgraph(640, 480, INIT_NOBORDER | INIT_TOPMOST); * @endcode */ void EGEAPI initgraph(int width, int height, initmode_flag mode); + inline void initgraph(int width, int height, int mode) { initgraph(width, height, static_cast(mode)); @@ -1280,10 +1304,10 @@ inline void initgraph(int width, int height, int mode) /** * @brief Create EGE graphics window (simplified version) - * + * * Create graphics window using currently set initialization mode * Uses default mode in debug version, shows EGE logo in release version - * + * * @param width Window width (pixels) * @param height Window height (pixels) */ @@ -1298,27 +1322,27 @@ inline void EGEAPI initgraph(int width, int height) /** * @brief Initialize graphics system (BGI compatible version) - * + * * Provides compatible interface with traditional BGI graphics library - * + * * @param graphdriver Graphics driver type pointer, usually pass DETECT for auto-detection * @param graphmode Graphics mode pointer, usually pass 0 for auto-selection * @param pathtodriver BGI driver file path, can pass empty string "" if driver file is in current directory */ -void initgraph(int *graphdriver, int *graphmode, const char *pathtodriver); +void initgraph(int* graphdriver, int* graphmode, const char* pathtodriver); /** * @brief Close graphics system - * + * * Logically close graphics system - * After execution, EGE window will be hidden, but resources won't be fully released, is_run() function still returns true (note this) - * If IMAGE object resources need to be released, delimage function still needs to be called + * After execution, EGE window will be hidden, but resources won't be fully released, is_run() function still returns + * true (note this) If IMAGE object resources need to be released, delimage function still needs to be called */ void EGEAPI closegraph(); /** * @brief Check if graphics environment is running - * + * * @return true When EGE graphics environment exists and window is not closed * @return false When EGE graphics environment doesn't exist or user clicks close button */ @@ -1347,7 +1371,7 @@ void EGEAPI seticon(int icon_id); * @param hWnd Window handle to attach to * @return Operation result code */ -int EGEAPI attachHWND(HWND hWnd); +int EGEAPI attachHWND(HWND hWnd); /** * @brief Show window @@ -1389,14 +1413,14 @@ void EGEAPI setrendermode(rendermode_e mode); * @brief Get current drawing target * @return Current drawing target image pointer, NULL means screen */ -PIMAGE gettarget(); +PIMAGE gettarget(); /** * @brief Set drawing target * @param pbuf Target image pointer, NULL means screen * @return Setting result code */ -int settarget(PIMAGE pbuf); +int settarget(PIMAGE pbuf); /** * @brief Clear device (clear screen) @@ -1424,7 +1448,7 @@ void EGEAPI getviewport(int* left, int* top, int* right, int* bottom, int* clip * @param clip Whether to enable clipping (default 1) * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI setviewport(int left, int top, int right, int bottom, int clip = 1, PIMAGE pimg = NULL); +void EGEAPI setviewport(int left, int top, int right, int bottom, int clip = 1, PIMAGE pimg = NULL); /** * @brief Clear viewport area @@ -1459,7 +1483,7 @@ void EGEAPI swappage(); * @brief Get window viewport settings * @param viewport Viewport structure pointer */ -void EGEAPI window_getviewport(viewporttype * viewport); +void EGEAPI window_getviewport(viewporttype* viewport); /** * @brief Get window viewport settings @@ -1477,7 +1501,7 @@ void EGEAPI window_getviewport(int* left, int* top, int* right, int* bottom); * @param right Right boundary * @param bottom Bottom boundary */ -void EGEAPI window_setviewport(int left, int top, int right, int bottom); +void EGEAPI window_setviewport(int left, int top, int right, int bottom); /** * @brief Set line width @@ -1502,7 +1526,7 @@ void EGEAPI getlinestyle(int* linestyle, unsigned short* pattern = NULL, int* th * @param thickness Line thickness (default 1) * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI setlinestyle(int linestyle, unsigned short pattern = 0, int thickness = 1, PIMAGE pimg = NULL); +void EGEAPI setlinestyle(int linestyle, unsigned short pattern = 0, int thickness = 1, PIMAGE pimg = NULL); /** * @brief Set line cap style @@ -1517,7 +1541,7 @@ void EGEAPI setlinecap(line_cap_type linecap, PIMAGE pimg = NULL); * @param endCap End cap style * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI setlinecap(line_cap_type startCap, line_cap_type endCap, PIMAGE pimg = NULL); +void EGEAPI setlinecap(line_cap_type startCap, line_cap_type endCap, PIMAGE pimg = NULL); /** * @brief Get line cap style @@ -1539,7 +1563,7 @@ line_cap_type EGEAPI getlinecap(PCIMAGE pimg = NULL); * @param linejoin Join style * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI setlinejoin(line_join_type linejoin, PIMAGE pimg = NULL); +void EGEAPI setlinejoin(line_join_type linejoin, PIMAGE pimg = NULL); /** * @brief Set line join style (with miter limit) @@ -1547,7 +1571,7 @@ void EGEAPI setlinejoin(line_join_type linejoin, PIMAGE pimg = NULL); * @param miterLimit Miter limit value * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI setlinejoin(line_join_type linejoin, float miterLimit, PIMAGE pimg = NULL); +void EGEAPI setlinejoin(line_join_type linejoin, float miterLimit, PIMAGE pimg = NULL); /** * @brief Get line join style @@ -1584,99 +1608,99 @@ void EGEAPI setwritemode(int mode, PIMAGE pimg = NULL); * @param pimg Target image pointer, NULL means current ege window * @return Current drawing color */ -color_t EGEAPI getcolor (PCIMAGE pimg = NULL); +color_t EGEAPI getcolor(PCIMAGE pimg = NULL); /** * @brief Get line color * @param pimg Target image pointer, NULL means current ege window * @return Current line color */ -color_t EGEAPI getlinecolor (PCIMAGE pimg = NULL); +color_t EGEAPI getlinecolor(PCIMAGE pimg = NULL); /** * @brief Get fill color * @param pimg Target image pointer, NULL means current ege window * @return Current fill color */ -color_t EGEAPI getfillcolor (PCIMAGE pimg = NULL); +color_t EGEAPI getfillcolor(PCIMAGE pimg = NULL); /** * @brief Get background color * @param pimg Target image pointer, NULL means current ege window * @return Current background color */ -color_t EGEAPI getbkcolor (PCIMAGE pimg = NULL); +color_t EGEAPI getbkcolor(PCIMAGE pimg = NULL); /** * @brief Get text color * @param pimg Target image pointer, NULL means current ege window * @return Current text color */ -color_t EGEAPI gettextcolor (PCIMAGE pimg = NULL); +color_t EGEAPI gettextcolor(PCIMAGE pimg = NULL); /** * @brief Set drawing color * @param color Drawing color * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI setcolor (color_t color, PIMAGE pimg = NULL); +void EGEAPI setcolor(color_t color, PIMAGE pimg = NULL); /** * @brief Set line color * @param color Line color * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI setlinecolor (color_t color, PIMAGE pimg = NULL); +void EGEAPI setlinecolor(color_t color, PIMAGE pimg = NULL); /** * @brief Set fill color * @param color Fill color * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI setfillcolor (color_t color, PIMAGE pimg = NULL); +void EGEAPI setfillcolor(color_t color, PIMAGE pimg = NULL); /** * @brief Set background color, will actively replace old background color pixels with new background color pixels * @param color Background color * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI setbkcolor (color_t color, PIMAGE pimg = NULL); +void EGEAPI setbkcolor(color_t color, PIMAGE pimg = NULL); /** * @brief Set background color, but will not replace old background color pixels with new background color pixels * @param color Background color * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI setbkcolor_f (color_t color, PIMAGE pimg = NULL); +void EGEAPI setbkcolor_f(color_t color, PIMAGE pimg = NULL); /** * @brief Set text color * @param color Text color * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI settextcolor (color_t color, PIMAGE pimg = NULL); +void EGEAPI settextcolor(color_t color, PIMAGE pimg = NULL); /** * @brief Set font background color * @param color Font background color * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI setfontbkcolor(color_t color, PIMAGE pimg = NULL); +void EGEAPI setfontbkcolor(color_t color, PIMAGE pimg = NULL); /** * @brief Set background blend mode * @param bkMode Background mode (TRANSPARENT or OPAQUE) * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI setbkmode(int bkMode, PIMAGE pimg = NULL); +void EGEAPI setbkmode(int bkMode, PIMAGE pimg = NULL); /// @defgroup ColorConversion Color conversion macro definitions /// @{ -#define RGBtoGRAY rgb2gray ///< RGB to grayscale -#define RGBtoHSL rgb2hsl ///< RGB to HSL -#define RGBtoHSV rgb2hsv ///< RGB to HSV -#define HSLtoRGB hsl2rgb ///< HSL to RGB -#define HSVtoRGB hsv2rgb ///< HSV to RGB +#define RGBtoGRAY rgb2gray ///< RGB to grayscale +#define RGBtoHSL rgb2hsl ///< RGB to HSL +#define RGBtoHSV rgb2hsv ///< RGB to HSV +#define HSLtoRGB hsl2rgb ///< HSL to RGB +#define HSVtoRGB hsv2rgb ///< HSV to RGB /// @} /** @@ -1693,7 +1717,7 @@ color_t EGEAPI rgb2gray(color_t rgb); * @param S Saturation output pointer (0-1) * @param L Lightness output pointer (0-1) */ -void EGEAPI rgb2hsl(color_t rgb, float* H, float* S, float* L); +void EGEAPI rgb2hsl(color_t rgb, float* H, float* S, float* L); /** * @brief RGB color to HSV conversion @@ -1702,7 +1726,7 @@ void EGEAPI rgb2hsl(color_t rgb, float* H, float* S, float* L); * @param S Saturation output pointer (0-1) * @param V Value output pointer (0-1) */ -void EGEAPI rgb2hsv(color_t rgb, float* H, float* S, float* V); +void EGEAPI rgb2hsv(color_t rgb, float* H, float* S, float* V); /** * @brief HSL color to RGB conversion @@ -1729,7 +1753,7 @@ color_t EGEAPI hsv2rgb(float H, float S, float V); * @param alpha Alpha transparency (0-255) * @return Blended color */ -color_t EGEAPI colorblend (color_t dst, color_t src, unsigned char alpha); +color_t EGEAPI colorblend(color_t dst, color_t src, unsigned char alpha); /** * @brief Color blending (fast version, lower precision) @@ -1746,7 +1770,7 @@ color_t EGEAPI colorblend_f(color_t dst, color_t src, unsigned char alpha); * @param src Source color (including alpha channel) * @return Blended color */ -color_t EGEAPI alphablend (color_t dst, color_t src); +color_t EGEAPI alphablend(color_t dst, color_t src); /** * @brief Alpha blending (with transparency factor) @@ -1755,7 +1779,7 @@ color_t EGEAPI alphablend (color_t dst, color_t src); * @param srcAlphaFactor Source color transparency factor (0-255) * @return Blended color */ -color_t EGEAPI alphablend (color_t dst, color_t src, unsigned char srcAlphaFactor); +color_t EGEAPI alphablend(color_t dst, color_t src, unsigned char srcAlphaFactor); /** * @brief Alpha blending (premultiplied alpha) @@ -1781,7 +1805,7 @@ color_t EGEAPI alphablend_premultiplied(color_t dst, color_t src, unsigned char * @param pimg Target image pointer, NULL means current ege window * @return Pixel color value */ -color_t EGEAPI getpixel (int x, int y, PCIMAGE pimg = NULL); +color_t EGEAPI getpixel(int x, int y, PCIMAGE pimg = NULL); /** * @brief Set pixel color @@ -1790,7 +1814,7 @@ color_t EGEAPI getpixel (int x, int y, PCIMAGE pimg = NULL); * @param color Color value * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI putpixel (int x, int y, color_t color, PIMAGE pimg = NULL); +void EGEAPI putpixel(int x, int y, color_t color, PIMAGE pimg = NULL); /** * @brief Get pixel color (fast version, no boundary check, ignores viewport) @@ -1799,7 +1823,7 @@ void EGEAPI putpixel (int x, int y, color_t color, PIMAGE pimg = NULL); * @param pimg Target image pointer, NULL means current ege window * @return Pixel color value */ -color_t EGEAPI getpixel_f (int x, int y, PCIMAGE pimg = NULL); +color_t EGEAPI getpixel_f(int x, int y, PCIMAGE pimg = NULL); /** * @brief Set pixel color (fast version, no boundary check, ignores viewport) @@ -1808,7 +1832,7 @@ color_t EGEAPI getpixel_f (int x, int y, PCIMAGE pimg = NULL); * @param color Color value * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI putpixel_f (int x, int y, color_t color, PIMAGE pimg = NULL); +void EGEAPI putpixel_f(int x, int y, color_t color, PIMAGE pimg = NULL); /** * @brief Set multiple pixels in batch @@ -1816,7 +1840,7 @@ void EGEAPI putpixel_f (int x, int y, color_t color, PIMAGE pimg = NULL); * @param points Point coordinate array, format: [x1,y1,x2,y2,...] * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI putpixels (int numOfPoints, const int* points, PIMAGE pimg = NULL); +void EGEAPI putpixels(int numOfPoints, const int* points, PIMAGE pimg = NULL); /** * @brief Set multiple pixels in batch (fast version, no boundary check) @@ -1824,7 +1848,7 @@ void EGEAPI putpixels (int numOfPoints, const int* points, PIMAGE pimg = NUL * @param points Point coordinate array, format: [x1,y1,x2,y2,...] * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI putpixels_f(int numOfPoints, const int* points, PIMAGE pimg = NULL); +void EGEAPI putpixels_f(int numOfPoints, const int* points, PIMAGE pimg = NULL); /** * @brief Set pixel (RGB channels are set to the result of blending with ARGB color, alpha channel remains unchanged) @@ -1833,7 +1857,7 @@ void EGEAPI putpixels_f(int numOfPoints, const int* points, PIMAGE pimg = NUL * @param color Color value (including alpha channel) * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI putpixel_withalpha (int x, int y, color_t color, PIMAGE pimg = NULL); +void EGEAPI putpixel_withalpha(int x, int y, color_t color, PIMAGE pimg = NULL); /** * @brief Set pixel (preserve alpha channel, fast version, no boundary check) @@ -1842,7 +1866,7 @@ void EGEAPI putpixel_withalpha (int x, int y, color_t color, PIMAGE pimg = * @param color Color value (including alpha channel) * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI putpixel_withalpha_f (int x, int y, color_t color, PIMAGE pimg = NULL); +void EGEAPI putpixel_withalpha_f(int x, int y, color_t color, PIMAGE pimg = NULL); /** * @brief Set pixel (RGB channels are replaced with specified color value, alpha channel remains unchanged) @@ -1851,7 +1875,7 @@ void EGEAPI putpixel_withalpha_f (int x, int y, color_t color, PIMAGE pimg = * @param color Color value * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI putpixel_savealpha (int x, int y, color_t color, PIMAGE pimg = NULL); +void EGEAPI putpixel_savealpha(int x, int y, color_t color, PIMAGE pimg = NULL); /** * @brief Set pixel (preserve alpha channel, fast version, no boundary check) @@ -1860,7 +1884,7 @@ void EGEAPI putpixel_savealpha (int x, int y, color_t color, PIMAGE pimg = * @param color Color value * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI putpixel_savealpha_f (int x, int y, color_t color, PIMAGE pimg = NULL); +void EGEAPI putpixel_savealpha_f(int x, int y, color_t color, PIMAGE pimg = NULL); /** * @brief Set pixel (alpha blending) @@ -1869,7 +1893,7 @@ void EGEAPI putpixel_savealpha_f (int x, int y, color_t color, PIMAGE pimg = * @param color Color value * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI putpixel_alphablend (int x, int y, color_t color, PIMAGE pimg = NULL); +void EGEAPI putpixel_alphablend(int x, int y, color_t color, PIMAGE pimg = NULL); /** * @brief Set pixel (alpha blending, fast version, no boundary check) @@ -1878,7 +1902,7 @@ void EGEAPI putpixel_alphablend (int x, int y, color_t color, PIMAGE pimg = * @param color Color value * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI putpixel_alphablend_f(int x, int y, color_t color, PIMAGE pimg = NULL); +void EGEAPI putpixel_alphablend_f(int x, int y, color_t color, PIMAGE pimg = NULL); /** * @brief Set pixel (alpha blending with transparency factor) @@ -1888,7 +1912,7 @@ void EGEAPI putpixel_alphablend_f(int x, int y, color_t color, PIMAGE pimg = * @param alphaFactor Transparency factor (0-255) * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI putpixel_alphablend (int x, int y, color_t color, unsigned char alphaFactor, PIMAGE pimg = NULL); +void EGEAPI putpixel_alphablend(int x, int y, color_t color, unsigned char alphaFactor, PIMAGE pimg = NULL); /** * @brief Set pixel (alpha blending with transparency factor, fast version, no boundary check) @@ -1898,7 +1922,7 @@ void EGEAPI putpixel_alphablend (int x, int y, color_t color, unsigned char * @param alphaFactor Transparency factor (0-255) * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI putpixel_alphablend_f(int x, int y, color_t color, unsigned char alphaFactor, PIMAGE pimg = NULL); +void EGEAPI putpixel_alphablend_f(int x, int y, color_t color, unsigned char alphaFactor, PIMAGE pimg = NULL); /** * @brief Move current drawing position @@ -1906,7 +1930,7 @@ void EGEAPI putpixel_alphablend_f(int x, int y, color_t color, unsigned char * @param y New y coordinate * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI moveto (int x, int y, PIMAGE pimg = NULL); +void EGEAPI moveto(int x, int y, PIMAGE pimg = NULL); /** * @brief Move current drawing position relatively @@ -1914,7 +1938,7 @@ void EGEAPI moveto (int x, int y, PIMAGE pimg = NULL); * @param dy Y direction offset * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI moverel(int dx, int dy, PIMAGE pimg = NULL); +void EGEAPI moverel(int dx, int dy, PIMAGE pimg = NULL); /** * @brief Draw line @@ -1924,7 +1948,7 @@ void EGEAPI moverel(int dx, int dy, PIMAGE pimg = NULL); * @param y2 End point y coordinate * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI line (int x1, int y1, int x2, int y2, PIMAGE pimg = NULL); +void EGEAPI line(int x1, int y1, int x2, int y2, PIMAGE pimg = NULL); /** * @brief Draw line (floating point version) @@ -1934,7 +1958,7 @@ void EGEAPI line (int x1, int y1, int x2, int y2, PIMAGE pimg = N * @param y2 End point y coordinate * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI line_f (float x1, float y1, float x2, float y2, PIMAGE pimg = NULL); +void EGEAPI line_f(float x1, float y1, float x2, float y2, PIMAGE pimg = NULL); /** * @brief Draw line from current position to specified point @@ -1942,7 +1966,7 @@ void EGEAPI line_f (float x1, float y1, float x2, float y2, PIMAGE pimg = N * @param y End point y coordinate * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI lineto (int x, int y, PIMAGE pimg = NULL); +void EGEAPI lineto(int x, int y, PIMAGE pimg = NULL); /** * @brief Draw line from current position to specified point (floating point version) @@ -1950,7 +1974,7 @@ void EGEAPI lineto (int x, int y, PIMAGE pimg = NULL); * @param y End point y coordinate * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI lineto_f (float x, float y, PIMAGE pimg = NULL); +void EGEAPI lineto_f(float x, float y, PIMAGE pimg = NULL); /** * @brief Draw relative line from current position @@ -1958,7 +1982,7 @@ void EGEAPI lineto_f (float x, float y, PIMAGE pimg = NULL); * @param dy Y direction offset * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI linerel (int dx, int dy, PIMAGE pimg = NULL); +void EGEAPI linerel(int dx, int dy, PIMAGE pimg = NULL); /** * @brief Draw relative line from current position (floating point version) @@ -1966,9 +1990,10 @@ void EGEAPI linerel (int dx, int dy, PIMAGE pimg = NULL); * @param dy Y direction offset * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI linerel_f(float dx, float dy, PIMAGE pimg = NULL); +void EGEAPI linerel_f(float dx, float dy, PIMAGE pimg = NULL); -//void EGEAPI getarccoords(int *px, int *py, int *pxstart, int *pystart, int *pxend, int *pyend, PIMAGE pimg = NULL); // ### +// void EGEAPI getarccoords(int *px, int *py, int *pxstart, int *pystart, int *pxend, int *pyend, PIMAGE pimg = NULL); +// // ### /** * @brief Draw elliptical arc @@ -1980,7 +2005,7 @@ void EGEAPI linerel_f(float dx, float dy, PIMAGE pimg = NULL); * @param yRadius Y-axis radius * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI ellipse (int x, int y, int startAngle, int endAngle, int xRadius, int yRadius, PIMAGE pimg = NULL); +void EGEAPI ellipse(int x, int y, int startAngle, int endAngle, int xRadius, int yRadius, PIMAGE pimg = NULL); /** * @brief Draw elliptical arc (floating point version) @@ -1992,7 +2017,8 @@ void EGEAPI ellipse (int x, int y, int startAngle, int endAngle, in * @param yRadius Y-axis radius * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI ellipsef (float x, float y, float startAngle, float endAngle, float xRadius, float yRadius, PIMAGE pimg = NULL); +void EGEAPI ellipsef( + float x, float y, float startAngle, float endAngle, float xRadius, float yRadius, PIMAGE pimg = NULL); /** * @brief Draw sector (outline only) @@ -2004,7 +2030,7 @@ void EGEAPI ellipsef (float x, float y, float startAngle, float endAngle, fl * @param yRadius Y-axis radius * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI sector (int x, int y, int startAngle, int endAngle, int xRadius, int yRadius, PIMAGE pimg = NULL); +void EGEAPI sector(int x, int y, int startAngle, int endAngle, int xRadius, int yRadius, PIMAGE pimg = NULL); /** * @brief Draw sector (outline only, floating point version) @@ -2016,7 +2042,8 @@ void EGEAPI sector (int x, int y, int startAngle, int endAngle, in * @param yRadius Y-axis radius * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI sectorf (float x, float y, float startAngle, float endAngle, float xRadius, float yRadius, PIMAGE pimg = NULL); +void EGEAPI sectorf( + float x, float y, float startAngle, float endAngle, float xRadius, float yRadius, PIMAGE pimg = NULL); /** * @brief Draw pie chart (outline only) @@ -2028,7 +2055,7 @@ void EGEAPI sectorf (float x, float y, float startAngle, float endAngle, fl * @param yRadius Y-axis radius * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI pie (int x, int y, int startAngle, int endAngle, int xRadius, int yRadius, PIMAGE pimg = NULL); +void EGEAPI pie(int x, int y, int startAngle, int endAngle, int xRadius, int yRadius, PIMAGE pimg = NULL); /** * @brief Draw pie chart (outline only, floating point version) @@ -2040,7 +2067,7 @@ void EGEAPI pie (int x, int y, int startAngle, int endAngle, in * @param yRadius Y-axis radius * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI pief (float x, float y, float startAngle, float endAngle, float xRadius, float yRadius, PIMAGE pimg = NULL); +void EGEAPI pief(float x, float y, float startAngle, float endAngle, float xRadius, float yRadius, PIMAGE pimg = NULL); /** * @brief Draw filled pie chart @@ -2052,7 +2079,7 @@ void EGEAPI pief (float x, float y, float startAngle, float endAngle, fl * @param yRadius Y-axis radius * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI fillpie (int x, int y, int startAngle, int endAngle, int xRadius, int yRadius, PIMAGE pimg = NULL); +void EGEAPI fillpie(int x, int y, int startAngle, int endAngle, int xRadius, int yRadius, PIMAGE pimg = NULL); /** * @brief Draw filled pie chart (floating point version) @@ -2064,7 +2091,8 @@ void EGEAPI fillpie (int x, int y, int startAngle, int endAngle, in * @param yRadius Y-axis radius * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI fillpief (float x, float y, float startAngle, float endAngle, float xRadius, float yRadius, PIMAGE pimg = NULL); +void EGEAPI fillpief( + float x, float y, float startAngle, float endAngle, float xRadius, float yRadius, PIMAGE pimg = NULL); /** * @brief Draw solid pie chart @@ -2076,7 +2104,7 @@ void EGEAPI fillpief (float x, float y, float startAngle, float endAngle, fl * @param yRadius Y-axis radius * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI solidpie (int x, int y, int startAngle, int endAngle, int xRadius, int yRadius, PIMAGE pimg = NULL); +void EGEAPI solidpie(int x, int y, int startAngle, int endAngle, int xRadius, int yRadius, PIMAGE pimg = NULL); /** * @brief Draw solid pie chart (floating point version) @@ -2088,7 +2116,8 @@ void EGEAPI solidpie (int x, int y, int startAngle, int endAngle, in * @param yRadius Y-axis radius * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI solidpief (float x, float y, float startAngle, float endAngle, float xRadius, float yRadius, PIMAGE pimg = NULL); +void EGEAPI solidpief( + float x, float y, float startAngle, float endAngle, float xRadius, float yRadius, PIMAGE pimg = NULL); /** * @brief Draw circular arc @@ -2099,7 +2128,7 @@ void EGEAPI solidpief (float x, float y, float startAngle, float endAngle, fl * @param radius Radius * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI arc (int x, int y, int startAngle, int endAngle, int radius, PIMAGE pimg = NULL); +void EGEAPI arc(int x, int y, int startAngle, int endAngle, int radius, PIMAGE pimg = NULL); /** * @brief Draw circular arc (floating point version) @@ -2110,7 +2139,7 @@ void EGEAPI arc (int x, int y, int startAngle, int endAngle, in * @param radius Radius * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI arcf (float x, float y, float startAngle, float endAngle, float radius, PIMAGE pimg = NULL); +void EGEAPI arcf(float x, float y, float startAngle, float endAngle, float radius, PIMAGE pimg = NULL); /** * @brief Draw circular sector @@ -2121,7 +2150,7 @@ void EGEAPI arcf (float x, float y, float startAngle, float endAngle, fl * @param radius Radius * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI pieslice (int x, int y, int startAngle, int endAngle, int radius, PIMAGE pimg = NULL); +void EGEAPI pieslice(int x, int y, int startAngle, int endAngle, int radius, PIMAGE pimg = NULL); /** * @brief Draw circular sector (floating point version) @@ -2132,7 +2161,7 @@ void EGEAPI pieslice (int x, int y, int startAngle, int endAngle, in * @param radius Radius * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI pieslicef (float x, float y, float startAngle, float endAngle, float radius, PIMAGE pimg = NULL); +void EGEAPI pieslicef(float x, float y, float startAngle, float endAngle, float radius, PIMAGE pimg = NULL); /** * @brief Draw filled ellipse @@ -2142,7 +2171,7 @@ void EGEAPI pieslicef (float x, float y, float startAngle, float endAngle, fl * @param yRadius Y-axis radius * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI fillellipse (int x, int y, int xRadius, int yRadius, PIMAGE pimg = NULL); +void EGEAPI fillellipse(int x, int y, int xRadius, int yRadius, PIMAGE pimg = NULL); /** * @brief Draw filled ellipse (floating point version) @@ -2152,7 +2181,7 @@ void EGEAPI fillellipse (int x, int y, int xRadius, int yRadius, PI * @param yRadius Y-axis radius * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI fillellipsef (float x, float y, float xRadius, float yRadius, PIMAGE pimg = NULL); +void EGEAPI fillellipsef(float x, float y, float xRadius, float yRadius, PIMAGE pimg = NULL); /** * @brief Draw solid ellipse @@ -2162,7 +2191,7 @@ void EGEAPI fillellipsef (float x, float y, float xRadius, float yRadius, PI * @param yRadius Y-axis radius * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI solidellipse (int x, int y, int xRadius, int yRadius, PIMAGE pimg = NULL); +void EGEAPI solidellipse(int x, int y, int xRadius, int yRadius, PIMAGE pimg = NULL); /** * @brief Draw solid ellipse (floating point version) @@ -2172,7 +2201,7 @@ void EGEAPI solidellipse (int x, int y, int xRadius, int yRadius, PI * @param yRadius Y-axis radius * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI solidellipsef(float x, float y, float xRadius, float yRadius, PIMAGE pimg = NULL); +void EGEAPI solidellipsef(float x, float y, float xRadius, float yRadius, PIMAGE pimg = NULL); /** * @brief Draw circle outline @@ -2181,7 +2210,7 @@ void EGEAPI solidellipsef(float x, float y, float xRadius, float yRadius, PI * @param radius Radius * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI circle (int x, int y, int radius, PIMAGE pimg = NULL); +void EGEAPI circle(int x, int y, int radius, PIMAGE pimg = NULL); /** * @brief Draw circle outline (floating point version) @@ -2190,7 +2219,7 @@ void EGEAPI circle (int x, int y, int radius, PIMAGE pimg = NULL); * @param radius Radius * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI circlef (float x, float y, float radius, PIMAGE pimg = NULL); +void EGEAPI circlef(float x, float y, float radius, PIMAGE pimg = NULL); /** * @brief Draw filled circle @@ -2199,7 +2228,7 @@ void EGEAPI circlef (float x, float y, float radius, PIMAGE pimg = NULL); * @param radius Radius * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI fillcircle (int x, int y, int radius, PIMAGE pimg = NULL); +void EGEAPI fillcircle(int x, int y, int radius, PIMAGE pimg = NULL); /** * @brief Draw filled circle (floating point version) @@ -2208,7 +2237,7 @@ void EGEAPI fillcircle (int x, int y, int radius, PIMAGE pimg = NULL); * @param radius Radius * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI fillcirclef (float x, float y, float radius, PIMAGE pimg = NULL); +void EGEAPI fillcirclef(float x, float y, float radius, PIMAGE pimg = NULL); /** * @brief Draw solid circle @@ -2217,7 +2246,7 @@ void EGEAPI fillcirclef (float x, float y, float radius, PIMAGE pimg = NULL); * @param radius Radius * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI solidcircle (int x, int y, int radius, PIMAGE pimg = NULL); +void EGEAPI solidcircle(int x, int y, int radius, PIMAGE pimg = NULL); /** * @brief Draw solid circle (floating point version) @@ -2226,7 +2255,7 @@ void EGEAPI solidcircle (int x, int y, int radius, PIMAGE pimg = NULL); * @param radius Radius * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI solidcirclef (float x, float y, float radius, PIMAGE pimg = NULL); +void EGEAPI solidcirclef(float x, float y, float radius, PIMAGE pimg = NULL); /** * @brief Draw 3D bar @@ -2238,7 +2267,7 @@ void EGEAPI solidcirclef (float x, float y, float radius, PIMAGE pimg = NULL); * @param topFlag Whether to draw top face * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI bar3d (int left, int top, int right, int bottom, int depth, int topFlag, PIMAGE pimg = NULL); +void EGEAPI bar3d(int left, int top, int right, int bottom, int depth, int topFlag, PIMAGE pimg = NULL); /** * @brief Draw bar (filled rectangle) @@ -2248,7 +2277,7 @@ void EGEAPI bar3d (int left, int top, int right, int bottom, int depth, * @param bottom Bottom boundary * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI bar (int left, int top, int right, int bottom, PIMAGE pimg = NULL); +void EGEAPI bar(int left, int top, int right, int bottom, PIMAGE pimg = NULL); /** * @brief Draw rectangle outline @@ -2258,7 +2287,7 @@ void EGEAPI bar (int left, int top, int right, int bottom, PIMAGE pimg * @param bottom Bottom boundary * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI rectangle (int left, int top, int right, int bottom, PIMAGE pimg = NULL); +void EGEAPI rectangle(int left, int top, int right, int bottom, PIMAGE pimg = NULL); /** * @brief Draw filled rectangle @@ -2268,7 +2297,7 @@ void EGEAPI rectangle (int left, int top, int right, int bottom, PIMAGE pimg * @param bottom Bottom boundary * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI fillrect (int left, int top, int right, int bottom, PIMAGE pimg = NULL); +void EGEAPI fillrect(int left, int top, int right, int bottom, PIMAGE pimg = NULL); /** * @brief Draw solid rectangle @@ -2278,7 +2307,7 @@ void EGEAPI fillrect (int left, int top, int right, int bottom, PIMAGE pimg * @param bottom Bottom boundary * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI solidrect (int left, int top, int right, int bottom, PIMAGE pimg = NULL); +void EGEAPI solidrect(int left, int top, int right, int bottom, PIMAGE pimg = NULL); /** * @brief Draw rounded rectangle outline @@ -2289,7 +2318,7 @@ void EGEAPI solidrect (int left, int top, int right, int bottom, PIMAGE pimg * @param radius Corner radius * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI roundrect (int left, int top, int right, int bottom, int radius, PIMAGE pimg = NULL); +void EGEAPI roundrect(int left, int top, int right, int bottom, int radius, PIMAGE pimg = NULL); /** * @brief Draw filled rounded rectangle @@ -2300,7 +2329,7 @@ void EGEAPI roundrect (int left, int top, int right, int bottom, int radius, * @param radius Corner radius * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI fillroundrect (int left, int top, int right, int bottom, int radius, PIMAGE pimg = NULL); +void EGEAPI fillroundrect(int left, int top, int right, int bottom, int radius, PIMAGE pimg = NULL); /** * @brief Draw solid rounded rectangle @@ -2311,7 +2340,7 @@ void EGEAPI fillroundrect (int left, int top, int right, int bottom, int radius, * @param radius Corner radius * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI solidroundrect(int left, int top, int right, int bottom, int radius, PIMAGE pimg = NULL); +void EGEAPI solidroundrect(int left, int top, int right, int bottom, int radius, PIMAGE pimg = NULL); /** * @brief Draw rounded rectangle outline (different corner radii) @@ -2323,7 +2352,7 @@ void EGEAPI solidroundrect(int left, int top, int right, int bottom, int radius, * @param yRadius Y-axis corner radius * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI roundrect (int left, int top, int right, int bottom, int xRadius, int yRadius, PIMAGE pimg = NULL); +void EGEAPI roundrect(int left, int top, int right, int bottom, int xRadius, int yRadius, PIMAGE pimg = NULL); /** * @brief Draw filled rounded rectangle (different corner radii) @@ -2335,7 +2364,7 @@ void EGEAPI roundrect (int left, int top, int right, int bottom, int xRadius * @param yRadius Y-axis corner radius * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI fillroundrect (int left, int top, int right, int bottom, int xRadius, int yRadius, PIMAGE pimg = NULL); +void EGEAPI fillroundrect(int left, int top, int right, int bottom, int xRadius, int yRadius, PIMAGE pimg = NULL); /** * @brief Draw solid rounded rectangle (different corner radii) @@ -2355,7 +2384,7 @@ void EGEAPI solidroundrect(int left, int top, int right, int bottom, int xRadius * @param points Point coordinate array, format: [x1,y1,x2,y2,...] * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI drawpoly (int numOfPoints, const int *points, PIMAGE pimg = NULL); +void EGEAPI drawpoly(int numOfPoints, const int* points, PIMAGE pimg = NULL); /** * @brief Draw multiple line segments @@ -2363,7 +2392,7 @@ void EGEAPI drawpoly (int numOfPoints, const int *points, PIMAGE pimg = NUL * @param points Point coordinate array, format: [x1,y1,x2,y2,...] * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI polyline (int numOfPoints, const int *points, PIMAGE pimg = NULL); +void EGEAPI polyline(int numOfPoints, const int* points, PIMAGE pimg = NULL); /** * @brief Draw polygon outline @@ -2371,7 +2400,7 @@ void EGEAPI polyline (int numOfPoints, const int *points, PIMAGE pimg = NUL * @param points Point coordinate array, format: [x1,y1,x2,y2,...] * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI polygon (int numOfPoints, const int *points, PIMAGE pimg = NULL); +void EGEAPI polygon(int numOfPoints, const int* points, PIMAGE pimg = NULL); /** * @brief Draw filled polygon @@ -2379,7 +2408,7 @@ void EGEAPI polygon (int numOfPoints, const int *points, PIMAGE pimg = NUL * @param points Point coordinate array, format: [x1,y1,x2,y2,...] * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI fillpoly (int numOfPoints, const int *points, PIMAGE pimg = NULL); +void EGEAPI fillpoly(int numOfPoints, const int* points, PIMAGE pimg = NULL); /** * @brief Draw solid polygon @@ -2387,7 +2416,7 @@ void EGEAPI fillpoly (int numOfPoints, const int *points, PIMAGE pimg = NUL * @param points Point coordinate array, format: [x1,y1,x2,y2,...] * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI solidpoly (int numOfPoints, const int *points, PIMAGE pimg = NULL); +void EGEAPI solidpoly(int numOfPoints, const int* points, PIMAGE pimg = NULL); /** * @brief Draw gradient filled polygon @@ -2403,7 +2432,7 @@ void EGEAPI fillpoly_gradient(int numOfPoints, const ege_colpoint* points, PIMAG * @param points Line segment endpoint coordinate array, every two points form one line segment * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI drawlines (int numOfLines, const int *points, PIMAGE pimg = NULL); +void EGEAPI drawlines(int numOfLines, const int* points, PIMAGE pimg = NULL); /** * @brief Draw Bezier curve @@ -2411,7 +2440,7 @@ void EGEAPI drawlines (int numOfLines, const int *points, PIMAGE pimg = NUL * @param points Control point coordinate array, format: [x1,y1,x2,y2,...] * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI drawbezier (int numOfPoints, const int *points, PIMAGE pimg = NULL); +void EGEAPI drawbezier(int numOfPoints, const int* points, PIMAGE pimg = NULL); /** * @brief Flood fill (based on boundary color) @@ -2420,7 +2449,7 @@ void EGEAPI drawbezier (int numOfPoints, const int *points, PIMAGE pimg = NUL * @param borderColor Boundary color * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI floodfill (int x, int y, int borderColor, PIMAGE pimg = NULL); +void EGEAPI floodfill(int x, int y, int borderColor, PIMAGE pimg = NULL); /** * @brief Area fill (based on area color) @@ -2429,7 +2458,7 @@ void EGEAPI floodfill (int x, int y, int borderColor, PIMAGE pimg = NULL); * @param areaColor Area color to be replaced * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI floodfillsurface (int x, int y, color_t areaColor, PIMAGE pimg = NULL); +void EGEAPI floodfillsurface(int x, int y, color_t areaColor, PIMAGE pimg = NULL); #ifdef EGE_GDIPLUS /// @defgroup EGEGDIPlus EGE GDI+ enhanced functions @@ -2466,7 +2495,7 @@ void EGEAPI ege_line(float x1, float y1, float x2, float y2, PIMAGE pimg = NULL) * @param points Point coordinate array * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI ege_drawpoly (int numOfPoints, const ege_point* points, PIMAGE pimg = NULL); +void EGEAPI ege_drawpoly(int numOfPoints, const ege_point* points, PIMAGE pimg = NULL); /** * @brief Draw multiple line segments (GDI+ enhanced version) @@ -2474,7 +2503,7 @@ void EGEAPI ege_drawpoly (int numOfPoints, const ege_point* points, PIMAGE * @param points Point coordinate array * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI ege_polyline (int numOfPoints, const ege_point* points, PIMAGE pimg = NULL); +void EGEAPI ege_polyline(int numOfPoints, const ege_point* points, PIMAGE pimg = NULL); /** * @brief Draw polygon outline (GDI+ enhanced version) @@ -2482,7 +2511,7 @@ void EGEAPI ege_polyline (int numOfPoints, const ege_point* points, PIMAGE * @param points Point coordinate array * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI ege_polygon (int numOfPoints, const ege_point* points, PIMAGE pimg = NULL); +void EGEAPI ege_polygon(int numOfPoints, const ege_point* points, PIMAGE pimg = NULL); /** * @brief Draw filled polygon (GDI+ enhanced version) @@ -2490,7 +2519,7 @@ void EGEAPI ege_polygon (int numOfPoints, const ege_point* points, PIMAGE * @param points Point coordinate array * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI ege_fillpoly (int numOfPoints, const ege_point* points, PIMAGE pimg = NULL); +void EGEAPI ege_fillpoly(int numOfPoints, const ege_point* points, PIMAGE pimg = NULL); /** * @brief Draw Bezier curve (GDI+ enhanced version) @@ -2498,7 +2527,7 @@ void EGEAPI ege_fillpoly (int numOfPoints, const ege_point* points, PIMAGE * @param points Control point coordinate array * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI ege_bezier (int numOfPoints, const ege_point* points, PIMAGE pimg = NULL); +void EGEAPI ege_bezier(int numOfPoints, const ege_point* points, PIMAGE pimg = NULL); /** * @brief Draw Bezier curve (same as ege_bezier) @@ -2506,7 +2535,7 @@ void EGEAPI ege_bezier (int numOfPoints, const ege_point* points, PIMAGE * @param points Control point coordinate array * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI ege_drawbezier (int numOfPoints, const ege_point* points, PIMAGE pimg = NULL); // Same as ege_bezier +void EGEAPI ege_drawbezier(int numOfPoints, const ege_point* points, PIMAGE pimg = NULL); // Same as ege_bezier /** * @brief Draw cardinal spline curve @@ -2514,7 +2543,7 @@ void EGEAPI ege_drawbezier (int numOfPoints, const ege_point* points, PIMAGE * @param points Control point coordinate array * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI ege_drawcurve (int numOfPoints, const ege_point* points, PIMAGE pimg = NULL); +void EGEAPI ege_drawcurve(int numOfPoints, const ege_point* points, PIMAGE pimg = NULL); /** * @brief Draw closed cardinal spline curve @@ -2539,7 +2568,7 @@ void EGEAPI ege_fillclosedcurve(int numOfPoints, const ege_point* points, PIMAGE * @param tension Tension parameter (0.0 for straight lines, higher values make curve more curved) * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI ege_drawcurve (int numOfPoints, const ege_point* points, float tension, PIMAGE pimg = NULL); +void EGEAPI ege_drawcurve(int numOfPoints, const ege_point* points, float tension, PIMAGE pimg = NULL); /** * @brief Draw closed cardinal spline curve (with tension parameter) @@ -2567,7 +2596,7 @@ void EGEAPI ege_fillclosedcurve(int numOfPoints, const ege_point* points, float * @param h Rectangle height * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI ege_rectangle (float x, float y, float w, float h, PIMAGE pimg = NULL); +void EGEAPI ege_rectangle(float x, float y, float w, float h, PIMAGE pimg = NULL); /** * @brief Draw filled rectangle (GDI+ enhanced version) @@ -2577,7 +2606,7 @@ void EGEAPI ege_rectangle (float x, float y, float w, float h, PIMAGE pimg = * @param h Rectangle height * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI ege_fillrect (float x, float y, float w, float h, PIMAGE pimg = NULL); +void EGEAPI ege_fillrect(float x, float y, float w, float h, PIMAGE pimg = NULL); /** * @brief Draw circle outline (GDI+ enhanced version) @@ -2586,7 +2615,7 @@ void EGEAPI ege_fillrect (float x, float y, float w, float h, PIMAGE pimg = * @param radius Radius * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI ege_circle (float x, float y, float radius, PIMAGE pimg = NULL); +void EGEAPI ege_circle(float x, float y, float radius, PIMAGE pimg = NULL); /** * @brief Draw filled circle (GDI+ enhanced version) @@ -2595,7 +2624,7 @@ void EGEAPI ege_circle (float x, float y, float radius, PIMAGE pimg = NULL * @param radius Radius * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI ege_fillcircle (float x, float y, float radius, PIMAGE pimg = NULL); +void EGEAPI ege_fillcircle(float x, float y, float radius, PIMAGE pimg = NULL); /** * @brief Draw ellipse outline (GDI+ enhanced version) @@ -2605,7 +2634,7 @@ void EGEAPI ege_fillcircle (float x, float y, float radius, PIMAGE pimg = NULL * @param h Ellipse bounding rectangle height * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI ege_ellipse (float x, float y, float w, float h, PIMAGE pimg = NULL); +void EGEAPI ege_ellipse(float x, float y, float w, float h, PIMAGE pimg = NULL); /** * @brief Draw filled ellipse (GDI+ enhanced version) @@ -2615,7 +2644,7 @@ void EGEAPI ege_ellipse (float x, float y, float w, float h, PIMAGE pimg = * @param h Ellipse bounding rectangle height * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI ege_fillellipse (float x, float y, float w, float h, PIMAGE pimg = NULL); +void EGEAPI ege_fillellipse(float x, float y, float w, float h, PIMAGE pimg = NULL); /** * @brief Draw elliptical arc (GDI+ enhanced version) @@ -2627,7 +2656,7 @@ void EGEAPI ege_fillellipse (float x, float y, float w, float h, PIMAGE pimg = * @param sweepAngle Sweep angle (degrees) * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI ege_arc (float x, float y, float w, float h, float startAngle, float sweepAngle, PIMAGE pimg = NULL); +void EGEAPI ege_arc(float x, float y, float w, float h, float startAngle, float sweepAngle, PIMAGE pimg = NULL); /** * @brief Draw pie chart outline (GDI+ enhanced version) @@ -2639,7 +2668,7 @@ void EGEAPI ege_arc (float x, float y, float w, float h, float startAng * @param sweepAngle Sweep angle (degrees) * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI ege_pie (float x, float y, float w, float h, float startAngle, float sweepAngle, PIMAGE pimg = NULL); +void EGEAPI ege_pie(float x, float y, float w, float h, float startAngle, float sweepAngle, PIMAGE pimg = NULL); /** * @brief Draw filled pie chart (GDI+ enhanced version) @@ -2651,7 +2680,7 @@ void EGEAPI ege_pie (float x, float y, float w, float h, float startAng * @param sweepAngle Sweep angle (degrees) * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI ege_fillpie (float x, float y, float w, float h, float startAngle, float sweepAngle, PIMAGE pimg = NULL); +void EGEAPI ege_fillpie(float x, float y, float w, float h, float startAngle, float sweepAngle, PIMAGE pimg = NULL); /** * @brief Draw rounded rectangle outline (GDI+ enhanced version) @@ -2662,7 +2691,7 @@ void EGEAPI ege_fillpie (float x, float y, float w, float h, float startAng * @param radius Corner radius * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI ege_roundrect (float x, float y, float w, float h, float radius, PIMAGE pimg = NULL); +void EGEAPI ege_roundrect(float x, float y, float w, float h, float radius, PIMAGE pimg = NULL); /** * @brief Draw filled rounded rectangle (GDI+ enhanced version) @@ -2673,7 +2702,7 @@ void EGEAPI ege_roundrect (float x, float y, float w, float h, float radius, * @param radius Corner radius * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI ege_fillroundrect(float x, float y, float w, float h, float radius, PIMAGE pimg = NULL); +void EGEAPI ege_fillroundrect(float x, float y, float w, float h, float radius, PIMAGE pimg = NULL); /** * @brief Draw rounded rectangle outline (different radius for each corner) @@ -2687,7 +2716,8 @@ void EGEAPI ege_fillroundrect(float x, float y, float w, float h, float radius, * @param radius4 Bottom-left corner radius * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI ege_roundrect (float x, float y, float w, float h, float radius1, float radius2, float radius3, float radius4, PIMAGE pimg = NULL); +void EGEAPI ege_roundrect( + float x, float y, float w, float h, float radius1, float radius2, float radius3, float radius4, PIMAGE pimg = NULL); /** * @brief Draw filled rounded rectangle (different radius for each corner) @@ -2701,7 +2731,8 @@ void EGEAPI ege_roundrect (float x, float y, float w, float h, float radius1 * @param radius4 Bottom-left corner radius * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI ege_fillroundrect(float x, float y, float w, float h, float radius1, float radius2, float radius3, float radius4, PIMAGE pimg = NULL); +void EGEAPI ege_fillroundrect( + float x, float y, float w, float h, float radius1, float radius2, float radius3, float radius4, PIMAGE pimg = NULL); /** * @brief Clear fill pattern (set to no pattern) @@ -2719,7 +2750,8 @@ void EGEAPI ege_setpattern_none(PIMAGE pimg = NULL); * @param c2 End point color * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI ege_setpattern_lineargradient(float x1, float y1, color_t c1, float x2, float y2, color_t c2, PIMAGE pimg = NULL); +void EGEAPI ege_setpattern_lineargradient( + float x1, float y1, color_t c1, float x2, float y2, color_t c2, PIMAGE pimg = NULL); /** * @brief Set path gradient fill pattern @@ -2731,7 +2763,8 @@ void EGEAPI ege_setpattern_lineargradient(float x1, float y1, color_t c1, float * @param pointColors Boundary color array * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI ege_setpattern_pathgradient(ege_point center, color_t centerColor, int count, const ege_point* points, int colorCount, const color_t* pointColors, PIMAGE pimg = NULL); +void EGEAPI ege_setpattern_pathgradient(ege_point center, color_t centerColor, int count, const ege_point* points, + int colorCount, const color_t* pointColors, PIMAGE pimg = NULL); /** * @brief Set ellipse gradient fill pattern @@ -2744,7 +2777,8 @@ void EGEAPI ege_setpattern_pathgradient(ege_point center, color_t centerColor, i * @param color Boundary color * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI ege_setpattern_ellipsegradient(ege_point center, color_t centerColor, float x, float y, float w, float h, color_t color, PIMAGE pimg = NULL); +void EGEAPI ege_setpattern_ellipsegradient( + ege_point center, color_t centerColor, float x, float y, float w, float h, color_t color, PIMAGE pimg = NULL); /** * @brief Set texture fill pattern @@ -2764,7 +2798,7 @@ void EGEAPI ege_setpattern_texture(PIMAGE imgSrc, float x, float y, float w, flo * @param y Text top-left corner y coordinate * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI ege_drawtext(const char* text, float x, float y, PIMAGE pimg = NULL); +void EGEAPI ege_drawtext(const char* text, float x, float y, PIMAGE pimg = NULL); /** * @brief Draw text (GDI+ enhanced version, Unicode) @@ -2810,7 +2844,7 @@ void EGEAPI ege_puttexture(PCIMAGE imgSrc, ege_rect dest, PIMAGE pimg = NULL); */ void EGEAPI ege_puttexture(PCIMAGE imgSrc, ege_rect dest, ege_rect src, PIMAGE pimg = NULL); -//draw image +// draw image /** * @brief Draw image (GDI+ enhanced version) * @param imgSrc Source image @@ -2818,7 +2852,7 @@ void EGEAPI ege_puttexture(PCIMAGE imgSrc, ege_rect dest, ege_rect src, PIMAGE p * @param yDest Target y coordinate * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI ege_drawimage(PCIMAGE imgSrc,int xDest, int yDest, PIMAGE pimg = NULL); +void EGEAPI ege_drawimage(PCIMAGE imgSrc, int xDest, int yDest, PIMAGE pimg = NULL); /** * @brief Draw image (GDI+ enhanced version, specify source and target areas) @@ -2833,7 +2867,8 @@ void EGEAPI ege_drawimage(PCIMAGE imgSrc,int xDest, int yDest, PIMAGE pimg = NUL * @param heightSrc Source area height * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI ege_drawimage(PCIMAGE imgSrc,int xDest, int yDest, int widthDest, int heightDest, int xSrc, int ySrc, int widthSrc, int heightSrc,PIMAGE pimg = NULL); +void EGEAPI ege_drawimage(PCIMAGE imgSrc, int xDest, int yDest, int widthDest, int heightDest, int xSrc, int ySrc, + int widthSrc, int heightSrc, PIMAGE pimg = NULL); /** * @brief Draw path outline @@ -2874,7 +2909,7 @@ void EGEAPI ege_fillpath(const ege_path* path, float x, float y, PIMAGE pimg = N * @brief Create new path object * @return Path object pointer */ -ege_path* EGEAPI ege_path_create (); +ege_path* EGEAPI ege_path_create(); /** * @brief Create path from point array and type array @@ -2883,57 +2918,57 @@ ege_path* EGEAPI ege_path_create (); * @param count Number of points * @return Path object pointer */ -ege_path* EGEAPI ege_path_createfrom (const ege_point* points, const unsigned char* types, int count); +ege_path* EGEAPI ege_path_createfrom(const ege_point* points, const unsigned char* types, int count); /** * @brief Clone path * @param path Source path object pointer * @return New path object pointer */ -ege_path* EGEAPI ege_path_clone (const ege_path* path); +ege_path* EGEAPI ege_path_clone(const ege_path* path); /** * @brief Destroy path object * @param path Path object pointer */ -void EGEAPI ege_path_destroy (const ege_path* path); +void EGEAPI ege_path_destroy(const ege_path* path); /** * @brief Start new subpath * @param path Path object pointer */ -void EGEAPI ege_path_start (ege_path* path); +void EGEAPI ege_path_start(ege_path* path); /** * @brief Close current subpath * @param path Path object pointer */ -void EGEAPI ege_path_close (ege_path* path); +void EGEAPI ege_path_close(ege_path* path); /** * @brief Close all open subpaths * @param path Path object pointer */ -void EGEAPI ege_path_closeall (ege_path* path); +void EGEAPI ege_path_closeall(ege_path* path); /** * @brief Set path fill mode * @param path Path object pointer * @param mode Fill mode */ -void EGEAPI ege_path_setfillmode(ege_path* path, fill_mode mode); +void EGEAPI ege_path_setfillmode(ege_path* path, fill_mode mode); /** * @brief Reset path (clear all subpaths) * @param path Path object pointer */ -void EGEAPI ege_path_reset (ege_path* path); +void EGEAPI ege_path_reset(ege_path* path); /** * @brief Reverse path direction * @param path Path object pointer */ -void EGEAPI ege_path_reverse (ege_path* path); +void EGEAPI ege_path_reverse(ege_path* path); /** * @brief Widen path (generate outline) @@ -2941,7 +2976,7 @@ void EGEAPI ege_path_reverse (ege_path* path); * @param lineWidth Line width * @param matrix Transform matrix (optional) */ -void EGEAPI ege_path_widen (ege_path* path, float lineWidth, const ege_transform_matrix* matrix = NULL); +void EGEAPI ege_path_widen(ege_path* path, float lineWidth, const ege_transform_matrix* matrix = NULL); /** * @brief Widen path (generate outline, specify flatness) @@ -2950,14 +2985,14 @@ void EGEAPI ege_path_widen (ege_path* path, float lineWidth, const ege * @param matrix Transform matrix * @param flatness Flatness value */ -void EGEAPI ege_path_widen (ege_path* path, float lineWidth, const ege_transform_matrix* matrix, float flatness); +void EGEAPI ege_path_widen(ege_path* path, float lineWidth, const ege_transform_matrix* matrix, float flatness); /** * @brief Flatten path (convert curves to line segments) * @param path Path object pointer * @param matrix Transform matrix (optional) */ -void EGEAPI ege_path_flatten (ege_path* path, const ege_transform_matrix* matrix = NULL); +void EGEAPI ege_path_flatten(ege_path* path, const ege_transform_matrix* matrix = NULL); /** * @brief Flatten path (specify flatness) @@ -2965,7 +3000,7 @@ void EGEAPI ege_path_flatten (ege_path* path, const ege_transform_matrix * @param matrix Transform matrix * @param flatness Flatness value */ -void EGEAPI ege_path_flatten (ege_path* path, const ege_transform_matrix* matrix, float flatness); +void EGEAPI ege_path_flatten(ege_path* path, const ege_transform_matrix* matrix, float flatness); /** * @brief Warp path @@ -2975,7 +3010,8 @@ void EGEAPI ege_path_flatten (ege_path* path, const ege_transform_matrix * @param rect Warp rectangle area * @param matrix Transform matrix (optional) */ -void EGEAPI ege_path_warp (ege_path* path, const ege_point* points, int count, const ege_rect* rect, const ege_transform_matrix* matrix = NULL); +void EGEAPI ege_path_warp(ege_path* path, const ege_point* points, int count, const ege_rect* rect, + const ege_transform_matrix* matrix = NULL); /** * @brief Warp path (specify flatness) @@ -2986,14 +3022,15 @@ void EGEAPI ege_path_warp (ege_path* path, const ege_point* points, i * @param matrix Transform matrix * @param flatness Flatness value */ -void EGEAPI ege_path_warp (ege_path* path, const ege_point* points, int count, const ege_rect* rect, const ege_transform_matrix* matrix, float flatness); +void EGEAPI ege_path_warp(ege_path* path, const ege_point* points, int count, const ege_rect* rect, + const ege_transform_matrix* matrix, float flatness); /** * @brief Generate path outline * @param path Path object pointer * @param matrix Transform matrix (optional) */ -void EGEAPI ege_path_outline (ege_path* path, const ege_transform_matrix* matrix = NULL); +void EGEAPI ege_path_outline(ege_path* path, const ege_transform_matrix* matrix = NULL); /** * @brief Generate path outline (specify flatness) @@ -3001,7 +3038,7 @@ void EGEAPI ege_path_outline (ege_path* path, const ege_transform_matrix * @param matrix Transform matrix * @param flatness Flatness value */ -void EGEAPI ege_path_outline (ege_path* path, const ege_transform_matrix* matrix, float flatness); +void EGEAPI ege_path_outline(ege_path* path, const ege_transform_matrix* matrix, float flatness); /** * @brief Check if point is inside path @@ -3010,7 +3047,7 @@ void EGEAPI ege_path_outline (ege_path* path, const ege_transform_matrix * @param y Test point y coordinate * @return true if point is inside path, false otherwise */ -bool EGEAPI ege_path_inpath (const ege_path* path, float x, float y); +bool EGEAPI ege_path_inpath(const ege_path* path, float x, float y); /** * @brief Check if point is inside path (specify image context) @@ -3020,7 +3057,7 @@ bool EGEAPI ege_path_inpath (const ege_path* path, float x, float y); * @param pimg Image context pointer * @return true if point is inside path, false otherwise */ -bool EGEAPI ege_path_inpath (const ege_path* path, float x, float y, PCIMAGE pimg); +bool EGEAPI ege_path_inpath(const ege_path* path, float x, float y, PCIMAGE pimg); /** * @brief Check if point is on path outline @@ -3029,7 +3066,7 @@ bool EGEAPI ege_path_inpath (const ege_path* path, float x, float y, PC * @param y Test point y coordinate * @return true if point is on path outline, false otherwise */ -bool EGEAPI ege_path_instroke (const ege_path* path, float x, float y); +bool EGEAPI ege_path_instroke(const ege_path* path, float x, float y); /** * @brief Check if point is on path outline (specify image context) @@ -3039,21 +3076,21 @@ bool EGEAPI ege_path_instroke (const ege_path* path, float x, float y); * @param pimg Image context pointer * @return true if point is on path outline, false otherwise */ -bool EGEAPI ege_path_instroke (const ege_path* path, float x, float y, PCIMAGE pimg); +bool EGEAPI ege_path_instroke(const ege_path* path, float x, float y, PCIMAGE pimg); /** * @brief Get coordinates of last point in path * @param path Path object pointer * @return Coordinates of last point */ -ege_point EGEAPI ege_path_lastpoint (const ege_path* path); +ege_point EGEAPI ege_path_lastpoint(const ege_path* path); /** * @brief Get number of points in path * @param path Path object pointer * @return Number of points in path */ -int EGEAPI ege_path_pointcount (const ege_path* path); +int EGEAPI ege_path_pointcount(const ege_path* path); /** * @brief Get path bounding rectangle @@ -3061,7 +3098,7 @@ int EGEAPI ege_path_pointcount (const ege_path* path); * @param matrix Transform matrix, NULL means no transformation * @return Path bounding rectangle */ -ege_rect EGEAPI ege_path_getbounds (const ege_path* path, const ege_transform_matrix* matrix = NULL); +ege_rect EGEAPI ege_path_getbounds(const ege_path* path, const ege_transform_matrix* matrix = NULL); /** * @brief Get path bounding rectangle (specify image context) @@ -3070,7 +3107,7 @@ ege_rect EGEAPI ege_path_getbounds (const ege_path* path, const ege_tra * @param pimg Image context pointer * @return Path bounding rectangle */ -ege_rect EGEAPI ege_path_getbounds (const ege_path* path, const ege_transform_matrix* matrix, PCIMAGE pimg); +ege_rect EGEAPI ege_path_getbounds(const ege_path* path, const ege_transform_matrix* matrix, PCIMAGE pimg); /** * @brief Get all points in path @@ -3079,7 +3116,7 @@ ege_rect EGEAPI ege_path_getbounds (const ege_path* path, const ege_tra * @return Pointer to point array * @note If points is NULL, function will allocate memory, caller is responsible for freeing it */ -ege_point* EGEAPI ege_path_getpathpoints(const ege_path* path, ege_point* points = NULL); +ege_point* EGEAPI ege_path_getpathpoints(const ege_path* path, ege_point* points = NULL); /** * @brief Get all point types in path @@ -3088,14 +3125,14 @@ ege_point* EGEAPI ege_path_getpathpoints(const ege_path* path, ege_point* po * @return Pointer to type array * @note If types is NULL, function will allocate memory, caller is responsible for freeing it */ -unsigned char* EGEAPI ege_path_getpathtypes (const ege_path* path, unsigned char* types = NULL); +unsigned char* EGEAPI ege_path_getpathtypes(const ege_path* path, unsigned char* types = NULL); /** * @brief Transform path * @param path Path object pointer * @param matrix Transform matrix */ -void EGEAPI ege_path_transform (ege_path* path, const ege_transform_matrix* matrix); +void EGEAPI ege_path_transform(ege_path* path, const ege_transform_matrix* matrix); /// @defgroup PathAdd Path addition functions /// @{ @@ -3106,7 +3143,7 @@ void EGEAPI ege_path_transform (ege_path* path, const ege_transform_matrix* * @param srcPath Source path object pointer * @param connect Whether to connect to the last point of current path */ -void EGEAPI ege_path_addpath (ege_path* dstPath, const ege_path* srcPath, bool connect); +void EGEAPI ege_path_addpath(ege_path* dstPath, const ege_path* srcPath, bool connect); /** * @brief Add line segment to path @@ -3116,7 +3153,7 @@ void EGEAPI ege_path_addpath (ege_path* dstPath, const ege_path* srcPath, * @param x2 End point x coordinate * @param y2 End point y coordinate */ -void EGEAPI ege_path_addline (ege_path* path, float x1, float y1, float x2, float y2); +void EGEAPI ege_path_addline(ege_path* path, float x1, float y1, float x2, float y2); /** * @brief Add arc to path @@ -3128,7 +3165,8 @@ void EGEAPI ege_path_addline (ege_path* path, float x1, float y1, float x2 * @param startAngle Start angle (degrees) * @param sweepAngle Sweep angle (degrees) */ -void EGEAPI ege_path_addarc (ege_path* path, float x, float y, float width, float height, float startAngle, float sweepAngle); +void EGEAPI ege_path_addarc( + ege_path* path, float x, float y, float width, float height, float startAngle, float sweepAngle); /** * @brief Add polyline to path @@ -3136,7 +3174,7 @@ void EGEAPI ege_path_addarc (ege_path* path, float x, float y, float widt * @param numOfPoints Number of points * @param points Point array */ -void EGEAPI ege_path_addpolyline (ege_path* path, int numOfPoints, const ege_point* points); +void EGEAPI ege_path_addpolyline(ege_path* path, int numOfPoints, const ege_point* points); /** * @brief Add Bezier curve to path (point array version) @@ -3144,7 +3182,7 @@ void EGEAPI ege_path_addpolyline (ege_path* path, int numOfPoints, const ege_p * @param numOfPoints Number of control points * @param points Control point array */ -void EGEAPI ege_path_addbezier (ege_path* path, int numOfPoints, const ege_point* points); +void EGEAPI ege_path_addbezier(ege_path* path, int numOfPoints, const ege_point* points); /** * @brief Add Bezier curve to path (coordinate version) @@ -3158,7 +3196,8 @@ void EGEAPI ege_path_addbezier (ege_path* path, int numOfPoints, const ege_p * @param x4 End point x coordinate * @param y4 End point y coordinate */ -void EGEAPI ege_path_addbezier (ege_path* path, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4); +void EGEAPI ege_path_addbezier( + ege_path* path, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4); /** * @brief Add cardinal spline curve to path @@ -3166,7 +3205,7 @@ void EGEAPI ege_path_addbezier (ege_path* path, float x1, float y1, float x2 * @param numOfPoints Number of control points * @param points Control point array */ -void EGEAPI ege_path_addcurve (ege_path* path, int numOfPoints, const ege_point* points); +void EGEAPI ege_path_addcurve(ege_path* path, int numOfPoints, const ege_point* points); /** * @brief Add cardinal spline curve to path (specify tension) @@ -3175,7 +3214,7 @@ void EGEAPI ege_path_addcurve (ege_path* path, int numOfPoints, const ege_p * @param points Control point array * @param tension Tension value (0.0-1.0) */ -void EGEAPI ege_path_addcurve (ege_path* path, int numOfPoints, const ege_point* points, float tension); +void EGEAPI ege_path_addcurve(ege_path* path, int numOfPoints, const ege_point* points, float tension); /** * @brief Add circle to path @@ -3184,7 +3223,7 @@ void EGEAPI ege_path_addcurve (ege_path* path, int numOfPoints, const ege_p * @param y Circle center y coordinate * @param radius Radius */ -void EGEAPI ege_path_addcircle (ege_path* path, float x, float y, float radius); +void EGEAPI ege_path_addcircle(ege_path* path, float x, float y, float radius); /** * @brief Add rectangle to path @@ -3194,7 +3233,7 @@ void EGEAPI ege_path_addcircle (ege_path* path, float x, float y, float radi * @param width Rectangle width * @param height Rectangle height */ -void EGEAPI ege_path_addrect (ege_path* path, float x, float y, float width, float height); +void EGEAPI ege_path_addrect(ege_path* path, float x, float y, float width, float height); /** * @brief Add ellipse to path @@ -3204,7 +3243,7 @@ void EGEAPI ege_path_addrect (ege_path* path, float x, float y, float widt * @param width Ellipse width * @param height Ellipse height */ -void EGEAPI ege_path_addellipse (ege_path* path, float x, float y, float width, float height); +void EGEAPI ege_path_addellipse(ege_path* path, float x, float y, float width, float height); /** * @brief Add pie chart to path @@ -3216,7 +3255,8 @@ void EGEAPI ege_path_addellipse (ege_path* path, float x, float y, float widt * @param startAngle Start angle (degrees) * @param sweepAngle Sweep angle (degrees) */ -void EGEAPI ege_path_addpie (ege_path* path, float x, float y, float width, float height, float startAngle, float sweepAngle); +void EGEAPI ege_path_addpie( + ege_path* path, float x, float y, float width, float height, float startAngle, float sweepAngle); /** * @brief Add text to path (ANSI version) @@ -3229,7 +3269,8 @@ void EGEAPI ege_path_addpie (ege_path* path, float x, float y, float widt * @param typeface Font name, NULL means use default font * @param fontStyle Font style */ -void EGEAPI ege_path_addtext (ege_path* path, float x, float y, const char* text, float height, int length = -1, const char* typeface = NULL, int fontStyle = 0); +void EGEAPI ege_path_addtext(ege_path* path, float x, float y, const char* text, float height, int length = -1, + const char* typeface = NULL, int fontStyle = 0); /** * @brief Add text to path (Unicode version) @@ -3242,7 +3283,8 @@ void EGEAPI ege_path_addtext (ege_path* path, float x, float y, const char * @param typeface Font name, NULL means use default font * @param fontStyle Font style */ -void EGEAPI ege_path_addtext (ege_path* path, float x, float y, const wchar_t* text, float height, int length = -1, const wchar_t* typeface = NULL, int fontStyle = 0); +void EGEAPI ege_path_addtext(ege_path* path, float x, float y, const wchar_t* text, float height, int length = -1, + const wchar_t* typeface = NULL, int fontStyle = 0); /** * @brief Add polygon to path @@ -3250,7 +3292,7 @@ void EGEAPI ege_path_addtext (ege_path* path, float x, float y, const wcha * @param numOfPoints Number of vertices * @param points Vertex array */ -void EGEAPI ege_path_addpolygon (ege_path* path, int numOfPoints, const ege_point* points); +void EGEAPI ege_path_addpolygon(ege_path* path, int numOfPoints, const ege_point* points); /** * @brief Add closed cardinal spline curve to path @@ -3271,7 +3313,6 @@ void EGEAPI ege_path_addclosedcurve(ege_path* path, int numOfPoints, const ege_p /// @} - /// @defgroup Transform Transform functions /// @{ @@ -3337,7 +3378,6 @@ ege_point EGEAPI ege_transform_calc(ege_point p, PIMAGE pimg = NULL); */ ege_point EGEAPI ege_transform_calc(float x, float y, PIMAGE pimg = NULL); - #endif // It is not supported in VC 6.0. @@ -3382,13 +3422,13 @@ bool EGEAPI close_console(); * @brief Get character from console (replacement for getch function in ) * @return Character code obtained */ -int EGEAPI getch_console(); +int EGEAPI getch_console(); /** * @brief Check if console has key press (replacement for kbhit function in ) * @return Returns non-zero if key pressed, 0 if no key pressed */ -int EGEAPI kbhit_console(); +int EGEAPI kbhit_console(); /// @} @@ -3400,59 +3440,59 @@ int EGEAPI kbhit_console(); * @param ms Delay time (milliseconds) * @note Precise delay function, not affected by system scheduling */ -void EGEAPI ege_sleep (long ms); +void EGEAPI ege_sleep(long ms); /** * @brief Delay function * @param ms Delay time (milliseconds) * @note Standard delay function */ -void EGEAPI delay (long ms); +void EGEAPI delay(long ms); /** * @brief Millisecond delay function * @param ms Delay time (milliseconds) */ -void EGEAPI delay_ms (long ms); +void EGEAPI delay_ms(long ms); /** * @brief API delay function * @param ms Delay time (milliseconds) * @note Delay implemented using system API */ -void EGEAPI api_sleep (long ms); +void EGEAPI api_sleep(long ms); /** * @brief Delay by frame rate (integer version) * @param fps Target frame rate * @note Automatically calculates delay time based on frame rate */ -void EGEAPI delay_fps (int fps); +void EGEAPI delay_fps(int fps); /** * @brief Delay by frame rate (long integer version) * @param fps Target frame rate */ -void EGEAPI delay_fps (long fps); +void EGEAPI delay_fps(long fps); /** * @brief Delay by frame rate (double precision floating-point version) * @param fps Target frame rate */ -void EGEAPI delay_fps (double fps); +void EGEAPI delay_fps(double fps); /** * @brief Frame rate delay with frame skipping * @param fps Target frame rate * @note More precise frame rate control */ -void EGEAPI delay_jfps(int fps); +void EGEAPI delay_jfps(int fps); /** * @brief Precise frame rate delay (long integer version) * @param fps Target frame rate */ -void EGEAPI delay_jfps(long fps); +void EGEAPI delay_jfps(long fps); /** * @brief Precise frame rate delay (double precision floating-point version) @@ -3481,7 +3521,7 @@ double EGEAPI fclock(); * @param pimg Target image pointer, NULL means current ege window * @note Text output position is determined by current drawing position, set using moveto() */ -void EGEAPI outtext(const char* text, PIMAGE pimg = NULL); +void EGEAPI outtext(const char* text, PIMAGE pimg = NULL); /** * @brief Output text string at current position (Unicode version) @@ -3497,7 +3537,7 @@ void EGEAPI outtext(const wchar_t* text, PIMAGE pimg = NULL); * @param pimg Target image pointer, NULL means current ege window * @note Text output position is determined by current drawing position, set using moveto() */ -void EGEAPI outtext(char c, PIMAGE pimg = NULL); +void EGEAPI outtext(char c, PIMAGE pimg = NULL); /** * @brief Output single character at current position (Unicode version) @@ -3515,7 +3555,7 @@ void EGEAPI outtext(wchar_t c, PIMAGE pimg = NULL); * @param pimg Target image pointer, NULL means current ege window * @note Actual output position is affected by text alignment and font tilt angle */ -void EGEAPI outtextxy(int x, int y, const char* text, PIMAGE pimg = NULL); +void EGEAPI outtextxy(int x, int y, const char* text, PIMAGE pimg = NULL); /** * @brief Output text string at specified position (Unicode version) @@ -3535,7 +3575,7 @@ void EGEAPI outtextxy(int x, int y, const wchar_t* text, PIMAGE pimg = NULL); * @param pimg Target image pointer, NULL means current ege window * @note Actual output position is affected by text alignment and font tilt angle */ -void EGEAPI outtextxy(int x, int y, char c, PIMAGE pimg = NULL); +void EGEAPI outtextxy(int x, int y, char c, PIMAGE pimg = NULL); /** * @brief Output single character at specified position (Unicode version) @@ -3555,7 +3595,7 @@ void EGEAPI outtextxy(int x, int y, wchar_t c, PIMAGE pimg = NULL); * @param ... Variable argument list * @note Actual output position is affected by text alignment and font tilt angle */ -void EGEAPI xyprintf (int x, int y, const char* format, ...); +void EGEAPI xyprintf(int x, int y, const char* format, ...); /** * @brief Format and output text at specified position (Unicode version) @@ -3565,7 +3605,7 @@ void EGEAPI xyprintf (int x, int y, const char* format, ...); * @param ... Variable argument list * @note Actual output position is affected by text alignment and font tilt angle */ -void EGEAPI xyprintf (int x, int y, const wchar_t* format, ...); +void EGEAPI xyprintf(int x, int y, const wchar_t* format, ...); /** * @brief Output text within specified rectangular area @@ -3577,7 +3617,7 @@ void EGEAPI xyprintf (int x, int y, const wchar_t* format, ...); * @param pimg Target image pointer, NULL means current ege window * @note Text will wrap automatically within the specified rectangle area, supports text alignment settings */ -void EGEAPI outtextrect(int x, int y, int w, int h, const char* text, PIMAGE pimg = NULL); +void EGEAPI outtextrect(int x, int y, int w, int h, const char* text, PIMAGE pimg = NULL); /** * @brief Output text within specified rectangular area (Unicode version) @@ -3601,7 +3641,7 @@ void EGEAPI outtextrect(int x, int y, int w, int h, const wchar_t* text, PIMAGE * @param ... Variable argument list * @note Text will wrap automatically within the specified rectangle area, supports text alignment settings */ -void EGEAPI rectprintf (int x, int y, int w, int h, const char* format, ...); +void EGEAPI rectprintf(int x, int y, int w, int h, const char* format, ...); /** * @brief Format and output text within specified rectangular area (Unicode version) @@ -3613,7 +3653,7 @@ void EGEAPI rectprintf (int x, int y, int w, int h, const char* format, ...); * @param ... Variable argument list * @note Text will wrap automatically within the specified rectangle area, supports text alignment settings */ -void EGEAPI rectprintf (int x, int y, int w, int h, const wchar_t* format, ...); +void EGEAPI rectprintf(int x, int y, int w, int h, const wchar_t* format, ...); /** * @brief Get display width of text string @@ -3622,7 +3662,7 @@ void EGEAPI rectprintf (int x, int y, int w, int h, const wchar_t* format, ...); * @return Text display width (pixels) * @note Return value is affected by current font settings */ -int EGEAPI textwidth(const char* text, PCIMAGE pimg = NULL); +int EGEAPI textwidth(const char* text, PCIMAGE pimg = NULL); /** * @brief Get display width of text string (Unicode version) @@ -3631,7 +3671,7 @@ int EGEAPI textwidth(const char* text, PCIMAGE pimg = NULL); * @return Text display width (pixels) * @note Return value is affected by current font settings */ -int EGEAPI textwidth(const wchar_t* text, PCIMAGE pimg = NULL); +int EGEAPI textwidth(const wchar_t* text, PCIMAGE pimg = NULL); /** * @brief Get display width of single character @@ -3640,7 +3680,7 @@ int EGEAPI textwidth(const wchar_t* text, PCIMAGE pimg = NULL); * @return Character display width (pixels) * @note Return value is affected by current font settings */ -int EGEAPI textwidth(char c, PCIMAGE pimg = NULL); +int EGEAPI textwidth(char c, PCIMAGE pimg = NULL); /** * @brief Get display width of single character (Unicode version) @@ -3649,7 +3689,7 @@ int EGEAPI textwidth(char c, PCIMAGE pimg = NULL); * @return Character display width (pixels) * @note Return value is affected by current font settings */ -int EGEAPI textwidth(wchar_t c, PCIMAGE pimg = NULL); +int EGEAPI textwidth(wchar_t c, PCIMAGE pimg = NULL); /** * @brief Get display height of text string @@ -3658,7 +3698,7 @@ int EGEAPI textwidth(wchar_t c, PCIMAGE pimg = NULL); * @return Text display height (pixels) * @note Return value is affected by current font settings */ -int EGEAPI textheight(const char* text, PCIMAGE pimg = NULL); +int EGEAPI textheight(const char* text, PCIMAGE pimg = NULL); /** * @brief Get display height of text string (Unicode version) @@ -3667,7 +3707,7 @@ int EGEAPI textheight(const char* text, PCIMAGE pimg = NULL); * @return Text display height (pixels) * @note Return value is affected by current font settings */ -int EGEAPI textheight(const wchar_t* text, PCIMAGE pimg = NULL); +int EGEAPI textheight(const wchar_t* text, PCIMAGE pimg = NULL); /** * @brief Get display height of single character @@ -3676,7 +3716,7 @@ int EGEAPI textheight(const wchar_t* text, PCIMAGE pimg = NULL); * @return Character display height (pixels) * @note Return value is affected by current font settings */ -int EGEAPI textheight(char c, PCIMAGE pimg = NULL); +int EGEAPI textheight(char c, PCIMAGE pimg = NULL); /** * @brief Get display height of single character (Unicode version) @@ -3685,7 +3725,7 @@ int EGEAPI textheight(char c, PCIMAGE pimg = NULL); * @return Character display height (pixels) * @note Return value is affected by current font settings */ -int EGEAPI textheight(wchar_t c, PCIMAGE pimg = NULL); +int EGEAPI textheight(wchar_t c, PCIMAGE pimg = NULL); /** * @brief Output text at specified position (supports floating-point coordinates and ARGB colors) @@ -3693,9 +3733,10 @@ int EGEAPI textheight(wchar_t c, PCIMAGE pimg = NULL); * @param y Y coordinate of output position (floating-point) * @param text Text string to output * @param pimg Target image pointer, NULL means current ege window - * @note Uses GDI+ rendering, supports ARGB colors and anti-aliasing, actual output position is affected by text alignment and font tilt angle + * @note Uses GDI+ rendering, supports ARGB colors and anti-aliasing, actual output position is affected by text + * alignment and font tilt angle */ -void EGEAPI ege_outtextxy(float x, float y, const char* text, PIMAGE pimg = NULL); +void EGEAPI ege_outtextxy(float x, float y, const char* text, PIMAGE pimg = NULL); /** * @brief Output text at specified position (supports floating-point coordinates and ARGB colors, Unicode version) @@ -3703,7 +3744,8 @@ void EGEAPI ege_outtextxy(float x, float y, const char* text, PIMAGE pimg = N * @param y Y coordinate of output position (floating-point) * @param text Text string to output * @param pimg Target image pointer, NULL means current ege window - * @note Uses GDI+ rendering, supports ARGB colors and anti-aliasing, actual output position is affected by text alignment and font tilt angle + * @note Uses GDI+ rendering, supports ARGB colors and anti-aliasing, actual output position is affected by text + * alignment and font tilt angle */ void EGEAPI ege_outtextxy(float x, float y, const wchar_t* text, PIMAGE pimg = NULL); @@ -3713,17 +3755,20 @@ void EGEAPI ege_outtextxy(float x, float y, const wchar_t* text, PIMAGE pimg = N * @param y Y coordinate of output position (floating-point) * @param c Character to output * @param pimg Target image pointer, NULL means current ege window - * @note Uses GDI+ rendering, supports ARGB colors and anti-aliasing, actual output position is affected by text alignment and font tilt angle + * @note Uses GDI+ rendering, supports ARGB colors and anti-aliasing, actual output position is affected by text + * alignment and font tilt angle */ -void EGEAPI ege_outtextxy(float x, float y, char c, PIMAGE pimg = NULL); +void EGEAPI ege_outtextxy(float x, float y, char c, PIMAGE pimg = NULL); /** - * @brief Output single character at specified position (supports floating-point coordinates and ARGB colors, Unicode version) + * @brief Output single character at specified position (supports floating-point coordinates and ARGB colors, Unicode + * version) * @param x X coordinate of output position (floating-point) * @param y Y coordinate of output position (floating-point) * @param c Character to output * @param pimg Target image pointer, NULL means current ege window - * @note Uses GDI+ rendering, supports ARGB colors and anti-aliasing, actual output position is affected by text alignment and font tilt angle + * @note Uses GDI+ rendering, supports ARGB colors and anti-aliasing, actual output position is affected by text + * alignment and font tilt angle */ void EGEAPI ege_outtextxy(float x, float y, wchar_t c, PIMAGE pimg = NULL); @@ -3733,19 +3778,22 @@ void EGEAPI ege_outtextxy(float x, float y, wchar_t c, PIMAGE pimg = NULL); * @param y Y coordinate of output position (floating-point) * @param format Format string (similar to printf) * @param ... Variable argument list - * @note Uses GDI+ rendering, supports ARGB colors and anti-aliasing, actual output position is affected by text alignment and font tilt angle + * @note Uses GDI+ rendering, supports ARGB colors and anti-aliasing, actual output position is affected by text + * alignment and font tilt angle */ -void EGEAPI ege_xyprintf (float x, float y, const char* format, ...); +void EGEAPI ege_xyprintf(float x, float y, const char* format, ...); /** - * @brief Format and output text at specified position (supports floating-point coordinates and ARGB colors, Unicode version) + * @brief Format and output text at specified position (supports floating-point coordinates and ARGB colors, Unicode + * version) * @param x X coordinate of output position (floating-point) * @param y Y coordinate of output position (floating-point) * @param format Format string (similar to printf) * @param ... Variable argument list - * @note Uses GDI+ rendering, supports ARGB colors and anti-aliasing, actual output position is affected by text alignment and font tilt angle + * @note Uses GDI+ rendering, supports ARGB colors and anti-aliasing, actual output position is affected by text + * alignment and font tilt angle */ -void EGEAPI ege_xyprintf (float x, float y, const wchar_t* format, ...); +void EGEAPI ege_xyprintf(float x, float y, const wchar_t* format, ...); /// @} @@ -3771,7 +3819,7 @@ void EGEAPI settextjustify(int horiz, int vert, PIMAGE pimg = NULL); * @param typeface Font name * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI setfont(int height, int width, const char* typeface, PIMAGE pimg = NULL); +void EGEAPI setfont(int height, int width, const char* typeface, PIMAGE pimg = NULL); /** * @brief Set font (simplified version, Unicode) @@ -3795,8 +3843,8 @@ void EGEAPI setfont(int height, int width, const wchar_t* typeface, PIMAGE pimg * @param strikeOut Whether strikethrough * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI setfont(int height, int width, const char* typeface, int escapement, int orientation, - int weight, bool italic, bool underline, bool strikeOut, PIMAGE pimg = NULL); +void EGEAPI setfont(int height, int width, const char* typeface, int escapement, int orientation, int weight, + bool italic, bool underline, bool strikeOut, PIMAGE pimg = NULL); /** * @brief Set font (complete version, Unicode) @@ -3811,8 +3859,8 @@ void EGEAPI setfont(int height, int width, const char* typeface, int escapement * @param strikeOut Whether strikethrough * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI setfont(int height, int width, const wchar_t* typeface, int escapement, int orientation, - int weight, bool italic, bool underline, bool strikeOut, PIMAGE pimg = NULL); +void EGEAPI setfont(int height, int width, const wchar_t* typeface, int escapement, int orientation, int weight, + bool italic, bool underline, bool strikeOut, PIMAGE pimg = NULL); /** * @brief Set font (advanced version) @@ -3832,9 +3880,9 @@ void EGEAPI setfont(int height, int width, const wchar_t* typeface, int escapeme * @param pitchAndFamily Font pitch and family information * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI setfont(int height, int width, const char* typeface, int escapement, int orientation, - int weight, bool italic, bool underline, bool strikeOut, BYTE charSet, - BYTE outPrecision, BYTE clipPrecision, BYTE quality, BYTE pitchAndFamily, PIMAGE pimg = NULL); +void EGEAPI setfont(int height, int width, const char* typeface, int escapement, int orientation, int weight, + bool italic, bool underline, bool strikeOut, BYTE charSet, BYTE outPrecision, BYTE clipPrecision, BYTE quality, + BYTE pitchAndFamily, PIMAGE pimg = NULL); /** * @brief Set font (advanced version, Unicode) @@ -3854,23 +3902,23 @@ void EGEAPI setfont(int height, int width, const char* typeface, int escapement * @param pitchAndFamily Font pitch and family information * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI setfont(int height, int width, const wchar_t* typeface, int escapement, int orientation, - int weight, bool italic, bool underline, bool strikeOut, BYTE charSet, - BYTE outPrecision, BYTE clipPrecision, BYTE quality, BYTE pitchAndFamily, PIMAGE pimg = NULL); +void EGEAPI setfont(int height, int width, const wchar_t* typeface, int escapement, int orientation, int weight, + bool italic, bool underline, bool strikeOut, BYTE charSet, BYTE outPrecision, BYTE clipPrecision, BYTE quality, + BYTE pitchAndFamily, PIMAGE pimg = NULL); /** * @brief Set font using LOGFONTW structure * @param font Pointer to LOGFONTW structure * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI setfont(const LOGFONTW *font, PIMAGE pimg = NULL); +void EGEAPI setfont(const LOGFONTW* font, PIMAGE pimg = NULL); /** * @brief Get current font settings * @param font LOGFONTW structure pointer to receive font information * @param pimg Target image pointer, NULL means current ege window */ -void EGEAPI getfont(LOGFONTW *font, PCIMAGE pimg = NULL); +void EGEAPI getfont(LOGFONTW* font, PCIMAGE pimg = NULL); /** * @brief Set font using LOGFONTA structure @@ -3879,7 +3927,7 @@ void EGEAPI getfont(LOGFONTW *font, PCIMAGE pimg = NULL); * @deprecated Recommend using setfont function with LOGFONTW parameter */ EGE_DEPRECATE(setfont, "Please use the 'getfont' function with the LOGFONTW* parameter instead.") -void EGEAPI setfont(const LOGFONTA *font, PIMAGE pimg = NULL); +void EGEAPI setfont(const LOGFONTA* font, PIMAGE pimg = NULL); /** * @brief Get current font settings (ANSI version) @@ -3888,7 +3936,7 @@ void EGEAPI setfont(const LOGFONTA *font, PIMAGE pimg = NULL); * @deprecated Recommend using getfont function with LOGFONTW parameter */ EGE_DEPRECATE(getfont, "Please use the 'getfont' function with the LOGFONTW* parameter instead.") -void EGEAPI getfont(LOGFONTA *font, PCIMAGE pimg = NULL); +void EGEAPI getfont(LOGFONTA* font, PCIMAGE pimg = NULL); /// @} @@ -3899,10 +3947,11 @@ void EGEAPI getfont(LOGFONTA *font, PCIMAGE pimg = NULL); * @brief Get width of window or image * @param pimg Image object pointer, NULL means get width of current drawing window * @return Returns width of window or image (pixels), returns 0 if image object is invalid - * + * * This function is used to get the width of the specified image or window. When pimg is NULL, - * it returns the width of the current EGE drawing window; when pimg points to a valid image, it returns the width of that image. - * + * it returns the width of the current EGE drawing window; when pimg points to a valid image, it returns the width of + * that image. + * * @see getheight() Get height * @see getx() Get current x coordinate * @see gety() Get current y coordinate @@ -3913,10 +3962,11 @@ int EGEAPI getwidth(PCIMAGE pimg = NULL); * @brief Get height of window or image * @param pimg Image object pointer, NULL means get height of current drawing window * @return Returns height of window or image (pixels), returns 0 if image object is invalid - * + * * This function is used to get the height of the specified image or window. When pimg is NULL, - * it returns the height of the current EGE drawing window; when pimg points to a valid image, it returns the height of that image. - * + * it returns the height of the current EGE drawing window; when pimg points to a valid image, it returns the height of + * that image. + * * @see getwidth() Get width * @see getx() Get current x coordinate * @see gety() Get current y coordinate @@ -3927,10 +3977,10 @@ int EGEAPI getheight(PCIMAGE pimg = NULL); * @brief Get x coordinate of current pen position * @param pimg Image object pointer, NULL means get pen position of current drawing window * @return Returns x coordinate of current pen position, returns -1 if image object is invalid - * - * Get the x coordinate of the current drawing position. The pen position is usually set by functions like moveto(), lineto(), - * or changed by the execution of drawing functions (like line()). - * + * + * Get the x coordinate of the current drawing position. The pen position is usually set by functions like moveto(), + * lineto(), or changed by the execution of drawing functions (like line()). + * * @see gety() Get current y coordinate * @see moveto() Move pen to specified position * @see getwidth() Get width @@ -3942,10 +3992,10 @@ int EGEAPI getx(PCIMAGE pimg = NULL); * @brief Get y coordinate of current pen position * @param pimg Image object pointer, NULL means get pen position of current drawing window * @return Returns y coordinate of current pen position, returns -1 if image object is invalid - * - * Get the y coordinate of the current drawing position. The pen position is usually set by functions like moveto(), lineto(), - * or changed by the execution of drawing functions (like line()). - * + * + * Get the y coordinate of the current drawing position. The pen position is usually set by functions like moveto(), + * lineto(), or changed by the execution of drawing functions (like line()). + * * @see getx() Get current x coordinate * @see moveto() Move pen to specified position * @see getwidth() Get width @@ -3956,64 +4006,64 @@ int EGEAPI gety(PCIMAGE pimg = NULL); /** * @brief Create a new image object (1x1 pixels) * @return Returns pointer to newly created image object, returns NULL on failure - * + * * Creates an image object with size 1x1 pixels, background color is black. * The created image needs to be destroyed using delimage() function to prevent memory leaks. - * + * * @note This function creates the minimum size image, usually used for subsequent resizing or as placeholder * @warning Must use delimage() to destroy the created image, otherwise it will cause memory leaks - * + * * @see newimage(int, int) Create image with specified size * @see delimage() Destroy image object * @see resize() Resize image */ -PIMAGE EGEAPI newimage(); +PIMAGE EGEAPI newimage(); /** * @brief Create new image object with specified size * @param width Image width (pixels), automatically adjusted to 1 if less than 1 * @param height Image height (pixels), automatically adjusted to 1 if less than 1 * @return Returns pointer to newly created image object, returns NULL on failure - * + * * Creates an image object with specified size, background color is black. * If the specified width or height is less than 1, it will be automatically adjusted to 1. * The created image needs to be destroyed using delimage() function to prevent memory leaks. - * + * * @warning Must use delimage() to destroy the created image, otherwise it will cause memory leaks - * + * * @see newimage() Create 1x1 pixel image * @see delimage() Destroy image object * @see resize() Resize image */ -PIMAGE EGEAPI newimage(int width, int height); +PIMAGE EGEAPI newimage(int width, int height); /** * @brief Destroy image object and free memory * @param pimg Image object pointer to destroy, ignored if NULL - * + * * Destroys image object created by newimage() function, freeing related memory and system resources. * The image pointer should not be used after destruction. - * + * * @note Passing NULL pointer is safe, the function will ignore NULL parameter * @warning Do not use the image pointer after destroying the image, otherwise it may cause program crash - * + * * @see newimage() Create image object * @see newimage(int, int) Create image object with specified size */ -void EGEAPI delimage(PCIMAGE pimg); +void EGEAPI delimage(PCIMAGE pimg); //================================================================================== // Image management and processing functions - Image operation functionality of EGE graphics library //================================================================================== /** * @defgroup image_management Image management and processing functions * @brief Image creation, loading, saving and processing functionality of EGE graphics library - * + * * The image management module provides complete image operation capabilities, including: * - Image buffer operations: getbuffer() get pixel buffer * - Image resizing: resize(), resize_f() adjust image size * - Image acquisition: getimage() series functions to get image data from different sources * - Image saving: saveimage(), savepng(), savebmp() save images to files - * + * * Supported image formats: PNG, BMP, JPG, GIF, EMF, WMF, ICO * Support getting images from window, file, resource, other IMAGE objects * @{ @@ -4026,12 +4076,13 @@ void EGEAPI delimage(PCIMAGE pimg); * @note Pixel at coordinate (x, y) corresponds to buffer index: buffer[y * width + x] * @note Returned pointer can directly manipulate pixel data, changes take effect immediately */ -color_t* EGEAPI getbuffer(PIMAGE pimg); +color_t* EGEAPI getbuffer(PIMAGE pimg); /** * @brief Get image pixel buffer pointer (read-only version) * @param pimg Image object pointer to get buffer from, default is NULL (represents window) - * @return First address of image buffer (read-only), buffer is one-dimensional array with size = image width × image height + * @return First address of image buffer (read-only), buffer is one-dimensional array with size = image width × image + * height * @note Pixel at coordinate (x, y) corresponds to buffer index: buffer[y * width + x] * @note Returned pointer can only read pixel data, cannot modify */ @@ -4047,7 +4098,7 @@ const color_t* EGEAPI getbuffer(PCIMAGE pimg); * @note This function is fast but does not preserve original image content * @warning Runtime exception will occur if pimg is invalid pointer */ -int EGEAPI resize_f(PIMAGE pimg, int width, int height); +int EGEAPI resize_f(PIMAGE pimg, int width, int height); /** * @brief Resize image (standard version) @@ -4059,7 +4110,7 @@ int EGEAPI resize_f(PIMAGE pimg, int width, int height); * @note This function clears image content and fills with background color * @warning Runtime exception will occur if pimg is invalid pointer */ -int EGEAPI resize (PIMAGE pimg, int width, int height); +int EGEAPI resize(PIMAGE pimg, int width, int height); /** * @brief Get image from window @@ -4072,7 +4123,7 @@ int EGEAPI resize (PIMAGE pimg, int width, int height); * @note Get image data from specified region of current window * @see getimage(PIMAGE, PCIMAGE, int, int, int, int) */ -int EGEAPI getimage(PIMAGE imgDest, int xSrc, int ySrc, int widthSrc, int heightSrc); +int EGEAPI getimage(PIMAGE imgDest, int xSrc, int ySrc, int widthSrc, int heightSrc); /** * @brief Get image from another IMAGE object @@ -4086,7 +4137,7 @@ int EGEAPI getimage(PIMAGE imgDest, int xSrc, int ySrc, int widthSrc, int heigh * @note Copy image data from specified region of source IMAGE object to destination IMAGE object * @see getimage(PIMAGE, int, int, int, int) */ -int EGEAPI getimage(PIMAGE imgDest, PCIMAGE imgSrc, int xSrc, int ySrc, int widthSrc, int heightSrc); +int EGEAPI getimage(PIMAGE imgDest, PCIMAGE imgSrc, int xSrc, int ySrc, int widthSrc, int heightSrc); /** * @brief Get image from image file (char* version) @@ -4094,12 +4145,13 @@ int EGEAPI getimage(PIMAGE imgDest, PCIMAGE imgSrc, int xSrc, int ySrc, int wid * @param imageFile Image file name * @param zoomWidth Set image scaling width, 0 means use original width, no scaling * @param zoomHeight Set image scaling height, 0 means use original height, no scaling - * @return Returns grOk(0) on success, corresponding error code on failure (grAllocError/grFileNotFound/grNullPointer/grIOerror) + * @return Returns grOk(0) on success, corresponding error code on failure + * (grAllocError/grFileNotFound/grNullPointer/grIOerror) * @note Supported formats: PNG, BMP, JPG, GIF, EMF, WMF, ICO * @note If image contains multiple frames, only get first frame * @see getimage(PIMAGE, const wchar_t*, int, int) */ -int EGEAPI getimage(PIMAGE imgDest, const char* imageFile, int zoomWidth = 0, int zoomHeight = 0); +int EGEAPI getimage(PIMAGE imgDest, const char* imageFile, int zoomWidth = 0, int zoomHeight = 0); /** * @brief Get image from image file (wchar_t* version) @@ -4107,12 +4159,13 @@ int EGEAPI getimage(PIMAGE imgDest, const char* imageFile, int zoomWidth = 0, * @param imageFile Image file name (wide character version) * @param zoomWidth Set image scaling width, 0 means use original width, no scaling * @param zoomHeight Set image scaling height, 0 means use original height, no scaling - * @return Returns grOk(0) on success, corresponding error code on failure (grAllocError/grFileNotFound/grNullPointer/grIOerror) + * @return Returns grOk(0) on success, corresponding error code on failure + * (grAllocError/grFileNotFound/grNullPointer/grIOerror) * @note Supported formats: PNG, BMP, JPG, GIF, EMF, WMF, ICO * @note If image contains multiple frames, only get first frame * @see getimage(PIMAGE, const char*, int, int) */ -int EGEAPI getimage(PIMAGE imgDest, const wchar_t* imageFile, int zoomWidth = 0, int zoomHeight = 0); +int EGEAPI getimage(PIMAGE imgDest, const wchar_t* imageFile, int zoomWidth = 0, int zoomHeight = 0); /** * @brief Get image from resource file (char* version) @@ -4121,12 +4174,13 @@ int EGEAPI getimage(PIMAGE imgDest, const wchar_t* imageFile, int zoomWidth = 0 * @param resName Resource name * @param zoomWidth Set image scaling width, 0 means use original width, no scaling * @param zoomHeight Set image scaling height, 0 means use original height, no scaling - * @return Returns grOk(0) on success, corresponding error code on failure (grAllocError/grFileNotFound/grNullPointer/grIOerror) + * @return Returns grOk(0) on success, corresponding error code on failure + * (grAllocError/grFileNotFound/grNullPointer/grIOerror) * @note Supported formats: PNG, BMP, JPG, GIF, EMF, WMF, ICO * @note If image contains multiple frames, only get first frame * @see getimage(PIMAGE, const wchar_t*, const wchar_t*, int, int) */ -int EGEAPI getimage(PIMAGE imgDest, const char* resType, const char* resName, int zoomWidth = 0, int zoomHeight = 0); +int EGEAPI getimage(PIMAGE imgDest, const char* resType, const char* resName, int zoomWidth = 0, int zoomHeight = 0); /** * @brief Get image from resource file (wchar_t* version) @@ -4135,12 +4189,14 @@ int EGEAPI getimage(PIMAGE imgDest, const char* resType, const char* resName, * @param resName Resource name (wide character version) * @param zoomWidth Set image scaling width, 0 means use original width, no scaling * @param zoomHeight Set image scaling height, 0 means use original height, no scaling - * @return Returns grOk(0) on success, corresponding error code on failure (grAllocError/grFileNotFound/grNullPointer/grIOerror) + * @return Returns grOk(0) on success, corresponding error code on failure + * (grAllocError/grFileNotFound/grNullPointer/grIOerror) * @note Supported formats: PNG, BMP, JPG, GIF, EMF, WMF, ICO * @note If image contains multiple frames, only get first frame * @see getimage(PIMAGE, const char*, const char*, int, int) */ -int EGEAPI getimage(PIMAGE imgDest, const wchar_t* resType, const wchar_t* resName, int zoomWidth = 0, int zoomHeight = 0); +int EGEAPI getimage( + PIMAGE imgDest, const wchar_t* resType, const wchar_t* resName, int zoomWidth = 0, int zoomHeight = 0); /** * @brief Get image from PNG image file (char* version) @@ -4152,7 +4208,7 @@ int EGEAPI getimage(PIMAGE imgDest, const wchar_t* resType, const wchar_t* resN * @warning Runtime exception will occur if pimg is invalid pointer * @see getimage_pngfile(PIMAGE, const wchar_t*) */ -int EGEAPI getimage_pngfile(PIMAGE pimg, const char* filename); +int EGEAPI getimage_pngfile(PIMAGE pimg, const char* filename); /** * @brief Get image from PNG image file (wchar_t* version) @@ -4164,7 +4220,7 @@ int EGEAPI getimage_pngfile(PIMAGE pimg, const char* filename); * @warning Runtime exception will occur if pimg is invalid pointer * @see getimage_pngfile(PIMAGE, const char*) */ -int EGEAPI getimage_pngfile(PIMAGE pimg, const wchar_t* filename); +int EGEAPI getimage_pngfile(PIMAGE pimg, const wchar_t* filename); //================================================================================== // putimage series functions - Core image drawing functionality of EGE graphics library @@ -4172,13 +4228,13 @@ int EGEAPI getimage_pngfile(PIMAGE pimg, const wchar_t* filename); /** * @defgroup putimage_functions putimage series functions * @brief Core image drawing functionality of EGE graphics library - * + * * putimage series functions provide rich image drawing and processing capabilities, including: * - Basic image drawing: putimage() series overloaded functions * - Transparency effects: putimage_transparent(), putimage_alphablend(), putimage_withalpha() * - Blending effects: putimage_alphatransparent(), putimage_alphafilter() * - Transform effects: putimage_rotate(), putimage_rotatezoom(), putimage_rotatetransparent() - * + * * These functions support multiple drawing modes: * - Draw to screen (imgDest = NULL) or another image * - Support region clipping, stretch scaling, rotation transformation @@ -4208,7 +4264,8 @@ void EGEAPI putimage(int x, int y, PCIMAGE pimg, DWORD dwRop = SRCCOPY); * @param ySrc Y coordinate of top-left corner of drawing content in source IMAGE object * @param dwRop Ternary raster operation code, default is SRCCOPY (direct copy) */ -void EGEAPI putimage(int xDest, int yDest, int widthDest, int heightDest, PCIMAGE imgSrc, int xSrc, int ySrc, DWORD dwRop = SRCCOPY); +void EGEAPI putimage( + int xDest, int yDest, int widthDest, int heightDest, PCIMAGE imgSrc, int xSrc, int ySrc, DWORD dwRop = SRCCOPY); /** * @brief Stretch image drawing function - Stretch source image region to target region @@ -4223,7 +4280,8 @@ void EGEAPI putimage(int xDest, int yDest, int widthDest, int heightDest, PCIMAG * @param heightSrc Height of drawing content in source IMAGE object * @param dwRop Ternary raster operation code, default is SRCCOPY (direct copy) */ -void EGEAPI putimage(int xDest, int yDest, int widthDest, int heightDest, PCIMAGE imgSrc, int xSrc, int ySrc, int widthSrc, int heightSrc, DWORD dwRop = SRCCOPY); +void EGEAPI putimage(int xDest, int yDest, int widthDest, int heightDest, PCIMAGE imgSrc, int xSrc, int ySrc, + int widthSrc, int heightSrc, DWORD dwRop = SRCCOPY); /** * @brief Image to image drawing function - Draw image on another image @@ -4247,7 +4305,8 @@ void EGEAPI putimage(PIMAGE imgDest, int xDest, int yDest, PCIMAGE imgSrc, DWORD * @param ySrc Y coordinate of top-left corner of drawing content in source IMAGE object * @param dwRop Ternary raster operation code, default is SRCCOPY (direct copy) */ -void EGEAPI putimage(PIMAGE imgDest, int xDest, int yDest, int widthDest, int heightDest, PCIMAGE imgSrc, int xSrc, int ySrc, DWORD dwRop = SRCCOPY); +void EGEAPI putimage(PIMAGE imgDest, int xDest, int yDest, int widthDest, int heightDest, PCIMAGE imgSrc, int xSrc, + int ySrc, DWORD dwRop = SRCCOPY); /** * @brief Image to image stretch drawing function - Stretch draw image on another image @@ -4263,7 +4322,8 @@ void EGEAPI putimage(PIMAGE imgDest, int xDest, int yDest, int widthDest, int he * @param heightSrc Height of drawing content in source IMAGE object * @param dwRop Ternary raster operation code, default is SRCCOPY (direct copy) */ -void EGEAPI putimage(PIMAGE imgDest, int xDest, int yDest, int widthDest, int heightDest, PCIMAGE imgSrc, int xSrc, int ySrc, int widthSrc, int heightSrc, DWORD dwRop = SRCCOPY); +void EGEAPI putimage(PIMAGE imgDest, int xDest, int yDest, int widthDest, int heightDest, PCIMAGE imgSrc, int xSrc, + int ySrc, int widthSrc, int heightSrc, DWORD dwRop = SRCCOPY); /** * @brief Save image to file (char* version) @@ -4277,7 +4337,7 @@ void EGEAPI putimage(PIMAGE imgDest, int xDest, int yDest, int widthDest, int he * @warning Runtime exception will occur if pimg is invalid pointer * @see saveimage(PCIMAGE, const wchar_t*, bool) */ -int EGEAPI saveimage(PCIMAGE pimg, const char* filename, bool withAlphaChannel = false); +int EGEAPI saveimage(PCIMAGE pimg, const char* filename, bool withAlphaChannel = false); /** * @brief Save image to file (wchar_t* version) @@ -4291,7 +4351,7 @@ int EGEAPI saveimage(PCIMAGE pimg, const char* filename, bool withAlphaChannel * @warning Runtime exception will occur if pimg is invalid pointer * @see saveimage(PCIMAGE, const char*, bool) */ -int EGEAPI saveimage(PCIMAGE pimg, const wchar_t* filename, bool withAlphaChannel = false); +int EGEAPI saveimage(PCIMAGE pimg, const wchar_t* filename, bool withAlphaChannel = false); /** * @brief Save image as PNG format to file (char* version) @@ -4304,7 +4364,7 @@ int EGEAPI saveimage(PCIMAGE pimg, const wchar_t* filename, bool withAlphaChann * @warning Runtime exception will occur if pimg is invalid pointer * @see savepng(PCIMAGE, const wchar_t*, bool) */ -int EGEAPI savepng (PCIMAGE pimg, const char* filename, bool withAlphaChannel = false); +int EGEAPI savepng(PCIMAGE pimg, const char* filename, bool withAlphaChannel = false); /** * @brief Save image as PNG format to file (wchar_t* version) @@ -4317,7 +4377,7 @@ int EGEAPI savepng (PCIMAGE pimg, const char* filename, bool withAlphaChannel * @warning Runtime exception will occur if pimg is invalid pointer * @see savepng(PCIMAGE, const char*, bool) */ -int EGEAPI savepng (PCIMAGE pimg, const wchar_t* filename, bool withAlphaChannel = false); +int EGEAPI savepng(PCIMAGE pimg, const wchar_t* filename, bool withAlphaChannel = false); /** * @brief Save image as BMP format to file (char* version) @@ -4330,7 +4390,7 @@ int EGEAPI savepng (PCIMAGE pimg, const wchar_t* filename, bool withAlphaChann * @warning Runtime exception will occur if pimg is invalid pointer * @see savebmp(PCIMAGE, const wchar_t*, bool) */ -int EGEAPI savebmp (PCIMAGE pimg, const char* filename, bool withAlphaChannel = false); +int EGEAPI savebmp(PCIMAGE pimg, const char* filename, bool withAlphaChannel = false); /** * @brief Save image as BMP format to file (wchar_t* version) @@ -4343,7 +4403,7 @@ int EGEAPI savebmp (PCIMAGE pimg, const char* filename, bool withAlphaChannel * @warning Runtime exception will occur if pimg is invalid pointer * @see savebmp(PCIMAGE, const char*, bool) */ -int EGEAPI savebmp (PCIMAGE pimg, const wchar_t* filename, bool withAlphaChannel = false); +int EGEAPI savebmp(PCIMAGE pimg, const wchar_t* filename, bool withAlphaChannel = false); /** * @brief Transparent color drawing function - Image drawing with specified color becoming transparent @@ -4358,16 +4418,15 @@ int EGEAPI savebmp (PCIMAGE pimg, const wchar_t* filename, bool withAlphaChann * @param heightSrc Height of drawing content in source IMAGE object, default is 0 (use entire image height) * @return Returns grOk on success, corresponding error code on failure */ -int EGEAPI putimage_transparent( - PIMAGE imgDest, // handle to dest - PCIMAGE imgSrc, // handle to source - int xDest, // x-coord of destination upper-left corner - int yDest, // y-coord of destination upper-left corner - color_t transparentColor, // color to make transparent - int xSrc = 0, // x-coord of source upper-left corner - int ySrc = 0, // y-coord of source upper-left corner - int widthSrc = 0, // width of source rectangle - int heightSrc = 0 // height of source rectangle +int EGEAPI putimage_transparent(PIMAGE imgDest, // handle to dest + PCIMAGE imgSrc, // handle to source + int xDest, // x-coord of destination upper-left corner + int yDest, // y-coord of destination upper-left corner + color_t transparentColor, // color to make transparent + int xSrc = 0, // x-coord of source upper-left corner + int ySrc = 0, // y-coord of source upper-left corner + int widthSrc = 0, // width of source rectangle + int heightSrc = 0 // height of source rectangle ); /** @@ -4380,14 +4439,8 @@ int EGEAPI putimage_transparent( * @param alphaType Alpha type of source image pixels, default is ALPHATYPE_STRAIGHT * @return Returns grOk on success, corresponding error code on failure */ -int EGEAPI putimage_alphablend( - PIMAGE imgDest, - PCIMAGE imgSrc, - int xDest, - int yDest, - unsigned char alpha, - alpha_type alphaType = ALPHATYPE_STRAIGHT -); +int EGEAPI putimage_alphablend(PIMAGE imgDest, PCIMAGE imgSrc, int xDest, int yDest, unsigned char alpha, + alpha_type alphaType = ALPHATYPE_STRAIGHT); /** * @brief Alpha blending drawing function - Specify source image starting position @@ -4401,16 +4454,8 @@ int EGEAPI putimage_alphablend( * @param alphaType Alpha type of source image pixels, default is ALPHATYPE_STRAIGHT * @return Returns grOk on success, corresponding error code on failure */ -int EGEAPI putimage_alphablend( - PIMAGE imgDest, - PCIMAGE imgSrc, - int xDest, - int yDest, - unsigned char alpha, - int xSrc, - int ySrc, - alpha_type alphaType = ALPHATYPE_STRAIGHT -); +int EGEAPI putimage_alphablend(PIMAGE imgDest, PCIMAGE imgSrc, int xDest, int yDest, unsigned char alpha, int xSrc, + int ySrc, alpha_type alphaType = ALPHATYPE_STRAIGHT); /** * @brief Alpha blending drawing function - Specify source image region @@ -4426,18 +4471,8 @@ int EGEAPI putimage_alphablend( * @param alphaType Alpha type of source image pixels, default is ALPHATYPE_STRAIGHT * @return Returns grOk on success, corresponding error code on failure */ -int EGEAPI putimage_alphablend( - PIMAGE imgDest, - PCIMAGE imgSrc, - int xDest, - int yDest, - unsigned char alpha, - int xSrc, - int ySrc, - int widthSrc, - int heightSrc, - alpha_type alphaType = ALPHATYPE_STRAIGHT -); +int EGEAPI putimage_alphablend(PIMAGE imgDest, PCIMAGE imgSrc, int xDest, int yDest, unsigned char alpha, int xSrc, + int ySrc, int widthSrc, int heightSrc, alpha_type alphaType = ALPHATYPE_STRAIGHT); /** * @brief Alpha blending drawing function - Complete version, supports stretching and smooth processing @@ -4456,21 +4491,9 @@ int EGEAPI putimage_alphablend( * @param alphaType Alpha type of source image pixels, default is ALPHATYPE_STRAIGHT * @return Returns grOk on success, corresponding error code on failure */ -int EGEAPI putimage_alphablend( - PIMAGE imgDest, - PCIMAGE imgSrc, - int xDest, - int yDest, - int widthDest, - int heightDest, - unsigned char alpha, - int xSrc, - int ySrc, - int widthSrc, - int heightSrc, - bool smooth = false, - alpha_type alphaType = ALPHATYPE_STRAIGHT -); +int EGEAPI putimage_alphablend(PIMAGE imgDest, PCIMAGE imgSrc, int xDest, int yDest, int widthDest, int heightDest, + unsigned char alpha, int xSrc, int ySrc, int widthSrc, int heightSrc, bool smooth = false, + alpha_type alphaType = ALPHATYPE_STRAIGHT); /** * @brief Alpha transparent color blending drawing function - Combine transparent color and Alpha blending @@ -4486,17 +4509,16 @@ int EGEAPI putimage_alphablend( * @param heightSrc Height of drawing content in source IMAGE object, default is 0 (use entire image height) * @return Returns grOk on success, corresponding error code on failure */ -int EGEAPI putimage_alphatransparent( - PIMAGE imgDest, // handle to dest - PCIMAGE imgSrc, // handle to source - int xDest, // x-coord of destination upper-left corner - int yDest, // y-coord of destination upper-left corner - color_t transparentColor, // color to make transparent - unsigned char alpha, // alpha - int xSrc = 0, // x-coord of source upper-left corner - int ySrc = 0, // y-coord of source upper-left corner - int widthSrc = 0, // width of source rectangle - int heightSrc = 0 // height of source rectangle +int EGEAPI putimage_alphatransparent(PIMAGE imgDest, // handle to dest + PCIMAGE imgSrc, // handle to source + int xDest, // x-coord of destination upper-left corner + int yDest, // y-coord of destination upper-left corner + color_t transparentColor, // color to make transparent + unsigned char alpha, // alpha + int xSrc = 0, // x-coord of source upper-left corner + int ySrc = 0, // y-coord of source upper-left corner + int widthSrc = 0, // width of source rectangle + int heightSrc = 0 // height of source rectangle ); /** @@ -4511,15 +4533,14 @@ int EGEAPI putimage_alphatransparent( * @param heightSrc Height of drawing content in source IMAGE object, default is 0 (use entire image height) * @return Returns grOk on success, corresponding error code on failure */ -int EGEAPI putimage_withalpha( - PIMAGE imgDest, // handle to dest - PCIMAGE imgSrc, // handle to source - int xDest, // x-coord of destination upper-left corner - int yDest, // y-coord of destination upper-left corner - int xSrc = 0, // x-coord of source upper-left corner - int ySrc = 0, // y-coord of source upper-left corner - int widthSrc = 0, // width of source rectangle - int heightSrc = 0 // height of source rectangle +int EGEAPI putimage_withalpha(PIMAGE imgDest, // handle to dest + PCIMAGE imgSrc, // handle to source + int xDest, // x-coord of destination upper-left corner + int yDest, // y-coord of destination upper-left corner + int xSrc = 0, // x-coord of source upper-left corner + int ySrc = 0, // y-coord of source upper-left corner + int widthSrc = 0, // width of source rectangle + int heightSrc = 0 // height of source rectangle ); /** @@ -4537,19 +4558,17 @@ int EGEAPI putimage_withalpha( * @param smooth Whether to use smooth processing (anti-aliasing), default is false * @return Returns grOk on success, corresponding error code on failure */ -int EGEAPI putimage_withalpha( - PIMAGE imgDest, // handle to dest - PCIMAGE imgSrc, // handle to source - int xDest, // x-coord of destination upper-left corner - int yDest, // y-coord of destination upper-left corner - int widthDest, // width of destination rectangle - int heightDest, // height of destination rectangle - int xSrc, // x-coord of source upper-left corner - int ySrc, // y-coord of source upper-left corner - int widthSrc, // width of source rectangle - int heightSrc, // height of source rectangle - bool smooth = false -); +int EGEAPI putimage_withalpha(PIMAGE imgDest, // handle to dest + PCIMAGE imgSrc, // handle to source + int xDest, // x-coord of destination upper-left corner + int yDest, // y-coord of destination upper-left corner + int widthDest, // width of destination rectangle + int heightDest, // height of destination rectangle + int xSrc, // x-coord of source upper-left corner + int ySrc, // y-coord of source upper-left corner + int widthSrc, // width of source rectangle + int heightSrc, // height of source rectangle + bool smooth = false); /** * @brief Alpha filter drawing function - Use another image as Alpha mask @@ -4564,16 +4583,15 @@ int EGEAPI putimage_withalpha( * @param heightSrc Height of drawing content in source IMAGE object * @return Returns grOk on success, corresponding error code on failure */ -int EGEAPI putimage_alphafilter( - PIMAGE imgDest, // handle to dest - PCIMAGE imgSrc, // handle to source - int xDest, // x-coord of destination upper-left corner - int yDest, // y-coord of destination upper-left corner - PCIMAGE imgAlpha, // handle to alpha - int xSrc, // x-coord of source upper-left corner - int ySrc, // y-coord of source upper-left corner - int widthSrc, // width of source rectangle - int heightSrc // height of source rectangle +int EGEAPI putimage_alphafilter(PIMAGE imgDest, // handle to dest + PCIMAGE imgSrc, // handle to source + int xDest, // x-coord of destination upper-left corner + int yDest, // y-coord of destination upper-left corner + PCIMAGE imgAlpha, // handle to alpha + int xSrc, // x-coord of source upper-left corner + int ySrc, // y-coord of source upper-left corner + int widthSrc, // width of source rectangle + int heightSrc // height of source rectangle ); /** @@ -4587,15 +4605,8 @@ int EGEAPI putimage_alphafilter( * @param heightDest Height of processing region, default is 0 (use entire image height) * @return Returns grOk on success, corresponding error code on failure */ -int EGEAPI imagefilter_blurring ( - PIMAGE imgDest, - int intensity, - int alpha, - int xDest = 0, - int yDest = 0, - int widthDest = 0, - int heightDest = 0 -); +int EGEAPI imagefilter_blurring( + PIMAGE imgDest, int intensity, int alpha, int xDest = 0, int yDest = 0, int widthDest = 0, int heightDest = 0); /** * @brief Rotation drawing function - Rotate image around center point @@ -4611,18 +4622,11 @@ int EGEAPI imagefilter_blurring ( * @param smooth Whether to use smooth processing (anti-aliasing), default is false * @return Returns grOk on success, corresponding error code on failure */ -int EGEAPI putimage_rotate( - PIMAGE imgDest, - PCIMAGE imgTexture, - int xDest, - int yDest, - float xCenter, - float yCenter, +int EGEAPI putimage_rotate(PIMAGE imgDest, PCIMAGE imgTexture, int xDest, int yDest, float xCenter, float yCenter, float radian, - bool transparent = false, // use the transparent channel of the image - int alpha = -1, // in range[0, 256], alpha== -1 means no alpha - bool smooth = false -); + bool transparent = false, // use the transparent channel of the image + int alpha = -1, // in range[0, 256], alpha== -1 means no alpha + bool smooth = false); /** * @brief Rotation and zoom drawing function - Perform rotation and scaling simultaneously @@ -4639,19 +4643,11 @@ int EGEAPI putimage_rotate( * @param smooth Whether to use smooth processing (anti-aliasing), default is false * @return Returns grOk on success, corresponding error code on failure */ -int EGEAPI putimage_rotatezoom( - PIMAGE imgDest, - PCIMAGE imgTexture, - int xDest, - int yDest, - float xCenter, - float yCenter, - float radian, - float zoom, - bool transparent = false, // use the transparent channel of the image - int alpha = -1, // in range[0, 256], alpha== -1 means no alpha - bool smooth = false -); +int EGEAPI putimage_rotatezoom(PIMAGE imgDest, PCIMAGE imgTexture, int xDest, int yDest, float xCenter, float yCenter, + float radian, float zoom, + bool transparent = false, // use the transparent channel of the image + int alpha = -1, // in range[0, 256], alpha== -1 means no alpha + bool smooth = false); /** * @brief Rotation transparent drawing function - Specify transparent color when rotating, basic version @@ -4666,16 +4662,15 @@ int EGEAPI putimage_rotatezoom( * @param zoom Scaling ratio, 1.0 is original size, default is 1.0f * @return Returns grOk on success, corresponding error code on failure */ -int EGEAPI putimage_rotatetransparent( - PIMAGE imgDest, /* handle to dest, NULL means the SCREEN */ - PCIMAGE imgSrc, /* handle to source */ - int xCenterDest, /* x-coord of rotation center in dest */ - int yCenterDest, /* y-coord of rotation center in dest */ - int xCenterSrc, /* x-coord of rotation center in source */ - int yCenterSrc, /* y-coord of rotation center in source */ - color_t transparentColor, /* color to make transparent */ - float radian, /* rotation angle (clockwise, in radian) */ - float zoom = 1.0f /* zoom factor */ +int EGEAPI putimage_rotatetransparent(PIMAGE imgDest, /* handle to dest, NULL means the SCREEN */ + PCIMAGE imgSrc, /* handle to source */ + int xCenterDest, /* x-coord of rotation center in dest */ + int yCenterDest, /* y-coord of rotation center in dest */ + int xCenterSrc, /* x-coord of rotation center in source */ + int yCenterSrc, /* y-coord of rotation center in source */ + color_t transparentColor, /* color to make transparent */ + float radian, /* rotation angle (clockwise, in radian) */ + float zoom = 1.0f /* zoom factor */ ); /** @@ -4695,20 +4690,19 @@ int EGEAPI putimage_rotatetransparent( * @param zoom Scaling ratio, 1.0 is original size, default is 1.0f * @return Returns grOk on success, corresponding error code on failure */ -int EGEAPI putimage_rotatetransparent( - PIMAGE imgDest, /* handle to dest, NULL means the SCREEN */ - PCIMAGE imgSrc, /* handle to source */ - int xCenterDest, /* x-coord of rotation center in dest */ - int yCenterDest, /* y-coord of rotation center in dest */ - int xSrc, /* x-coord of source upper-left corner */ - int ySrc, /* y-coord of source upper-left corner */ - int widthSrc, /* width of source rectangle */ - int heightSrc, /* height of source rectangle */ - int xCenterSrc, /* x-coord of rotation center in source */ - int yCenterSrc, /* y-coord of rotation center in source */ - color_t transparentColor, /* color to make transparent */ - float radian, /* rotation angle (clockwise, in radian) */ - float zoom = 1.0f /* zoom factor */ +int EGEAPI putimage_rotatetransparent(PIMAGE imgDest, /* handle to dest, NULL means the SCREEN */ + PCIMAGE imgSrc, /* handle to source */ + int xCenterDest, /* x-coord of rotation center in dest */ + int yCenterDest, /* y-coord of rotation center in dest */ + int xSrc, /* x-coord of source upper-left corner */ + int ySrc, /* y-coord of source upper-left corner */ + int widthSrc, /* width of source rectangle */ + int heightSrc, /* height of source rectangle */ + int xCenterSrc, /* x-coord of rotation center in source */ + int yCenterSrc, /* y-coord of rotation center in source */ + color_t transparentColor, /* color to make transparent */ + float radian, /* rotation angle (clockwise, in radian) */ + float zoom = 1.0f /* zoom factor */ ); /** @} */ // End putimage_functions group @@ -4719,7 +4713,7 @@ int EGEAPI putimage_rotatetransparent( * @note Returns Windows system window handle, can be used for Windows API calls * @see getHInstance(), getHDC() */ -HWND EGEAPI getHWnd(); +HWND EGEAPI getHWnd(); /** * @brief Get drawing window instance handle @@ -4727,7 +4721,7 @@ HWND EGEAPI getHWnd(); * @note Returns Windows system application instance handle, can be used for Windows API calls * @see getHWnd(), getHDC() */ -HINSTANCE EGEAPI getHInstance(); +HINSTANCE EGEAPI getHInstance(); /** * @brief Get drawing device context @@ -4737,21 +4731,21 @@ HINSTANCE EGEAPI getHInstance(); * @warning Do not manually release returned HDC, managed automatically by EGE library * @see getHWnd(), getHInstance() */ -HDC EGEAPI getHDC(PCIMAGE pimg = NULL); +HDC EGEAPI getHDC(PCIMAGE pimg = NULL); /** * @brief Get process function pointer * @return Process function pointer * @note Internal use function, used to get window procedure function pointer */ -PVOID EGEAPI getProcfunc(); +PVOID EGEAPI getProcfunc(); /** * @brief Get EGE graphics library version number * @return EGE graphics library version number * @note Version number is in numeric format, can be used for compatibility checks */ -long EGEAPI getGraphicsVer(); +long EGEAPI getGraphicsVer(); /** * @brief Get current frame rate @@ -4759,7 +4753,7 @@ long EGEAPI getGraphicsVer(); * @note Returns frames per second, used for performance monitoring and debugging * @see delay_fps() */ -float EGEAPI getfps(); +float EGEAPI getfps(); /** * @brief Initialize random number generator (using current time as seed) @@ -4767,7 +4761,7 @@ float EGEAPI getfps(); * @note Uses current timestamp as seed to initialize Mersenne Twister random number generator * @see randomize(unsigned int seed), random(), randomf() */ -unsigned int EGEAPI randomize(); +unsigned int EGEAPI randomize(); /** * @brief Initialize random number generator (using specified seed) @@ -4776,7 +4770,7 @@ unsigned int EGEAPI randomize(); * @note Uses specified seed to initialize Mersenne Twister random number generator, same seed produces same sequence * @see randomize(), random(), randomf() */ -unsigned int EGEAPI randomize(unsigned int seed); +unsigned int EGEAPI randomize(unsigned int seed); /** * @brief Generate random integer @@ -4785,7 +4779,7 @@ unsigned int EGEAPI randomize(unsigned int seed); * @note Uses Mersenne Twister algorithm to generate high-quality random numbers * @see randomize(), randomf() */ -unsigned int EGEAPI random(unsigned int n = 0); +unsigned int EGEAPI random(unsigned int n = 0); /** * @brief Generate random floating point number @@ -4793,7 +4787,7 @@ unsigned int EGEAPI random(unsigned int n = 0); * @note Uses Mersenne Twister algorithm to generate high-quality random floating point numbers * @see randomize(), random() */ -double EGEAPI randomf(); +double EGEAPI randomf(); /** * @brief Show input dialog to get single line text (ASCII version) @@ -4806,7 +4800,7 @@ double EGEAPI randomf(); * @warning Ensure buffer is large enough to avoid overflow * @see inputbox_getline(const wchar_t*, const wchar_t*, LPWSTR, int) */ -int EGEAPI inputbox_getline(const char* title, const char* text, LPSTR buf, int len); +int EGEAPI inputbox_getline(const char* title, const char* text, LPSTR buf, int len); /** * @brief Show input dialog to get single line text (Unicode version) @@ -4821,8 +4815,6 @@ int EGEAPI inputbox_getline(const char* title, const char* text, LPSTR buf, i */ int EGEAPI inputbox_getline(const wchar_t* title, const wchar_t* text, LPWSTR buf, int len); - - /// @defgroup InputHandling Input handling /// Keyboard and mouse input handling related functions /// @{ @@ -4837,7 +4829,7 @@ int EGEAPI inputbox_getline(const wchar_t* title, const wchar_t* text, LPWSTR bu * @note Used for non-blocking detection of keyboard input, typically used with getkey() in main loop * @see getkey() */ -int EGEAPI kbmsg(); +int EGEAPI kbmsg(); /** * @brief Get keyboard message @@ -4856,7 +4848,7 @@ key_msg EGEAPI getkey(); * @see getch() */ EGE_DEPRECATE(getchEx, "Please use the 'getch' function instead.") -int EGEAPI getchEx(int flag); +int EGEAPI getchEx(int flag); /** * @brief Check if there are currently keyboard character inputs (extended version) @@ -4867,7 +4859,7 @@ int EGEAPI getchEx(int flag); * @see kbhit() */ EGE_DEPRECATE(kbhitEx, "Please use the 'kbhit' function instead.") -int EGEAPI kbhitEx(int flag); +int EGEAPI kbhitEx(int flag); /** * @brief Determine if a certain key on keyboard or mouse is in pressed state @@ -4876,18 +4868,17 @@ int EGEAPI kbhitEx(int flag); * @note Real-time key state detection, does not consume message queue; supports keyboard and mouse keys * @see key_code_e */ -bool EGEAPI keystate(int key); -int EGEAPI keypress(int key); -int EGEAPI keyrelease(int key); -int EGEAPI keyrepeat(int key); - +bool EGEAPI keystate(int key); +int EGEAPI keypress(int key); +int EGEAPI keyrelease(int key); +int EGEAPI keyrepeat(int key); /** * @brief Clear key message buffer * @note Clears all unprocessed keyboard messages, commonly used to ignore cached key inputs * @see flushmouse() */ -void EGEAPI flushkey(); +void EGEAPI flushkey(); /// @} // KeyboardInput @@ -4901,7 +4892,7 @@ void EGEAPI flushkey(); * @note EGE internal implementation, used to avoid conflicts with conio.h library * @see getch() */ -int EGEAPI ege_getch(); +int EGEAPI ege_getch(); /** * @brief Check if there are currently keyboard character inputs (EGE internal version) @@ -4909,7 +4900,7 @@ int EGEAPI ege_getch(); * @note EGE internal implementation, used to avoid conflicts with conio.h library * @see kbhit() */ -int EGEAPI ege_kbhit(); +int EGEAPI ege_kbhit(); #if !defined(_INC_CONIO) && !defined(_CONIO_H_) #define _INC_CONIO @@ -4921,7 +4912,7 @@ int EGEAPI ege_kbhit(); * @note If there is no character input currently, it waits; equivalent to ege_getch() * @see ege_getch(), kbhit() */ -int EGEAPI getch(); // Same as ege_getch() +int EGEAPI getch(); // Same as ege_getch() /** * @brief Check if there are currently keyboard character inputs @@ -4929,7 +4920,7 @@ int EGEAPI getch(); // Same as ege_getch() * @note Used for non-blocking detection of character input, usually used with getch; equivalent to ege_kbhit() * @see ege_kbhit(), getch() */ -int EGEAPI kbhit(); // Same as ege_kbhit() +int EGEAPI kbhit(); // Same as ege_kbhit() #else #define getch ege_getch #define kbhit ege_kbhit @@ -4947,7 +4938,7 @@ int EGEAPI kbhit(); // Same as ege_kbhit() * @note Used for non-blocking detection of mouse input, usually used with getmouse * @see getmouse() */ -int EGEAPI mousemsg(); +int EGEAPI mousemsg(); /** * @brief Get a mouse message @@ -4955,7 +4946,7 @@ int EGEAPI mousemsg(); * @note If current mouse message queue is empty, it waits until new message is generated * @see mousemsg(), mouse_msg, mouse_msg_e, mouse_flag_e */ -mouse_msg EGEAPI getmouse(); +mouse_msg EGEAPI getmouse(); /** * @brief Get a mouse message (deprecated function) @@ -4965,14 +4956,14 @@ mouse_msg EGEAPI getmouse(); * @see getmouse() */ EGE_DEPRECATE(GetMouseMsg, "Please use the 'getmouse' function instead.") -MOUSEMSG EGEAPI GetMouseMsg(); +MOUSEMSG EGEAPI GetMouseMsg(); /** * @brief Clear mouse message buffer * @note Clears all unprocessed mouse messages, commonly used to ignore cached mouse inputs * @see flushkey() */ -void EGEAPI flushmouse(); +void EGEAPI flushmouse(); /** * @brief Set whether mouse pointer is displayed @@ -4980,7 +4971,7 @@ void EGEAPI flushmouse(); * @return Previous display state * @note Used to control mouse cursor visibility in graphics window */ -int EGEAPI showmouse(int bShow); +int EGEAPI showmouse(int bShow); /** * @brief Get current mouse position coordinates @@ -4990,7 +4981,7 @@ int EGEAPI showmouse(int bShow); * @note Gets real-time mouse coordinate position in graphics window * @see keystate() */ -int EGEAPI mousepos(int *x, int *y); +int EGEAPI mousepos(int* x, int* y); /// @} // MouseInput /// @} // InputHandling @@ -5002,24 +4993,24 @@ msg: see 'enum message_event' key: keycode return zero means process this message, otherwise means pass it and then process with 'getkey' function */ -//int message_addkeyhandler(void* param, LPMSG_KEY_PROC func); +// int message_addkeyhandler(void* param, LPMSG_KEY_PROC func); /* callback function define as: int __stdcall on_msg_mouse(void* param, unsigned msg, int key, int x, int y); msg: see 'enum message_event' -key: see 'enum message_mouse', if msg==MSG_EVENT_WHELL, key is a int number that indicates the distance the wheel is rotated, expressed in multiples or divisions of WHEEL_DELTA, which is 120. -x,y: current mouse (x, y) -return zero means process this message, otherwise means pass it and then process with 'GetMouseMsg' function +key: see 'enum message_mouse', if msg==MSG_EVENT_WHELL, key is a int number that indicates the distance the wheel is +rotated, expressed in multiples or divisions of WHEEL_DELTA, which is 120. x,y: current mouse (x, y) return zero means +process this message, otherwise means pass it and then process with 'GetMouseMsg' function */ -//int message_addmousehandler(void* param, LPMSG_MOUSE_PROC func); +// int message_addmousehandler(void* param, LPMSG_MOUSE_PROC func); int EGEAPI SetCloseHandler(LPCALLBACK_PROC func); /** * @brief Music playback class - * + * * MUSIC class provides music playback functionality based on Windows Media Control Interface (MCI), * supports playing various audio formats such as WAV, MP3, MIDI, etc. - * + * * @note This class is based on Windows MCI implementation, only supports Windows platform * @note Supported audio formats include: WAV, MP3, MIDI, etc. * @see music_state_flag, MUSIC_ERROR @@ -5032,7 +5023,7 @@ class MUSIC * @note Initializes music player, sets initial state to not opened */ MUSIC(); - + /** * @brief Destructor * @note Automatically closes opened music file and cleans up resources @@ -5063,7 +5054,7 @@ class MUSIC * @see OpenFile(const wchar_t*), Close() */ DWORD OpenFile(const char* filepath); - + /** * @brief Open music file (Unicode version) * @param filepath Music file path (including filename) @@ -5073,7 +5064,7 @@ class MUSIC * @see OpenFile(const char*), Close() */ DWORD OpenFile(const wchar_t* filepath); - + /** * @brief Play music * @param dwFrom Start position for playback (milliseconds), default is MUSIC_ERROR (continue playing) @@ -5084,7 +5075,7 @@ class MUSIC * @see Pause(), Stop(), RepeatPlay() */ DWORD Play(DWORD dwFrom = MUSIC_ERROR, DWORD dwTo = MUSIC_ERROR); - + /** * @brief Loop play music * @param dwFrom Start position for playback (milliseconds), default is MUSIC_ERROR @@ -5094,7 +5085,7 @@ class MUSIC * @see Play(), Pause(), Stop() */ DWORD RepeatPlay(DWORD dwFrom = MUSIC_ERROR, DWORD dwTo = MUSIC_ERROR); - + /** * @brief Pause playback * @return Returns 0 on success, non-zero on failure @@ -5102,7 +5093,7 @@ class MUSIC * @see Play(), Stop() */ DWORD Pause(); - + /** * @brief Seek to playback position * @param dwTo Target playback position (milliseconds) @@ -5112,7 +5103,7 @@ class MUSIC * @see Play() */ DWORD Seek(DWORD dwTo); - + /** * @brief Set playback volume * @param value Volume level, range 0.0~1.0 @@ -5120,7 +5111,7 @@ class MUSIC * @note 0.0 is mute, 1.0 is maximum volume */ DWORD SetVolume(float value); - + /** * @brief Close music file * @return Returns 0 on success, non-zero on failure @@ -5128,7 +5119,7 @@ class MUSIC * @see OpenFile() */ DWORD Close(); - + /** * @brief Stop playback * @return Returns 0 on success, non-zero on failure @@ -5136,7 +5127,7 @@ class MUSIC * @see Play(), Pause() */ DWORD Stop(); - + /** * @brief Get current playback position * @return Current playback position (milliseconds) @@ -5144,7 +5135,7 @@ class MUSIC * @see GetLength(), GetPlayStatus() */ DWORD GetPosition(); - + /** * @brief Get total music duration * @return Total music duration (milliseconds) @@ -5173,29 +5164,29 @@ class MUSIC PVOID m_dwCallBack; ///< Callback handle }; -int EGEAPI ege_compress (void *dest, unsigned long *destLen, const void *source, unsigned long sourceLen); -int EGEAPI ege_compress2 (void *dest, unsigned long *destLen, const void *source, unsigned long sourceLen, int level); -int EGEAPI ege_uncompress(void *dest, unsigned long *destLen, const void *source, unsigned long sourceLen); -unsigned long EGEAPI ege_uncompress_size(const void *source, unsigned long sourceLen); +int EGEAPI ege_compress(void* dest, unsigned long* destLen, const void* source, unsigned long sourceLen); +int EGEAPI ege_compress2(void* dest, unsigned long* destLen, const void* source, unsigned long sourceLen, int level); +int EGEAPI ege_uncompress(void* dest, unsigned long* destLen, const void* source, unsigned long sourceLen); +unsigned long EGEAPI ege_uncompress_size(const void* source, unsigned long sourceLen); -} +} // namespace ege #ifndef EGE_GRAPH_LIB_BUILD - #if defined(_MSC_VER) && (defined(HIDE_CONSOLE) || !defined(SHOW_CONSOLE)) - #pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" ) - #endif +#if defined(_MSC_VER) && (defined(HIDE_CONSOLE) || !defined(SHOW_CONSOLE)) +#pragma comment(linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"") +#endif - #define Sleep(ms) delay_ms(ms) +#define Sleep(ms) delay_ms(ms) #endif #if !defined(_MSC_VER) - #define WinMain(...) WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) +#define WinMain(...) WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) #elif defined(_CONSOLE) - #if (_MSC_VER > 1200) - #define WinMain(...) main(int argc, char* argv[]) - #else - #define WinMain main - #endif +#if (_MSC_VER > 1200) +#define WinMain(...) main(int argc, char* argv[]) +#else +#define WinMain main +#endif #endif #endif diff --git a/include/ege/stdint.h b/include/ege/stdint.h index 13dceee6..2d35b26f 100644 --- a/include/ege/stdint.h +++ b/include/ege/stdint.h @@ -26,10 +26,10 @@ #ifndef _STDINT_HEADER_NOT_SUPPORT #if defined(_MSC_VER) && (_MSC_VER < 1600) #define _STDINT_HEADER_NOT_SUPPORT -#elif defined(__GNUC__) && ((__GNUC__ < 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ < 5))) +#elif defined(__GNUC__) && ((__GNUC__ < 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ < 5))) #define _STDINT_HEADER_NOT_SUPPORT #else - /* Other compilers always assume support for . */ +/* Other compilers always assume support for . */ #endif #endif @@ -48,7 +48,7 @@ #else /* Avoid duplication with definitions in other stdint.h header files */ -#if !definded(_STDINT) && !defined(_GCC_STDINT_H) +#if !defined(_STDINT) && !defined(_GCC_STDINT_H) #if defined(_MSC_VER) #define _STDINT #elif defined(__GNUC__) @@ -69,7 +69,7 @@ #ifndef __GNUC_EXTENSION__ #if defined(__GNUC__) -#define __GNUC_EXTENSION__ __extension__ +#define __GNUC_EXTENSION__ __extension__ #else #define __GNUC_EXTENSION__ #endif @@ -81,22 +81,22 @@ #endif /* 7.18.1.1 Exact-width integer types */ -typedef signed char int8_t; -typedef unsigned char uint8_t; -typedef short int16_t; -typedef unsigned short uint16_t; -typedef int int32_t; -typedef unsigned uint32_t; +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef short int16_t; +typedef unsigned short uint16_t; +typedef int int32_t; +typedef unsigned uint32_t; __GNUC_EXTENSION__ typedef _LONGLONG int64_t; __GNUC_EXTENSION__ typedef unsigned _LONGLONG uint64_t; /* 7.18.1.2 Minimum-width integer types */ -typedef signed char int_least8_t; -typedef unsigned char uint_least8_t; -typedef short int_least16_t; -typedef unsigned short uint_least16_t; -typedef int int_least32_t; -typedef unsigned uint_least32_t; +typedef signed char int_least8_t; +typedef unsigned char uint_least8_t; +typedef short int_least16_t; +typedef unsigned short uint_least16_t; +typedef int int_least32_t; +typedef unsigned uint_least32_t; __GNUC_EXTENSION__ typedef _LONGLONG int_least64_t; __GNUC_EXTENSION__ typedef unsigned _LONGLONG uint_least64_t; @@ -104,12 +104,12 @@ __GNUC_EXTENSION__ typedef unsigned _LONGLONG uint_least64_t; * Not actually guaranteed to be fastest for all purposes * Here we use the exact-width types for 8 and 16-bit ints. */ -typedef char int_fast8_t; -typedef unsigned char uint_fast8_t; -typedef short int_fast16_t; -typedef unsigned short uint_fast16_t; -typedef int int_fast32_t; -typedef unsigned int uint_fast32_t; +typedef char int_fast8_t; +typedef unsigned char uint_fast8_t; +typedef short int_fast16_t; +typedef unsigned short uint_fast16_t; +typedef int int_fast32_t; +typedef unsigned int uint_fast32_t; __GNUC_EXTENSION__ typedef _LONGLONG int_fast64_t; __GNUC_EXTENSION__ typedef unsigned _LONGLONG uint_fast64_t; @@ -154,10 +154,10 @@ __GNUC_EXTENSION__ typedef unsigned _LONGLONG uintmax_t; #define INT32_MAX 2147483647 #define INT64_MAX 9223372036854775807LL -#define UINT8_MAX 0xff /* 255U */ -#define UINT16_MAX 0xffff /* 65535U */ -#define UINT32_MAX 0xffffffff /* 4294967295U */ -#define UINT64_MAX 0xffffffffffffffffULL /* 18446744073709551615ULL */ +#define UINT8_MAX 0xff /* 255U */ +#define UINT16_MAX 0xffff /* 65535U */ +#define UINT32_MAX 0xffffffff /* 4294967295U */ +#define UINT64_MAX 0xffffffffffffffffULL /* 18446744073709551615ULL */ /* 7.18.2.2 Limits of minimum-width integer types */ #define INT_LEAST8_MIN INT8_MIN @@ -176,10 +176,10 @@ __GNUC_EXTENSION__ typedef unsigned _LONGLONG uintmax_t; #define UINT_LEAST64_MAX UINT64_MAX /* 7.18.2.3 Limits of fastest minimum-width integer types */ -#define INT_FAST8_MIN INT8_MIN -#define INT_FAST16_MIN INT16_MIN -#define INT_FAST32_MIN INT32_MIN -#define INT_FAST64_MIN INT64_MIN +#define INT_FAST8_MIN INT8_MIN +#define INT_FAST16_MIN INT16_MIN +#define INT_FAST32_MIN INT32_MIN +#define INT_FAST64_MIN INT64_MIN #define INT_FAST8_MAX INT8_MAX #define INT_FAST16_MAX INT16_MAX @@ -203,7 +203,7 @@ __GNUC_EXTENSION__ typedef unsigned _LONGLONG uintmax_t; #define UINTPTR_MAX UINT32_MAX #endif - /* 7.18.2.5 Limits of greatest-width integer types */ +/* 7.18.2.5 Limits of greatest-width integer types */ #define INTMAX_MIN INT64_MIN #define INTMAX_MAX INT64_MAX #define UINTMAX_MAX UINT64_MAX @@ -230,7 +230,7 @@ __GNUC_EXTENSION__ typedef unsigned _LONGLONG uintmax_t; #endif /* !defined ( __cplusplus) || defined __STDC_LIMIT_MACROS */ - /* 7.18.4 Macros for integer constants */ +/* 7.18.4 Macros for integer constants */ #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) /* 7.18.4.1 Macros for minimum-width integer constants @@ -246,15 +246,15 @@ __GNUC_EXTENSION__ typedef unsigned _LONGLONG uintmax_t; *expression* with *promoted* type." */ -#define INT8_C(val) ((int8_t) + (val)) -#define UINT8_C(val) ((uint8_t) + (val##U)) -#define INT16_C(val) ((int16_t) + (val)) -#define UINT16_C(val) ((uint16_t) + (val##U)) +#define INT8_C(val) ((int8_t)+(val)) +#define UINT8_C(val) ((uint8_t)+(val##U)) +#define INT16_C(val) ((int16_t)+(val)) +#define UINT16_C(val) ((uint16_t)+(val##U)) -#define INT32_C(val) val##L -#define UINT32_C(val) val##UL -#define INT64_C(val) val##LL -#define UINT64_C(val) val##ULL +#define INT32_C(val) val##L +#define UINT32_C(val) val##UL +#define INT64_C(val) val##LL +#define UINT64_C(val) val##ULL /* 7.18.4.2 Macros for greatest-width integer constants */ #define INTMAX_C(val) INT64_C(val) diff --git a/src/array.h b/src/array.h index 3ca406a7..63f36ad0 100644 --- a/src/array.h +++ b/src/array.h @@ -1,5 +1,6 @@ #pragma once +#include #include namespace ege @@ -8,14 +9,14 @@ namespace ege template class Array { public: - typedef T* iterator; + using iterator = T*; class reverse_iterator { public: - reverse_iterator(iterator it) { _it = it; } + reverse_iterator(iterator it) : _it{it} {} - reverse_iterator(const reverse_iterator& rit) { _it = rit._it; } + reverse_iterator(const reverse_iterator& rit) : _it{rit._it} {} reverse_iterator& operator++() { @@ -40,19 +41,10 @@ template class Array }; public: - Array() - { - m_capacity = 0; - m_size = 0; - m_arr = NULL; - } + Array() : m_capacity{0}, m_size{0}, m_arr{nullptr} {} - Array(const Array& arr) + Array(const Array& arr) : m_capacity{arr.m_capacity}, m_size{arr.m_size}, m_arr{new T[m_size]} { - m_capacity = arr.m_capacity; - m_size = arr.m_size; - m_arr = new T[m_size]; - for (size_t i = 0; i < m_size; ++i) { m_arr[i] = arr.m_arr[i]; } @@ -61,14 +53,14 @@ template class Array ~Array() { if (m_arr) { - delete m_arr; + delete[] m_arr; m_arr = NULL; } } void resize(size_t sz, T c = T()) { - if (m_arr == NULL) { + if (m_arr == nullptr) { m_arr = new T[sz]; for (size_t i = 0; i < sz; ++i) { m_arr[i] = c; @@ -162,4 +154,4 @@ template class Array T* m_arr; }; -} +} // namespace ege diff --git a/src/color.cpp b/src/color.cpp index 4374a878..bec29464 100644 --- a/src/color.cpp +++ b/src/color.cpp @@ -23,18 +23,18 @@ static COLORHSL EGE_PRIVATE_RGBtoHSL(int _col) g = EGEGET_G(_col) / 255.0f; r = EGEGET_R(_col) / 255.0f; -#define IFSWAP(a, b) \ - if (*a > *b) { \ - t = a; \ - a = b; \ - b = t; \ - } { - IFSWAP(dp[0], dp[1]); - IFSWAP(dp[1], dp[2]); - IFSWAP(dp[0], dp[1]); + auto ifswap = [](float* a, float* b) { + if (*a > *b) { + float t = *a; + *a = *b; + *b = t; + } + }; + ifswap(dp[0], dp[1]); + ifswap(dp[1], dp[2]); + ifswap(dp[0], dp[1]); } -#undef IFSWAP { _crCol.l = (*dp[0] + *dp[2]) / 2; @@ -54,27 +54,27 @@ static COLORHSL EGE_PRIVATE_RGBtoHSL(int _col) _crCol.l = 0.5; } } -#define BLACKUNFORMAT(c, v) ((c) / ((v) * 2)) -#define WHITEUNFORMAT(c, v) (1 - (1 - c) / ((1 - (v)) * 2)) + if (_crCol.l == 0.5) { ; } else if (_crCol.l < 0.5) { + auto blackunformat = [](float c, float v) -> float { return c / ((v) * 2); }; for (int n = 0; n < 3; ++n) { - *dp[n] = BLACKUNFORMAT(*dp[n], _crCol.l); + *dp[n] = blackunformat(*dp[n], _crCol.l); if (*dp[n] > 1) { *dp[n] = 1; } } } else { + auto whiteunformat = [](float c, float v) -> float { return 1 - (1 - c) / ((1 - (v)) * 2); }; for (int n = 0; n < 3; ++n) { - *dp[n] = WHITEUNFORMAT(*dp[n], _crCol.l); + *dp[n] = whiteunformat(*dp[n], _crCol.l); if (*dp[n] > 1) { *dp[n] = 1; } } } -#undef BLACKUNFORMAT -#undef WHITEUNFORMAT + { _crCol.s = *dp[2] * 2 - 1; if (_crCol.s < 1e-2) { @@ -82,16 +82,17 @@ static COLORHSL EGE_PRIVATE_RGBtoHSL(int _col) return _crCol; } } -#define SATUNFORMAT(c, s) (((c)-0.5f) / (s) + 0.5f) + { + auto satunformat = [](float c, float s) -> float { return (c - 0.5f) / s + 0.5f; }; for (int n = 0; n < 3; ++n) { - *dp[n] = SATUNFORMAT(*dp[n], _crCol.s); + *dp[n] = satunformat(*dp[n], _crCol.s); if (*dp[n] > 1) { *dp[n] = 1; } } } -#undef SATUNFORMAT + { _crCol.h = *dp[1]; if ((dp[2] == &r) && (dp[1] == &g)) { @@ -142,32 +143,32 @@ static int EGE_PRIVATE_HSLtoRGB(float _h, float _s, float _l) } else { dp[1] = xh; } -#define SATFORMAT(c, s) (((c)-0.5f) * (s) + 0.5f) + + auto satformat = [](float c, float s) { return (c - 0.5f) * s + 0.5f; }; for (n = 0; n < 3; ++n) { - dp[n] = SATFORMAT(dp[n], _s); + dp[n] = satformat(dp[n], _s); } -#undef SATFORMAT -#define BLACKFORMAT(c, v) ((c) * (v) * 2) -#define WHITEFORMAT(c, v) (1 - (1 - (c)) * (1 - (v)) * 2) + if (_l == 0.5f) { ; } else if (_l < 0.5f) { + auto blackformat = [](float c, float v) { return c * v * 2; }; if (_l < 0) { _l = 0; } for (n = 0; n < 3; ++n) { - dp[n] = BLACKFORMAT(dp[n], _l); + dp[n] = blackformat(dp[n], _l); } } else { + auto whiteformat = [](float c, float v) { return 1 - (1 - c) * (1 - v) * 2; }; if (_l > 1) { _l = 1; } for (n = 0; n < 3; ++n) { - dp[n] = WHITEFORMAT(dp[n], _l); + dp[n] = whiteformat(dp[n], _l); } } -#undef BLACKFORMAT -#undef WHITEFORMAT + { if (i == 0) { r = dp[0]; @@ -208,8 +209,8 @@ static void RGB_TO_HSV(const COLORRGB* input, COLORHSV* output) g = input->g / 255.0f; b = input->b / 255.0f; - minRGB = MIN(r, MIN(g, b)); - maxRGB = MAX(r, MAX(g, b)); + minRGB = min(r, g, b); + maxRGB = max(r, g, b); deltaRGB = maxRGB - minRGB; output->v = maxRGB; @@ -379,10 +380,10 @@ color_t alphablend_premultiplied(color_t dst, color_t src) color_t alphablend_premultiplied(color_t dst, color_t src, unsigned char srcAlphaFactor) { - byte alpha = DIVIDE_255_FAST(EGEGET_A(src) * srcAlphaFactor + 255/2); - byte red = DIVIDE_255_FAST(EGEGET_R(src) * srcAlphaFactor + 255/2); - byte green = DIVIDE_255_FAST(EGEGET_G(src) * srcAlphaFactor + 255/2); - byte blue = DIVIDE_255_FAST(EGEGET_B(src) * srcAlphaFactor + 255/2); + byte alpha = DIVIDE_255_FAST(EGEGET_A(src) * srcAlphaFactor + 255 / 2); + byte red = DIVIDE_255_FAST(EGEGET_R(src) * srcAlphaFactor + 255 / 2); + byte green = DIVIDE_255_FAST(EGEGET_G(src) * srcAlphaFactor + 255 / 2); + byte blue = DIVIDE_255_FAST(EGEGET_B(src) * srcAlphaFactor + 255 / 2); return alphablend_premultiplied_inline(dst, EGEARGB(alpha, red, green, blue)); } diff --git a/src/color.h b/src/color.h index a9abce0b..6394c022 100644 --- a/src/color.h +++ b/src/color.h @@ -5,15 +5,9 @@ #include "ege/stdint.h" #include "ege_def.h" +#include "ege_head.h" #include "ege_math.h" -// 交换颜色中 R 通道和 B 通道: 0xAARRGGBB -> 0xAABBGGRR -#define RGBTOBGR(color) ((color_t)((((color) & 0xFF) << 16) | (((color) & 0xFF0000) >> 16) | ((color) & 0xFF00FF00))) - -// 将 color_t 与 Bitmap Buffer 所用的 0xAARRGGBB 格式转换为 COLORREF 的 0x00BBGGRR 格式 -// 仅用于向 GDI32 API 传递颜色时 -#define ARGBTOZBGR(c) ((color_t)((((c) & 0xFF) << 16) | (((c) & 0xFF0000) >> 16) | ((c) & 0xFF00))) - namespace ege { @@ -22,6 +16,19 @@ namespace ege typedef uint32_t color_t; #endif +// 交换颜色中 R 通道和 B 通道: 0xAARRGGBB -> 0xAABBGGRR +constexpr color_t RGBTOBGR(color_t color) +{ + return (color_t)(((color & 0xFF) << 16) | (((color & 0xFF0000) >> 16) | (color & 0xFF00FF00))); +} + +// 将 color_t 与 Bitmap Buffer 所用的 0xAARRGGBB 格式转换为 COLORREF 的 0x00BBGGRR 格式 +// 仅用于向 GDI32 API 传递颜色时 +constexpr color_t ARGBTOZBGR(color_t c) +{ + return (color_t)(((c) & 0xFF) << 16) | (((c) & 0xFF0000) >> 16) | ((c) & 0xFF00); +} + typedef struct COLORHSL { float h; @@ -29,6 +36,8 @@ typedef struct COLORHSL float l; } COLORHSL; +// 将 color_t 与 Bitmap Buffer 所用的 0xAARRGGBB 格式转换为 COLORREF 的 0x00BBGGRR 格式 +// 仅用于向 GDI32 API 传递颜色时 typedef struct COLORHSV { float h; @@ -51,13 +60,13 @@ typedef struct COLORRGB * @param alpha 透明度(0~255) * @return 混合后的 RGB 颜色,透明度与背景色一致 */ -EGE_FORCEINLINE color_t colorblend_inline(color_t dst, color_t src, uint8_t alpha) +EGE_FORCEINLINE constexpr color_t colorblend_inline(color_t dst, color_t src, uint8_t alpha) { - uint8_t r = DIVIDE_255_FAST(255 * EGEGET_R(dst) + ((int)(EGEGET_R(src) - EGEGET_R(dst)) * alpha + 255/2)); - uint8_t g = DIVIDE_255_FAST(255 * EGEGET_G(dst) + ((int)(EGEGET_G(src) - EGEGET_G(dst)) * alpha + 255/2)); - uint8_t b = DIVIDE_255_FAST(255 * EGEGET_B(dst) + ((int)(EGEGET_B(src) - EGEGET_B(dst)) * alpha + 255/2)); + uint8_t r = DIVIDE_255_FAST(255 * EGEGET_R(dst) + ((int)(EGEGET_R(src) - EGEGET_R(dst)) * alpha + 255 / 2)); + uint8_t g = DIVIDE_255_FAST(255 * EGEGET_G(dst) + ((int)(EGEGET_G(src) - EGEGET_G(dst)) * alpha + 255 / 2)); + uint8_t b = DIVIDE_255_FAST(255 * EGEGET_B(dst) + ((int)(EGEGET_B(src) - EGEGET_B(dst)) * alpha + 255 / 2)); - return EGEARGB(EGEGET_A(dst),r, g, b); + return EGEARGB(EGEGET_A(dst), r, g, b); } /** @@ -69,28 +78,27 @@ EGE_FORCEINLINE color_t colorblend_inline(color_t dst, color_t src, uint8_t alph * @return 混合后的 RGB 颜色,透明度与背景色一致 * @note 结果与标准公式相比有一定误差 */ -EGE_FORCEINLINE color_t colorblend_inline_fast(color_t dst, color_t src, uint8_t alpha) +EGE_FORCEINLINE constexpr color_t colorblend_inline_fast(color_t dst, color_t src, uint8_t alpha) { -#define COLORBLEND_INLINE_FAST_OPTION 1 -#if COLORBLEND_INLINE_FAST_OPTION == 0 - // 误差较大,可能取不到端点,而且无近似取整 - uint32_t rb = dst & 0x00FF00FF; - uint32_t g = dst & 0x0000FF00; - - rb += ((src & 0x00FF00FF) - rb) * alpha >> 8; - g += ((src & 0x0000FF00) - g ) * alpha >> 8; - return (rb & 0x00FF00FF) | (g & 0x0000FF00) | (dst & 0xFF000000); -#elif COLORBLEND_INLINE_FAST_OPTION == 1 - // 有近似取整,端点正常,误差较小 - uint32_t rb = dst & 0x00FF00FF; - uint32_t g = dst & 0x0000FF00; - int alphaFactor = DIVIDE_255_FAST((alpha << 8) + 255/2); - - rb += (((src & 0x00FF00FF) - rb) * alphaFactor + 0x007F007F) >> 8; - g += (((src & 0x0000FF00) - g ) * alphaFactor + 0x00007F00) >> 8; - return (dst & 0xFF000000) | (rb & 0x00FF00FF) | (g & 0x0000FF00); -#endif -#undef COLORBLEND_INLINE_FAST_OPTION + constexpr int colorblend_inline_fast_option = 1; + if constexpr (colorblend_inline_fast_option == 0) { + // 误差较大,可能取不到端点,而且无近似取整 + uint32_t rb = dst & 0x00FF00FF; + uint32_t g = dst & 0x0000FF00; + + rb += ((src & 0x00FF00FF) - rb) * alpha >> 8; + g += ((src & 0x0000FF00) - g) * alpha >> 8; + return (rb & 0x00FF00FF) | (g & 0x0000FF00) | (dst & 0xFF000000); + } else if constexpr (colorblend_inline_fast_option == 1) { + // 有近似取整,端点正常,误差较小 + uint32_t rb = dst & 0x00FF00FF; + uint32_t g = dst & 0x0000FF00; + int alphaFactor = DIVIDE_255_FAST((alpha << 8) + 255 / 2); + + rb += (((src & 0x00FF00FF) - rb) * alphaFactor + 0x007F007F) >> 8; + g += (((src & 0x0000FF00) - g) * alphaFactor + 0x00007F00) >> 8; + return (dst & 0xFF000000) | (rb & 0x00FF00FF) | (g & 0x0000FF00); + } } /** @@ -106,12 +114,12 @@ EGE_FORCEINLINE color_t colorblend_inline_fast(color_t dst, color_t src, uint8_t * G = G(dst) + alpha * (G(src) - G(dst)); * B = B(dst) + alpha * (B(src) - B(dst)); */ -EGE_FORCEINLINE color_t alphablend_specify_inline(color_t dst, color_t src, uint8_t alpha) +EGE_FORCEINLINE constexpr color_t alphablend_specify_inline(color_t dst, color_t src, uint8_t alpha) { - const uint8_t a = DIVIDE_255_FAST(255 * EGEGET_A(dst) + ((int)( 255 - EGEGET_A(dst)) * alpha + 255/2)); - const uint8_t r = DIVIDE_255_FAST(255 * EGEGET_R(dst) + ((int)(EGEGET_R(src) - EGEGET_R(dst)) * alpha + 255/2)); - const uint8_t g = DIVIDE_255_FAST(255 * EGEGET_G(dst) + ((int)(EGEGET_G(src) - EGEGET_G(dst)) * alpha + 255/2)); - const uint8_t b = DIVIDE_255_FAST(255 * EGEGET_B(dst) + ((int)(EGEGET_B(src) - EGEGET_B(dst)) * alpha + 255/2)); + const uint8_t a = DIVIDE_255_FAST(255 * EGEGET_A(dst) + ((int)(255 - EGEGET_A(dst)) * alpha + 255 / 2)); + const uint8_t r = DIVIDE_255_FAST(255 * EGEGET_R(dst) + ((int)(EGEGET_R(src) - EGEGET_R(dst)) * alpha + 255 / 2)); + const uint8_t g = DIVIDE_255_FAST(255 * EGEGET_G(dst) + ((int)(EGEGET_G(src) - EGEGET_G(dst)) * alpha + 255 / 2)); + const uint8_t b = DIVIDE_255_FAST(255 * EGEGET_B(dst) + ((int)(EGEGET_B(src) - EGEGET_B(dst)) * alpha + 255 / 2)); return EGEARGB(a, r, g, b); } @@ -123,22 +131,22 @@ EGE_FORCEINLINE color_t alphablend_specify_inline(color_t dst, color_t src, uint * @param src 前景色 * @return 混合后的 ARGB 颜色 */ -EGE_FORCEINLINE color_t alphablend_inline(color_t dst, color_t src) +EGE_FORCEINLINE constexpr color_t alphablend_inline(color_t dst, color_t src) { return alphablend_specify_inline(dst, src, EGEGET_A(src)); } /** - * @brief ARGB 颜色混合 (alpha = 前景色透明度 * 比例系数) + * @brief ARGB 颜色混合 (alpha = 前景色透明度 * 比例系数) COLORHSL * * @param dst 背景色(ARGB) * @param src 前景色(ARGB) * @param srcAlphaFactor 前景色的比例系数,0~255 对应 0.0~1.0 * @return 混合后的 ARGB 颜色 */ -EGE_FORCEINLINE color_t alphablend_inline(color_t dst, color_t src, uint8_t srcAlphaFactor) +EGE_FORCEINLINE constexpr color_t alphablend_inline(color_t dst, color_t src, uint8_t srcAlphaFactor) { - uint8_t alpha = DIVIDE_255_FAST(EGEGET_A(src) * srcAlphaFactor + 255/2); + uint8_t alpha = DIVIDE_255_FAST(EGEGET_A(src) * srcAlphaFactor + 255 / 2); return alphablend_specify_inline(dst, src, alpha); } @@ -154,7 +162,7 @@ EGE_FORCEINLINE color_t alphablend_inline(color_t dst, color_t src, uint8_t srcA * G = G(src) + (1.0 - alpha) * G(dst); * B = B(src) + (1.0 - alpha) * B(dst); */ -EGE_FORCEINLINE color_t alphablend_premultiplied_inline(color_t dst, color_t src) +EGE_FORCEINLINE constexpr color_t alphablend_premultiplied_inline(color_t dst, color_t src) { const uint8_t a = DIVIDE_255_FAST(255 * EGEGET_A(src) + (255 - EGEGET_A(src)) * EGEGET_A(dst)); const uint8_t r = DIVIDE_255_FAST(255 * EGEGET_R(src) + (255 - EGEGET_A(src)) * EGEGET_R(dst)); @@ -164,6 +172,4 @@ EGE_FORCEINLINE color_t alphablend_premultiplied_inline(color_t dst, color_t src return EGEARGB(a, r, g, b); } -} //namespace ege - - +} // namespace ege diff --git a/src/compress.cpp b/src/compress.cpp index 21af9fad..85e5d609 100644 --- a/src/compress.cpp +++ b/src/compress.cpp @@ -10,12 +10,10 @@ int ege_compress(void* dest, unsigned long* destLen, const void* source, unsigne return -1; } - { - int ret = compress((Bytef*)dest + sizeof(unsigned long), (uLongf*)destLen, (Bytef*)source, (uLong)sourceLen); - ((unsigned long*)dest)[0] = sourceLen; - *destLen += 4; - return ret; - } + int ret = compress((Bytef*)dest + sizeof(unsigned long), (uLongf*)destLen, (Bytef*)source, (uLong)sourceLen); + ((unsigned long*)dest)[0] = sourceLen; + *destLen += 4; + return ret; } int ege_compress2(void* dest, unsigned long* destLen, const void* source, unsigned long sourceLen, int level) @@ -24,13 +22,11 @@ int ege_compress2(void* dest, unsigned long* destLen, const void* source, unsign return -1; } - { - int ret = - compress2((Bytef*)dest + sizeof(unsigned long), (uLongf*)destLen, (Bytef*)source, (uLong)sourceLen, level); - *(unsigned long*)dest = sourceLen; - *destLen += sizeof(unsigned long); - return ret; - } + int ret = + compress2((Bytef*)dest + sizeof(unsigned long), (uLongf*)destLen, (Bytef*)source, (uLong)sourceLen, level); + *(unsigned long*)dest = sourceLen; + *destLen += sizeof(unsigned long); + return ret; } unsigned long ege_uncompress_size(const void* source, unsigned long sourceLen) @@ -46,9 +42,7 @@ int ege_uncompress(void* dest, unsigned long* destLen, const void* source, unsig { *(uLongf*)destLen = ege_uncompress_size(source, sourceLen); if (*(uLongf*)destLen > 0) { - int ret = uncompress((Bytef*)dest, - (uLongf*)destLen, - (Bytef*)source + sizeof(unsigned long), + int ret = uncompress((Bytef*)dest, (uLongf*)destLen, (Bytef*)source + sizeof(unsigned long), (uLong)sourceLen - sizeof(unsigned long)); return ret; } else { diff --git a/src/console.cpp b/src/console.cpp index 0f3eacd9..ff87401e 100644 --- a/src/console.cpp +++ b/src/console.cpp @@ -5,7 +5,6 @@ #include #include - #undef _INC_CONIO #undef _CONIO_H_ #include @@ -14,7 +13,7 @@ #define CHECK_CONSOLE_HANDLE(hHandle) \ { \ if (hHandle == NULL) \ - return FALSE; \ + return false; \ } namespace ege @@ -23,16 +22,16 @@ namespace ege // We don't support vc6 #ifndef EGE_COMPILERINFO_VC6 -static HANDLE hInput = NULL; -static HANDLE hOutput = NULL; -static HWND hConsoleWnd = NULL; -static FILE fOldIn; -static FILE fOldOut; +static HANDLE hInput = NULL; +static HANDLE hOutput = NULL; +static HWND hConsoleWnd = NULL; +static FILE fOldIn; +static FILE fOldOut; bool init_console() { HMENU hMenu; - int hCrt; + int hCrt; FILE* hf; if (hInput != NULL) { return false; @@ -63,14 +62,14 @@ bool init_console() DrawMenuBar(hConsoleWnd); } - hCrt = _open_osfhandle((intptr_t)hOutput, _O_TEXT); - hf = _fdopen(hCrt, "w"); + hCrt = _open_osfhandle((intptr_t)hOutput, _O_TEXT); + hf = _fdopen(hCrt, "w"); fOldOut = *stdout; *stdout = *hf; setvbuf(stdout, NULL, _IONBF, 0); - hCrt = _open_osfhandle((intptr_t)hInput, _O_TEXT); - hf = _fdopen(hCrt, "r"); + hCrt = _open_osfhandle((intptr_t)hInput, _O_TEXT); + hf = _fdopen(hCrt, "r"); fOldIn = *stdin; *stdin = *hf; // setvbuf( stdin, NULL, _IONBF, 0 ); @@ -92,10 +91,10 @@ bool clear_console() COORD coordScreen = {0, 0}; - bool bSuccess; - DWORD cCharsWritten; + bool bSuccess; + DWORD cCharsWritten; CONSOLE_SCREEN_BUFFER_INFO csbi; /* to get buffer info */ - DWORD dwConSize; + DWORD dwConSize; if (hOutput == NULL) { return false; @@ -160,11 +159,11 @@ bool close_console() return false; } - hOutput = NULL; - hInput = NULL; + hOutput = NULL; + hInput = NULL; hConsoleWnd = NULL; - *stdout = fOldOut; - *stdin = fOldIn; + *stdout = fOldOut; + *stdin = fOldIn; return true; }; diff --git a/src/ege_common.h b/src/ege_common.h index 3f652697..c39d27a8 100644 --- a/src/ege_common.h +++ b/src/ege_common.h @@ -25,5 +25,3 @@ #include "window.h" #include "image.h" #include "console.h" - - diff --git a/src/ege_math.h b/src/ege_math.h index b4656288..6e6bb4f8 100644 --- a/src/ege_math.h +++ b/src/ege_math.h @@ -2,6 +2,8 @@ #include +#include "ege_def.h" + namespace ege { @@ -13,7 +15,7 @@ inline int round(double x) return (int)((x > 0.0) ? (x + 0.5) : (x - 0.5)); } -inline int round(float x) +inline int round(float x) { return (int)((x > 0.0f) ? (x + 0.5f) : (x - 0.5f)); } @@ -23,13 +25,13 @@ inline int positiveRound(double x) return (int)(x + 0.5); } -inline int positiveRound(float x) +inline int positiveRound(float x) { return (int)(x + 0.5f); } #else using std::round; -#endif // __cplusplus < 201103L +#endif // __cplusplus < 201103L #else // round() 函数在低版本 GCC 中可用 (如 2005-11-30 的 GCC 3.4.5) @@ -37,24 +39,26 @@ using std::round; #endif // 快除 255,有效范围:[0, 65790) -#define DIVIDE_255_FAST(x) (((x) + (((x) + 257) >> 8)) >> 8) +template EGE_FORCEINLINE constexpr T DIVIDE_255_FAST(T x) +{ + return ((x + ((x + 257) >> 8)) >> 8); +} -template -T clamp(T value, T min, T max) +template constexpr T clamp(T value, T min, T max) { return (value < min) ? min : ((value > max) ? max : value); } // Overflow 判断 -inline bool sumIsOverflow(int a, int b) +inline constexpr bool sumIsOverflow(int a, int b) { return (a > 0) && (b > 0) && (b > (INT_MAX - a)); } // Underflow 判断 -inline bool sumIsUnderflow(int a, int b) +inline constexpr bool sumIsUnderflow(int a, int b) { return (a < 0) && (b < 0) && (b < (INT_MIN - a)); } -} // namespace ege +} // namespace ege diff --git a/src/egegapi.cpp b/src/egegapi.cpp index b51e4523..d01a6ba2 100644 --- a/src/egegapi.cpp +++ b/src/egegapi.cpp @@ -26,7 +26,6 @@ #include #include - namespace ege { @@ -46,17 +45,17 @@ bool isinitialized() int showmouse(int bShow) { - struct _graph_setting* pg = &graph_setting; - int ret = pg->mouse_show; - pg->mouse_show = bShow; + struct _graph_setting* pg = &graph_setting; + int ret = pg->mouse_show; + pg->mouse_show = bShow; return ret; } int mousepos(int* x, int* y) { struct _graph_setting* pg = &graph_setting; - *x = pg->mouse_pos.x; - *y = pg->mouse_pos.y; + *x = pg->mouse_pos.x; + *y = pg->mouse_pos.y; return 0; } @@ -89,9 +88,9 @@ color_t getpixel(int x, int y, PCIMAGE pimg) void putpixel(int x, int y, color_t color, PIMAGE pimg) { - PIMAGE img = CONVERT_IMAGE(pimg); - x += img->m_vpt.left; - y += img->m_vpt.top; + PIMAGE img = CONVERT_IMAGE(pimg); + x += img->m_vpt.left; + y += img->m_vpt.top; if (in_rect(x, y, img->m_vpt.right, img->m_vpt.bottom)) { img->m_pBuffer[y * img->m_width + x] = color; } @@ -101,10 +100,10 @@ void putpixel(int x, int y, color_t color, PIMAGE pimg) void putpixels(int numOfPoints, const int* points, PIMAGE pimg) { PIMAGE img = CONVERT_IMAGE(pimg); - int x, y, c; + int x, y, c; PDWORD pb = &img->m_pBuffer[img->m_vpt.top * img->m_width + img->m_vpt.left]; - int w = img->m_vpt.right - img->m_vpt.left, h = img->m_vpt.bottom - img->m_vpt.top; - int tw = img->m_width; + int w = img->m_vpt.right - img->m_vpt.left, h = img->m_vpt.bottom - img->m_vpt.top; + int tw = img->m_width; for (int n = 0; n < numOfPoints; ++n, points += 3) { x = points[0], y = points[1], c = points[2]; if (in_rect(x, y, w, h)) { @@ -117,9 +116,9 @@ void putpixels(int numOfPoints, const int* points, PIMAGE pimg) void putpixels_f(int numOfPoints, const int* points, PIMAGE pimg) { PIMAGE img = CONVERT_IMAGE(pimg); - int x, y, c; - int tw = img->m_width; - int th = img->m_height; + int x, y, c; + int tw = img->m_width; + int th = img->m_height; for (int n = 0; n < numOfPoints; ++n, points += 3) { x = points[0], y = points[1], c = points[2]; if (in_rect(x, y, tw, th)) { @@ -148,12 +147,12 @@ void putpixel_f(int x, int y, color_t color, PIMAGE pimg) void putpixel_withalpha(int x, int y, color_t color, PIMAGE pimg) { - PIMAGE img = CONVERT_IMAGE(pimg); - x += img->m_vpt.left; - y += img->m_vpt.top; + PIMAGE img = CONVERT_IMAGE(pimg); + x += img->m_vpt.left; + y += img->m_vpt.top; if (in_rect(x, y, img->m_vpt.right, img->m_vpt.bottom)) { color_t& dst_color = (color_t&)img->m_pBuffer[y * img->m_width + x]; - dst_color = colorblend_inline(dst_color, color, EGEGET_A(color)); + dst_color = colorblend_inline(dst_color, color, EGEGET_A(color)); } CONVERT_IMAGE_END; } @@ -163,19 +162,19 @@ void putpixel_withalpha_f(int x, int y, color_t color, PIMAGE pimg) PIMAGE img = CONVERT_IMAGE_F(pimg); if (in_rect(x, y, img->m_width, img->m_height)) { color_t& dst_color = (color_t&)img->m_pBuffer[y * img->m_width + x]; - dst_color = colorblend_inline_fast(dst_color, color, EGEGET_A(color)); + dst_color = colorblend_inline_fast(dst_color, color, EGEGET_A(color)); } CONVERT_IMAGE_END; } void putpixel_savealpha(int x, int y, color_t color, PIMAGE pimg) { - PIMAGE img = CONVERT_IMAGE(pimg); - x += img->m_vpt.left; - y += img->m_vpt.top; + PIMAGE img = CONVERT_IMAGE(pimg); + x += img->m_vpt.left; + y += img->m_vpt.top; if (in_rect(x, y, img->m_vpt.right, img->m_vpt.bottom)) { color_t& dst_color = (color_t&)img->m_pBuffer[y * img->m_width + x]; - dst_color = EGECOLORA(color, EGEGET_A(dst_color)); + dst_color = EGECOLORA(color, EGEGET_A(dst_color)); } CONVERT_IMAGE_END; } @@ -185,19 +184,19 @@ void putpixel_savealpha_f(int x, int y, color_t color, PIMAGE pimg) PIMAGE img = CONVERT_IMAGE_F(pimg); if (in_rect(x, y, img->m_width, img->m_height)) { color_t& dst_color = (color_t&)img->m_pBuffer[y * img->m_width + x]; - dst_color = EGECOLORA(color, EGEGET_A(dst_color)); + dst_color = EGECOLORA(color, EGEGET_A(dst_color)); } CONVERT_IMAGE_END; } void putpixel_alphablend(int x, int y, color_t color, PIMAGE pimg) { - PIMAGE img = CONVERT_IMAGE(pimg); - x += img->m_vpt.left; - y += img->m_vpt.top; + PIMAGE img = CONVERT_IMAGE(pimg); + x += img->m_vpt.left; + y += img->m_vpt.top; if (in_rect(x, y, img->m_vpt.right, img->m_vpt.bottom)) { color_t& dst_color = (color_t&)img->m_pBuffer[y * img->m_width + x]; - dst_color = alphablend_inline(dst_color, color); + dst_color = alphablend_inline(dst_color, color); } CONVERT_IMAGE_END; } @@ -207,19 +206,19 @@ void putpixel_alphablend_f(int x, int y, color_t color, PIMAGE pimg) PIMAGE img = CONVERT_IMAGE(pimg); if (in_rect(x, y, img->m_width, img->m_height)) { color_t& dst_color = (color_t&)img->m_pBuffer[y * img->m_width + x]; - dst_color = alphablend_inline(dst_color, color); + dst_color = alphablend_inline(dst_color, color); } CONVERT_IMAGE_END; } void putpixel_alphablend(int x, int y, color_t color, unsigned char alphaFactor, PIMAGE pimg) { - PIMAGE img = CONVERT_IMAGE(pimg); - x += img->m_vpt.left; - y += img->m_vpt.top; + PIMAGE img = CONVERT_IMAGE(pimg); + x += img->m_vpt.left; + y += img->m_vpt.top; if (in_rect(x, y, img->m_vpt.right, img->m_vpt.bottom)) { color_t& dst_color = (color_t&)img->m_pBuffer[y * img->m_width + x]; - dst_color = alphablend_inline(dst_color, color, alphaFactor); + dst_color = alphablend_inline(dst_color, color, alphaFactor); } CONVERT_IMAGE_END; } @@ -229,7 +228,7 @@ void putpixel_alphablend_f(int x, int y, color_t color, unsigned char alphaFacto PIMAGE img = CONVERT_IMAGE(pimg); if (in_rect(x, y, img->m_width, img->m_height)) { color_t& dst_color = (color_t&)img->m_pBuffer[y * img->m_width + x]; - dst_color = alphablend_inline(dst_color, color, alphaFactor); + dst_color = alphablend_inline(dst_color, color, alphaFactor); } CONVERT_IMAGE_END; } @@ -244,7 +243,7 @@ void moveto(int x, int y, PIMAGE pimg) void moverel(int dx, int dy, PIMAGE pimg) { PIMAGE img = CONVERT_IMAGE(pimg); - POINT pt; + POINT pt; GetCurrentPositionEx(img->m_hDC, &pt); dx += pt.x; dy += pt.y; @@ -298,15 +297,14 @@ void lineto(int x, int y, PIMAGE pimg) /* private function */ static void line_base(float x1, float y1, float x2, float y2, PIMAGE img) { - int bswap = 2; - color_t col = getcolor(img); - color_t endp = 0; + int bswap = 2; + color_t col = getcolor(img); + color_t endp = 0; color_t* pBuffer = (color_t*)img->m_pBuffer; - int rw = img->m_width; + int rw = img->m_width; if (x1 > x2) { - float ft; - SWAP(x1, x2, ft); - SWAP(y1, y2, ft); + swap(x1, x2); + swap(y1, y2); if (bswap) { bswap ^= 3; } @@ -322,8 +320,8 @@ static void line_base(float x1, float y1, float x2, float y2, PIMAGE img) return; } float d = (x2 - img->m_vpt.left) / (x2 - x1); - y1 = (y1 - y2) * d + y2; - x1 = (float)img->m_vpt.left; + y1 = (y1 - y2) * d + y2; + x1 = (float)img->m_vpt.left; if (bswap == 1) { bswap = 0; } @@ -333,16 +331,15 @@ static void line_base(float x1, float y1, float x2, float y2, PIMAGE img) return; } float d = (img->m_vpt.right - x1) / (x2 - x1); - y2 = (y2 - y1) * d + y1; - x2 = (float)img->m_vpt.right; + y2 = (y2 - y1) * d + y1; + x2 = (float)img->m_vpt.right; if (bswap == 2) { bswap = 0; } } if (y1 > y2) { - float ft; - SWAP(x1, x2, ft); - SWAP(y1, y2, ft); + swap(x1, x2); + swap(y1, y2); if (bswap) { bswap ^= 3; } @@ -358,8 +355,8 @@ static void line_base(float x1, float y1, float x2, float y2, PIMAGE img) return; } float d = (y2 - img->m_vpt.top) / (y2 - y1); - x1 = (x1 - x2) * d + x2; - y1 = (float)img->m_vpt.top; + x1 = (x1 - x2) * d + x2; + y1 = (float)img->m_vpt.top; if (bswap == 1) { bswap = 0; } @@ -369,8 +366,8 @@ static void line_base(float x1, float y1, float x2, float y2, PIMAGE img) return; } float d = (img->m_vpt.bottom - y1) / (y2 - y1); - x2 = (x2 - x1) * d + x1; - y2 = (float)img->m_vpt.bottom; + x2 = (x2 - x1) * d + x1; + y2 = (float)img->m_vpt.bottom; if (bswap == 2) { bswap = 0; } @@ -383,14 +380,14 @@ static void line_base(float x1, float y1, float x2, float y2, PIMAGE img) } } if (y2 - y1 > fabs(x2 - x1)) { - int y = (int)(y1 + 0.9f); - int ye = (int)(y2); + int y = (int)(y1 + 0.9f); + int ye = (int)(y2); float x, dx; if (y < y1) { ++y; } dx = (x2 - x1) / (y2 - y1); - x = (y - y1) * dx + x1 + 0.5f; + x = (y - y1) * dx + x1 + 0.5f; if (ye >= img->m_vpt.bottom) { ye = img->m_vpt.bottom - 1; } @@ -403,20 +400,20 @@ static void line_base(float x1, float y1, float x2, float y2, PIMAGE img) } else { if (x1 > x2) { float ft; - SWAP(x1, x2, ft); - SWAP(y1, y2, ft); + swap(x1, x2); + swap(y1, y2); if (bswap) { bswap ^= 3; } } - int x = (int)(x1 + 0.9f); - int xe = (int)(x2); + int x = (int)(x1 + 0.9f); + int xe = (int)(x2); float y, dy; if (x < x1) { ++x; } dy = (y2 - y1) / (x2 - x1); - y = (x - x1) * dy + y1 + 0.5f; + y = (x - x1) * dy + y1 + 0.5f; if (xe >= img->m_vpt.right) { xe = img->m_vpt.right - 1; } @@ -477,8 +474,8 @@ static int saveBrush(PIMAGE img, int save) // 此函数调用前,已经有Lock if (save) { LOGBRUSH lbr = {0}; - lbr.lbColor = 0; - lbr.lbStyle = BS_NULL; + lbr.lbColor = 0; + lbr.lbStyle = BS_NULL; pg->savebrush_hbr = CreateBrushIndirect(&lbr); if (pg->savebrush_hbr) { pg->savebrush_hbr = (HBRUSH)SelectObject(img->m_hDC, pg->savebrush_hbr); @@ -533,14 +530,14 @@ static int upattern2array(unsigned short pattern, DWORD style[]) if (state == currentBit) { segmentLength += 1; } else { - state = currentBit; - style[segments] = segmentLength; - segments += 1; - segmentLength = 1; + state = currentBit; + style[segments] = segmentLength; + segments += 1; + segmentLength = 1; } } - style[segments] = segmentLength; - segments += 1; + style[segments] = segmentLength; + segments += 1; // 若 pattern 以 0 开头且为偶数段 if (!(pattern & 1) && segments % 2 == 0) { @@ -556,18 +553,18 @@ static int upattern2array(unsigned short pattern, DWORD style[]) static void update_pen(PIMAGE img) { - const int linestyle = img->m_linestyle.linestyle; - const unsigned short pattern = img->m_linestyle.upattern; - const int thickness = img->m_linestyle.thickness; + const int linestyle = img->m_linestyle.linestyle; + const unsigned short pattern = img->m_linestyle.upattern; + const int thickness = img->m_linestyle.thickness; HPEN hpen; if ((thickness == 1) && ((linestyle == SOLID_LINE) || (linestyle == NULL_LINE))) { LOGPEN logPen; - logPen.lopnStyle = linestyle; // Other styles may be drawn incorrectly - logPen.lopnWidth.x = 1; // Width - logPen.lopnWidth.y = 1; // Unuse - logPen.lopnColor = ARGBTOZBGR(img->m_linecolor); + logPen.lopnStyle = linestyle; // Other styles may be drawn incorrectly + logPen.lopnWidth.x = 1; // Width + logPen.lopnWidth.y = 1; // Unuse + logPen.lopnColor = ARGBTOZBGR(img->m_linecolor); hpen = CreatePenIndirect(&logPen); } else { @@ -576,17 +573,33 @@ static void update_pen(PIMAGE img) penStyle |= PS_GEOMETRIC; switch (img->m_linestartcap) { - case LINECAP_FLAT : penStyle |= PS_ENDCAP_FLAT; break; - case LINECAP_ROUND: penStyle |= PS_ENDCAP_ROUND; break; - case LINECAP_SQUARE: penStyle |= PS_ENDCAP_SQUARE; break; - default: penStyle |= PS_ENDCAP_FLAT; break; + case LINECAP_FLAT: + penStyle |= PS_ENDCAP_FLAT; + break; + case LINECAP_ROUND: + penStyle |= PS_ENDCAP_ROUND; + break; + case LINECAP_SQUARE: + penStyle |= PS_ENDCAP_SQUARE; + break; + default: + penStyle |= PS_ENDCAP_FLAT; + break; } - switch(img->m_linejoin) { - case LINEJOIN_MITER: penStyle |= PS_JOIN_MITER; break; - case LINEJOIN_BEVEL: penStyle |= PS_JOIN_BEVEL; break; - case LINEJOIN_ROUND: penStyle |= PS_JOIN_ROUND; break; - default: penStyle |= PS_JOIN_MITER; break; + switch (img->m_linejoin) { + case LINEJOIN_MITER: + penStyle |= PS_JOIN_MITER; + break; + case LINEJOIN_BEVEL: + penStyle |= PS_JOIN_BEVEL; + break; + case LINEJOIN_ROUND: + penStyle |= PS_JOIN_ROUND; + break; + default: + penStyle |= PS_JOIN_MITER; + break; } LOGBRUSH lbr; @@ -596,8 +609,8 @@ static void update_pen(PIMAGE img) if (linestyle == USERBIT_LINE) { DWORD style[20] = {0}; - int bn = upattern2array(pattern, style); - hpen = ExtCreatePen(penStyle, thickness, &lbr, bn, style); + int bn = upattern2array(pattern, style); + hpen = ExtCreatePen(penStyle, thickness, &lbr, bn, style); } else { hpen = ExtCreatePen(penStyle, thickness, &lbr, 0, NULL); } @@ -641,9 +654,9 @@ void setlinecolor(color_t color, PIMAGE pimg) void setfillcolor(color_t color, PIMAGE pimg) { - PIMAGE img = CONVERT_IMAGE(pimg); + PIMAGE img = CONVERT_IMAGE(pimg); img->m_fillcolor = color; - HBRUSH hbr = CreateSolidBrush(ARGBTOZBGR(color)); + HBRUSH hbr = CreateSolidBrush(ARGBTOZBGR(color)); if (hbr) { DeleteObject(SelectObject(img->m_hDC, hbr)); } @@ -761,7 +774,7 @@ PIMAGE gettarget() int settarget(PIMAGE pbuf) { struct _graph_setting* pg = &graph_setting; - pg->imgtarget_set = pbuf; + pg->imgtarget_set = pbuf; if (pbuf == NULL) { pg->imgtarget = pg->img_page[graph_setting.active_page]; } else { @@ -777,8 +790,7 @@ void cleardevice(PIMAGE pimg) if (img && img->m_hDC) { color_t c = getbkcolor(img); for (color_t *p = (color_t*)img->getbuffer(), *e = (color_t*)&img->getbuffer()[img->m_width * img->m_height]; - p != e; - ++p) + p != e; ++p) { *p = c; } @@ -796,9 +808,15 @@ void arcf(float x, float y, float startAngle, float endAngle, float radius, PIMA ellipsef(x, y, startAngle, endAngle, radius, radius, pimg); } -void circle(int x, int y, int radius, PIMAGE pimg) { ellipse(x, y, 0, 360, radius, radius, pimg); } +void circle(int x, int y, int radius, PIMAGE pimg) +{ + ellipse(x, y, 0, 360, radius, radius, pimg); +} -void circlef(float x, float y, float radius, PIMAGE pimg) { ellipsef(x, y, 0.0f, 360.0f, radius, radius, pimg); } +void circlef(float x, float y, float radius, PIMAGE pimg) +{ + ellipsef(x, y, 0.0f, 360.0f, radius, radius, pimg); +} void ellipse(int x, int y, int startAngle, int endAngle, int xRadius, int yRadius, PIMAGE pimg) { @@ -807,15 +825,8 @@ void ellipse(int x, int y, int startAngle, int endAngle, int xRadius, int yRadiu double sr = startAngle / 180.0 * PI, er = endAngle / 180.0 * PI; if (img) { - Arc(img->m_hDC, - x - xRadius, - y - yRadius, - x + xRadius, - y + yRadius, - (int)(x + xRadius * cos(sr)), - (int)(y - yRadius * sin(sr)), - (int)(x + xRadius * cos(er)), - (int)(y - yRadius * sin(er))); + Arc(img->m_hDC, x - xRadius, y - yRadius, x + xRadius, y + yRadius, (int)(x + xRadius * cos(sr)), + (int)(y - yRadius * sin(sr)), (int)(x + xRadius * cos(er)), (int)(y - yRadius * sin(er))); } CONVERT_IMAGE_END; } @@ -827,14 +838,8 @@ void ellipsef(float x, float y, float startAngle, float endAngle, float xRadius, double sr = startAngle / 180.0 * PI, er = endAngle / 180.0 * PI; if (img) { - Arc(img->m_hDC, - (int)(x - xRadius), - (int)(y - yRadius), - (int)(x + xRadius), - (int)(y + yRadius), - (int)(x + xRadius * cos(sr)), - (int)(y - yRadius * sin(sr)), - (int)(x + xRadius * cos(er)), + Arc(img->m_hDC, (int)(x - xRadius), (int)(y - yRadius), (int)(x + xRadius), (int)(y + yRadius), + (int)(x + xRadius * cos(sr)), (int)(y - yRadius * sin(sr)), (int)(x + xRadius * cos(er)), (int)(y - yRadius * sin(er))); } CONVERT_IMAGE_END; @@ -862,7 +867,7 @@ void sectorf(float x, float y, float startAngle, float endAngle, float xRadius, void pie(int x, int y, int startAngle, int endAngle, int xRadius, int yRadius, PIMAGE pimg) { - PIMAGE img = CONVERT_IMAGE(pimg); + PIMAGE img = CONVERT_IMAGE(pimg); HBRUSH oldBrush = (HBRUSH)SelectObject(img->m_hDC, GetStockObject(NULL_BRUSH)); fillpie(x, y, startAngle, endAngle, xRadius, yRadius, pimg); SelectObject(img->m_hDC, oldBrush); @@ -871,7 +876,7 @@ void pie(int x, int y, int startAngle, int endAngle, int xRadius, int yRadius, P void pief(float x, float y, float startAngle, float endAngle, float xRadius, float yRadius, PIMAGE pimg) { - PIMAGE img = CONVERT_IMAGE(pimg); + PIMAGE img = CONVERT_IMAGE(pimg); HBRUSH oldBrush = (HBRUSH)SelectObject(img->m_hDC, GetStockObject(NULL_BRUSH)); fillpief(x, y, startAngle, endAngle, xRadius, yRadius, pimg); SelectObject(img->m_hDC, oldBrush); @@ -883,15 +888,8 @@ void fillpie(int x, int y, int startAngle, int endAngle, int xRadius, int yRadiu PIMAGE img = CONVERT_IMAGE(pimg); double sr = startAngle / 180.0 * PI, er = endAngle / 180.0 * PI; if (img) { - Pie(img->m_hDC, - x - xRadius, - y - yRadius, - x + xRadius, - y + yRadius, - (int)round(x + xRadius * cos(sr)), - (int)round(y - yRadius * sin(sr)), - (int)round(x + xRadius * cos(er)), - (int)round(y - yRadius * sin(er))); + Pie(img->m_hDC, x - xRadius, y - yRadius, x + xRadius, y + yRadius, (int)round(x + xRadius * cos(sr)), + (int)round(y - yRadius * sin(sr)), (int)round(x + xRadius * cos(er)), (int)round(y - yRadius * sin(er))); } CONVERT_IMAGE_END; } @@ -901,14 +899,8 @@ void fillpief(float x, float y, float startAngle, float endAngle, float xRadius, PIMAGE img = CONVERT_IMAGE(pimg); double sr = startAngle / 180.0 * PI, er = endAngle / 180.0 * PI; if (img) { - Pie(img->m_hDC, - (int)(x - xRadius), - (int)(y - yRadius), - (int)(x + xRadius), - (int)(y + yRadius), - (int)round(x + xRadius * cos(sr)), - (int)round(y - yRadius * sin(sr)), - (int)round(x + xRadius * cos(er)), + Pie(img->m_hDC, (int)(x - xRadius), (int)(y - yRadius), (int)(x + xRadius), (int)(y + yRadius), + (int)round(x + xRadius * cos(sr)), (int)round(y - yRadius * sin(sr)), (int)round(x + xRadius * cos(er)), (int)round(y - yRadius * sin(er))); } CONVERT_IMAGE_END; @@ -916,7 +908,7 @@ void fillpief(float x, float y, float startAngle, float endAngle, float xRadius, void solidpie(int x, int y, int startAngle, int endAngle, int xRadius, int yRadius, PIMAGE pimg) { - PIMAGE img = CONVERT_IMAGE(pimg); + PIMAGE img = CONVERT_IMAGE(pimg); HBRUSH oldPen = (HBRUSH)SelectObject(img->m_hDC, GetStockObject(NULL_PEN)); fillpie(x, y, startAngle, endAngle, xRadius, yRadius, pimg); SelectObject(img->m_hDC, oldPen); @@ -925,7 +917,7 @@ void solidpie(int x, int y, int startAngle, int endAngle, int xRadius, int yRadi void solidpief(float x, float y, float startAngle, float endAngle, float xRadius, float yRadius, PIMAGE pimg) { - PIMAGE img = CONVERT_IMAGE(pimg); + PIMAGE img = CONVERT_IMAGE(pimg); HBRUSH oldPen = (HBRUSH)SelectObject(img->m_hDC, GetStockObject(NULL_PEN)); fillpief(x, y, startAngle, endAngle, xRadius, yRadius, pimg); SelectObject(img->m_hDC, oldPen); @@ -952,7 +944,7 @@ void fillellipsef(float x, float y, float xRadius, float yRadius, PIMAGE pimg) void solidellipse(int x, int y, int xRadius, int yRadius, PIMAGE pimg) { - PIMAGE img = CONVERT_IMAGE(pimg); + PIMAGE img = CONVERT_IMAGE(pimg); HBRUSH oldPen = (HBRUSH)SelectObject(img->m_hDC, GetStockObject(NULL_PEN)); fillellipse(x, y, xRadius, yRadius, pimg); SelectObject(img->m_hDC, oldPen); @@ -961,7 +953,7 @@ void solidellipse(int x, int y, int xRadius, int yRadius, PIMAGE pimg) void solidellipsef(float x, float y, float xRadius, float yRadius, PIMAGE pimg) { - PIMAGE img = CONVERT_IMAGE(pimg); + PIMAGE img = CONVERT_IMAGE(pimg); HBRUSH oldPen = (HBRUSH)SelectObject(img->m_hDC, GetStockObject(NULL_PEN)); fillellipsef(x, y, xRadius, yRadius, pimg); SelectObject(img->m_hDC, oldPen); @@ -975,12 +967,12 @@ void fillcircle(int x, int y, int radius, PIMAGE pimg) void fillcirclef(float x, float y, float radius, PIMAGE pimg) { - fillellipsef(x,y,radius,radius,pimg); + fillellipsef(x, y, radius, radius, pimg); } void solidcircle(int x, int y, int radius, PIMAGE pimg) { - PIMAGE img = CONVERT_IMAGE(pimg); + PIMAGE img = CONVERT_IMAGE(pimg); HBRUSH oldPen = (HBRUSH)SelectObject(img->m_hDC, GetStockObject(NULL_PEN)); fillcircle(x, y, radius, pimg); SelectObject(img->m_hDC, oldPen); @@ -989,7 +981,7 @@ void solidcircle(int x, int y, int radius, PIMAGE pimg) void solidcirclef(float x, float y, float radius, PIMAGE pimg) { - PIMAGE img = CONVERT_IMAGE(pimg); + PIMAGE img = CONVERT_IMAGE(pimg); HBRUSH oldPen = (HBRUSH)SelectObject(img->m_hDC, GetStockObject(NULL_PEN)); fillcirclef(x, y, radius, pimg); SelectObject(img->m_hDC, oldPen); @@ -998,8 +990,8 @@ void solidcirclef(float x, float y, float radius, PIMAGE pimg) void bar(int left, int top, int right, int bottom, PIMAGE pimg) { - PIMAGE img = CONVERT_IMAGE(pimg); - RECT rect = {left, top, right, bottom}; + PIMAGE img = CONVERT_IMAGE(pimg); + RECT rect = {left, top, right, bottom}; HBRUSH hbr_last = (HBRUSH)GetCurrentObject(img->m_hDC, OBJ_BRUSH); //(HBRUSH)SelectObject(pg->g_hdc, hbr); if (img) { @@ -1013,25 +1005,25 @@ void roundrect(int left, int top, int right, int bottom, int xRadius, int yRadiu PIMAGE img = CONVERT_IMAGE(pimg); if (img) { HBRUSH oldBrush = (HBRUSH)SelectObject(img->m_hDC, GetStockObject(NULL_BRUSH)); - RoundRect(img->m_hDC, left, top, right, bottom, xRadius * 2 , yRadius * 2); + RoundRect(img->m_hDC, left, top, right, bottom, xRadius * 2, yRadius * 2); SelectObject(img->m_hDC, oldBrush); } CONVERT_IMAGE_END; } -void roundrect(int left, int top, int right, int bottom, int radius, PIMAGE pimg) +void roundrect(int left, int top, int right, int bottom, int radius, PIMAGE pimg) { roundrect(left, top, right, bottom, radius, radius, pimg); } -void fillroundrect(int left, int top, int right, int bottom, int radius, PIMAGE pimg) +void fillroundrect(int left, int top, int right, int bottom, int radius, PIMAGE pimg) { fillroundrect(left, top, right, bottom, radius, radius, pimg); } void solidroundrect(int left, int top, int right, int bottom, int radius, PIMAGE pimg) { - PIMAGE img = CONVERT_IMAGE(pimg); + PIMAGE img = CONVERT_IMAGE(pimg); HBRUSH oldPen = (HBRUSH)SelectObject(img->m_hDC, GetStockObject(NULL_PEN)); fillroundrect(left, top, right, bottom, radius, pimg); SelectObject(img->m_hDC, oldPen); @@ -1049,7 +1041,7 @@ void fillroundrect(int left, int top, int right, int bottom, int xRadius, int yR void solidroundrect(int left, int top, int right, int bottom, int xRadius, int yRadius, PIMAGE pimg) { - PIMAGE img = CONVERT_IMAGE(pimg); + PIMAGE img = CONVERT_IMAGE(pimg); HBRUSH oldPen = (HBRUSH)SelectObject(img->m_hDC, GetStockObject(NULL_PEN)); fillroundrect(left, top, right, bottom, xRadius, yRadius, pimg); SelectObject(img->m_hDC, oldPen); @@ -1067,7 +1059,7 @@ void fillrect(int left, int top, int right, int bottom, PIMAGE pimg) void solidrect(int left, int top, int right, int bottom, PIMAGE pimg) { - PIMAGE img = CONVERT_IMAGE(pimg); + PIMAGE img = CONVERT_IMAGE(pimg); HBRUSH oldPen = (HBRUSH)SelectObject(img->m_hDC, GetStockObject(NULL_PEN)); fillrect(left, top, right, bottom, pimg); SelectObject(img->m_hDC, oldPen); @@ -1079,13 +1071,12 @@ void bar3d(int left, int top, int right, int bottom, int depth, int topFlag, PIM /* 6个外边界顶点(从左上角开始逆时针数) */ POINT boundVertexes[6] = { {left, top}, - {left, bottom}, + {left, bottom}, {right, bottom}, {right + depth, bottom - depth}, {right + depth, top - depth}, - {left + depth, top - depth}, - }; - + {left + depth, top - depth}, + }; bar(left, top, right, bottom, pimg); @@ -1113,7 +1104,7 @@ void drawpoly(int numOfPoints, const int* points, PIMAGE pimg) Gdiplus::Point* pointArray = (Gdiplus::Point*)points; /* 闭合曲线, 转为绘制带边框无填充多边形 */ - if ((numOfPoints > 3) && (pointArray[0].Equals(pointArray[numOfPoints-1]))) { + if ((numOfPoints > 3) && (pointArray[0].Equals(pointArray[numOfPoints - 1]))) { polygon(numOfPoints - 1, points, pimg); } else { polyline(numOfPoints, points, pimg); @@ -1130,16 +1121,16 @@ void fillpoly(int numOfPoints, const int* points, PIMAGE pimg) CONVERT_IMAGE_END; } -void solidpoly(int numOfPoints, const int *points, PIMAGE pimg) +void solidpoly(int numOfPoints, const int* points, PIMAGE pimg) { - PIMAGE img = CONVERT_IMAGE(pimg); + PIMAGE img = CONVERT_IMAGE(pimg); HBRUSH oldPen = (HBRUSH)SelectObject(img->m_hDC, GetStockObject(NULL_PEN)); fillpoly(numOfPoints, points, pimg); SelectObject(img->m_hDC, oldPen); CONVERT_IMAGE_END } -void polyline(int numOfPoints, const int *points, PIMAGE pimg) +void polyline(int numOfPoints, const int* points, PIMAGE pimg) { PIMAGE img = CONVERT_IMAGE(pimg); if (img) { @@ -1148,7 +1139,7 @@ void polyline(int numOfPoints, const int *points, PIMAGE pimg) CONVERT_IMAGE_END; } -void polygon(int numOfPoints, const int *points, PIMAGE pimg) +void polygon(int numOfPoints, const int* points, PIMAGE pimg) { PIMAGE img = CONVERT_IMAGE(pimg); if (img) { @@ -1171,11 +1162,11 @@ void fillpoly_gradient(int numOfPoints, const ege_colpoint* points, PIMAGE pimg) GRADIENT_TRIANGLE* tri = (GRADIENT_TRIANGLE*)malloc(sizeof(GRADIENT_TRIANGLE) * (numOfPoints - 2)); if (tri) { for (int i = 0; i < numOfPoints; ++i) { - vert[i].x = (long)points[i].x; - vert[i].y = (long)points[i].y; - vert[i].Red = EGEGET_R(points[i].color) << 8; + vert[i].x = (long)points[i].x; + vert[i].y = (long)points[i].y; + vert[i].Red = EGEGET_R(points[i].color) << 8; vert[i].Green = EGEGET_G(points[i].color) << 8; - vert[i].Blue = EGEGET_B(points[i].color) << 8; + vert[i].Blue = EGEGET_B(points[i].color) << 8; // vert[i].Alpha = EGEGET_A(points[i].color) << 8; vert[i].Alpha = 0; } @@ -1219,8 +1210,6 @@ void drawlines(int numlines, const int* points, PIMAGE pimg) CONVERT_IMAGE_END; } - - void floodfill(int x, int y, int borderColor, PIMAGE pimg) { PIMAGE img = CONVERT_IMAGE(pimg); @@ -1264,9 +1253,9 @@ void setlinestyle(int linestyle, unsigned short pattern, int thickness, PIMAGE p } img->m_linestyle.thickness = thickness; - img->m_linewidth = (float)thickness; + img->m_linewidth = (float)thickness; img->m_linestyle.linestyle = linestyle; - img->m_linestyle.upattern = pattern; + img->m_linestyle.upattern = pattern; update_pen(img); @@ -1279,7 +1268,7 @@ void setlinewidth(float width, PIMAGE pimg) if (img && img->m_hDC) { img->m_linestyle.thickness = (int)width; - img->m_linewidth = width; + img->m_linewidth = width; update_pen(img); } @@ -1289,10 +1278,16 @@ void setlinewidth(float width, PIMAGE pimg) Gdiplus::LineCap convertToGdiplusLineCap(line_cap_type linecap) { Gdiplus::LineCap cap = Gdiplus::LineCapFlat; - switch(linecap) { - case LINECAP_FLAT: cap = Gdiplus::LineCapFlat; break; - case LINECAP_SQUARE: cap = Gdiplus::LineCapSquare; break; - case LINECAP_ROUND: cap = Gdiplus::LineCapRound; break; + switch (linecap) { + case LINECAP_FLAT: + cap = Gdiplus::LineCapFlat; + break; + case LINECAP_SQUARE: + cap = Gdiplus::LineCapSquare; + break; + case LINECAP_ROUND: + cap = Gdiplus::LineCapRound; + break; } return cap; @@ -1301,10 +1296,16 @@ Gdiplus::LineCap convertToGdiplusLineCap(line_cap_type linecap) Gdiplus::LineJoin convertToGdiplusLineJoin(line_join_type linejoin) { Gdiplus::LineJoin joinType = Gdiplus::LineJoinMiter; - switch(linejoin) { - case LINEJOIN_MITER: joinType = Gdiplus::LineJoinMiter; break; - case LINEJOIN_BEVEL: joinType = Gdiplus::LineJoinBevel; break; - case LINEJOIN_ROUND: joinType = Gdiplus::LineJoinRound; break; + switch (linejoin) { + case LINEJOIN_MITER: + joinType = Gdiplus::LineJoinMiter; + break; + case LINEJOIN_BEVEL: + joinType = Gdiplus::LineJoinBevel; + break; + case LINEJOIN_ROUND: + joinType = Gdiplus::LineJoinRound; + break; } return joinType; @@ -1374,15 +1375,15 @@ void setlinejoin(line_join_type linejoin, float miterLimit, PIMAGE pimg) PIMAGE img = CONVERT_IMAGE(pimg); if (img && img->m_hDC) { - miterLimit = MAX(1.0f, miterLimit); - img->m_linejoin = linejoin; + miterLimit = max(1.0f, miterLimit); + img->m_linejoin = linejoin; img->m_linejoinmiterlimit = miterLimit; update_pen(img); } CONVERT_IMAGE_END; } -void getlinejoin(line_join_type *linejoin, float *miterLimit, PCIMAGE pimg) +void getlinejoin(line_join_type* linejoin, float* miterLimit, PCIMAGE pimg) { PCIMAGE img = CONVERT_IMAGE_CONST(pimg); if (img && img->m_hDC) { @@ -1410,28 +1411,18 @@ line_join_type getlinejoin(PCIMAGE pimg) void setfillstyle(int pattern, color_t color, PIMAGE pimg) { - PIMAGE img = CONVERT_IMAGE(pimg); - LOGBRUSH lbr = {0}; + PIMAGE img = CONVERT_IMAGE(pimg); + LOGBRUSH lbr = {0}; img->m_fillcolor = color; - lbr.lbColor = ARGBTOZBGR(color); + lbr.lbColor = ARGBTOZBGR(color); // SetBkColor(img->m_hDC, color); if (pattern == EMPTY_FILL) { lbr.lbStyle = BS_NULL; } else if (pattern == SOLID_FILL) { lbr.lbStyle = BS_SOLID; } else if (pattern < USER_FILL) { // dose not finish - int hatchmap[] = { - HS_HORIZONTAL, - HS_BDIAGONAL, - HS_BDIAGONAL, - HS_FDIAGONAL, - HS_FDIAGONAL, - HS_CROSS, - HS_DIAGCROSS, - HS_VERTICAL, - HS_DIAGCROSS, - HS_DIAGCROSS - }; + int hatchmap[] = {HS_HORIZONTAL, HS_BDIAGONAL, HS_BDIAGONAL, HS_FDIAGONAL, HS_FDIAGONAL, HS_CROSS, HS_DIAGCROSS, + HS_VERTICAL, HS_DIAGCROSS, HS_DIAGCROSS}; lbr.lbStyle = BS_HATCHED; lbr.lbHatch = hatchmap[pattern - 2]; @@ -1468,7 +1459,7 @@ void setrendermode(rendermode_e mode) delay_ms(0); SetTimer(pg->hwnd, RENDER_TIMER_ID, 50, NULL); pg->skip_timer_mark = false; - pg->lock_window = false; + pg->lock_window = false; } } @@ -1480,12 +1471,12 @@ void setactivepage(int page) /* 为未创建的绘图页分配图像 */ if (pg->img_page[page] == NULL) { - color_t bkColor = (page == 0) ? pg->window_initial_color : BLACK; + color_t bkColor = (page == 0) ? pg->window_initial_color : BLACK; pg->img_page[page] = new IMAGE(pg->dc_w, pg->dc_h, bkColor); } pg->imgtarget = pg->img_page[page]; - pg->dc = pg->img_page[page]->m_hDC; + pg->dc = pg->img_page[page]->m_hDC; } } @@ -1511,10 +1502,10 @@ void swappage() void window_getviewport(struct viewporttype* viewport) { struct _graph_setting* pg = &graph_setting; - viewport->left = pg->base_x; - viewport->top = pg->base_y; - viewport->right = pg->base_w + pg->base_x; - viewport->bottom = pg->base_h + pg->base_y; + viewport->left = pg->base_x; + viewport->top = pg->base_y; + viewport->right = pg->base_w + pg->base_x; + viewport->bottom = pg->base_h + pg->base_y; } void window_getviewport(int* left, int* top, int* right, int* bottom) @@ -1536,8 +1527,8 @@ void window_getviewport(int* left, int* top, int* right, int* bottom) void window_setviewport(int left, int top, int right, int bottom) { - struct _graph_setting* pg = &graph_setting; - int same_xy = 0, same_wh = 0; + struct _graph_setting* pg = &graph_setting; + int same_xy = 0, same_wh = 0; if (pg->base_x == left && pg->base_y == top) { same_xy = 1; } @@ -1554,7 +1545,7 @@ void window_setviewport(int left, int top, int right, int bottom) /* 修正窗口大小 */ if (same_wh == 0) { RECT rect, crect; - int dw, dh; + int dw, dh; GetClientRect(pg->hwnd, &crect); GetWindowRect(pg->hwnd, &rect); dw = pg->base_w - crect.right; @@ -1564,9 +1555,9 @@ void window_setviewport(int left, int top, int right, int bottom) if (hwnd) { POINT pt = {0, 0}; ClientToScreen(hwnd, &pt); - rect.left -= pt.x; - rect.top -= pt.y; - rect.right -= pt.x; + rect.left -= pt.x; + rect.top -= pt.y; + rect.right -= pt.x; rect.bottom -= pt.y; } @@ -1609,7 +1600,7 @@ void setviewport(int left, int top, int right, int bottom, int clip, PIMAGE pimg Point oldOrigin(img->m_vpt.left, img->m_vpt.top); SetViewportOrgEx(img->m_hDC, 0, 0, NULL); - img->m_vpt = viewport; + img->m_vpt = viewport; img->m_enableclip = clip; if (clip) { @@ -1622,7 +1613,7 @@ void setviewport(int left, int top, int right, int bottom, int clip, PIMAGE pimg /* GDI+ 设置裁剪区域时受当前坐标系影响,确保在设备坐标系下进行 */ Gdiplus::Graphics* graphics = img->getGraphics(); - Gdiplus::Matrix matrix; + Gdiplus::Matrix matrix; graphics->GetTransform(&matrix); graphics->ResetTransform(); @@ -1648,8 +1639,8 @@ void clearviewport(PIMAGE pimg) PIMAGE img = CONVERT_IMAGE(pimg); if (img && img->m_hDC) { - RECT rect = {0, 0, img->m_vpt.right - img->m_vpt.left, img->m_vpt.bottom - img->m_vpt.top}; - HBRUSH hbr = CreateSolidBrush(GetBkColor(img->m_hDC)); + RECT rect = {0, 0, img->m_vpt.right - img->m_vpt.left, img->m_vpt.bottom - img->m_vpt.top}; + HBRUSH hbr = CreateSolidBrush(GetBkColor(img->m_hDC)); FillRect(img->m_hDC, &rect, hbr); DeleteObject(hbr); } @@ -1680,7 +1671,7 @@ void ege_line(float x1, float y1, float x2, float y2, PIMAGE pimg) return; } Gdiplus::Graphics* graphics = img->getGraphics(); - Gdiplus::Pen* pen = img->getPen(); + Gdiplus::Pen* pen = img->getPen(); graphics->DrawLine(pen, x1, y1, x2, y2); } CONVERT_IMAGE_END; @@ -1689,15 +1680,14 @@ void ege_line(float x1, float y1, float x2, float y2, PIMAGE pimg) void ege_drawpoly(int numOfPoints, const ege_point* points, PIMAGE pimg) { /* 当首尾顶点为同一坐标时转成多边形,否则绘制折线 */ - if (numOfPoints > 3 && points[0].x == points[numOfPoints-1].x - && points[0].y == points[numOfPoints-1].y) { + if (numOfPoints > 3 && points[0].x == points[numOfPoints - 1].x && points[0].y == points[numOfPoints - 1].y) { ege_polygon(numOfPoints - 1, points, pimg); } else { ege_polyline(numOfPoints, points, pimg); } } -void ege_polyline(int numOfPoints, const ege_point *points, PIMAGE pimg) +void ege_polyline(int numOfPoints, const ege_point* points, PIMAGE pimg) { PIMAGE img = CONVERT_IMAGE(pimg); if (img) { @@ -1705,13 +1695,13 @@ void ege_polyline(int numOfPoints, const ege_point *points, PIMAGE pimg) return; } Gdiplus::Graphics* graphics = img->getGraphics(); - Gdiplus::Pen* pen = img->getPen(); + Gdiplus::Pen* pen = img->getPen(); graphics->DrawLines(pen, (const Gdiplus::PointF*)points, numOfPoints); } CONVERT_IMAGE_END; } -void ege_polygon(int numOfPoints, const ege_point *points, PIMAGE pimg) +void ege_polygon(int numOfPoints, const ege_point* points, PIMAGE pimg) { PIMAGE img = CONVERT_IMAGE(pimg); if (img) { @@ -1719,7 +1709,7 @@ void ege_polygon(int numOfPoints, const ege_point *points, PIMAGE pimg) return; } Gdiplus::Graphics* graphics = img->getGraphics(); - Gdiplus::Pen* pen = img->getPen(); + Gdiplus::Pen* pen = img->getPen(); graphics->DrawPolygon(pen, (const Gdiplus::PointF*)points, numOfPoints); } CONVERT_IMAGE_END; @@ -1733,13 +1723,13 @@ void ege_drawcurve(int numOfPoints, const ege_point* points, PIMAGE pimg) return; } Gdiplus::Graphics* graphics = img->getGraphics(); - Gdiplus::Pen* pen = img->getPen(); + Gdiplus::Pen* pen = img->getPen(); graphics->DrawCurve(pen, (const Gdiplus::PointF*)points, numOfPoints); } CONVERT_IMAGE_END; } -void ege_drawcurve(int numOfPoints, const ege_point *points, float tension, PIMAGE pimg) +void ege_drawcurve(int numOfPoints, const ege_point* points, float tension, PIMAGE pimg) { PIMAGE img = CONVERT_IMAGE(pimg); if (img) { @@ -1752,7 +1742,7 @@ void ege_drawcurve(int numOfPoints, const ege_point *points, float tension, PIMA CONVERT_IMAGE_END; } -void ege_drawclosedcurve(int numOfPoints, const ege_point *points, PIMAGE pimg) +void ege_drawclosedcurve(int numOfPoints, const ege_point* points, PIMAGE pimg) { PIMAGE img = CONVERT_IMAGE(pimg); if (img) { @@ -1765,7 +1755,7 @@ void ege_drawclosedcurve(int numOfPoints, const ege_point *points, PIMAGE pimg) CONVERT_IMAGE_END; } -void ege_drawclosedcurve(int numOfPoints, const ege_point *points, float tension, PIMAGE pimg) +void ege_drawclosedcurve(int numOfPoints, const ege_point* points, float tension, PIMAGE pimg) { PIMAGE img = CONVERT_IMAGE(pimg); if (img) { @@ -1778,8 +1768,7 @@ void ege_drawclosedcurve(int numOfPoints, const ege_point *points, float tension CONVERT_IMAGE_END; } - -void ege_fillclosedcurve(int numOfPoints, const ege_point *points, PIMAGE pimg) +void ege_fillclosedcurve(int numOfPoints, const ege_point* points, PIMAGE pimg) { PIMAGE img = CONVERT_IMAGE(pimg); if (img) { @@ -1789,13 +1778,13 @@ void ege_fillclosedcurve(int numOfPoints, const ege_point *points, PIMAGE pimg) CONVERT_IMAGE_END; } -void ege_fillclosedcurve(int numOfPoints, const ege_point *points, float tension, PIMAGE pimg) +void ege_fillclosedcurve(int numOfPoints, const ege_point* points, float tension, PIMAGE pimg) { PIMAGE img = CONVERT_IMAGE(pimg); if (img) { Gdiplus::Graphics* graphics = img->getGraphics(); - graphics->FillClosedCurve(img->getBrush(), (const Gdiplus::PointF*)points, numOfPoints, - Gdiplus::FillModeAlternate, tension); + graphics->FillClosedCurve( + img->getBrush(), (const Gdiplus::PointF*)points, numOfPoints, Gdiplus::FillModeAlternate, tension); } CONVERT_IMAGE_END; } @@ -1808,7 +1797,7 @@ void ege_rectangle(float x, float y, float w, float h, PIMAGE pimg) return; } Gdiplus::Graphics* graphics = img->getGraphics(); - Gdiplus::Pen* pen = img->getPen(); + Gdiplus::Pen* pen = img->getPen(); graphics->DrawRectangle(pen, x, y, w, h); } CONVERT_IMAGE_END; @@ -1832,7 +1821,7 @@ void ege_ellipse(float x, float y, float w, float h, PIMAGE pimg) return; } Gdiplus::Graphics* graphics = img->getGraphics(); - Gdiplus::Pen* pen = img->getPen(); + Gdiplus::Pen* pen = img->getPen(); graphics->DrawEllipse(pen, x, y, w, h); } CONVERT_IMAGE_END; @@ -1846,7 +1835,7 @@ void ege_pie(float x, float y, float w, float h, float startAngle, float sweepAn return; } Gdiplus::Graphics* graphics = img->getGraphics(); - Gdiplus::Pen* pen = img->getPen(); + Gdiplus::Pen* pen = img->getPen(); graphics->DrawPie(pen, x, y, w, h, startAngle, sweepAngle); } CONVERT_IMAGE_END; @@ -1860,7 +1849,7 @@ void ege_arc(float x, float y, float w, float h, float startAngle, float sweepAn return; } Gdiplus::Graphics* graphics = img->getGraphics(); - Gdiplus::Pen* pen = img->getPen(); + Gdiplus::Pen* pen = img->getPen(); graphics->DrawArc(pen, x, y, w, h, startAngle, sweepAngle); } CONVERT_IMAGE_END; @@ -1879,7 +1868,7 @@ void ege_drawbezier(int numOfPoints, const ege_point* points, PIMAGE pimg) return; } Gdiplus::Graphics* graphics = img->getGraphics(); - Gdiplus::Pen* pen = img->getPen(); + Gdiplus::Pen* pen = img->getPen(); graphics->DrawBeziers(pen, (const Gdiplus::PointF*)points, numOfPoints); } CONVERT_IMAGE_END; @@ -1903,10 +1892,8 @@ void ege_setpattern_lineargradient(float x1, float y1, color_t c1, float x2, flo CONVERT_IMAGE_END; } -void ege_setpattern_pathgradient(ege_point center, color_t centerColor, - int count, const ege_point* points, - int colorCount, const color_t* pointColors, - PIMAGE pimg) +void ege_setpattern_pathgradient(ege_point center, color_t centerColor, int count, const ege_point* points, + int colorCount, const color_t* pointColors, PIMAGE pimg) { PIMAGE img = CONVERT_IMAGE(pimg); if (img) { @@ -1920,21 +1907,15 @@ void ege_setpattern_pathgradient(ege_point center, color_t centerColor, CONVERT_IMAGE_END; } -void ege_setpattern_ellipsegradient(ege_point center, - color_t centerColor, - float x, - float y, - float w, - float h, - color_t color, - PIMAGE pimg) +void ege_setpattern_ellipsegradient( + ege_point center, color_t centerColor, float x, float y, float w, float h, color_t color, PIMAGE pimg) { PIMAGE img = CONVERT_IMAGE(pimg); if (img) { Gdiplus::GraphicsPath path; path.AddEllipse(x, y, w, h); Gdiplus::PathGradientBrush* pbrush = new Gdiplus::PathGradientBrush(&path); - int count = 1; + int count = 1; pbrush->SetCenterColor(Gdiplus::Color(centerColor)); pbrush->SetCenterPoint(Gdiplus::PointF(center.x, center.y)); pbrush->SetSurroundColors((const Gdiplus::Color*)&color, &count); @@ -1961,7 +1942,7 @@ void ege_fillpoly(int numOfPoints, const ege_point* points, PIMAGE pimg) PIMAGE img = CONVERT_IMAGE(pimg); if (img) { Gdiplus::Graphics* graphics = img->getGraphics(); - Gdiplus::Brush* brush = img->getBrush(); + Gdiplus::Brush* brush = img->getBrush(); graphics->FillPolygon(brush, (const Gdiplus::PointF*)points, numOfPoints); } CONVERT_IMAGE_END; @@ -1972,66 +1953,78 @@ void ege_fillrect(float x, float y, float w, float h, PIMAGE pimg) PIMAGE img = CONVERT_IMAGE(pimg); if (img) { Gdiplus::Graphics* graphics = img->getGraphics(); - Gdiplus::Brush* brush = img->getBrush(); + Gdiplus::Brush* brush = img->getBrush(); graphics->FillRectangle(brush, x, y, w, h); } CONVERT_IMAGE_END; } -static Gdiplus::GraphicsPath* createRoundRectPath(float x, float y, float w, float h, - float radius1, float radius2, float radius3, float radius4) +static Gdiplus::GraphicsPath* createRoundRectPath( + float x, float y, float w, float h, float radius1, float radius2, float radius3, float radius4) { - if ((w <= 0.0f) || (h <= 0.0f)) + if ((w <= 0.0f) || (h <= 0.0f)) { return NULL; + } - radius1 = clamp(radius1, 0.0f, MIN(w, h)); - radius2 = clamp(radius2, 0.0f, MIN(w - radius1, h)); - radius3 = clamp(radius3, 0.0f, MIN(h - radius2, w)); - radius4 = clamp(radius4, 0.0f, MIN(h - radius1, w - radius3)); + radius1 = clamp(radius1, 0.0f, min(w, h)); + radius2 = clamp(radius2, 0.0f, min(w - radius1, h)); + radius3 = clamp(radius3, 0.0f, min(h - radius2, w)); + radius4 = clamp(radius4, 0.0f, min(h - radius1, w - radius3)); Gdiplus::GraphicsPath* path = new Gdiplus::GraphicsPath; - if (radius2 < w - radius1) - path->AddLine(x + radius1, y, x + w - radius2, y); + if (radius2 < w - radius1) { + path->AddLine(x + radius1, y, x + w - radius2, y); + } - if (radius2 > 0.0f) - path->AddArc (x + w - (radius2 * 2), y, radius2 * 2, radius2 * 2, 270, 90); + if (radius2 > 0.0f) { + path->AddArc(x + w - (radius2 * 2), y, radius2 * 2, radius2 * 2, 270, 90); + } - if (radius3 < h - radius2) - path->AddLine(x + w, y + radius2, x + w, y + h - radius3); + if (radius3 < h - radius2) { + path->AddLine(x + w, y + radius2, x + w, y + h - radius3); + } - if (radius3 > 0.0f) - path->AddArc (x + w - (radius3 * 2), y + h - (radius3 * 2), radius3 * 2, radius3 * 2, 0, 90); + if (radius3 > 0.0f) { + path->AddArc(x + w - (radius3 * 2), y + h - (radius3 * 2), radius3 * 2, radius3 * 2, 0, 90); + } - if (radius4 < w - radius3) - path->AddLine(x + w - radius3, y + h, x + radius4, y + h); + if (radius4 < w - radius3) { + path->AddLine(x + w - radius3, y + h, x + radius4, y + h); + } - if (radius4 > 0.0f) - path->AddArc (x, y + h - (radius4 * 2), radius4 * 2, radius4 * 2, 90, 90); + if (radius4 > 0.0f) { + path->AddArc(x, y + h - (radius4 * 2), radius4 * 2, radius4 * 2, 90, 90); + } - if (radius4 < w - radius1) - path->AddLine(x, y + h - radius4 , x, y + radius1); + if (radius4 < w - radius1) { + path->AddLine(x, y + h - radius4, x, y + radius1); + } - if (radius1 > 0.0f) - path->AddArc (x, y, radius1 * 2, radius1 * 2, 180, 90); + if (radius1 > 0.0f) { + path->AddArc(x, y, radius1 * 2, radius1 * 2, 180, 90); + } path->CloseFigure(); return path; } -void ege_roundrect(float x, float y, float w, float h, float radius, PIMAGE pimg) +void ege_roundrect(float x, float y, float w, float h, float radius, PIMAGE pimg) { - ege_roundrect(x, y, w, h, radius, radius, radius, radius); + ege_roundrect(x, y, w, h, radius, radius, radius, radius); } -void ege_fillroundrect(float x, float y, float w, float h, float radius, PIMAGE pimg) + +void ege_fillroundrect(float x, float y, float w, float h, float radius, PIMAGE pimg) { - ege_fillroundrect(x, y, w, h, radius, radius, radius, radius, pimg); + ege_fillroundrect(x, y, w, h, radius, radius, radius, radius, pimg); } -void ege_roundrect(float x, float y, float w, float h, float radius1, float radius2, float radius3, float radius4, PIMAGE pimg) + +void ege_roundrect( + float x, float y, float w, float h, float radius1, float radius2, float radius3, float radius4, PIMAGE pimg) { - PIMAGE img = CONVERT_IMAGE(pimg); - Gdiplus::GraphicsPath* path = createRoundRectPath(x, y, w, h, radius1, radius2, radius3, radius4); + PIMAGE img = CONVERT_IMAGE(pimg); + Gdiplus::GraphicsPath* path = createRoundRectPath(x, y, w, h, radius1, radius2, radius3, radius4); if (path != NULL) { Gdiplus::Graphics* graphics = img->getGraphics(); @@ -2041,10 +2034,11 @@ void ege_roundrect(float x, float y, float w, float h, float radius1, float rad CONVERT_IMAGE_END } -void ege_fillroundrect(float x, float y, float w, float h, float radius1, float radius2, float radius3, float radius4, PIMAGE pimg) +void ege_fillroundrect( + float x, float y, float w, float h, float radius1, float radius2, float radius3, float radius4, PIMAGE pimg) { - PIMAGE img = CONVERT_IMAGE(pimg); - Gdiplus::GraphicsPath* path = createRoundRectPath(x, y, w, h, radius1, radius2, radius3, radius4); + PIMAGE img = CONVERT_IMAGE(pimg); + Gdiplus::GraphicsPath* path = createRoundRectPath(x, y, w, h, radius1, radius2, radius3, radius4); if (path != NULL) { Gdiplus::Graphics* graphics = img->getGraphics(); @@ -2059,7 +2053,7 @@ void ege_fillellipse(float x, float y, float w, float h, PIMAGE pimg) PIMAGE img = CONVERT_IMAGE(pimg); if (img) { Gdiplus::Graphics* graphics = img->getGraphics(); - Gdiplus::Brush* brush = img->getBrush(); + Gdiplus::Brush* brush = img->getBrush(); graphics->FillEllipse(brush, x, y, w, h); } CONVERT_IMAGE_END; @@ -2070,7 +2064,7 @@ void ege_fillpie(float x, float y, float w, float h, float startAngle, float swe PIMAGE img = CONVERT_IMAGE(pimg); if (img) { Gdiplus::Graphics* graphics = img->getGraphics(); - Gdiplus::Brush* brush = img->getBrush(); + Gdiplus::Brush* brush = img->getBrush(); graphics->FillPie(brush, x, y, w, h, startAngle, sweepAngle); } CONVERT_IMAGE_END; @@ -2080,10 +2074,10 @@ void ege_setalpha(int alpha, PIMAGE pimg) { PIMAGE img = CONVERT_IMAGE(pimg); if (img && img->m_hDC) { - int a = alpha << 24; + int a = alpha << 24; int len = img->m_width * img->m_height; for (int i = 0; i < len; ++i) { - DWORD c = img->m_pBuffer[i]; + DWORD c = img->m_pBuffer[i]; img->m_pBuffer[i] = a | (c & 0xFFFFFF); } } @@ -2108,7 +2102,7 @@ void ege_puttexture(PCIMAGE srcimg, float x, float y, float w, float h, PIMAGE p void ege_puttexture(PCIMAGE srcimg, ege_rect dest, PIMAGE pimg) { ege_rect src; - PIMAGE img = CONVERT_IMAGE(pimg); + PIMAGE img = CONVERT_IMAGE(pimg); if (img) { src.x = 0; src.y = 0; @@ -2139,11 +2133,8 @@ void ege_puttexture(PCIMAGE srcimg, ege_rect dest, ege_rect src, PIMAGE pimg) ia.SetColorMatrix(&mx); // */ // graphics.SetTransform(); - graphics->DrawImage((Gdiplus::Image*)srcimg->m_texture, - Gdiplus::RectF(dest.x, dest.y, dest.w, dest.h), - src.x, src.y, src.w, src.h, - Gdiplus::UnitPixel, - NULL); + graphics->DrawImage((Gdiplus::Image*)srcimg->m_texture, Gdiplus::RectF(dest.x, dest.y, dest.w, dest.h), + src.x, src.y, src.w, src.h, Gdiplus::UnitPixel, NULL); } } CONVERT_IMAGE_END; @@ -2154,61 +2145,46 @@ void EGEAPI ege_drawimage(PCIMAGE srcimg, int xDest, int yDest, PIMAGE pimg) PIMAGE img = CONVERT_IMAGE(pimg); if (img && srcimg) { Gdiplus::Graphics* graphics = img->getGraphics(); - Gdiplus::Bitmap bitmap(srcimg->getwidth(), - srcimg->getheight(), - 4 * srcimg->getwidth(), - PixelFormat32bppARGB, - (BYTE*)(srcimg->m_pBuffer)); - Gdiplus::Point p(xDest, yDest); + Gdiplus::Bitmap bitmap(srcimg->getwidth(), srcimg->getheight(), 4 * srcimg->getwidth(), PixelFormat32bppARGB, + (BYTE*)(srcimg->m_pBuffer)); + Gdiplus::Point p(xDest, yDest); graphics->DrawImage(&bitmap, p); } CONVERT_IMAGE_END; } -void EGEAPI ege_drawimage(PCIMAGE srcimg, - int xDest, - int yDest, - int widthDest, - int heightDest, - int xSrc, - int ySrc, - int srcWidth, - int srcHeight, - PIMAGE pimg) +void EGEAPI ege_drawimage(PCIMAGE srcimg, int xDest, int yDest, int widthDest, int heightDest, int xSrc, int ySrc, + int srcWidth, int srcHeight, PIMAGE pimg) { PIMAGE img = CONVERT_IMAGE(pimg); if (img && srcimg) { Gdiplus::Graphics* graphics = img->getGraphics(); - Gdiplus::Bitmap bitmap(srcimg->getwidth(), - srcimg->getheight(), - 4 * srcimg->getwidth(), - PixelFormat32bppARGB, - (BYTE*)(srcimg->m_pBuffer)); - Gdiplus::Point destPoints[3] = { - Gdiplus::Point(xDest, yDest), Gdiplus::Point(xDest + widthDest, yDest), Gdiplus::Point(xDest, yDest + heightDest)}; + Gdiplus::Bitmap bitmap(srcimg->getwidth(), srcimg->getheight(), 4 * srcimg->getwidth(), PixelFormat32bppARGB, + (BYTE*)(srcimg->m_pBuffer)); + Gdiplus::Point destPoints[3] = {Gdiplus::Point(xDest, yDest), Gdiplus::Point(xDest + widthDest, yDest), + Gdiplus::Point(xDest, yDest + heightDest)}; graphics->DrawImage( &bitmap, destPoints, 3, xSrc, ySrc, srcWidth, srcHeight, Gdiplus::UnitPixel, NULL, NULL, NULL); } CONVERT_IMAGE_END; } - ege_path::ege_path() { gdiplusinit(); m_data = new Gdiplus::GraphicsPath; } -ege_path::ege_path(const ege_point *points, const unsigned char *types, int count) +ege_path::ege_path(const ege_point* points, const unsigned char* types, int count) { gdiplusinit(); m_data = new Gdiplus::GraphicsPath((const Gdiplus::PointF*)points, (const BYTE*)types, count); } -ege_path::ege_path(const ege_path &path) +ege_path::ege_path(const ege_path& path) { const Gdiplus::GraphicsPath* graphicsPath = (const Gdiplus::GraphicsPath*)path.m_data; - m_data = (graphicsPath != NULL) ? graphicsPath->Clone() : NULL; + m_data = (graphicsPath != NULL) ? graphicsPath->Clone() : NULL; } ege_path::~ege_path() @@ -2236,7 +2212,7 @@ ege_path& ege_path::operator=(const ege_path& path) } const Gdiplus::GraphicsPath* graphicsPath = (Gdiplus::GraphicsPath*)path.m_data; - m_data = (graphicsPath != NULL) ? graphicsPath->Clone() : NULL; + m_data = (graphicsPath != NULL) ? graphicsPath->Clone() : NULL; } return *this; @@ -2297,20 +2273,21 @@ void ege_fillpath(const ege_path* path, float x, float y, PIMAGE pimg) ege_path* ege_path_create() { - return new(std::nothrow) ege_path; + return new (std::nothrow) ege_path; } ege_path* ege_path_createfrom(const ege_point* points, const unsigned char* types, int count) { - return new(std::nothrow) ege_path(points, types, count); + return new (std::nothrow) ege_path(points, types, count); } ege_path* ege_path_clone(const ege_path* path) { - if (path == NULL) + if (path == NULL) { return NULL; + } - return new(std::nothrow) ege_path(*path); + return new (std::nothrow) ege_path(*path); } void ege_path_destroy(const ege_path* path) @@ -2355,9 +2332,14 @@ void ege_path_setfillmode(ege_path* path, fill_mode mode) if (graphicsPath != NULL) { Gdiplus::FillMode fillMode = Gdiplus::FillModeAlternate; switch (mode) { - case FILLMODE_ALTERNATE: fillMode = Gdiplus::FillModeAlternate; break; - case FILLMODE_WINDING: fillMode = Gdiplus::FillModeWinding; break; - default: break; + case FILLMODE_ALTERNATE: + fillMode = Gdiplus::FillModeAlternate; + break; + case FILLMODE_WINDING: + fillMode = Gdiplus::FillModeWinding; + break; + default: + break; } graphicsPath->SetFillMode(fillMode); } @@ -2389,7 +2371,7 @@ void ege_path_widen(ege_path* path, float lineWidth, const ege_transform_matrix* ege_path_widen(path, lineWidth, matrix, Gdiplus::FlatnessDefault); } -void ege_path_widen(ege_path* path, float lineWidth, const ege_transform_matrix* matrix, float flatness) +void ege_path_widen(ege_path* path, float lineWidth, const ege_transform_matrix* matrix, float flatness) { if (path != NULL) { Gdiplus::GraphicsPath* graphicsPath = (Gdiplus::GraphicsPath*)path->data(); @@ -2429,10 +2411,10 @@ void ege_path_flatten(ege_path* path, const ege_transform_matrix* matrix, float } } -void ege_path_warp(ege_path* path, const ege_point* points, int count, const ege_rect* rect, - const ege_transform_matrix* matrix) +void ege_path_warp( + ege_path* path, const ege_point* points, int count, const ege_rect* rect, const ege_transform_matrix* matrix) { - ege_path_warp(path, points, count , rect, matrix, Gdiplus::FlatnessDefault); + ege_path_warp(path, points, count, rect, matrix, Gdiplus::FlatnessDefault); } void ege_path_warp(ege_path* path, const ege_point* points, int count, const ege_rect* rect, @@ -2442,7 +2424,7 @@ void ege_path_warp(ege_path* path, const ege_point* points, int count, const ege Gdiplus::GraphicsPath* graphicsPath = (Gdiplus::GraphicsPath*)path->data(); if (graphicsPath != NULL) { const Gdiplus::PointF* p = (const Gdiplus::PointF*)points; - const Gdiplus::RectF r(rect->x, rect->y, rect->w, rect->h); + const Gdiplus::RectF r(rect->x, rect->y, rect->w, rect->h); if (matrix != NULL) { Gdiplus::Matrix mat; @@ -2599,7 +2581,7 @@ ege_point* ege_path_getpathpoints(const ege_path* path, ege_point* points) int pointCount = graphicsPath->GetPointCount(); if (points == NULL) { - points = new(std::nothrow) ege_point[pointCount]; + points = new (std::nothrow) ege_point[pointCount]; } if (points != NULL) { @@ -2620,7 +2602,7 @@ unsigned char* ege_path_getpathtypes(const ege_path* path, unsigned char* types) int pointCount = graphicsPath->GetPointCount(); if (types == NULL) { - types = new(std::nothrow) unsigned char[pointCount]; + types = new (std::nothrow) unsigned char[pointCount]; } if (types != NULL) { @@ -2634,7 +2616,7 @@ unsigned char* ege_path_getpathtypes(const ege_path* path, unsigned char* types) return NULL; } -void ege_path_transform(ege_path* path, const ege_transform_matrix *matrix) +void ege_path_transform(ege_path* path, const ege_transform_matrix* matrix) { if ((path != NULL) && (matrix != NULL)) { Gdiplus::GraphicsPath* graphicsPath = (Gdiplus::GraphicsPath*)path->data(); @@ -2649,7 +2631,7 @@ void ege_path_transform(ege_path* path, const ege_transform_matrix *matrix) void ege_path_addpath(ege_path* dstPath, const ege_path* srcPath, bool connect) { if ((dstPath != NULL) && (srcPath != NULL)) { - Gdiplus::GraphicsPath* dstGraphicsPath = (Gdiplus::GraphicsPath*)dstPath->data(); + Gdiplus::GraphicsPath* dstGraphicsPath = (Gdiplus::GraphicsPath*)dstPath->data(); const Gdiplus::GraphicsPath* srcGraphicsPath = (const Gdiplus::GraphicsPath*)srcPath->data(); if ((dstGraphicsPath != NULL) && (srcGraphicsPath != NULL)) { dstGraphicsPath->AddPath(srcGraphicsPath, connect); @@ -2677,7 +2659,7 @@ void ege_path_addarc(ege_path* path, float x, float y, float width, float height } } -void ege_path_addpolyline(ege_path* path, int numOfPoints, const ege_point *points) +void ege_path_addpolyline(ege_path* path, int numOfPoints, const ege_point* points) { if (path != NULL) { Gdiplus::GraphicsPath* graphicsPath = (Gdiplus::GraphicsPath*)path->data(); @@ -2687,7 +2669,7 @@ void ege_path_addpolyline(ege_path* path, int numOfPoints, const ege_point *poin } } -void ege_path_addbezier(ege_path* path, int numOfPoints, const ege_point *points) +void ege_path_addbezier(ege_path* path, int numOfPoints, const ege_point* points) { if (path != NULL) { Gdiplus::GraphicsPath* graphicsPath = (Gdiplus::GraphicsPath*)path->data(); @@ -2707,7 +2689,7 @@ void ege_path_addbezier(ege_path* path, float x1, float y1, float x2, float y2, } } -void ege_path_addcurve(ege_path* path, int numOfPoints, const ege_point *points) +void ege_path_addcurve(ege_path* path, int numOfPoints, const ege_point* points) { if (path != NULL) { Gdiplus::GraphicsPath* graphicsPath = (Gdiplus::GraphicsPath*)path->data(); @@ -2717,7 +2699,7 @@ void ege_path_addcurve(ege_path* path, int numOfPoints, const ege_point *points) } } -void ege_path_addcurve(ege_path* path, int numOfPoints, const ege_point *points, float tension) +void ege_path_addcurve(ege_path* path, int numOfPoints, const ege_point* points, float tension) { if (path != NULL) { Gdiplus::GraphicsPath* graphicsPath = (Gdiplus::GraphicsPath*)path->data(); @@ -2768,21 +2750,20 @@ void ege_path_addpie(ege_path* path, float x, float y, float width, float height } } -void ege_path_addtext(ege_path* path, float x, float y, const char* text, float height, int length, - const char* typeface, int fontStyle) +void ege_path_addtext( + ege_path* path, float x, float y, const char* text, float height, int length, const char* typeface, int fontStyle) { ege_path_addtext(path, x, y, mb2w(text).c_str(), height, length, mb2w(typeface).c_str(), fontStyle); } void ege_path_addtext(ege_path* path, float x, float y, const wchar_t* text, float height, int length, - const wchar_t* typeface, int fontStyle) + const wchar_t* typeface, int fontStyle) { - if ((path != NULL) && (text != NULL) && (length != 0)) { + if ((path != NULL) && (text != NULL) && (length != 0)) { Gdiplus::GraphicsPath* graphicsPath = (Gdiplus::GraphicsPath*)path->data(); if (graphicsPath != NULL) { - - Gdiplus::REAL emSize = height; - Gdiplus::PointF origin(x, y); + Gdiplus::REAL emSize = height; + Gdiplus::PointF origin(x, y); const Gdiplus::StringFormat* format = Gdiplus::StringFormat::GenericTypographic(); if ((typeface == NULL) || (typeface[0] == L'\0')) { @@ -2792,17 +2773,25 @@ void ege_path_addtext(ege_path* path, float x, float y, const wchar_t* text, flo Gdiplus::FontFamily fontFamliy(typeface); INT style = 0; - if (fontStyle & FONTSTYLE_BOLD) style |= Gdiplus::FontStyleBold; - if (fontStyle & FONTSTYLE_ITALIC) style |= Gdiplus::FontStyleItalic; - if (fontStyle & FONTSTYLE_UNDERLINE) style |= Gdiplus::FontStyleUnderline; - if (fontStyle & FONTSTYLE_STRIKEOUT) style |= Gdiplus::FontStyleStrikeout; + if (fontStyle & FONTSTYLE_BOLD) { + style |= Gdiplus::FontStyleBold; + } + if (fontStyle & FONTSTYLE_ITALIC) { + style |= Gdiplus::FontStyleItalic; + } + if (fontStyle & FONTSTYLE_UNDERLINE) { + style |= Gdiplus::FontStyleUnderline; + } + if (fontStyle & FONTSTYLE_STRIKEOUT) { + style |= Gdiplus::FontStyleStrikeout; + } graphicsPath->AddString(text, length, &fontFamliy, style, emSize, origin, format); } } } -void ege_path_addpolygon(ege_path* path, int numOfPoints, const ege_point *points) +void ege_path_addpolygon(ege_path* path, int numOfPoints, const ege_point* points) { if (path != NULL) { Gdiplus::GraphicsPath* graphicsPath = (Gdiplus::GraphicsPath*)path->data(); @@ -2812,7 +2801,7 @@ void ege_path_addpolygon(ege_path* path, int numOfPoints, const ege_point *point } } -void ege_path_addclosedcurve(ege_path* path, int numOfPoints, const ege_point *points) +void ege_path_addclosedcurve(ege_path* path, int numOfPoints, const ege_point* points) { if (path != NULL) { Gdiplus::GraphicsPath* graphicsPath = (Gdiplus::GraphicsPath*)path->data(); @@ -2822,7 +2811,7 @@ void ege_path_addclosedcurve(ege_path* path, int numOfPoints, const ege_point *p } } -void ege_path_addclosedcurve(ege_path* path, int numOfPoints, const ege_point *points, float tension) +void ege_path_addclosedcurve(ege_path* path, int numOfPoints, const ege_point* points, float tension) { if (path != NULL) { Gdiplus::GraphicsPath* graphicsPath = (Gdiplus::GraphicsPath*)path->data(); @@ -2832,7 +2821,6 @@ void ege_path_addclosedcurve(ege_path* path, int numOfPoints, const ege_point *p } } - void EGEAPI ege_transform_rotate(float angle, PIMAGE pimg) { PIMAGE img = CONVERT_IMAGE(pimg); @@ -2872,13 +2860,14 @@ void EGEAPI ege_transform_reset(PIMAGE pimg) } CONVERT_IMAGE_END; } + void EGEAPI ege_get_transform(ege_transform_matrix* matrix, PIMAGE pimg) { PIMAGE img = CONVERT_IMAGE(pimg); if (img && matrix) { Gdiplus::Graphics* graphics = img->getGraphics(); - Gdiplus::Matrix mat; - Gdiplus::REAL elements[6]; + Gdiplus::Matrix mat; + Gdiplus::REAL elements[6]; graphics->GetTransform(&mat); mat.GetElements(elements); matrix->m11 = elements[0]; @@ -2896,7 +2885,7 @@ void EGEAPI ege_set_transform(const ege_transform_matrix* matrix, PIMAGE pimg) PIMAGE img = CONVERT_IMAGE(pimg); if (img && matrix) { Gdiplus::Graphics* graphics = img->getGraphics(); - Gdiplus::Matrix mat; + Gdiplus::Matrix mat; matrixConvert(*matrix, mat); graphics->SetTransform(&mat); } @@ -2910,11 +2899,11 @@ ege_point EGEAPI ege_transform_calc(ege_point p, PIMAGE pimg) ege_point EGEAPI ege_transform_calc(float x, float y, PIMAGE pimg) { - PIMAGE img = CONVERT_IMAGE(pimg); + PIMAGE img = CONVERT_IMAGE(pimg); ege_point point = {0.0f, 0.0f}; if (img) { Gdiplus::Graphics* graphics = img->getGraphics(); - Gdiplus::Matrix matrix; + Gdiplus::Matrix matrix; graphics->GetTransform(&matrix); matrix.TransformPoints((Gdiplus::PointF*)&point, 1); } @@ -2939,23 +2928,23 @@ HINSTANCE getHInstance() int message_addkeyhandler(void* param, LPMSG_KEY_PROC func) { struct _graph_setting* pg = &graph_setting; - pg->callback_key = func; - pg->callback_key_param = param; + pg->callback_key = func; + pg->callback_key_param = param; return grOk; } int message_addmousehandler(void* param, LPMSG_MOUSE_PROC func) { struct _graph_setting* pg = &graph_setting; - pg->callback_mouse = func; - pg->callback_mouse_param = param; + pg->callback_mouse = func; + pg->callback_mouse_param = param; return grOk; } int SetCloseHandler(LPCALLBACK_PROC func) { struct _graph_setting* pg = &graph_setting; - pg->callback_close = func; + pg->callback_close = func; return grOk; } @@ -2975,9 +2964,9 @@ static void draw_frame(PIMAGE img, int l, int t, int r, int b, color_t lc, color int inputbox_getline(const char* title, const char* text, LPSTR buf, int len) { const std::wstring& title_w = mb2w(title); - const std::wstring& text_w = mb2w(text); - std::wstring buf_w(len, L'\0'); - int ret = inputbox_getline(title_w.c_str(), text_w.c_str(), &buf_w[0], len); + const std::wstring& text_w = mb2w(text); + std::wstring buf_w(len, L'\0'); + int ret = inputbox_getline(title_w.c_str(), text_w.c_str(), &buf_w[0], len); if (ret) { WideCharToMultiByte(getcodepage(), 0, buf_w.c_str(), -1, buf, len, 0, 0); } @@ -2988,8 +2977,8 @@ int inputbox_getline(const wchar_t* title, const wchar_t* text, LPWSTR buf, int { IMAGE bg; IMAGE window; - int w = 400, h = 300, x = (getwidth() - w) / 2, y = (getheight() - h) / 2; - int ret = 0; + int w = 400, h = 300, x = (getwidth() - w) / 2, y = (getheight() - h) / 2; + int ret = 0; bg.getimage(0, 0, getwidth(), getheight()); window.resize(w, h); @@ -3020,10 +3009,7 @@ int inputbox_getline(const wchar_t* title, const wchar_t* text, LPWSTR buf, int { RECT rect = {30, 32, w - 30, 128 - 3}; - DrawTextW(window.m_hDC, - text, - -1, - &rect, + DrawTextW(window.m_hDC, text, -1, &rect, DT_NOPREFIX | DT_LEFT | DT_TOP | TA_NOUPDATECP | DT_WORDBREAK | DT_EDITCONTROL | DT_EXPANDTABS); } @@ -3052,10 +3038,10 @@ int inputbox_getline(const wchar_t* title, const wchar_t* text, LPWSTR buf, int return ret; } -static double static_frameRate = 0.0; /* 帧率 */ -static int static_frameCount = 0; /* 帧数 */ -static double static_totalFrameTime = 0.0; /* 累计时间 */ -static double static_lastFrameTime = 0.0; /* 上一帧更新时间 */ +static double static_frameRate = 0.0; /* 帧率 */ +static int static_frameCount = 0; /* 帧数 */ +static double static_totalFrameTime = 0.0; /* 累计时间 */ +static double static_lastFrameTime = 0.0; /* 上一帧更新时间 */ /** * 更新帧率 @@ -3064,8 +3050,8 @@ static double static_lastFrameTime = 0.0; /* 上一帧更新时间 */ */ void updateFrameRate(bool addFrameCount) { - struct _graph_setting* pg = &graph_setting; - double currentTime = get_highfeq_time_ls(pg); + struct _graph_setting* pg = &graph_setting; + double currentTime = get_highfeq_time_ls(pg); if (static_lastFrameTime == 0.0) { static_lastFrameTime = currentTime; @@ -3084,18 +3070,18 @@ void updateFrameRate(bool addFrameCount) if (elapsedTime >= 0.5) { static_frameRate = static_frameCount / elapsedTime; - static_frameCount = 0; + static_frameCount = 0; static_totalFrameTime = 0.0; - static_lastFrameTime = currentTime; + static_lastFrameTime = currentTime; } } void resetFrameRate() { - static_frameRate = 0.0; - static_frameCount = 0; + static_frameRate = 0.0; + static_frameCount = 0; static_totalFrameTime = 0.0; - static_lastFrameTime = 0.0; + static_lastFrameTime = 0.0; } float getfps() @@ -3118,7 +3104,7 @@ LRESULT sys_edit::onMessage(UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_CTLCOLOREDIT: { - HDC dc = (HDC)wParam; + HDC dc = (HDC)wParam; HBRUSH br = ::CreateSolidBrush(ARGBTOZBGR(m_bgcolor)); ::SetBkColor(dc, ARGBTOZBGR(m_bgcolor)); diff --git a/src/encodeconv.h b/src/encodeconv.h index 3e1a1466..9bf8ccd5 100644 --- a/src/encodeconv.h +++ b/src/encodeconv.h @@ -16,4 +16,4 @@ std::string w2mb(const wchar_t wStr[]); // convert multibyte string to wide char string, using ege::getcodepage std::wstring mb2w(const char mbStr[]); -} +} // namespace ege diff --git a/src/image.cpp b/src/image.cpp index cd30e913..96b6b535 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -24,7 +24,6 @@ #include - #include #include @@ -39,7 +38,7 @@ void IMAGE::reset() m_width = 0; m_height = 0; m_pBuffer = NULL; - m_linecolor = 0; + m_linecolor = 0; m_fillcolor = 0; m_textcolor = 0; m_bk_color = 0; @@ -47,12 +46,12 @@ void IMAGE::reset() memset(&m_vpt, 0, sizeof(m_vpt)); memset(&m_texttype, 0, sizeof(m_texttype)); memset(&m_linestyle, 0, sizeof(m_linestyle)); - m_linewidth = 0.0f; - m_linestartcap = LINECAP_FLAT; - m_lineendcap = LINECAP_FLAT; - m_linejoin = LINEJOIN_MITER; + m_linewidth = 0.0f; + m_linestartcap = LINECAP_FLAT; + m_lineendcap = LINECAP_FLAT; + m_linejoin = LINEJOIN_MITER; m_linejoinmiterlimit = 10.0f; - m_texture = NULL; + m_texture = NULL; #ifdef EGE_GDIPLUS m_graphics = NULL; m_pen = NULL; @@ -273,7 +272,7 @@ Gdiplus::Graphics* IMAGE::getGraphics() POINT origin; SetViewportOrgEx(m_hDC, 0, 0, &origin); HRGN clipRgn = CreateRectRgn(0, 0, 0, 0); - int result = GetClipRgn(m_hDC, clipRgn); + int result = GetClipRgn(m_hDC, clipRgn); m_graphics = new Gdiplus::Graphics(m_hDC); @@ -349,7 +348,7 @@ int IMAGE::resize_f(int width, int height) Size oldWindowSize(m_width, m_height); PDWORD bmp_buf; - HBITMAP bitmap = newbitmap(width, height, &bmp_buf); + HBITMAP bitmap = newbitmap(width, height, &bmp_buf); if (bitmap == NULL) { return grAllocError; } @@ -471,9 +470,9 @@ graphics_errors getimage_from_bitmap(PIMAGE pimg, Gdiplus::Bitmap& bitmap) Gdiplus::BitmapData bitmapData; bitmapData.Width = width; bitmapData.Height = height; - bitmapData.Stride = width * sizeof(color_t); // 至下一行像素的偏移量(字节) - bitmapData.PixelFormat = PixelFormat32bppARGB; // 像素颜色格式: 32 位 ARGB - bitmapData.Scan0 = getbuffer(pimg); // 图像首行像素的首地址 + bitmapData.Stride = width * sizeof(color_t); // 至下一行像素的偏移量(字节) + bitmapData.PixelFormat = PixelFormat32bppARGB; // 像素颜色格式: 32 位 ARGB + bitmapData.Scan0 = getbuffer(pimg); // 图像首行像素的首地址 /* 读取区域设置为整个图像 */ Gdiplus::Rect rect(0, 0, width, height); @@ -509,7 +508,7 @@ int IMAGE::getimage(const wchar_t* filename, int zoomWidth, int zoomHeight) /* GDI+ Bitmap 仅报 InvalidParameter 错误,无法进一步区分是不支持的格式还是格式错误 */ /* 通过文件扩展名判断文件是否在支持的格式中,支持为 grInvalidFileFormat,不支持则为 grUnsupportedFormat */ ImageDecodeFormat imageFormat = checkImageDecodeFormatByFileName(filename); - return (imageFormat == ImageDecodeFormat_NULL) ? grUnsupportedFormat : grInvalidFileFormat ; + return (imageFormat == ImageDecodeFormat_NULL) ? grUnsupportedFormat : grInvalidFileFormat; } return getimage_from_bitmap(this, bitmap); @@ -533,16 +532,15 @@ graphics_errors getimage_from_png_struct(PIMAGE self, void* vpng_ptr, void* vinf png_structp png_ptr = (png_structp)vpng_ptr; png_infop info_ptr = (png_infop)vinfo_ptr; - #if defined(PNG_SKIP_sRGB_CHECK_PROFILE) && defined(PNG_SET_OPTION_SUPPORTED) - png_set_option(png_ptr, PNG_SKIP_sRGB_CHECK_PROFILE, - PNG_OPTION_ON); - #endif +#if defined(PNG_SKIP_sRGB_CHECK_PROFILE) && defined(PNG_SET_OPTION_SUPPORTED) + png_set_option(png_ptr, PNG_SKIP_sRGB_CHECK_PROFILE, PNG_OPTION_ON); +#endif // 读取 PNG 文件信息, 存入 info_ptr 中 png_read_info(png_ptr, info_ptr); const png_byte color_type = png_get_color_type(png_ptr, info_ptr); - const png_byte bit_depth = png_get_bit_depth(png_ptr, info_ptr); // 每通道位深度 + const png_byte bit_depth = png_get_bit_depth(png_ptr, info_ptr); // 每通道位深度 // 将颜色类型转为 RGB 或 RGBA if (color_type == PNG_COLOR_TYPE_PALETTE) { @@ -554,7 +552,7 @@ graphics_errors getimage_from_png_struct(PIMAGE self, void* vpng_ptr, void* vinf // 将位深度设置为每通道 8 bit // (PNG 格式规定,RGB(RGBA) 位深度为 8 或 16,不会低于 8) if (bit_depth == 16) { - png_set_strip_16(png_ptr); // bit depth 16 to 8 + png_set_strip_16(png_ptr); // bit depth 16 to 8 } // 补齐 alpha 通道 @@ -606,7 +604,7 @@ graphics_errors getimage_from_png_struct(PIMAGE self, void* vpng_ptr, void* vinf int IMAGE::getpngimg(FILE* fp) { { - char header[16]; + char header[16]; const uint32_t number = 8; if (fread(header, 1, number, fp) != number) { @@ -725,7 +723,7 @@ struct MemCursor static void read_data_from_MemCursor(png_structp png_ptr, png_bytep outBytes, png_size_t byteCountToRead) { MemCursor& cursor = *(MemCursor*)png_get_io_ptr(png_ptr); - png_size_t count = MIN(cursor.size - cursor.cur, byteCountToRead); + png_size_t count = min(cursor.size - cursor.cur, byteCountToRead); memcpy(outBytes, cursor.data + cursor.cur, count); cursor.cur += count; } @@ -760,9 +758,9 @@ inline int getimage_from_resource(PIMAGE self, HRSRC hrsrc) png_destroy_read_struct(&png_ptr, &info_ptr, NULL); } else { - HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, dwSize); - LPVOID pvData; - IStream* pStm; + HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, dwSize); + LPVOID pvData; + IStream* pStm; if (hGlobal == NULL || (pvData = GlobalLock(hGlobal)) == NULL) { return grAllocError; @@ -814,10 +812,10 @@ int IMAGE::getimage(void* pMem, long size) inittest(L"IMAGE::getimage"); if (pMem) { - DWORD dwSize = size; - HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, dwSize); - LPVOID pvData; - IStream* pStm; + DWORD dwSize = size; + HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, dwSize); + LPVOID pvData; + IStream* pStm; if (hGlobal == NULL || (pvData = GlobalLock(hGlobal)) == NULL) { return grAllocError; @@ -846,8 +844,8 @@ int IMAGE::getimage(void* pMem, long size) return grIOerror; } -void IMAGE::putimage(PIMAGE imgDest, int xDest, int yDest, int widthDest, int heightDest, int xSrc, int ySrc, int srcWidth, - int srcHeight, DWORD dwRop) const +void IMAGE::putimage(PIMAGE imgDest, int xDest, int yDest, int widthDest, int heightDest, int xSrc, int ySrc, + int srcWidth, int srcHeight, DWORD dwRop) const { inittest(L"IMAGE::putimage"); const PCIMAGE img = CONVERT_IMAGE(imgDest); @@ -858,16 +856,16 @@ void IMAGE::putimage(PIMAGE imgDest, int xDest, int yDest, int widthDest, int he CONVERT_IMAGE_END; } -static void fix_rect_1size(PCIMAGE imgDest, PCIMAGE imgSrc, int* xDest, int* yDest, - int* xSrc, int* ySrc, int* width, int* height) +static void fix_rect_1size( + PCIMAGE imgDest, PCIMAGE imgSrc, int* xDest, int* yDest, int* xSrc, int* ySrc, int* width, int* height) { - Bound vpt = imgDest->m_vpt; + Bound vpt = imgDest->m_vpt; Point srcPos(*xSrc, *ySrc); Point dstPos(*xDest + vpt.left, *yDest + vpt.top); /* 区域位于图像右下角,此区域内无内容 */ - if ( (srcPos.x >= imgSrc->m_width) || (srcPos.y >= imgSrc->m_height) - || (dstPos.x >= imgDest->m_width) || (dstPos.y >= imgDest->m_height)) + if ((srcPos.x >= imgSrc->m_width) || (srcPos.y >= imgSrc->m_height) || (dstPos.x >= imgDest->m_width) || + (dstPos.y >= imgDest->m_height)) { *width = *height = 0; return; @@ -877,7 +875,7 @@ static void fix_rect_1size(PCIMAGE imgDest, PCIMAGE imgSrc, int* xDest, int* yDe srcBound.setTopLeft(*xSrc, *ySrc); /* 调整区域: 宽高参数 <= 0 则将区域扩展至图像右下边缘,否则截断在 int 范围内*/ - (*width <= 0) ? srcBound.setRight(imgSrc->m_width) : (void)srcBound.setLargeWidth(*width); + (*width <= 0) ? srcBound.setRight(imgSrc->m_width) : (void)srcBound.setLargeWidth(*width); (*height <= 0) ? srcBound.setBottom(imgSrc->m_height) : (void)srcBound.setLargeHeight(*height); /* 绘制区域 */ @@ -886,7 +884,7 @@ static void fix_rect_1size(PCIMAGE imgDest, PCIMAGE imgSrc, int* xDest, int* yDe dstBound.setLargeSize(srcBound.width(), srcBound.height()); /* 由视口区域计算绘制目标裁剪区域 */ - Bound srcClip(0, 0, imgSrc->m_width, imgSrc->m_height); + Bound srcClip(0, 0, imgSrc->m_width, imgSrc->m_height); Bound dstClip(0, 0, imgDest->m_width, imgDest->m_height); dstClip.intersect(vpt); @@ -916,14 +914,14 @@ static void fix_rect_1size(PCIMAGE imgDest, PCIMAGE imgSrc, int* xDest, int* yDe } } -int IMAGE::putimage_transparent(PIMAGE imgDest, // handle to dest - int xDest, // x-coord of destination upper-left corner - int yDest, // y-coord of destination upper-left corner - color_t transparentColor, // color to make transparent - int xSrc, // x-coord of source upper-left corner - int ySrc, // y-coord of source upper-left corner - int widthSrc, // width of source rectangle - int heightSrc // height of source rectangle +int IMAGE::putimage_transparent(PIMAGE imgDest, // handle to dest + int xDest, // x-coord of destination upper-left corner + int yDest, // y-coord of destination upper-left corner + color_t transparentColor, // color to make transparent + int xSrc, // x-coord of source upper-left corner + int ySrc, // y-coord of source upper-left corner + int widthSrc, // width of source rectangle + int heightSrc // height of source rectangle ) const { inittest(L"IMAGE::putimage_transparent"); @@ -936,8 +934,9 @@ int IMAGE::putimage_transparent(PIMAGE imgDest, // handle to dest // fix rect fix_rect_1size(img, imgSrc, &xDest, &yDest, &xSrc, &ySrc, &widthSrc, &heightSrc); - if ((widthSrc == 0) || (heightSrc == 0)) + if ((widthSrc == 0) || (heightSrc == 0)) { return grOk; + } // draw pdp = img->m_pBuffer + yDest * img->m_width + xDest; @@ -959,28 +958,30 @@ int IMAGE::putimage_transparent(PIMAGE imgDest, // handle to dest return grOk; } -int IMAGE::putimage_alphablend(PIMAGE imgDest, // handle to dest - int xDest, // x-coord of destination upper-left corner - int yDest, // y-coord of destination upper-left corner - unsigned char alpha, // alpha - int xSrc, // x-coord of source upper-left corner - int ySrc, // y-coord of source upper-left corner - int widthSrc, // width of source rectangle - int heightSrc,// height of source rectangle - alpha_type alphaType // alpha mode(straight alpha or premultiplied alpha) +int IMAGE::putimage_alphablend(PIMAGE imgDest, // handle to dest + int xDest, // x-coord of destination upper-left corner + int yDest, // y-coord of destination upper-left corner + unsigned char alpha, // alpha + int xSrc, // x-coord of source upper-left corner + int ySrc, // y-coord of source upper-left corner + int widthSrc, // width of source rectangle + int heightSrc, // height of source rectangle + alpha_type alphaType // alpha mode(straight alpha or premultiplied alpha) ) const { inittest(L"IMAGE::putimage_alphablend"); const PIMAGE img = CONVERT_IMAGE(imgDest); if (img) { - if (alpha == 0) + if (alpha == 0) { return grOk; + } PCIMAGE imgSrc = this; fix_rect_1size(img, imgSrc, &xDest, &yDest, &xSrc, &ySrc, &widthSrc, &heightSrc); - if ((widthSrc == 0) || (heightSrc == 0)) + if ((widthSrc == 0) || (heightSrc == 0)) { return grOk; + } if (alphaType == ALPHATYPE_PREMULTIPLIED) { BLENDFUNCTION bf; @@ -989,8 +990,8 @@ int IMAGE::putimage_alphablend(PIMAGE imgDest, // handle to dest bf.SourceConstantAlpha = alpha; bf.AlphaFormat = AC_SRC_ALPHA; // draw - dll::AlphaBlend(img->m_hDC, xDest, yDest, widthSrc, heightSrc, - imgSrc->m_hDC, xSrc, ySrc, widthSrc, heightSrc, bf); + dll::AlphaBlend( + img->m_hDC, xDest, yDest, widthSrc, heightSrc, imgSrc->m_hDC, xSrc, ySrc, widthSrc, heightSrc, bf); } else { DWORD* pdp = img->m_pBuffer + yDest * img->m_width + xDest; DWORD* psp = imgSrc->m_pBuffer + ySrc * imgSrc->m_width + xSrc; @@ -1033,21 +1034,30 @@ int IMAGE::putimage_alphablend(PIMAGE imgDest, // handle to dest int widthSrc, // width of source rectangle int heightSrc, // height of source rectangle bool smooth, - alpha_type alphaType // alpha mode(straight alpha or premultiplied alpha) + alpha_type alphaType // alpha mode(straight alpha or premultiplied alpha) ) const { inittest(L"IMAGE::putimage_alphablend"); const PIMAGE img = CONVERT_IMAGE(imgDest); if (img) { - if (alpha == 0) + if (alpha == 0) { return grOk; + } PCIMAGE imgSrc = this; - if (widthSrc <= 0) widthSrc = imgSrc->m_width; - if (heightSrc <= 0) heightSrc = imgSrc->m_height; - if (widthDest <= 0) widthDest = widthSrc; - if (heightDest <= 0) heightDest = heightSrc; + if (widthSrc <= 0) { + widthSrc = imgSrc->m_width; + } + if (heightSrc <= 0) { + heightSrc = imgSrc->m_height; + } + if (widthDest <= 0) { + widthDest = widthSrc; + } + if (heightDest <= 0) { + heightDest = heightSrc; + } if ((alphaType == ALPHATYPE_PREMULTIPLIED) && !smooth) { BLENDFUNCTION bf; @@ -1056,16 +1066,16 @@ int IMAGE::putimage_alphablend(PIMAGE imgDest, // handle to dest bf.SourceConstantAlpha = alpha; bf.AlphaFormat = AC_SRC_ALPHA; // draw - dll::AlphaBlend(img->m_hDC, xDest, yDest, widthDest, heightDest, imgSrc->m_hDC, xSrc, ySrc, widthSrc, - heightSrc, bf); + dll::AlphaBlend( + img->m_hDC, xDest, yDest, widthDest, heightDest, imgSrc->m_hDC, xSrc, ySrc, widthSrc, heightSrc, bf); } else { const Bound& vptDest = img->m_vpt; const Bound& vptSrc = imgSrc->m_vpt; - Rect drawDest(xDest + vptDest.left, yDest + vptDest.top, widthDest, heightDest); - Rect drawSrc(xSrc + vptSrc.left, ySrc + vptSrc.top, widthSrc, heightSrc); + Rect drawDest(xDest + vptDest.left, yDest + vptDest.top, widthDest, heightDest); + Rect drawSrc(xSrc + vptSrc.left, ySrc + vptSrc.top, widthSrc, heightSrc); Gdiplus::Graphics* graphics = img->getGraphics(); - Gdiplus::Matrix matrix; + Gdiplus::Matrix matrix; graphics->GetTransform(&matrix); graphics->ResetTransform(); @@ -1085,24 +1095,22 @@ int IMAGE::putimage_alphablend(PIMAGE imgDest, // handle to dest Gdiplus::ImageAttributes* imageAtt = NULL; if (alpha != 0xFF) { - float scale = alpha / 255.0f; - Gdiplus::ColorMatrix colorMatrix = { - 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, scale, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 1.0f - }; - imageAtt = new Gdiplus::ImageAttributes; - imageAtt->SetColorMatrix(&colorMatrix, Gdiplus::ColorMatrixFlagsDefault, Gdiplus::ColorAdjustTypeBitmap); + float scale = alpha / 255.0f; + Gdiplus::ColorMatrix colorMatrix = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, scale, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; + imageAtt = new Gdiplus::ImageAttributes; + imageAtt->SetColorMatrix( + &colorMatrix, Gdiplus::ColorMatrixFlagsDefault, Gdiplus::ColorAdjustTypeBitmap); } - Gdiplus::RectF rectDest((float)drawDest.x, (float)drawDest.y, (float)drawDest.width, (float)drawDest.height); + Gdiplus::RectF rectDest( + (float)drawDest.x, (float)drawDest.y, (float)drawDest.width, (float)drawDest.height); Gdiplus::RectF rectSrc((float)drawSrc.x, (float)drawSrc.y, (float)drawSrc.width, (float)drawSrc.height); - int stride = sizeof(color_t) * imgSrc->m_width; + int stride = sizeof(color_t) * imgSrc->m_width; Gdiplus::Bitmap bitmap(imgSrc->m_width, imgSrc->m_height, stride, pixelFormat, (BYTE*)imgSrc->m_pBuffer); - graphics->DrawImage(&bitmap, rectDest, rectSrc.X, rectSrc.Y, rectSrc.Width, rectSrc.Height, Gdiplus::UnitPixel, imageAtt); + graphics->DrawImage( + &bitmap, rectDest, rectSrc.X, rectSrc.Y, rectSrc.Width, rectSrc.Height, Gdiplus::UnitPixel, imageAtt); graphics->SetTransform(&matrix); delete imageAtt; @@ -1112,15 +1120,15 @@ int IMAGE::putimage_alphablend(PIMAGE imgDest, // handle to dest return grOk; } -int IMAGE::putimage_alphatransparent(PIMAGE imgDest, // handle to dest - int xDest, // x-coord of destination upper-left corner - int yDest, // y-coord of destination upper-left corner - color_t transparentColor, // color to make transparent - unsigned char alpha, // alpha - int xSrc, // x-coord of source upper-left corner - int ySrc, // y-coord of source upper-left corner - int widthSrc, // width of source rectangle - int heightSrc // height of source rectangle +int IMAGE::putimage_alphatransparent(PIMAGE imgDest, // handle to dest + int xDest, // x-coord of destination upper-left corner + int yDest, // y-coord of destination upper-left corner + color_t transparentColor, // color to make transparent + unsigned char alpha, // alpha + int xSrc, // x-coord of source upper-left corner + int ySrc, // y-coord of source upper-left corner + int widthSrc, // width of source rectangle + int heightSrc // height of source rectangle ) const { inittest(L"IMAGE::putimage_alphatransparent"); @@ -1133,8 +1141,9 @@ int IMAGE::putimage_alphatransparent(PIMAGE imgDest, // handle to dest // fix rect fix_rect_1size(img, imgSrc, &xDest, &yDest, &xSrc, &ySrc, &widthSrc, &heightSrc); - if ((widthSrc == 0) || (heightSrc == 0)) + if ((widthSrc == 0) || (heightSrc == 0)) { return grOk; + } // draw pdp = img->m_pBuffer + yDest * img->m_width + xDest; psp = imgSrc->m_pBuffer + ySrc * imgSrc->m_width + xSrc; @@ -1156,13 +1165,13 @@ int IMAGE::putimage_alphatransparent(PIMAGE imgDest, // handle to dest return grOk; } -int IMAGE::putimage_withalpha(PIMAGE imgDest, // handle to dest - int xDest, // x-coord of destination upper-left corner - int yDest, // y-coord of destination upper-left corner - int xSrc, // x-coord of source upper-left corner - int ySrc, // y-coord of source upper-left corner - int widthSrc, // width of source rectangle - int heightSrc // height of source rectangle +int IMAGE::putimage_withalpha(PIMAGE imgDest, // handle to dest + int xDest, // x-coord of destination upper-left corner + int yDest, // y-coord of destination upper-left corner + int xSrc, // x-coord of source upper-left corner + int ySrc, // y-coord of source upper-left corner + int widthSrc, // width of source rectangle + int heightSrc // height of source rectangle ) const { inittest(L"IMAGE::putimage_withalpha"); @@ -1175,8 +1184,9 @@ int IMAGE::putimage_withalpha(PIMAGE imgDest, // handle to dest // fix rect fix_rect_1size(img, imgSrc, &xDest, &yDest, &xSrc, &ySrc, &widthSrc, &heightSrc); - if ((widthSrc == 0) || (heightSrc == 0)) + if ((widthSrc == 0) || (heightSrc == 0)) { return grOk; + } // draw pdp = img->m_pBuffer + yDest * img->m_width + xDest; psp = imgSrc->m_pBuffer + ySrc * imgSrc->m_width + xSrc; @@ -1211,7 +1221,7 @@ int IMAGE::putimage_withalpha(PIMAGE imgDest, // handle to dest imgDest = CONVERT_IMAGE(imgDest); if (imgDest) { PCIMAGE imgSrc = this; - #if 0 +#if 0 int x, y; DWORD ddx, dsx; DWORD * pdp, *psp; @@ -1249,18 +1259,26 @@ int IMAGE::putimage_withalpha(PIMAGE imgDest, // handle to dest dll::AlphaBlend(img->m_hDC, xDest, yDest, widthDest, heightDest, alphaSrc->m_hDC, 0, 0, widthSrc, heightSrc, bf); delimage(alphaSrc); - #endif +#endif - if (widthSrc <= 0) widthSrc = imgSrc->m_width; - if (heightSrc <= 0) heightSrc = imgSrc->m_height; - if (widthDest <= 0) widthDest = widthSrc; - if (heightDest <= 0) heightDest = heightSrc; + if (widthSrc <= 0) { + widthSrc = imgSrc->m_width; + } + if (heightSrc <= 0) { + heightSrc = imgSrc->m_height; + } + if (widthDest <= 0) { + widthDest = widthSrc; + } + if (heightDest <= 0) { + heightDest = heightSrc; + } const Bound& vptDest = imgDest->m_vpt; const Bound& vptSrc = imgSrc->m_vpt; - Rect drawDest(xDest + vptDest.left, yDest + vptDest.top, widthDest, heightDest); - Rect drawSrc(xSrc + vptSrc.left, ySrc + vptSrc.top, widthSrc, heightSrc); - Rect clipDest(0, 0, imgDest->m_width, imgDest->m_height); + Rect drawDest(xDest + vptDest.left, yDest + vptDest.top, widthDest, heightDest); + Rect drawSrc(xSrc + vptSrc.left, ySrc + vptSrc.top, widthSrc, heightSrc); + Rect clipDest(0, 0, imgDest->m_width, imgDest->m_height); if (imgDest->m_enableclip) { clipDest = Rect(vptDest.left, vptDest.top, vptDest.right - vptDest.left, vptDest.bottom - vptDest.top); @@ -1270,7 +1288,7 @@ int IMAGE::putimage_withalpha(PIMAGE imgDest, // handle to dest Gdiplus::Region region(&path); Gdiplus::Graphics* graphics = imgDest->getGraphics(); - Gdiplus::Matrix matrix; + Gdiplus::Matrix matrix; graphics->GetTransform(&matrix); graphics->ResetTransform(); graphics->SetClip(®ion); @@ -1285,22 +1303,23 @@ int IMAGE::putimage_withalpha(PIMAGE imgDest, // handle to dest Gdiplus::RectF rectSrc((float)drawSrc.x, (float)drawSrc.y, (float)drawSrc.width, (float)drawSrc.height); Gdiplus::Bitmap bitmap(imgSrc->m_width, imgSrc->m_height, sizeof(color_t) * imgSrc->m_width, - PixelFormat32bppARGB, (BYTE*)imgSrc->m_pBuffer); - graphics->DrawImage(&bitmap, rectDest, rectSrc.X, rectSrc.Y, rectSrc.Width, rectSrc.Height, Gdiplus::UnitPixel, NULL); + PixelFormat32bppARGB, (BYTE*)imgSrc->m_pBuffer); + graphics->DrawImage( + &bitmap, rectDest, rectSrc.X, rectSrc.Y, rectSrc.Width, rectSrc.Height, Gdiplus::UnitPixel, NULL); graphics->SetTransform(&matrix); } CONVERT_IMAGE_END; return grOk; } -int IMAGE::putimage_alphafilter(PIMAGE imgDest, // handle to dest - int xDest, // x-coord of destination upper-left corner - int yDest, // y-coord of destination upper-left corner - PCIMAGE imgAlpha, // alpha - int xSrc, // x-coord of source upper-left corner - int ySrc, // y-coord of source upper-left corner - int widthSrc, // width of source rectangle - int heightSrc // height of source rectangle +int IMAGE::putimage_alphafilter(PIMAGE imgDest, // handle to dest + int xDest, // x-coord of destination upper-left corner + int yDest, // y-coord of destination upper-left corner + PCIMAGE imgAlpha, // alpha + int xSrc, // x-coord of source upper-left corner + int ySrc, // y-coord of source upper-left corner + int widthSrc, // width of source rectangle + int heightSrc // height of source rectangle ) const { inittest(L"IMAGE::putimage_alphafilter"); @@ -1314,8 +1333,9 @@ int IMAGE::putimage_alphafilter(PIMAGE imgDest, // handle to dest // fix rect fix_rect_1size(img, imgSrc, &xDest, &yDest, &xSrc, &ySrc, &widthSrc, &heightSrc); - if ((widthSrc == 0) || (heightSrc == 0)) + if ((widthSrc == 0) || (heightSrc == 0)) { return grOk; + } // draw pdp = img->m_pBuffer + yDest * img->m_width + xDest; psp = imgSrc->m_pBuffer + ySrc * imgSrc->m_width + xSrc; @@ -1324,7 +1344,7 @@ int IMAGE::putimage_alphafilter(PIMAGE imgDest, // handle to dest dsx = imgSrc->m_width - widthSrc; for (y = 0; y < heightSrc; ++y) { for (x = 0; x < widthSrc; ++x, ++psp, ++pdp, ++pap) { - DWORD d = *pdp, s = *psp; + DWORD d = *pdp, s = *psp; unsigned char alpha = *pap & 0xFF; if (*pap) { *pdp = alphablend_inline(d, s, alpha); @@ -1340,11 +1360,11 @@ int IMAGE::putimage_alphafilter(PIMAGE imgDest, // handle to dest } /* private function */ -static void fix_rect_0size(PIMAGE imgDest, // - int* xDest, // x-coord of destination upper-left corner - int* yDest, // y-coord of destination upper-left corner - int* widthDest, // width of destination rectangle - int* heightDest // height of destination rectangle +static void fix_rect_0size(PIMAGE imgDest, // + int* xDest, // x-coord of destination upper-left corner + int* yDest, // y-coord of destination upper-left corner + int* widthDest, // width of destination rectangle + int* heightDest // height of destination rectangle ) { struct viewporttype _vpt = {0, 0, imgDest->m_width, imgDest->m_height}; @@ -1355,25 +1375,24 @@ static void fix_rect_0size(PIMAGE imgDest, // *heightDest = imgDest->m_height; } if (*xDest < _vpt.left) { - int dx = _vpt.left - *xDest; + int dx = _vpt.left - *xDest; *xDest += dx; } if (*yDest < _vpt.top) { - int dy = _vpt.top - *yDest; + int dy = _vpt.top - *yDest; *yDest += dy; } if (*xDest + *widthDest > _vpt.right) { - int dx = *xDest + *widthDest - _vpt.right; + int dx = *xDest + *widthDest - _vpt.right; *widthDest -= dx; } if (*yDest + *heightDest > _vpt.bottom) { - int dy = *yDest + *heightDest - _vpt.bottom; + int dy = *yDest + *heightDest - _vpt.bottom; *heightDest -= dy; } } -int IMAGE::imagefilter_blurring_4( - int intensity, int alpha, int xDest, int yDest, int widthDest, int heightDest) +int IMAGE::imagefilter_blurring_4(int intensity, int alpha, int xDest, int yDest, int widthDest, int heightDest) { inittest(L"IMAGE::imagefilter_blurring_4"); struct _graph_setting* pg = &graph_setting; @@ -1494,8 +1513,7 @@ int IMAGE::imagefilter_blurring_4( return grOk; } -int IMAGE::imagefilter_blurring_8( - int intensity, int alpha, int xDest, int yDest, int widthDest, int heightDest) +int IMAGE::imagefilter_blurring_8(int intensity, int alpha, int xDest, int yDest, int widthDest, int heightDest) { inittest(L"IMAGE::imagefilter_blurring_4"); struct _graph_setting* pg = &graph_setting; @@ -1636,8 +1654,7 @@ int IMAGE::imagefilter_blurring_8( return grOk; } -int IMAGE::imagefilter_blurring( - int intensity, int alpha, int xDest, int yDest, int widthDest, int heightDest) +int IMAGE::imagefilter_blurring(int intensity, int alpha, int xDest, int yDest, int widthDest, int heightDest) { inittest(L"IMAGE::imagefilter_blurring"); PIMAGE imgDest = this; @@ -1659,21 +1676,19 @@ int IMAGE::imagefilter_blurring( return grOk; } -int IMAGE::putimage_rotate(PIMAGE imgTexture, int xDest, int yDest, float centerx, float centery, - float radian, - int btransparent, // transparent (1) or not (0) - int alpha, // in range[0, 256], alpha== -1 means no alpha - int smooth) -{ - return ege::putimage_rotate( - this, imgTexture, xDest, yDest, centerx, centery, radian, btransparent, alpha, smooth); -} - -int IMAGE::putimage_rotatezoom(PIMAGE imgTexture, int xDest, int yDest, float centerx, float centery, - float radian, float zoom, +int IMAGE::putimage_rotate(PIMAGE imgTexture, int xDest, int yDest, float centerx, float centery, float radian, int btransparent, // transparent (1) or not (0) int alpha, // in range[0, 256], alpha== -1 means no alpha int smooth) +{ + return ege::putimage_rotate(this, imgTexture, xDest, yDest, centerx, centery, radian, btransparent, alpha, smooth); +} + +int IMAGE::putimage_rotatezoom(PIMAGE imgTexture, int xDest, int yDest, float centerx, float centery, float radian, + float zoom, + int btransparent, // transparent (1) or not (0) + int alpha, // in range[0, 256], alpha== -1 means no alpha + int smooth) { return ege::putimage_rotatezoom( this, imgTexture, xDest, yDest, centerx, centery, radian, zoom, btransparent, alpha, smooth); @@ -2135,20 +2150,17 @@ static void draw_flat_trangle_alpha(PIMAGE dc_dest, const struct trangle2d* dt, b_alpha = 0; } { - struct point2d _t; - struct point2d _t3; - if (t2d.p[1].y > t2d.p[2].y) { - SWAP(t2d.p[1], t2d.p[2], _t); - SWAP(t3d.p[1], t3d.p[2], _t3); + swap(t2d.p[1], t2d.p[2]); + swap(t3d.p[1], t3d.p[2]); } if (t2d.p[0].y > t2d.p[1].y) { - SWAP(t2d.p[0], t2d.p[1], _t); - SWAP(t3d.p[0], t3d.p[1], _t3); + swap(t2d.p[0], t2d.p[1]); + swap(t3d.p[0], t3d.p[1]); } if (t2d.p[1].y > t2d.p[2].y) { - SWAP(t2d.p[1], t2d.p[2], _t); - SWAP(t3d.p[1], t3d.p[2], _t3); + swap(t2d.p[1], t2d.p[2]); + swap(t3d.p[1], t3d.p[2]); } } { @@ -2157,7 +2169,7 @@ static void draw_flat_trangle_alpha(PIMAGE dc_dest, const struct trangle2d* dt, int rs, re; int i, lh, rh; - struct point2d pl, pr, pt; + struct point2d pl, pr; struct point2d spl, spr; pl.x = t2d.p[1].x - t2d.p[0].x; @@ -2169,8 +2181,8 @@ static void draw_flat_trangle_alpha(PIMAGE dc_dest, const struct trangle2d* dt, spl.y = t3d.p[1].y - t3d.p[0].y; spr.y = t3d.p[2].y - t3d.p[0].y; - h = m - s; - rs = s; + h = m - s; + rs = s; if (s < y1) { s = y1; } @@ -2189,8 +2201,8 @@ static void draw_flat_trangle_alpha(PIMAGE dc_dest, const struct trangle2d* dt, spr.y *= dd; }// */ if (pl.x > pr.x) { - SWAP(pl, pr, pt); - SWAP(spl, spr, pt); + swap(pl, pr); + swap(spl, spr); } else { ; } @@ -2305,8 +2317,8 @@ static void draw_flat_trangle_alpha(PIMAGE dc_dest, const struct trangle2d* dt, spr.y *= dd; }// */ if (pl.x > pr.x) { - SWAP(pl, pr, pt); - SWAP(spl, spr, pt); + swap(pl, pr); + swap(spl, spr); } else { ; } @@ -2372,20 +2384,17 @@ static void draw_flat_trangle_alpha_s(PIMAGE dc_dest, const struct trangle2d* dt b_alpha = 0; } { - struct point2d _t; - struct point2d _t3; - if (t2d.p[1].y > t2d.p[2].y) { - SWAP(t2d.p[1], t2d.p[2], _t); - SWAP(t3d.p[1], t3d.p[2], _t3); + swap(t2d.p[1], t2d.p[2]); + swap(t3d.p[1], t3d.p[2]); } if (t2d.p[0].y > t2d.p[1].y) { - SWAP(t2d.p[0], t2d.p[1], _t); - SWAP(t3d.p[0], t3d.p[1], _t3); + swap(t2d.p[0], t2d.p[1]); + swap(t3d.p[0], t3d.p[1]); } if (t2d.p[1].y > t2d.p[2].y) { - SWAP(t2d.p[1], t2d.p[2], _t); - SWAP(t3d.p[1], t3d.p[2], _t3); + swap(t2d.p[1], t2d.p[2]); + swap(t3d.p[1], t3d.p[2]); } } { @@ -2394,7 +2403,7 @@ static void draw_flat_trangle_alpha_s(PIMAGE dc_dest, const struct trangle2d* dt int rs, re; int i, lh, rh; - struct point2d pl, pr, pt; + struct point2d pl, pr; struct point2d spl, spr; pl.x = t2d.p[1].x - t2d.p[0].x; @@ -2406,8 +2415,8 @@ static void draw_flat_trangle_alpha_s(PIMAGE dc_dest, const struct trangle2d* dt spl.y = t3d.p[1].y - t3d.p[0].y; spr.y = t3d.p[2].y - t3d.p[0].y; - h = m - s; - rs = s; + h = m - s; + rs = s; if (s < y1) { s = y1; } @@ -2426,8 +2435,8 @@ static void draw_flat_trangle_alpha_s(PIMAGE dc_dest, const struct trangle2d* dt spr.y *= dd; }// */ if (pl.x > pr.x) { - SWAP(pl, pr, pt); - SWAP(spl, spr, pt); + swap(pl, pr); + swap(spl, spr); } else { ; } @@ -2543,8 +2552,8 @@ static void draw_flat_trangle_alpha_s(PIMAGE dc_dest, const struct trangle2d* dt spr.y *= dd; }// */ if (pl.x > pr.x) { - SWAP(pl, pr, pt); - SWAP(spl, spr, pt); + swap(pl, pr); + swap(spl, spr); } else { ; } @@ -2633,10 +2642,9 @@ int putimage_trangle(PIMAGE imgDest, PCIMAGE imgTexture, return grOk; } -int putimage_rotate(PIMAGE imgDest, PCIMAGE imgTexture, int xDest, int yDest, float centerx, - float centery, float radian, - bool transparent, - int alpha, // in range[0, 256], alpha==256 means no alpha +int putimage_rotate(PIMAGE imgDest, PCIMAGE imgTexture, int xDest, int yDest, float centerx, float centery, + float radian, bool transparent, + int alpha, // in range[0, 256], alpha==256 means no alpha bool smooth) { PIMAGE dc_dest = CONVERT_IMAGE(imgDest); @@ -2645,8 +2653,8 @@ int putimage_rotate(PIMAGE imgDest, PCIMAGE imgTexture, int xDest, int yDest, fl if (dc_dest) { struct trangle2d _tt[2]; struct trangle2d _dt[2]; - double dx, dy, cr = cos(radian), sr = sin(radian); - int i, j; + double dx, dy, cr = cos(radian), sr = sin(radian); + int i, j; _tt[0].p[0].x = 0; _tt[0].p[0].y = 0; _tt[0].p[1].x = 0; @@ -2677,10 +2685,10 @@ int putimage_rotate(PIMAGE imgDest, PCIMAGE imgTexture, int xDest, int yDest, fl return grOk; } -int putimage_rotatezoom(PIMAGE imgDest, PCIMAGE imgTexture, int xDest, int yDest, float centerx, - float centery, float radian, float zoom, +int putimage_rotatezoom(PIMAGE imgDest, PCIMAGE imgTexture, int xDest, int yDest, float centerx, float centery, + float radian, float zoom, bool transparent, // transparent (1) or not (0) - int alpha, // in range[0, 256], alpha==256 means no alpha + int alpha, // in range[0, 256], alpha==256 means no alpha bool smooth) { PIMAGE dc_dest = CONVERT_IMAGE(imgDest); @@ -2688,8 +2696,8 @@ int putimage_rotatezoom(PIMAGE imgDest, PCIMAGE imgTexture, int xDest, int yDest if (dc_dest) { struct trangle2d _tt[2]; struct trangle2d _dt[2]; - double dx, dy, cr = cos(radian), sr = sin(radian); - int i, j; + double dx, dy, cr = cos(radian), sr = sin(radian); + int i, j; _tt[0].p[0].x = 0; _tt[0].p[0].y = 0; _tt[0].p[1].x = 0; @@ -2907,8 +2915,8 @@ void putimage(PIMAGE imgDest, int xDest, int yDest, PCIMAGE pSrcImg, DWORD dwRop pSrcImg->putimage(imgDest, xDest, yDest, dwRop); } -void putimage(PIMAGE imgDest, int xDest, int yDest, int widthDest, int heightDest, - PCIMAGE pSrcImg, int xSrc, int ySrc, DWORD dwRop) +void putimage(PIMAGE imgDest, int xDest, int yDest, int widthDest, int heightDest, PCIMAGE pSrcImg, int xSrc, int ySrc, + DWORD dwRop) { pSrcImg = CONVERT_IMAGE_CONST(pSrcImg); pSrcImg->putimage(imgDest, xDest, yDest, widthDest, heightDest, xSrc, ySrc, dwRop); @@ -2938,106 +2946,83 @@ int getimage(PIMAGE imgDest, const wchar_t* resType, const wchar_t* resName, int return imgDest->getimage(resType, resName, zoomWidth, zoomHeight); } -void putimage(PIMAGE imgDest, int xDest, int yDest, int widthDest, int heightDest, - PCIMAGE pSrcImg, int xSrc, int ySrc, int srcWidth, int srcHeight, DWORD dwRop) +void putimage(PIMAGE imgDest, int xDest, int yDest, int widthDest, int heightDest, PCIMAGE pSrcImg, int xSrc, int ySrc, + int srcWidth, int srcHeight, DWORD dwRop) { pSrcImg = CONVERT_IMAGE_CONST(pSrcImg); pSrcImg->putimage(imgDest, xDest, yDest, widthDest, heightDest, xSrc, ySrc, srcWidth, srcHeight, dwRop); } -void putimage(int xDest, int yDest, int widthDest, int heightDest, - PCIMAGE pSrcImg, int xSrc, int ySrc, int srcWidth, int srcHeight, DWORD dwRop) +void putimage(int xDest, int yDest, int widthDest, int heightDest, PCIMAGE pSrcImg, int xSrc, int ySrc, int srcWidth, + int srcHeight, DWORD dwRop) { pSrcImg = CONVERT_IMAGE_CONST(pSrcImg); pSrcImg->putimage(NULL, xDest, yDest, widthDest, heightDest, xSrc, ySrc, srcWidth, srcHeight, dwRop); } -int putimage_transparent(PIMAGE imgDest, // handle to dest - PCIMAGE imgSrc, // handle to source - int xDest, // x-coord of destination upper-left corner - int yDest, // y-coord of destination upper-left corner - color_t transparentColor, // color to make transparent - int xSrc, // x-coord of source upper-left corner - int ySrc, // y-coord of source upper-left corner - int widthSrc, // width of source rectangle - int heightSrc // height of source rectangle +int putimage_transparent(PIMAGE imgDest, // handle to dest + PCIMAGE imgSrc, // handle to source + int xDest, // x-coord of destination upper-left corner + int yDest, // y-coord of destination upper-left corner + color_t transparentColor, // color to make transparent + int xSrc, // x-coord of source upper-left corner + int ySrc, // y-coord of source upper-left corner + int widthSrc, // width of source rectangle + int heightSrc // height of source rectangle ) { imgSrc = CONVERT_IMAGE_CONST(imgSrc); - return imgSrc->putimage_transparent( - imgDest, xDest, yDest, transparentColor, xSrc, ySrc, widthSrc, heightSrc); + return imgSrc->putimage_transparent(imgDest, xDest, yDest, transparentColor, xSrc, ySrc, widthSrc, heightSrc); } int EGEAPI putimage_alphablend( - PIMAGE imgDest, - PCIMAGE imgSrc, - int xDest, int yDest, - unsigned char alpha, - alpha_type alphaType -) + PIMAGE imgDest, PCIMAGE imgSrc, int xDest, int yDest, unsigned char alpha, alpha_type alphaType) { return putimage_alphablend(imgDest, imgSrc, xDest, yDest, alpha, 0, 0, 0, 0, alphaType); } int EGEAPI putimage_alphablend( - PIMAGE imgDest, - PCIMAGE imgSrc, - int xDest, int yDest, - unsigned char alpha, - int xSrc, int ySrc, - alpha_type alphaType -) + PIMAGE imgDest, PCIMAGE imgSrc, int xDest, int yDest, unsigned char alpha, int xSrc, int ySrc, alpha_type alphaType) { return putimage_alphablend(imgDest, imgSrc, xDest, yDest, alpha, xSrc, ySrc, 0, 0, alphaType); } -int putimage_alphablend(PIMAGE imgDest, // handle to dest - PCIMAGE imgSrc, // handle to source - int xDest, // x-coord of destination upper-left corner - int yDest, // y-coord of destination upper-left corner - unsigned char alpha, // alpha - int xSrc, // x-coord of source upper-left corner - int ySrc, // y-coord of source upper-left corner - int widthSrc, // width of source rectangle - int heightSrc, // height of source rectangle - alpha_type alphaType // alpha mode(straight alpha or premultiplied alpha) +int putimage_alphablend(PIMAGE imgDest, // handle to dest + PCIMAGE imgSrc, // handle to source + int xDest, // x-coord of destination upper-left corner + int yDest, // y-coord of destination upper-left corner + unsigned char alpha, // alpha + int xSrc, // x-coord of source upper-left corner + int ySrc, // y-coord of source upper-left corner + int widthSrc, // width of source rectangle + int heightSrc, // height of source rectangle + alpha_type alphaType // alpha mode(straight alpha or premultiplied alpha) ) { imgSrc = CONVERT_IMAGE_CONST(imgSrc); return imgSrc->putimage_alphablend(imgDest, xDest, yDest, alpha, xSrc, ySrc, widthSrc, heightSrc, alphaType); } -int EGEAPI putimage_alphablend( - PIMAGE imgDest, // handle to dest - PCIMAGE imgSrc, // handle to source - int xDest, int yDest, int widthDest, int heightDest, - unsigned char alpha, - int xSrc, int ySrc, int widthSrc, int heightSrc, - bool smooth, - alpha_type alphaType -) +int EGEAPI putimage_alphablend(PIMAGE imgDest, // handle to dest + PCIMAGE imgSrc, // handle to source + int xDest, int yDest, int widthDest, int heightDest, unsigned char alpha, int xSrc, int ySrc, int widthSrc, + int heightSrc, bool smooth, alpha_type alphaType) { imgSrc = CONVERT_IMAGE_CONST(imgSrc); return imgSrc->putimage_alphablend( - imgDest, - xDest, yDest, widthDest, heightDest, - alpha, - xSrc, ySrc, widthSrc, heightSrc, - smooth, - alphaType - ); -} - -int putimage_alphatransparent(PIMAGE imgDest, // handle to dest - PCIMAGE imgSrc, // handle to source - int xDest, // x-coord of destination upper-left corner - int yDest, // y-coord of destination upper-left corner - color_t transparentColor, // color to make transparent - unsigned char alpha, // alpha - int xSrc, // x-coord of source upper-left corner - int ySrc, // y-coord of source upper-left corner - int widthSrc, // width of source rectangle - int heightSrc // height of source rectangle + imgDest, xDest, yDest, widthDest, heightDest, alpha, xSrc, ySrc, widthSrc, heightSrc, smooth, alphaType); +} + +int putimage_alphatransparent(PIMAGE imgDest, // handle to dest + PCIMAGE imgSrc, // handle to source + int xDest, // x-coord of destination upper-left corner + int yDest, // y-coord of destination upper-left corner + color_t transparentColor, // color to make transparent + unsigned char alpha, // alpha + int xSrc, // x-coord of source upper-left corner + int ySrc, // y-coord of source upper-left corner + int widthSrc, // width of source rectangle + int heightSrc // height of source rectangle ) { imgSrc = CONVERT_IMAGE_CONST(imgSrc); @@ -3056,8 +3041,7 @@ int putimage_withalpha(PIMAGE imgDest, // handle to dest ) { imgSrc = CONVERT_IMAGE_CONST(imgSrc); - return imgSrc->putimage_withalpha( - imgDest, xDest, yDest, xSrc, ySrc, widthSrc, heightSrc); + return imgSrc->putimage_withalpha(imgDest, xDest, yDest, xSrc, ySrc, widthSrc, heightSrc); } int EGEAPI putimage_withalpha(PIMAGE imgDest, // handle to dest @@ -3070,32 +3054,29 @@ int EGEAPI putimage_withalpha(PIMAGE imgDest, // handle to dest int ySrc, // y-coord of source upper-left corner int widthSrc, // width of source rectangle int heightSrc, // height of source rectangle - bool smooth -) + bool smooth) { imgSrc = CONVERT_IMAGE_CONST(imgSrc); return imgSrc->putimage_withalpha( imgDest, xDest, yDest, widthDest, heightDest, xSrc, ySrc, widthSrc, heightSrc, smooth); } -int putimage_alphafilter(PIMAGE imgDest, // handle to dest - PCIMAGE imgSrc, // handle to source - int xDest, // x-coord of destination upper-left corner - int yDest, // y-coord of destination upper-left corner - PCIMAGE imgAlpha, // alpha - int xSrc, // x-coord of source upper-left corner - int ySrc, // y-coord of source upper-left corner - int widthSrc, // width of source rectangle - int heightSrc // height of source rectangle +int putimage_alphafilter(PIMAGE imgDest, // handle to dest + PCIMAGE imgSrc, // handle to source + int xDest, // x-coord of destination upper-left corner + int yDest, // y-coord of destination upper-left corner + PCIMAGE imgAlpha, // alpha + int xSrc, // x-coord of source upper-left corner + int ySrc, // y-coord of source upper-left corner + int widthSrc, // width of source rectangle + int heightSrc // height of source rectangle ) { imgSrc = CONVERT_IMAGE_CONST(imgSrc); - return imgSrc->putimage_alphafilter( - imgDest, xDest, yDest, imgAlpha, xSrc, ySrc, widthSrc, heightSrc); + return imgSrc->putimage_alphafilter(imgDest, xDest, yDest, imgAlpha, xSrc, ySrc, widthSrc, heightSrc); } -int imagefilter_blurring( - PIMAGE imgDest, int intensity, int alpha, int xDest, int yDest, int widthDest, int heightDest) +int imagefilter_blurring(PIMAGE imgDest, int intensity, int alpha, int xDest, int yDest, int widthDest, int heightDest) { PIMAGE img = CONVERT_IMAGE(imgDest); int ret = 0; @@ -3167,8 +3148,9 @@ int getimage_pngfile(PIMAGE pimg, const char* filename) int getimage_pngfile(PIMAGE pimg, const wchar_t* filename) { - if ((filename == NULL) || (filename[0] == '\0')) + if ((filename == NULL) || (filename[0] == '\0')) { return grParamError; + } FILE* fp = _wfopen(filename, L"rb"); @@ -3189,10 +3171,11 @@ int savepng(PCIMAGE pimg, const char* filename, bool withAlphaChannel) int savepng(PCIMAGE pimg, const wchar_t* filename, bool withAlphaChannel) { - if ((filename == NULL) || (filename[0] == '\0')) + if ((filename == NULL) || (filename[0] == '\0')) { return grParamError; + } - pimg = CONVERT_IMAGE_CONST(pimg); + pimg = CONVERT_IMAGE_CONST(pimg); FILE* fp = _wfopen(filename, L"wb"); if (fp == NULL) { @@ -3254,65 +3237,67 @@ int savebmp(PCIMAGE pimg, const wchar_t* filename, bool withAlphaChannel) */ int savebmp(PCIMAGE pimg, FILE* file, bool withAlphaChannel) { - if (file == NULL) + if (file == NULL) { return grIOerror; + } - int infoHeaderSize = 0; // InfoHeader 大小 (BITMAPINFOHEADER: 40), (BITMAPV4HEADER: 108) - int bytesPerPixel = 4; // 每像素所占字节数 - int paddingBytes = 0; // 每行填充字节数( BMP 格式规定:除非使用 RLE 压缩,否则每行像素必须是4字节对齐) - DWORD Compression = 0; // 图像压缩方式 + int infoHeaderSize = 0; // InfoHeader 大小 (BITMAPINFOHEADER: 40), (BITMAPV4HEADER: 108) + int bytesPerPixel = 4; // 每像素所占字节数 + int paddingBytes = 0; // 每行填充字节数( BMP 格式规定:除非使用 RLE 压缩,否则每行像素必须是4字节对齐) + DWORD Compression = 0; // 图像压缩方式 if (withAlphaChannel) { // 以 ARGB 格式保存, 使用 BITMAPV4HEADER - infoHeaderSize = sizeof(BITMAPV4HEADER); // 108 - bytesPerPixel = 4; // 32 位 - Compression = BI_BITFIELDS; // ARGB (各颜色分量由 Mask 确定) + infoHeaderSize = sizeof(BITMAPV4HEADER); // 108 + bytesPerPixel = 4; // 32 位 + Compression = BI_BITFIELDS; // ARGB (各颜色分量由 Mask 确定) } else { // 以 RGB24 格式保存, 使用 BITMAPINFOHEADER - infoHeaderSize = sizeof(BITMAPINFOHEADER); // 40 - bytesPerPixel = 3; // 24 位 - Compression = BI_RGB; // RGB + infoHeaderSize = sizeof(BITMAPINFOHEADER); // 40 + bytesPerPixel = 3; // 24 位 + Compression = BI_RGB; // RGB // 计算每行填充字节(每行4字节对齐) - int originalBytesPerRow = getwidth(pimg) * bytesPerPixel; - int remBytes = originalBytesPerRow % 4; + int originalBytesPerRow = getwidth(pimg) * bytesPerPixel; + int remBytes = originalBytesPerRow % 4; if (remBytes != 0) { paddingBytes = 4 - remBytes; } } - int bytesPerRow = bytesPerPixel * getwidth(pimg) + paddingBytes; // 每行所占字节数(包括填充字节) + int bytesPerRow = bytesPerPixel * getwidth(pimg) + paddingBytes; // 每行所占字节数(包括填充字节) BITMAPV4HEADER bitmapInfoHeader = {0}; // -------- BITMAPINFOHEADER, BITMAPV4HEADER 共有参数 -------- - bitmapInfoHeader.bV4Size = infoHeaderSize; // Header 大小(可用于识别 Header 版本) - bitmapInfoHeader.bV4Width = getwidth(pimg); // 位图宽度(单位为像素) - bitmapInfoHeader.bV4Height = getheight(pimg); // 位图高度(单位为像素, 正数表示从下到上存储, 负数为从上到下) - bitmapInfoHeader.bV4Planes = 1; // 固定值,必须为 1 - bitmapInfoHeader.bV4BitCount = (WORD)bytesPerPixel * 8; // 每像素的位数(即 位深度) - bitmapInfoHeader.bV4V4Compression = Compression; // 压缩方式 - bitmapInfoHeader.bV4SizeImage = bytesPerRow * getheight(pimg); // 图像像素部分所占大小(单位为字节,包括填充字节) - bitmapInfoHeader.bV4XPelsPerMeter = 3780; // 96 DPI x 39.3701(inch/m) - bitmapInfoHeader.bV4YPelsPerMeter = 3780; // 96 DPI x 39.3701(inch/m) - bitmapInfoHeader.bV4ClrUsed = 0; // 不使用颜色表 - bitmapInfoHeader.bV4ClrImportant = 0; // 颜色表中所有颜色都重要 + bitmapInfoHeader.bV4Size = infoHeaderSize; // Header 大小(可用于识别 Header 版本) + bitmapInfoHeader.bV4Width = getwidth(pimg); // 位图宽度(单位为像素) + bitmapInfoHeader.bV4Height = getheight(pimg); // 位图高度(单位为像素, 正数表示从下到上存储, 负数为从上到下) + bitmapInfoHeader.bV4Planes = 1; // 固定值,必须为 1 + bitmapInfoHeader.bV4BitCount = (WORD)bytesPerPixel * 8; // 每像素的位数(即 位深度) + bitmapInfoHeader.bV4V4Compression = Compression; // 压缩方式 + bitmapInfoHeader.bV4SizeImage = bytesPerRow * getheight(pimg); // 图像像素部分所占大小(单位为字节,包括填充字节) + bitmapInfoHeader.bV4XPelsPerMeter = 3780; // 96 DPI x 39.3701(inch/m) + bitmapInfoHeader.bV4YPelsPerMeter = 3780; // 96 DPI x 39.3701(inch/m) + bitmapInfoHeader.bV4ClrUsed = 0; // 不使用颜色表 + bitmapInfoHeader.bV4ClrImportant = 0; // 颜色表中所有颜色都重要 // --------------- BITMAPV4HEADER 特有参数 ------------------ - bitmapInfoHeader.bV4RedMask = 0x00FF0000U; - bitmapInfoHeader.bV4GreenMask = 0x0000FF00U; - bitmapInfoHeader.bV4BlueMask = 0x000000FFU; - bitmapInfoHeader.bV4AlphaMask = 0xFF000000U; - bitmapInfoHeader.bV4CSType = 0x73524742U; // 使用标准 RGB 颜色空间(LCS_sRGB宏: 'sRGB' 的值) + bitmapInfoHeader.bV4RedMask = 0x00FF0000U; + bitmapInfoHeader.bV4GreenMask = 0x0000FF00U; + bitmapInfoHeader.bV4BlueMask = 0x000000FFU; + bitmapInfoHeader.bV4AlphaMask = 0xFF000000U; + bitmapInfoHeader.bV4CSType = 0x73524742U; // 使用标准 RGB 颜色空间(LCS_sRGB宏: 'sRGB' 的值) // 当 bV4CSType 为 'sRGB' 或 'Win ' 时忽略以下参数 - //bitmapInfoHeader.bV4Endpoints - //bitmapInfoHeader.bV4GammaRed - //bitmapInfoHeader.bV4GammaGreen - //bitmapInfoHeader.bV4GammaBlue + // bitmapInfoHeader.bV4Endpoints + // bitmapInfoHeader.bV4GammaRed + // bitmapInfoHeader.bV4GammaGreen + // bitmapInfoHeader.bV4GammaBlue BITMAPFILEHEADER bitmapFileHeader = {0}; - bitmapFileHeader.bfType = (WORD&)"BM"; // Windows Bitmap 格式 - bitmapFileHeader.bfSize = sizeof(BITMAPFILEHEADER) + infoHeaderSize + bytesPerRow * getheight(pimg) ; // BMP 文件总字节数 - bitmapFileHeader.bfOffBits = sizeof(BITMAPFILEHEADER) + infoHeaderSize; // 从文件起始至像素数据的偏移字节数 + bitmapFileHeader.bfType = (WORD&)"BM"; // Windows Bitmap 格式 + bitmapFileHeader.bfSize = + sizeof(BITMAPFILEHEADER) + infoHeaderSize + bytesPerRow * getheight(pimg); // BMP 文件总字节数 + bitmapFileHeader.bfOffBits = sizeof(BITMAPFILEHEADER) + infoHeaderSize; // 从文件起始至像素数据的偏移字节数 // 1. 写入 File Header if (fwrite(&bitmapFileHeader, sizeof(BITMAPFILEHEADER), 1, file) != 1) { @@ -3325,12 +3310,12 @@ int savebmp(PCIMAGE pimg, FILE* file, bool withAlphaChannel) }; const color_t* buffer = getbuffer(pimg); - const int rowCnt = getheight(pimg); - const int colCnt = getwidth(pimg); + const int rowCnt = getheight(pimg); + const int colCnt = getwidth(pimg); // 3. 写入图像数据(从下到上进行存储) if (bytesPerPixel == 4) { - for (int row = rowCnt-1; row >= 0; row--) { + for (int row = rowCnt - 1; row >= 0; row--) { if (fwrite(&buffer[row * colCnt], bytesPerRow, 1, file) != 1) { return grIOerror; } @@ -3338,10 +3323,10 @@ int savebmp(PCIMAGE pimg, FILE* file, bool withAlphaChannel) } else if (bytesPerPixel == 3) { const unsigned char zeroPadding[4] = {0, 0, 0, 0}; - for (int row = rowCnt-1; row >= 0; row--) { - const color_t* pixels = &buffer[row * colCnt]; // 每行像素首地址 + for (int row = rowCnt - 1; row >= 0; row--) { + const color_t* pixels = &buffer[row * colCnt]; // 每行像素首地址 - for(int col = 0; col < colCnt; col++) { + for (int col = 0; col < colCnt; col++) { if (fwrite(&pixels[col], bytesPerPixel, 1, file) != 1) { return grIOerror; } @@ -3349,7 +3334,7 @@ int savebmp(PCIMAGE pimg, FILE* file, bool withAlphaChannel) // 每行末尾填充对齐 4 字节 if (paddingBytes != 0) { - if (fwrite(zeroPadding, paddingBytes,1, file) != 1) { + if (fwrite(zeroPadding, paddingBytes, 1, file) != 1) { return grIOerror; } } @@ -3359,7 +3344,6 @@ int savebmp(PCIMAGE pimg, FILE* file, bool withAlphaChannel) return grOk; } - void ege_enable_aa(bool enable, PIMAGE pimg) { PIMAGE img = CONVERT_IMAGE(pimg); @@ -3369,33 +3353,35 @@ void ege_enable_aa(bool enable, PIMAGE pimg) ImageDecodeFormat checkImageDecodeFormatByFileName(const wchar_t* fileName) { - if (fileName == NULL) + if (fileName == NULL) { return ImageDecodeFormat_NULL; + } - const wchar_t* fileExtension = wcsrchr(fileName, L'.'); + const wchar_t* fileExtension = wcsrchr(fileName, L'.'); if (fileExtension == NULL) { return ImageDecodeFormat_NULL; } fileExtension++; // skip '.' - const struct { - const wchar_t* ext; + const struct + { + const wchar_t* ext; ImageDecodeFormat format; } formatMap[] = { - {L"png", ImageDecodeFormat_PNG }, - {L"bmp", ImageDecodeFormat_BMP }, - {L"dib", ImageDecodeFormat_BMP }, - {L"jpg", ImageDecodeFormat_JPEG}, + {L"png", ImageDecodeFormat_PNG}, + {L"bmp", ImageDecodeFormat_BMP}, + {L"dib", ImageDecodeFormat_BMP}, + {L"jpg", ImageDecodeFormat_JPEG}, {L"jpeg", ImageDecodeFormat_JPEG}, - {L"jpe", ImageDecodeFormat_JPEG}, + {L"jpe", ImageDecodeFormat_JPEG}, {L"jfif", ImageDecodeFormat_JPEG}, - {L"gif", ImageDecodeFormat_GIF }, - {L"tif", ImageDecodeFormat_TIFF}, + {L"gif", ImageDecodeFormat_GIF}, + {L"tif", ImageDecodeFormat_TIFF}, {L"tiff", ImageDecodeFormat_TIFF}, {L"exif", ImageDecodeFormat_EXIF}, - {L"wmf", ImageDecodeFormat_WMF }, - {L"emf", ImageDecodeFormat_EMF }, + {L"wmf", ImageDecodeFormat_WMF}, + {L"emf", ImageDecodeFormat_EMF}, }; const int formatMapLength = sizeof(formatMap) / sizeof(formatMap[0]); diff --git a/src/utils.h b/src/utils.h index 68d585bd..ddcb78f5 100644 --- a/src/utils.h +++ b/src/utils.h @@ -1,25 +1,37 @@ #pragma once -// 交换 a 和 b 的值(t 为临时变量) -#ifndef SWAP -#define SWAP(a, b, t) \ - { \ - t = a; \ - a = b; \ - b = t; \ - } -#endif +#include -#ifndef MAX -#define MAX(a, b) (((a) > (b)) ? (a) : (b)) -#endif +template void swap(T& a, T& b) +{ + T t = a; + a = b; + b = t; +} -#ifndef MIN -#define MIN(a, b) (((a) < (b)) ? (a) : (b)) -#endif +template constexpr T min(T a) +{ + return a; +} +template constexpr T min(T a, Args... args) +{ + static_assert((std::is_same_v && ...), "min() 的所有参数必须是相同类型"); + T b = min(args...); + return (a < b) ? a : b; +} -namespace ege +template constexpr T max(T a) { + return a; +} -} // namespace ege +template constexpr T max(T a, Args... args) +{ + static_assert((std::is_same_v && ...), "max() 的所有参数必须是相同类型"); + T b = max(args...); + return (a > b) ? a : b; +} + +namespace ege +{} // namespace ege From 9a36437062631b27e32bdbb21d0892a1e53a1da0 Mon Sep 17 00:00:00 2001 From: pointertobios Date: Sun, 13 Jul 2025 21:37:31 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E6=94=B9=E5=86=99thread=5Fqueue=E4=B8=BA?= =?UTF-8?q?=E6=97=A0=E9=94=81=E9=98=9F=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .clangd | 2 + .gitignore | 1 + src/thread_queue.h | 134 +++++++++++++++++++++++++++++---------------- 3 files changed, 89 insertions(+), 48 deletions(-) create mode 100644 .clangd diff --git a/.clangd b/.clangd new file mode 100644 index 00000000..c1579a58 --- /dev/null +++ b/.clangd @@ -0,0 +1,2 @@ +CompileFlags: + Add: -std=c++17 diff --git a/.gitignore b/.gitignore index 61734990..57f542fb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .vs/ +.cache/ .history *.tlog *.obj diff --git a/src/thread_queue.h b/src/thread_queue.h index 8fe66e85..3c3ed094 100644 --- a/src/thread_queue.h +++ b/src/thread_queue.h @@ -1,96 +1,134 @@ #pragma once -#include +#include #define QUEUE_LEN 1024 namespace ege { -class Lock -{ -public: - Lock(LPCRITICAL_SECTION p_) : _psection(p_) { ::EnterCriticalSection(_psection); } - - ~Lock() { ::LeaveCriticalSection(_psection); } - -private: - LPCRITICAL_SECTION _psection; -}; - +/** @note 拷贝/移动不安全 */ template class thread_queue { public: - thread_queue(void) - { - ::InitializeCriticalSection(&_section); - _begin = _end = 0; - } + thread_queue(void) : _begin{0}, _end{0}, _unoccupied(0) {} - ~thread_queue(void) { ::DeleteCriticalSection(&_section); } + ~thread_queue(void) {} void push(const T& d_) { - Lock lock(&_section); - int w = (_end + 1) % QUEUE_LEN; - _queue[_end] = d_; - if (w == _begin) { - _begin = (_begin + 1) % QUEUE_LEN; - } - _end = w; + int e = _end.load(); + int w; + + do { + w = (e + 1) % QUEUE_LEN; + + int wi = (w + 1) % QUEUE_LEN; + + // 若队列满,强制从队头清理一个元素 + // 并发访问时,只要有一个线程清理就可以了,因此只需要CAS一次,失败直接跳过计科 + if (_unoccupied.compare_exchange_strong(wi, (_unoccupied.load() + 1) % QUEUE_LEN)) { + int b = _begin.load(); + int ww; + do { + ww = (b + 1) % QUEUE_LEN; + } while (!_begin.compare_exchange_strong(b, ww)); + } + + // 占据当前元素 + } while (!_end.compare_exchange_weak(e, w)); + + _queue[e] = d_; } int pop(T& d_) { - Lock lock(&_section); - if (_end == _begin) { + // process 遍历 _begin 元素时自旋等待 + while (_head_locked.load()) { + } + + // 无需判断 _begin ,因为只能从 _unoccupied 开始 pop 元素 + if (_end.load() == _unoccupied.load()) { return 0; } - d_ = _queue[_begin]; - _last = d_; - _begin = (_begin + 1) % QUEUE_LEN; + + int u = _unoccupied.load(); + int w; + + do { + w = (u + 1) % QUEUE_LEN; + } while (!_unoccupied.compare_exchange_weak(u, w)); + + _last = &_queue[u]; + d_ = *_last; + + int b = _begin.load(); + do { + w = (b + 1) % QUEUE_LEN; + } while (!_begin.compare_exchange_weak(b, w)); return 1; } int unpop() { - Lock lock(&_section); - if (_begin == (_end + 1) % QUEUE_LEN) { + // process 遍历 _begin 元素时自旋等待 + while (_head_locked.load()) { + } + + if (_begin.load() == (_end.load() + 1) % QUEUE_LEN) { return 0; } - _begin = (_begin + QUEUE_LEN - 1) % QUEUE_LEN; + + int u = _unoccupied.load(); + int w; + do { + w = (u + QUEUE_LEN - 1) % QUEUE_LEN; + } while (!_unoccupied.compare_exchange_weak(u, w)); + + u = _begin.load(); + do { + w = (u + QUEUE_LEN - 1) % QUEUE_LEN; + } while (!_begin.compare_exchange_weak(u, w)); + return 1; } - T last() { return _last; } + // 获取上次 pop 时得到的元素 + T last() { return *_last; } void process(void (*process_func)(T&)) { - Lock lock(&_section); - int r = _begin; - int w = _end; + int r = _begin.load(); + int w = _end.load(); if (r != w) { if (w < r) { w += QUEUE_LEN; } for (; r < w; r++) { - int pos = r % QUEUE_LEN; - process_func(_queue[pos]); + bool l_head_locked{false}; + if (r == _begin.load()) { + for (bool b = false; !_head_locked.compare_exchange_weak(b, true); b = false) { + } + l_head_locked = true; + } + process_func(_queue[r % QUEUE_LEN]); + if (l_head_locked) { + _head_locked.store(false); + } } } } - bool empty() - { - Lock lock(&_section); - return _begin == _end; - } + bool empty() { return _begin.load() == _end.load(); } private: - CRITICAL_SECTION _section; - T _queue[QUEUE_LEN]; - T _last; - int _begin, _end; + T _queue[QUEUE_LEN]; + T* _last; // 上次 pop 操作时获得的元素 + std::atomic_int _begin, _end; + // 对于 _begin 端,pop 时先将这个值向后移动,将值 pop 出来,最后后移 _begin, + // 这样并发进入 pop() 函数时也可以并发地将每个值 pop 出来而不用阻塞。 + std::atomic_int _unoccupied; + std::atomic_bool _head_locked; }; } // namespace ege From bcb71684b3d250b335d06ad958c9e479642792af Mon Sep 17 00:00:00 2001 From: pointertobios Date: Sun, 13 Jul 2025 21:59:18 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E5=BC=80=E5=90=AFC++17?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 32b83cd1..d6e736bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,7 @@ cmake_minimum_required(VERSION 3.13) +set(CMAKE_CXX_STANDARD 17) + # 当 CMakeLists.txt 是顶层项目的 CMakeLists.txt 时,设置默认选项。 if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) set(EGE_IS_ROOT_PROJECT ON) From 0a536b2a1a6b63db4da27d8192c3f30805a190d8 Mon Sep 17 00:00:00 2001 From: pointer-to-bios <84652600+pointertobios@users.noreply.github.com> Date: Mon, 14 Jul 2025 00:14:12 +0800 Subject: [PATCH 4/5] Update src/thread_queue.h Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/thread_queue.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/thread_queue.h b/src/thread_queue.h index 3c3ed094..90c134ba 100644 --- a/src/thread_queue.h +++ b/src/thread_queue.h @@ -11,7 +11,7 @@ namespace ege template class thread_queue { public: - thread_queue(void) : _begin{0}, _end{0}, _unoccupied(0) {} + thread_queue(void) : _begin{0}, _end{0}, _unoccupied(0), _head_locked{false}, _last{nullptr} {} ~thread_queue(void) {} From 88608983a0c0a7fa5bdccd68008bfa67b71928be Mon Sep 17 00:00:00 2001 From: pointertobios Date: Mon, 14 Jul 2025 14:16:51 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BB=85=E4=BD=BF=E7=94=A8C++11=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0EGE=5FCONSTEXPR=E5=AE=8F=EF=BC=9B=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E4=B8=8D=E5=BF=85=E8=A6=81=E7=9A=84swap=E5=87=BD?= =?UTF-8?q?=E6=95=B0=EF=BC=8C=E7=9B=B4=E6=8E=A5=E4=BD=BF=E7=94=A8std::swap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 2 +- src/color.h | 22 +++++++++++----------- src/ege_def.h | 21 ++++++++++++--------- src/ege_math.h | 8 ++++---- src/egegapi.cpp | 2 ++ src/image.cpp | 2 ++ src/utils.h | 16 +++++----------- 7 files changed, 37 insertions(+), 36 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d6e736bc..4f0e54a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.13) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 11) # 当 CMakeLists.txt 是顶层项目的 CMakeLists.txt 时,设置默认选项。 if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) diff --git a/src/color.h b/src/color.h index 6394c022..8e943f5a 100644 --- a/src/color.h +++ b/src/color.h @@ -17,14 +17,14 @@ typedef uint32_t color_t; #endif // 交换颜色中 R 通道和 B 通道: 0xAARRGGBB -> 0xAABBGGRR -constexpr color_t RGBTOBGR(color_t color) +EGE_CONSTEXPR color_t RGBTOBGR(color_t color) { return (color_t)(((color & 0xFF) << 16) | (((color & 0xFF0000) >> 16) | (color & 0xFF00FF00))); } // 将 color_t 与 Bitmap Buffer 所用的 0xAARRGGBB 格式转换为 COLORREF 的 0x00BBGGRR 格式 // 仅用于向 GDI32 API 传递颜色时 -constexpr color_t ARGBTOZBGR(color_t c) +EGE_CONSTEXPR color_t ARGBTOZBGR(color_t c) { return (color_t)(((c) & 0xFF) << 16) | (((c) & 0xFF0000) >> 16) | ((c) & 0xFF00); } @@ -60,7 +60,7 @@ typedef struct COLORRGB * @param alpha 透明度(0~255) * @return 混合后的 RGB 颜色,透明度与背景色一致 */ -EGE_FORCEINLINE constexpr color_t colorblend_inline(color_t dst, color_t src, uint8_t alpha) +EGE_FORCEINLINE EGE_CONSTEXPR color_t colorblend_inline(color_t dst, color_t src, uint8_t alpha) { uint8_t r = DIVIDE_255_FAST(255 * EGEGET_R(dst) + ((int)(EGEGET_R(src) - EGEGET_R(dst)) * alpha + 255 / 2)); uint8_t g = DIVIDE_255_FAST(255 * EGEGET_G(dst) + ((int)(EGEGET_G(src) - EGEGET_G(dst)) * alpha + 255 / 2)); @@ -78,10 +78,10 @@ EGE_FORCEINLINE constexpr color_t colorblend_inline(color_t dst, color_t src, ui * @return 混合后的 RGB 颜色,透明度与背景色一致 * @note 结果与标准公式相比有一定误差 */ -EGE_FORCEINLINE constexpr color_t colorblend_inline_fast(color_t dst, color_t src, uint8_t alpha) +EGE_FORCEINLINE EGE_CONSTEXPR color_t colorblend_inline_fast(color_t dst, color_t src, uint8_t alpha) { - constexpr int colorblend_inline_fast_option = 1; - if constexpr (colorblend_inline_fast_option == 0) { + EGE_CONSTEXPR int colorblend_inline_fast_option = 1; + if EGE_CONSTEXPR (colorblend_inline_fast_option == 0) { // 误差较大,可能取不到端点,而且无近似取整 uint32_t rb = dst & 0x00FF00FF; uint32_t g = dst & 0x0000FF00; @@ -89,7 +89,7 @@ EGE_FORCEINLINE constexpr color_t colorblend_inline_fast(color_t dst, color_t sr rb += ((src & 0x00FF00FF) - rb) * alpha >> 8; g += ((src & 0x0000FF00) - g) * alpha >> 8; return (rb & 0x00FF00FF) | (g & 0x0000FF00) | (dst & 0xFF000000); - } else if constexpr (colorblend_inline_fast_option == 1) { + } else if EGE_CONSTEXPR (colorblend_inline_fast_option == 1) { // 有近似取整,端点正常,误差较小 uint32_t rb = dst & 0x00FF00FF; uint32_t g = dst & 0x0000FF00; @@ -114,7 +114,7 @@ EGE_FORCEINLINE constexpr color_t colorblend_inline_fast(color_t dst, color_t sr * G = G(dst) + alpha * (G(src) - G(dst)); * B = B(dst) + alpha * (B(src) - B(dst)); */ -EGE_FORCEINLINE constexpr color_t alphablend_specify_inline(color_t dst, color_t src, uint8_t alpha) +EGE_FORCEINLINE EGE_CONSTEXPR color_t alphablend_specify_inline(color_t dst, color_t src, uint8_t alpha) { const uint8_t a = DIVIDE_255_FAST(255 * EGEGET_A(dst) + ((int)(255 - EGEGET_A(dst)) * alpha + 255 / 2)); const uint8_t r = DIVIDE_255_FAST(255 * EGEGET_R(dst) + ((int)(EGEGET_R(src) - EGEGET_R(dst)) * alpha + 255 / 2)); @@ -131,7 +131,7 @@ EGE_FORCEINLINE constexpr color_t alphablend_specify_inline(color_t dst, color_t * @param src 前景色 * @return 混合后的 ARGB 颜色 */ -EGE_FORCEINLINE constexpr color_t alphablend_inline(color_t dst, color_t src) +EGE_FORCEINLINE EGE_CONSTEXPR color_t alphablend_inline(color_t dst, color_t src) { return alphablend_specify_inline(dst, src, EGEGET_A(src)); } @@ -144,7 +144,7 @@ EGE_FORCEINLINE constexpr color_t alphablend_inline(color_t dst, color_t src) * @param srcAlphaFactor 前景色的比例系数,0~255 对应 0.0~1.0 * @return 混合后的 ARGB 颜色 */ -EGE_FORCEINLINE constexpr color_t alphablend_inline(color_t dst, color_t src, uint8_t srcAlphaFactor) +EGE_FORCEINLINE EGE_CONSTEXPR color_t alphablend_inline(color_t dst, color_t src, uint8_t srcAlphaFactor) { uint8_t alpha = DIVIDE_255_FAST(EGEGET_A(src) * srcAlphaFactor + 255 / 2); return alphablend_specify_inline(dst, src, alpha); @@ -162,7 +162,7 @@ EGE_FORCEINLINE constexpr color_t alphablend_inline(color_t dst, color_t src, ui * G = G(src) + (1.0 - alpha) * G(dst); * B = B(src) + (1.0 - alpha) * B(dst); */ -EGE_FORCEINLINE constexpr color_t alphablend_premultiplied_inline(color_t dst, color_t src) +EGE_FORCEINLINE EGE_CONSTEXPR color_t alphablend_premultiplied_inline(color_t dst, color_t src) { const uint8_t a = DIVIDE_255_FAST(255 * EGEGET_A(src) + (255 - EGEGET_A(src)) * EGEGET_A(dst)); const uint8_t r = DIVIDE_255_FAST(255 * EGEGET_R(src) + (255 - EGEGET_A(src)) * EGEGET_R(dst)); diff --git a/src/ege_def.h b/src/ege_def.h index 1368339d..416aacc7 100644 --- a/src/ege_def.h +++ b/src/ege_def.h @@ -6,13 +6,19 @@ #define EGE_FORCEINLINE __attribute__((always_inline)) inline #endif +#if __cplusplus >= 201703L +#define EGE_CONSTEXPR constexpr +#else +#define EGE_CONSTEXPR +#endif + #if defined(_MSC_VER) -# ifndef _ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH -# define _ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH -# endif -# ifndef _ALLOW_RUNTIME_LIBRARY_MISMATCH -# define _ALLOW_RUNTIME_LIBRARY_MISMATCH -# endif +#ifndef _ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH +#define _ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH +#endif +#ifndef _ALLOW_RUNTIME_LIBRARY_MISMATCH +#define _ALLOW_RUNTIME_LIBRARY_MISMATCH +#endif #endif #if !defined(EGE_W64) @@ -22,6 +28,3 @@ #define EGE_W64 #endif #endif - - - diff --git a/src/ege_math.h b/src/ege_math.h index 6e6bb4f8..cd550010 100644 --- a/src/ege_math.h +++ b/src/ege_math.h @@ -39,24 +39,24 @@ using std::round; #endif // 快除 255,有效范围:[0, 65790) -template EGE_FORCEINLINE constexpr T DIVIDE_255_FAST(T x) +template EGE_FORCEINLINE EGE_CONSTEXPR T DIVIDE_255_FAST(T x) { return ((x + ((x + 257) >> 8)) >> 8); } -template constexpr T clamp(T value, T min, T max) +template EGE_CONSTEXPR T clamp(T value, T min, T max) { return (value < min) ? min : ((value > max) ? max : value); } // Overflow 判断 -inline constexpr bool sumIsOverflow(int a, int b) +inline EGE_CONSTEXPR bool sumIsOverflow(int a, int b) { return (a > 0) && (b > 0) && (b > (INT_MAX - a)); } // Underflow 判断 -inline constexpr bool sumIsUnderflow(int a, int b) +inline EGE_CONSTEXPR bool sumIsUnderflow(int a, int b) { return (a < 0) && (b < 0) && (b < (INT_MIN - a)); } diff --git a/src/egegapi.cpp b/src/egegapi.cpp index d01a6ba2..8b174021 100644 --- a/src/egegapi.cpp +++ b/src/egegapi.cpp @@ -29,6 +29,8 @@ namespace ege { +using std::swap; + bool is_run() { struct _graph_setting* pg = &graph_setting; diff --git a/src/image.cpp b/src/image.cpp index 96b6b535..bb0da622 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -30,6 +30,8 @@ namespace ege { +using std::swap; + void IMAGE::reset() { m_initflag = IMAGE_INIT_FLAG; diff --git a/src/utils.h b/src/utils.h index ddcb78f5..240f0913 100644 --- a/src/utils.h +++ b/src/utils.h @@ -1,32 +1,26 @@ #pragma once +#include "ege_def.h" #include -template void swap(T& a, T& b) -{ - T t = a; - a = b; - b = t; -} - -template constexpr T min(T a) +template EGE_CONSTEXPR T min(T a) { return a; } -template constexpr T min(T a, Args... args) +template EGE_CONSTEXPR T min(T a, Args... args) { static_assert((std::is_same_v && ...), "min() 的所有参数必须是相同类型"); T b = min(args...); return (a < b) ? a : b; } -template constexpr T max(T a) +template EGE_CONSTEXPR T max(T a) { return a; } -template constexpr T max(T a, Args... args) +template EGE_CONSTEXPR T max(T a, Args... args) { static_assert((std::is_same_v && ...), "max() 的所有参数必须是相同类型"); T b = max(args...);