-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathege.h
1137 lines (998 loc) · 44.5 KB
/
ege.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*********************************************************
* EGE (Easy Graphics Engine)
* FileName ege.h
* HomePage1 http://misakamm.github.com/xege
* HomePage2 http://misakamm.bitbucket.org/index.htm
* teiba1 http://tieba.baidu.com/f?kw=ege
* teiba2 http://tieba.baidu.com/f?kw=ege%C4%EF
* Blog: http://misakamm.com
* E-Mail: mailto:misakamm[at gmail com]
*
* FileName: ege.h
* 在 VC 下模拟 Borland BGI 绘图库,实现简单的绘图之余,扩展了较复杂的绘图能力
*
* 包含并使用本库时,不要包含conio.h头文件
* 这些头文件不应共存,否则可能会编译错误,
* 或者getch被conio.h内的覆盖(由包含次序决定),请注意
* 如需共存,请使用多文件分开包含的模式使用,
* 即不能一个cpp同时包含,但可以分开包含
* 使用本库,必须用C++编译,可支持的编译器:
* VC6/VC2008/VC2010/VC2012/VC2013/MinGW3.4.5/MinGW4.7.1/MinGW4.8.1
*********************************************************/
/****************************************************************************
** 注意事项:
* ★如果需要显示控制台窗口,请在包含本文件的前面加一行define SHOW_CONSOLE
* ★调用Sleep这个API时,或者调用delay,实际均会转化为调用delay_ms,如必需调用API请使用api_sleep
* ★delay_ms(0)能自行判断有没有更新的必要,连续多次但不大量的调用并不会产生帧率的影响
* ★调用delay_ms, delay_fps, getch, getkey, getmouse 时,窗口内容可能会更新,这些函数相当于内置了delay_ms(0),
* 如果你只需要更新窗口,而不想等待,可以用delay_ms(0)。注意delay只延时而不更新窗口
* ★合理地使用delay_ms/delay_fps函数,可以减少你的程序占用的CPU,否则一个都没有调用同时也没有getch/getmouse的话,程序将占满一个CPU的时间
****************************************************************************/
#ifndef _EGE_H_
#define _EGE_H_
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
#pragma once
#endif
#ifndef __cplusplus
#error You must use C++ compiler, or you need filename with '.cpp' suffix
#endif
#if defined(_INC_CONIO) || defined(_CONIO_H_)
#error can not include "conio.h" before "graphics.h"
#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
#endif
#if !defined(_GRAPH_LIB_BUILD_) && !defined(_GRAPH_NO_LIB_)
# ifdef _MSC_VER
# pragma comment(lib,"gdiplus.lib")
# ifdef _WIN64 // 64 bit libs
# pragma comment(lib,"graphics64.lib")
# else // 32 bit libs
# pragma comment(lib,"graphics.lib")
# endif
# endif
#endif
#if !defined(_GRAPH_LIB_BUILD_) && !defined(_GRAPH_NO_LIB_)
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif
#ifndef _CRT_SECURE_NO_DEPRECATE
#define _CRT_SECURE_NO_DEPRECATE
#endif
#ifndef _CRT_NON_CONFORMING_SWPRINTFS
#define _CRT_NON_CONFORMING_SWPRINTFS
#endif
#endif
#include "windows.h"
#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
#endif
#ifndef WM_MOUSEWHEEL
#define WM_MOUSEWHEEL 0x020A
#endif
#ifndef _Cdecl
# if __STDC__
# define _Cdecl __cdecl
# else
# define _Cdecl __cdecl
# endif
#endif
#ifdef _MSC_VER
# if defined(_WIN64)
# define EGEAPI
# else
# define EGEAPI _Cdecl
# endif
#else
# if defined(__WORDSIZE)
# if __WORDSIZE > 32
# define EGEAPI
# else
# define EGEAPI _Cdecl
# endif
# else
# define EGEAPI
# endif
#endif
#ifndef EGE_DEPRECATE
# ifdef _MSC_VER
# ifdef _CRT_DEPRECATE_TEXT
# define EGE_DEPRECATE(text) _CRT_DEPRECATE_TEXT("This function is deprecated, more info visit http://tcgraphics.sourceforge.net/")
# else
# define EGE_DEPRECATE(text)
# endif
# else
# define EGE_DEPRECATE(text) __attribute__((deprecated))
# endif
#endif
#define SHOWCONSOLE 1 // 进入图形模式时,保留控制台的显示
#define EGERGBA(r, g, b, a) ( ((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) ( ((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)
#define NAMESPACE_EGE_L namespace ege {
#define NAMESPACE_EGE_R }
NAMESPACE_EGE_L
const double PI = 3.1415926535897932384626;
enum graphics_drivers { /* define graphics drivers */
DETECT, /* requests autodetection */
CGA, MCGA, EGA, EGA64, EGAMONO, IBM8514,/* 1 - 6 */
HERCMONO, ATT400, VGA, PC3270, /* 7 - 10 */
TRUECOLOR, TRUECOLORSIZE,
CURRENT_DRIVER = -1
};
enum graphics_modes { /* graphics modes for each driver */
CGAC0 = 0, /* 320x200 palette 0; 1 page */
CGAC1 = 1, /* 320x200 palette 1; 1 page */
CGAC2 = 2, /* 320x200 palette 2: 1 page */
CGAC3 = 3, /* 320x200 palette 3; 1 page */
CGAHI = 4, /* 640x200 1 page */
MCGAC0 = 0, /* 320x200 palette 0; 1 page */
MCGAC1 = 1, /* 320x200 palette 1; 1 page */
MCGAC2 = 2, /* 320x200 palette 2; 1 page */
MCGAC3 = 3, /* 320x200 palette 3; 1 page */
MCGAMED = 4, /* 640x200 1 page */
MCGAHI = 5, /* 640x480 1 page */
EGALO = 0, /* 640x200 16 color 4 pages */
EGAHI = 1, /* 640x350 16 color 2 pages */
EGA64LO = 0, /* 640x200 16 color 1 page */
EGA64HI = 1, /* 640x350 4 color 1 page */
EGAMONOHI = 0, /* 640x350 64K on card, 1 page - 256K on card, 4 pages */
HERCMONOHI = 0, /* 720x348 2 pages */
ATT400C0 = 0, /* 320x200 palette 0; 1 page */
ATT400C1 = 1, /* 320x200 palette 1; 1 page */
ATT400C2 = 2, /* 320x200 palette 2; 1 page */
ATT400C3 = 3, /* 320x200 palette 3; 1 page */
ATT400MED = 4, /* 640x200 1 page */
ATT400HI = 5, /* 640x400 1 page */
VGALO = 0, /* 640x200 16 color 4 pages */
VGAMED = 1, /* 640x350 16 color 2 pages */
VGAHI = 2, /* 640x480 16 color 1 page */
PC3270HI = 0, /* 720x350 1 page */
IBM8514LO = 0, /* 640x480 256 colors */
IBM8514HI = 1 /*1024x768 256 colors */
};
enum graphics_errors { /* graphresult error return codes */
grOk = 0,
grNoInitGraph = -1,
grNotDetected = -2,
grFileNotFound = -3,
grInvalidDriver = -4,
grNoLoadMem = -5,
grNoScanMem = -6,
grNoFloodMem = -7,
grFontNotFound = -8,
grNoFontMem = -9,
grInvalidMode = -10,
grError = -11, /* generic error */
grIOerror = -12,
grInvalidFont = -13,
grInvalidFontNum = -14,
grInvalidVersion = -18,
grException = 0x10, /* ege error */
grParamError = 0x11,
grInvalidRegion = 0x12,
grOutOfMemory = 0x13,
grNullPointer = 0x14,
grAllocError = 0x15,
grInvalidMemory = 0xCDCDCDCD,
};
enum message_event {
MSG_EVENT_UP = 0x00,
MSG_EVENT_DOWN = 0x01,
MSG_EVENT_CLICK = 0x01,
MSG_EVENT_DBCLICK = 0x02,
MSG_EVENT_MOVE = 0x04,
MSG_EVENT_WHEEL = 0x10,
};
enum message_mouse {
MSG_MOUSE_LEFT = 0x01,
MSG_MOUSE_RIGHT = 0x02,
MSG_MOUSE_MID = 0x04,
};
// 颜色
enum COLORS {
BLACK = EGERGB(0, 0, 0),
BLUE = EGERGB(0, 0, 0xA8),
GREEN = EGERGB(0, 0xA8, 0),
CYAN = EGERGB(0, 0xA8, 0xA8),
RED = EGERGB(0xA8, 0, 0),
MAGENTA = EGERGB(0xA8, 0, 0xA8),
BROWN = EGERGB(0xA8, 0xA8, 0),
LIGHTGRAY = EGERGB(0xA8, 0xA8, 0xA8),
DARKGRAY = EGERGB(0x54, 0x54, 0x54),
LIGHTBLUE = EGERGB(0x54, 0x54, 0xFC),
LIGHTGREEN = EGERGB(0x54, 0xFC, 0x54),
LIGHTCYAN = EGERGB(0x54, 0xFC, 0xFC),
LIGHTRED = EGERGB(0xFC, 0x54, 0x54),
LIGHTMAGENTA = EGERGB(0xFC, 0x54, 0xFC),
YELLOW = EGERGB(0xFC, 0xFC, 0x54),
WHITE = EGERGB(0xFC, 0xFC, 0xFC),
};
// 填充模式
enum fill_patterns {/* Fill patterns for get/setfillstyle */
EMPTY_FILL, /* fills area in background color */
SOLID_FILL, /* fills area in solid fill color */
LINE_FILL, /* --- fill */
LTSLASH_FILL, /* /// fill */
SLASH_FILL, /* /// fill with thick lines */
BKSLASH_FILL, /* \\\ fill with thick lines */
LTBKSLASH_FILL, /* \\\ fill */
HATCH_FILL, /* light hatch fill */
XHATCH_FILL, /* heavy cross hatch fill */
INTERLEAVE_FILL,/* interleaving line fill */
WIDE_DOT_FILL, /* Widely spaced dot fill */
CLOSE_DOT_FILL, /* Closely spaced dot fill */
USER_FILL /* user defined fill */
};
enum text_just { /* Horizontal and vertical justification
for settextjustify */
LEFT_TEXT = 0,
CENTER_TEXT = 1,
RIGHT_TEXT = 2,
BOTTOM_TEXT = 0,
/* CENTER_TEXT = 1, already defined above */
TOP_TEXT = 2
};
enum line_styles { /* Line styles for get/setlinestyle */
SOLID_LINE = PS_SOLID,
CENTER_LINE = PS_DASH,
DOTTED_LINE = PS_DOT,
DASHED_LINE = PS_DASHDOT,
NULL_LINE = PS_NULL,
USERBIT_LINE = PS_USERSTYLE, /* User defined line style */
};
enum key_msg_flag {
KEYMSG_CHAR_FLAG = 2,
KEYMSG_DOWN_FLAG = 1,
KEYMSG_UP_FLAG = 1,
KEYMSG_CHAR = 0x40000,
KEYMSG_DOWN = 0x10000,
KEYMSG_UP = 0x20000,
KEYMSG_FIRSTDOWN = 0x80000,
};
enum music_state_flag {
MUSIC_MODE_NOT_OPEN = 0x0,
MUSIC_MODE_NOT_READY = 0x20C,
MUSIC_MODE_PAUSE = 0x211,
MUSIC_MODE_PLAY = 0x20E,
MUSIC_MODE_STOP = 0x20D,
MUSIC_MODE_OPEN = 0x212,
MUSIC_MODE_SEEK = 0x210,
};
enum initmode_flag {
INIT_DEFAULT = 0x0,
INIT_NOBORDER = 0x1,
INIT_CHILD = 0x2,
INIT_TOPMOST = 0x4,
INIT_RENDERMANUAL = 0x8,
INIT_NOFORCEEXIT = 0x10,
INIT_UNICODE = 0x20,
INIT_WITHLOGO = 0x100,
INIT_ANIMATION = INIT_DEFAULT | INIT_RENDERMANUAL | INIT_NOFORCEEXIT,
};
enum rendermode_e {
RENDER_AUTO,
RENDER_MANUAL,
};
typedef enum key_code_e {
key_mouse_l = 0x01,
key_mouse_r = 0x02,
key_mouse_m = 0x04,
key_back = 0x08,
key_tab = 0x09,
key_enter = 0x0d,
key_shift = 0x10,
key_control = 0x11,
key_menu = 0x12,
key_pause = 0x13,
key_capslock = 0x14,
key_esc = 0x1b,
key_space = 0x20,
key_pageup = 0x21,
key_pagedown = 0x22,
key_home = 0x23,
key_end = 0x24,
key_left = 0x25,
key_up = 0x26,
key_right = 0x27,
key_down = 0x28,
key_print = 0x2a,
key_snapshot = 0x2c,
key_insert = 0x2d,
key_delete = 0x2e,
key_0 = 0x30,
key_1 = 0x31,
key_2 = 0x32,
key_3 = 0x33,
key_4 = 0x34,
key_5 = 0x35,
key_6 = 0x36,
key_7 = 0x37,
key_8 = 0x38,
key_9 = 0x39,
key_A = 0x41,
key_Z = 0x5a,
key_win_l = 0x5b,
key_win_r = 0x5c,
key_sleep = 0x5f,
key_num0 = 0x60,
key_num1 = 0x61,
key_num2 = 0x62,
key_num3 = 0x63,
key_num4 = 0x64,
key_num5 = 0x65,
key_num6 = 0x66,
key_num7 = 0x67,
key_num8 = 0x68,
key_num9 = 0x69,
key_multiply = 0x6a,
key_add = 0x6b,
key_separator = 0x6c,
key_subtract = 0x6d,
key_decimal = 0x6e,
key_divide = 0x6f,
key_f1 = 0x70,
key_f2 = 0x71,
key_f3 = 0x72,
key_f4 = 0x73,
key_f5 = 0x74,
key_f6 = 0x75,
key_f7 = 0x76,
key_f8 = 0x77,
key_f9 = 0x78,
key_f10 = 0x79,
key_f11 = 0x7a,
key_f12 = 0x7b,
key_numlock = 0x90,
key_scrolllock = 0x91,
key_shift_l = 0xa0,
key_shift_r = 0xa1,
key_control_l = 0xa2,
key_control_r = 0xa3,
key_menu_l = 0xa4,
key_menu_r = 0xa5,
key_semicolon = 0xba,
key_plus = 0xbb,
key_comma = 0xbc,
key_minus = 0xbd,
key_period = 0xbe,
key_slash = 0xbf,
key_tilde = 0xc0,
key_lbrace = 0xdb,
key_backslash = 0xdc,
key_rbrace = 0xdd,
key_quote = 0xde,
key_ime_process = 0xe5,
}key_code_e;
typedef enum key_msg_e {
key_msg_down = 1,
key_msg_up = 2,
key_msg_char = 4,
}key_msg_e;
typedef enum key_flag_e {
key_flag_shift = 0x100,
key_flag_ctrl = 0x200,
}key_flag_e;
typedef enum mouse_msg_e {
mouse_msg_down = 0x10,
mouse_msg_up = 0x20,
mouse_msg_move = 0x40,
mouse_msg_wheel = 0x80,
}mouse_msg_e;
typedef enum mouse_flag_e {
mouse_flag_left = 1,
mouse_flag_right = 2,
mouse_flag_mid = 4,
mouse_flag_shift = 0x100,
mouse_flag_ctrl = 0x200,
}mouse_flag_e;
typedef enum pattern_type_e {
pattern_none = 0,
pattern_lineargradient = 1,
pattern_pathgradient = 2,
pattern_texture = 3,
}pattern_type_e;
typedef DWORD color_t;
struct viewporttype {
int left;
int top;
int right;
int bottom;
int clipflag;
};
struct textsettingstype {
int font;
int direction;
int charsize;
int horiz;
int vert;
};
struct linestyletype {
int linestyle;
unsigned short upattern;
int thickness;
};
typedef struct key_msg {
int key;
key_msg_e msg;
unsigned int flags;
}key_msg;
typedef struct mouse_msg {
int x;
int y;
mouse_msg_e msg;
unsigned int flags;
int wheel;
bool is_left() { return (flags & mouse_flag_left) != 0; }
bool is_right() { return (flags & mouse_flag_right) != 0; }
bool is_mid() { return (flags & mouse_flag_mid) != 0; }
bool is_down() { return msg == mouse_msg_down; }
bool is_up() { return msg == mouse_msg_up; }
bool is_move() { return msg == mouse_msg_move; }
bool is_wheel() { return msg == mouse_msg_wheel; }
}mouse_msg;
typedef struct ege_point {
float x;
float y;
}ege_point;
typedef struct ege_rect {
float x;
float y;
float w;
float h;
}ege_rect;
typedef struct ege_colpoint {
float x;
float y;
color_t color;
}ege_colpoint;
// 鼠标消息
struct MOUSEMSG {
UINT uMsg; // 当前鼠标消息
bool mkCtrl; // Ctrl 键是否按下
bool mkShift; // Shift 键是否按下
bool mkLButton; // 鼠标左键是否按下
bool mkMButton; // 鼠标中键是否按下
bool mkRButton; // 鼠标右键是否按下
short x; // 当前鼠标 x 坐标
short y; // 当前鼠标 y 坐标
short wheel; // 鼠标滚轮滚动值(120为基数)
};
struct msg_createwindow {
HANDLE hEvent;
HWND hwnd;
LPCWSTR classname;
DWORD style;
DWORD exstyle;
size_t id;
LPVOID param;
};
//音乐类宏
#define MUSIC_ERROR 0xFFFFFFFF
typedef void (CALLBACK_PROC)();
typedef int (__stdcall MSG_KEY_PROC )(void*, unsigned, int);
typedef int (__stdcall MSG_MOUSE_PROC)(void*, unsigned, int, int, int);
typedef CALLBACK_PROC * LPCALLBACK_PROC;
typedef MSG_KEY_PROC * LPMSG_KEY_PROC;
typedef MSG_MOUSE_PROC * LPMSG_MOUSE_PROC;
/*
注意:以下函数的注释后带'###'的函数表示未实现
*/
struct VECTOR3D;
// 3d 计算辅助函数
void EGEAPI rotate_point3d_x(VECTOR3D * pt, float r); //弧度,右手定则
void EGEAPI rotate_point3d_y(VECTOR3D * pt, float r);
void EGEAPI rotate_point3d_z(VECTOR3D * pt, float r);
struct VECTOR3D {
float x, y, z;
VECTOR3D() {
x = 0; y = 0; z = 0;
}
VECTOR3D(float _x, float _y) {
x = _x; y = _y; z = 0;
}
VECTOR3D(float _x, float _y, float _z) {
x = _x; y = _y; z = _z;
}
VECTOR3D& operator = (const VECTOR3D& _fp) {
x = _fp.x; y = _fp.y; z = _fp.z;
return *this;
}
VECTOR3D& operator += (const VECTOR3D& _fp);
VECTOR3D& operator -= (const VECTOR3D& _fp);
VECTOR3D operator + (const VECTOR3D& _fp) const;
VECTOR3D operator - (const VECTOR3D& _fp) const;
VECTOR3D& operator *= (float f); //缩放
VECTOR3D operator * (float f) const; //缩放
float operator * (const VECTOR3D& _fp) const; //点乘
VECTOR3D operator & (const VECTOR3D& _fp) const; //叉乘
VECTOR3D& operator &= (const VECTOR3D& _fp); //叉乘
float GetModule() const;
float GetSqrModule() const {
return float(x*x + y*y + z*z);
}
VECTOR3D& SetModule(float m) {
float t = m / GetModule();
*this *= t;
return *this;
}
VECTOR3D& Rotate(float rad, const VECTOR3D& v); //绕任意轴旋转,右手定则,rad为弧度
VECTOR3D& Rotate(float rad, float x, float y, float z) {
VECTOR3D v(x, y, z);
return Rotate(rad, v);
}
VECTOR3D& Rotate(const VECTOR3D& e, const VECTOR3D& s = VECTOR3D(0.0f, 0.0f, 1.0f)); //从s到e之间的夹角确定旋转
static float GetAngel(const VECTOR3D& e, const VECTOR3D& s = VECTOR3D(0.0f, 0.0f, 1.0f));
};
class IMAGE;
typedef IMAGE *PIMAGE;
typedef const IMAGE *PCIMAGE;
// 绘图环境相关函数
void EGEAPI setinitmode(int mode, int x = CW_USEDEFAULT, int y = CW_USEDEFAULT); //设置初始化模式,mode=0为普通,1为无边框窗口,xy是初始窗口坐标
int EGEAPI getinitmode();
void EGEAPI initgraph(int Width, int Height, int Flag); // 初始化图形环境
// Debug 配置下默认不显示 LOGO,Release 模式下默认显示。
#if !defined(NDEBUG) || defined(DEBUG) || defined(_DEBUG)
inline void EGEAPI initgraph(int Width, int Height) {
initgraph(Width, Height, getinitmode());
}
#else
inline void EGEAPI initgraph(int Width, int Height) {
initgraph(Width, Height, getinitmode()|INIT_WITHLOGO);
}
#endif
void EGEAPI initgraph(int* gdriver, int* gmode, const char* path); // 兼容 Borland C++ 3.1 的重载,只使用 640x480x24bit
void EGEAPI closegraph(); // 关闭图形环境
bool EGEAPI is_run(); // 判断UI是否退出
void EGEAPI setcaption(LPCSTR caption);
void EGEAPI setcaption(LPCWSTR caption);
void EGEAPI seticon(int icon_id);
int EGEAPI attachHWND(HWND hWnd);
void EGEAPI movewindow(int x, int y, bool redraw = true); //移动窗口
void EGEAPI resizewindow(int width, int height); //重设窗口尺寸
void EGEAPI setrendermode(rendermode_e mode);
// 绘图环境设置
PIMAGE gettarget();
int settarget(PIMAGE pbuf); // 用 NULL 设置窗口为绘图目标
void EGEAPI cleardevice(PIMAGE pimg = NULL); // 清屏
void EGEAPI getviewport(int *pleft, int *ptop, int *pright, int *pbottom, int *pclip = 0, PCIMAGE pimg = NULL); // 获取视图信息
void EGEAPI setviewport(int left, int top, int right, int bottom, int clip = 1, PIMAGE pimg = NULL); // 设置视图
void EGEAPI clearviewport(PIMAGE pimg = NULL); // 清空视图
EGE_DEPRECATE(setactivepage)
void EGEAPI setactivepage(int page); // 设置当前绘图页,即绘图函数默认的输出缓冲,范围0-1,默认为0
EGE_DEPRECATE(setvisualpage)
void EGEAPI setvisualpage(int page); // 设置当前显示页,用于设置显示到窗口上的页,范围0-1,默认为0
EGE_DEPRECATE(swappage)
void EGEAPI swappage();
void EGEAPI window_getviewport(struct viewporttype * viewport);
void EGEAPI window_getviewport(int* left, int* top, int* right, int* bottom);
void EGEAPI window_setviewport(int left, int top, int right, int bottom);
// 绘图属性
EGE_DEPRECATE(getlinestyle)
void EGEAPI getlinestyle(int *plinestyle, unsigned short *pupattern = NULL, int *pthickness = NULL, PCIMAGE pimg = NULL); // 获取当前线形
void EGEAPI setlinestyle(int linestyle, unsigned short upattern = 0, int thickness = 1, PIMAGE pimg = NULL); // 设置当前线形
void EGEAPI setlinewidth(float width, PIMAGE pimg = NULL); // 设置当前线宽
//EGE_DEPRECATE(getfillstyle)
//void getfillstyle(color_t *pcolor, int *ppattern = NULL, PIMAGE pimg = NULL); // 获取填充类型 ###
EGE_DEPRECATE(setfillstyle)
void EGEAPI setfillstyle(int pattern, color_t color, PIMAGE pimg = NULL); // 设置填充类型
void EGEAPI setwritemode(int mode, PIMAGE pimg = NULL); // 设置绘图位操作模式
//void EGEAPI graphdefaults(PIMAGE pimg = NULL); // 重置所有绘图设置为默认值 ###
// 色彩函数
color_t EGEAPI getcolor(PCIMAGE pimg = NULL); // 获取当前绘图前景色
color_t EGEAPI getfillcolor(PCIMAGE pimg = NULL); // 获取当前绘图填充色
color_t EGEAPI getbkcolor(PCIMAGE pimg = NULL); // 获取当前绘图背景色
void EGEAPI setcolor(color_t color, PIMAGE pimg = NULL); // 设置当前绘图前景色
void EGEAPI setfillcolor(color_t color, PIMAGE pimg = NULL); // 设置当前绘图填充色
void EGEAPI setbkcolor(color_t color, PIMAGE pimg = NULL); // 设置当前绘图背景色(设置并做背景色像素替换)
void EGEAPI setbkcolor_f(color_t color, PIMAGE pimg = NULL); // 快速设置当前绘图背景色(只设置不绘画)
void EGEAPI setfontbkcolor(color_t color, PIMAGE pimg = NULL); // 设置当前文字背景色
void EGEAPI setbkmode(int iBkMode, PIMAGE pimg = NULL); // 设置背景混合模式(0=OPAQUE, 1=TRANSPARENT)
// 兼容宏
#define RGBtoGRAY rgb2gray
#define RGBtoHSL rgb2hsl
#define RGBtoHSV rgb2hsv
#define HSLtoRGB hsl2rgb
#define HSVtoRGB hsv2rgb
// 颜色模型转换函数
color_t EGEAPI rgb2gray(color_t rgb);
void EGEAPI rgb2hsl(color_t rgb, float *H, float *S, float *L);
void EGEAPI rgb2hsv(color_t rgb, float *H, float *S, float *V);
color_t EGEAPI hsl2rgb(float H, float S, float L);
color_t EGEAPI hsv2rgb(float H, float S, float V);
// 按 Alpha 通道混合颜色,将 src 作为背景色,dst 作为前景色进行混合
color_t EGEAPI alphablend(color_t dst, color_t src); // 使用 EGEGET_A(src) 作为 Alpha 值
color_t EGEAPI alphablend(color_t dst, color_t src, unsigned char alpha);
// 基本绘图函数
color_t EGEAPI getpixel (int x, int y, PCIMAGE pimg = NULL); // 获取点的颜色
void EGEAPI putpixel (int x, int y, color_t color, PIMAGE pimg = NULL); // 画点
color_t EGEAPI getpixel_f(int x, int y, PCIMAGE pimg = NULL); // 获取点的颜色
void EGEAPI putpixel_f(int x, int y, color_t color, PIMAGE pimg = NULL); // 绝对坐标画点
void EGEAPI putpixels (int nPoint, int* pPoints, PIMAGE pimg = NULL); // 批量画点
void EGEAPI putpixels_f(int nPoint, int* pPoints, PIMAGE pimg = NULL); // 批量画点
void EGEAPI putpixel_withalpha (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); // 带透明度绝对坐标画点
void EGEAPI moveto(int x, int y, PIMAGE pimg = NULL); // 移动当前点(绝对坐标)
void EGEAPI moverel(int dx, int dy, PIMAGE pimg = NULL); // 移动当前点(相对坐标)
void EGEAPI line(int x1, int y1, int x2, int y2, PIMAGE pimg = NULL); // 画线
void EGEAPI linerel(int dx, int dy, PIMAGE pimg = NULL); // 画线(至相对坐标)
void EGEAPI lineto(int x, int y, PIMAGE pimg = NULL); // 画线(至绝对坐标)
void EGEAPI line_f(float x1, float y1, float x2, float y2, PIMAGE pimg = NULL); // 画线
void EGEAPI linerel_f(float dx, float dy, PIMAGE pimg = NULL); // 画线(至相对坐标)
void EGEAPI lineto_f(float x, float y, PIMAGE pimg = NULL); // 画线(至绝对坐标)
void EGEAPI rectangle(int left, int top, int right, int bottom, PIMAGE pimg = NULL); // 画矩形
//void EGEAPI getarccoords(int *px, int *py, int *pxstart, int *pystart, int *pxend, int *pyend, PIMAGE pimg = NULL); // 获取圆弧坐标信息 ###
void EGEAPI arc(int x, int y, int stangle, int endangle, int radius, PIMAGE pimg = NULL); // 画圆弧
void EGEAPI circle(int x, int y, int radius, PIMAGE pimg = NULL); // 画圆
void EGEAPI pieslice(int x, int y, int stangle, int endangle, int radius, PIMAGE pimg = NULL); // 画填充圆扇形
void EGEAPI ellipse(int x, int y, int stangle, int endangle, int xradius, int yradius, PIMAGE pimg = NULL);// 画椭圆弧线
void EGEAPI fillellipse(int x, int y, int xradius, int yradius, PIMAGE pimg = NULL); // 画填充椭圆
void EGEAPI sector(int x, int y, int stangle, int endangle, int xradius, int yradius, PIMAGE pimg = NULL); // 画填充椭圆扇形
void EGEAPI arcf(float x, float y, float stangle, float endangle, float radius, PIMAGE pimg = NULL); // 画圆弧
void EGEAPI circlef(float x, float y, float radius, PIMAGE pimg = NULL); // 画圆
void EGEAPI pieslicef(float x, float y, float stangle, float endangle, float radius, PIMAGE pimg = NULL); // 画填充圆扇形
void EGEAPI ellipsef(float x, float y, float stangle, float endangle, float xradius, float yradius, PIMAGE pimg = NULL);// 画椭圆弧线
void EGEAPI fillellipsef(float x, float y, float xradius, float yradius, PIMAGE pimg = NULL); // 画填充椭圆
void EGEAPI sectorf(float x, float y, float stangle, float endangle, float xradius, float yradius, PIMAGE pimg = NULL); // 画填充椭圆扇形
void EGEAPI bar(int left, int top, int right, int bottom, PIMAGE pimg = NULL); // 画无边框填充矩形
void EGEAPI bar3d(int left, int top, int right, int bottom, int depth, int topflag, PIMAGE pimg = NULL); // 画有边框三维填充矩形
void EGEAPI drawpoly(int numpoints, const int *polypoints, PIMAGE pimg = NULL); // 画多边形
void EGEAPI drawlines(int numlines, const int *polypoints, PIMAGE pimg = NULL); // 画多条不连续线(扩展函数)
void EGEAPI drawbezier(int numpoints, const int *polypoints, PIMAGE pimg = NULL); // 画bezier曲线(扩展函数)
void EGEAPI fillpoly(int numpoints, const int *polypoints, PIMAGE pimg = NULL); // 画填充的多边形
void EGEAPI fillpoly_gradient(int numpoints, const ege_colpoint* polypoints, PIMAGE pimg = NULL); // 画渐变填充的多边形
void EGEAPI floodfill(int x, int y, int border, PIMAGE pimg = NULL); // 按边界颜色填充区域
void EGEAPI floodfillsurface(int x, int y, color_t areacolor, PIMAGE pimg = NULL); // 按起始点颜色填充区域
// 高级绘图函数(带AA)
// ege new_api
void EGEAPI ege_enable_aa(bool enable, PIMAGE pimg = NULL);
void EGEAPI ege_line(float x1, float y1, float x2, float y2, PIMAGE pimg = NULL);
void EGEAPI ege_drawpoly(int numpoints, ege_point* polypoints, PIMAGE pimg = NULL);
void EGEAPI ege_drawcurve(int numpoints, ege_point* polypoints, PIMAGE pimg = NULL);
void EGEAPI ege_rectangle(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);
void EGEAPI ege_pie(float x, float y, float w, float h, float stangle, float sweepAngle, PIMAGE pimg = NULL);
void EGEAPI ege_arc(float x, float y, float w, float h, float stangle, float sweepAngle, PIMAGE pimg = NULL);
void EGEAPI ege_bezier(int numpoints, ege_point* polypoints, PIMAGE pimg = NULL);
void EGEAPI ege_fillpoly(int numpoints, ege_point* polypoints, PIMAGE pimg = NULL);
void EGEAPI ege_fillrect(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);
void EGEAPI ege_fillpie(float x, float y, float w, float h, float stangle, float sweepAngle, PIMAGE pimg = NULL);
void EGEAPI ege_setpattern_none(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);
void EGEAPI ege_setpattern_pathgradient(ege_point center, color_t centercolor,
int count, ege_point* points, int colcount, color_t* pointscolor, 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);
void EGEAPI ege_setpattern_texture(PIMAGE srcimg, float x, float y, float w, float h, PIMAGE pimg = NULL);
void EGEAPI ege_drawtext(LPCSTR textstring, float x, float y, PIMAGE pimg = NULL);
void EGEAPI ege_drawtext(LPCWSTR textstring, float x, float y, PIMAGE pimg = NULL);
void EGEAPI ege_setalpha(int alpha, PIMAGE pimg = NULL);
void EGEAPI ege_gentexture(bool gen, PIMAGE pimg = NULL);
void EGEAPI ege_puttexture(PCIMAGE srcimg, float x, float y, float w, float h, PIMAGE pimg = NULL);
void EGEAPI ege_puttexture(PCIMAGE srcimg, ege_rect dest, PIMAGE pimg = NULL);
void EGEAPI ege_puttexture(PCIMAGE srcimg, ege_rect dest, ege_rect src, PIMAGE pimg = NULL);
//
//int EGEAPI Begin2d();
//void EGEAPI EndRender();
//时间函数(以下函数不能在多线程下使用,只能给绘图主线程调用)
void EGEAPI ege_sleep(long ms); // 至少延迟ms毫秒
void EGEAPI delay(long ms); // 至少延迟ms毫秒
void EGEAPI delay_ms(long ms); // 平均延迟ms毫秒
void EGEAPI delay_fps(int fps); // 平均延迟1000/fps毫秒,用于稳定帧率控制
void EGEAPI delay_fps(long fps); // 平均延迟1000/fps毫秒,用于稳定帧率控制
void EGEAPI delay_fps(double fps); // 平均延迟1000/fps毫秒,用于稳定帧率控制
void EGEAPI delay_jfps(int fps); // 平均延迟1000/fps毫秒,用于稳定逻辑帧率控制,绘图带跳帧
void EGEAPI delay_jfps(long fps); // 平均延迟1000/fps毫秒,用于稳定逻辑帧率控制,绘图带跳帧
void EGEAPI delay_jfps(double fps); // 平均延迟1000/fps毫秒,用于稳定逻辑帧率控制,绘图带跳帧
// 以下函数可以多线程下使用,非图形(worker)线程的sleep使用这个
void EGEAPI api_sleep(long dwMilliseconds);
double EGEAPI fclock(); // 获取以秒为单位的浮点时间,只用于计时用,精度0.01秒,
// 文字相关函数
void EGEAPI outtext(LPCSTR textstring, PIMAGE pimg = NULL); // 在当前位置输出文字
void EGEAPI outtext(LPCWSTR textstring, PIMAGE pimg = NULL); // 在当前位置输出文字
void EGEAPI outtext(CHAR c, PIMAGE pimg = NULL); // 在当前位置输出字符
void EGEAPI outtext(WCHAR c, PIMAGE pimg = NULL); // 在当前位置输出字符
void EGEAPI outtextxy(int x, int y, LPCSTR textstring, PIMAGE pimg = NULL); // 在指定位置输出文字
void EGEAPI outtextxy(int x, int y, LPCWSTR textstring, PIMAGE pimg = NULL); // 在指定位置输出文字
void EGEAPI outtextxy(int x, int y, CHAR c, PIMAGE pimg = NULL); // 在指定位置输出字符
void EGEAPI outtextxy(int x, int y, WCHAR c, PIMAGE pimg = NULL); // 在指定位置输出字符
void EGEAPI outtextrect(int x, int y, int w, int h, LPCSTR textstring, PIMAGE pimg = NULL); // 在指定矩形范围输出文字
void EGEAPI outtextrect(int x, int y, int w, int h, LPCWSTR textstring, PIMAGE pimg = NULL); // 在指定矩形范围输出文字
void EGEAPI xyprintf(int x, int y, LPCSTR fmt, ...); // 在指定位置输出格式化字符串,指定绘图目标调用settarget
void EGEAPI xyprintf(int x, int y, LPCWSTR fmt, ...); // 在指定位置输出格式化字符串,指定绘图目标调用settarget
void EGEAPI rectprintf(int x, int y, int w, int h, LPCSTR fmt, ...); // 在指定矩形输出格式化字符串,指定绘图目标调用settarget
void EGEAPI rectprintf(int x, int y, int w, int h, LPCWSTR fmt, ...); // 在指定矩形输出格式化字符串,指定绘图目标调用settarget
int EGEAPI textwidth(LPCSTR textstring, PIMAGE pimg = NULL); // 获取字符串占用的像素宽
int EGEAPI textwidth(LPCWSTR textstring, PIMAGE pimg = NULL); // 获取字符串占用的像素宽
int EGEAPI textwidth(CHAR c, PIMAGE pimg = NULL);
int EGEAPI textwidth(WCHAR c, PIMAGE pimg = NULL);
int EGEAPI textheight(LPCSTR textstring, PIMAGE pimg = NULL); // 获取字符串占用的像素高
int EGEAPI textheight(LPCWSTR textstring, PIMAGE pimg = NULL); // 获取字符串占用的像素高
int EGEAPI textheight(CHAR c, PIMAGE pimg = NULL);
int EGEAPI textheight(WCHAR c, PIMAGE pimg = NULL);
void EGEAPI settextjustify(int horiz, int vert, PIMAGE pimg = NULL);
// 设置当前字体样式(详见帮助)
// nHeight: 字符的平均高度;
// nWidth: 字符的平均宽度(0 表示自适应);
// lpszFace: 字体名称;
// nEscapement: 字符串的书写角度(单位 0.1 度);
// nOrientation: 每个字符的书写角度(单位 0.1 度);
// nWeight: 字符的笔画粗细(0 表示默认粗细);
// bItalic: 是否斜体;
// bUnderline: 是否下划线;
// bStrikeOut: 是否删除线;
// fbCharSet: 指定字符集;
// fbOutPrecision: 指定文字的输出精度;
// fbClipPrecision: 指定文字的剪辑精度;
// fbQuality: 指定文字的输出质量;
// fbPitchAndFamily: 指定以常规方式描述字体的字体系列。
void EGEAPI setfont(int nHeight, int nWidth, LPCSTR lpszFace, PIMAGE pimg = NULL);
void EGEAPI setfont(int nHeight, int nWidth, LPCWSTR lpszFace, PIMAGE pimg = NULL);
void EGEAPI setfont(int nHeight, int nWidth, LPCSTR lpszFace, int nEscapement, int nOrientation,
int nWeight, int bItalic, int bUnderline, int bStrikeOut, PIMAGE pimg = NULL);
void EGEAPI setfont(int nHeight, int nWidth, LPCWSTR lpszFace, int nEscapement, int nOrientation,
int nWeight, int bItalic, int bUnderline, int bStrikeOut, PIMAGE pimg = NULL);
void EGEAPI setfont(int nHeight, int nWidth, LPCSTR lpszFace, int nEscapement, int nOrientation,
int nWeight, int bItalic, int bUnderline, int bStrikeOut, BYTE fbCharSet,
BYTE fbOutPrecision, BYTE fbClipPrecision, BYTE fbQuality, BYTE fbPitchAndFamily, PIMAGE pimg = NULL);
void EGEAPI setfont(int nHeight, int nWidth, LPCWSTR lpszFace, int nEscapement, int nOrientation,
int nWeight, int bItalic, int bUnderline, int bStrikeOut, BYTE fbCharSet,
BYTE fbOutPrecision, BYTE fbClipPrecision, BYTE fbQuality, BYTE fbPitchAndFamily, PIMAGE pimg = NULL);
void EGEAPI setfont(const LOGFONTA *font, PIMAGE pimg = NULL); // 设置当前字体样式
void EGEAPI setfont(const LOGFONTW *font, PIMAGE pimg = NULL); // 设置当前字体样式
void EGEAPI getfont(LOGFONTA *font, PCIMAGE pimg = NULL); // 获取当前字体样式
void EGEAPI getfont(LOGFONTW *font, PCIMAGE pimg = NULL); // 获取当前字体样式
//图片函数
#define getmaxx getwidth
#define getmaxy getheight
int EGEAPI getwidth(PCIMAGE pimg = NULL); // 获取图片宽度
int EGEAPI getheight(PCIMAGE pimg = NULL); // 获取图片高度
int EGEAPI getx(PCIMAGE pimg = NULL); // 获取当前 x 坐标
int EGEAPI gety(PCIMAGE pimg = NULL); // 获取当前 y 坐标
PIMAGE EGEAPI newimage(); // 创建 PIMAGE
PIMAGE EGEAPI newimage(int width, int height); // 创建 PIMAGE
void EGEAPI delimage(PCIMAGE pImg); // 删除 PIMAGE
color_t* EGEAPI getbuffer(PIMAGE pImg);
const color_t* EGEAPI getbuffer(PCIMAGE pImg);
int EGEAPI resize(PIMAGE pDstImg, int width, int height); //重设尺寸
void EGEAPI getimage(PIMAGE pDstImg, int srcX, int srcY, int srcWidth, int srcHeight); // 从屏幕获取图像
void EGEAPI getimage(PIMAGE pDstImg, PCIMAGE pSrcImg, int srcX, int srcY, int srcWidth, int srcHeight); // 从另一个 PIMAGE 对象中获取图像
int EGEAPI getimage(PIMAGE pDstImg, LPCSTR pImgFile, int zoomWidth = 0, int zoomHeight = 0); // 从图片文件获取图像(bmp/jpg/gif/emf/wmf)
int EGEAPI getimage(PIMAGE pDstImg, LPCWSTR pImgFile, int zoomWidth = 0, int zoomHeight = 0); // 从图片文件获取图像(bmp/jpg/gif/emf/wmf)
int EGEAPI getimage(PIMAGE pDstImg, LPCSTR pResType, LPCSTR pResName, int zoomWidth = 0, int zoomHeight = 0); // 从资源文件获取图像(bmp/jpg/gif/emf/wmf)
int EGEAPI getimage(PIMAGE pDstImg, LPCWSTR pResType, LPCWSTR pResName, int zoomWidth = 0, int zoomHeight = 0); // 从资源文件获取图像(bmp/jpg/gif/emf/wmf)
void EGEAPI putimage(int dstX, int dstY, PCIMAGE pSrcImg, DWORD dwRop = SRCCOPY); // 绘制图像到屏幕
void EGEAPI putimage(int dstX, int dstY, int dstWidth, int dstHeight, PCIMAGE pSrcImg, int srcX, int srcY, DWORD dwRop = SRCCOPY); // 绘制图像到屏幕(指定宽高)
void EGEAPI putimage(int dstX, int dstY, int dstWidth, int dstHeight, PCIMAGE pSrcImg, int srcX, int srcY, int srcWidth, int srcHeight, DWORD dwRop = SRCCOPY); // 绘制图像到屏幕(指定源宽高和目标宽高进行拉伸)
void EGEAPI putimage(PIMAGE pDstImg, int dstX, int dstY, PCIMAGE pSrcImg, DWORD dwRop = SRCCOPY); // 绘制图像到另一图像中
void EGEAPI putimage(PIMAGE pDstImg, int dstX, int dstY, int dstWidth, int dstHeight, PCIMAGE pSrcImg, int srcX, int srcY, DWORD dwRop = SRCCOPY); // 绘制图像到另一图像中(指定宽高)
void EGEAPI putimage(PIMAGE pDstImg, int dstX, int dstY, int dstWidth, int dstHeight, PCIMAGE pSrcImg, int srcX, int srcY, int srcWidth, int srcHeight, DWORD dwRop = SRCCOPY); // 绘制图像到另一图像中(指定源宽高和目标宽高进行拉伸)
int EGEAPI saveimage(PCIMAGE pimg, LPCSTR filename);
int EGEAPI saveimage(PCIMAGE pimg, LPCWSTR filename);
int EGEAPI savepng(PCIMAGE pimg, LPCSTR filename, int bAlpha = 0);
int EGEAPI savepng(PCIMAGE pimg, LPCWSTR filename, int bAlpha = 0);
int EGEAPI getimage_pngfile(PIMAGE pimg, LPCSTR filename);
int EGEAPI getimage_pngfile(PIMAGE pimg, LPCWSTR filename);
int EGEAPI putimage_transparent(
PIMAGE imgdest, // handle to dest
PCIMAGE imgsrc, // handle to source
int nXOriginDest, // x-coord of destination upper-left corner
int nYOriginDest, // y-coord of destination upper-left corner
color_t crTransparent, // color to make transparent
int nXOriginSrc = 0, // x-coord of source upper-left corner
int nYOriginSrc = 0, // y-coord of source upper-left corner
int nWidthSrc = 0, // width of source rectangle
int nHeightSrc = 0 // height of source rectangle
);
int EGEAPI putimage_alphablend(
PIMAGE imgdest, // handle to dest
PCIMAGE imgsrc, // handle to source
int nXOriginDest, // x-coord of destination upper-left corner
int nYOriginDest, // y-coord of destination upper-left corner
unsigned char alpha, // alpha
int nXOriginSrc = 0, // x-coord of source upper-left corner
int nYOriginSrc = 0, // y-coord of source upper-left corner
int nWidthSrc = 0, // width of source rectangle
int nHeightSrc = 0 // height of source rectangle
);
int EGEAPI putimage_alphatransparent(
PIMAGE imgdest, // handle to dest
PCIMAGE imgsrc, // handle to source
int nXOriginDest, // x-coord of destination upper-left corner
int nYOriginDest, // y-coord of destination upper-left corner
color_t crTransparent, // color to make transparent
unsigned char alpha, // alpha
int nXOriginSrc = 0, // x-coord of source upper-left corner
int nYOriginSrc = 0, // y-coord of source upper-left corner
int nWidthSrc = 0, // width of source rectangle
int nHeightSrc = 0 // height of source rectangle
);
int EGEAPI putimage_withalpha(
PIMAGE imgdest, // handle to dest
PCIMAGE imgsrc, // handle to source
int nXOriginDest, // x-coord of destination upper-left corner
int nYOriginDest, // y-coord of destination upper-left corner
int nXOriginSrc = 0, // x-coord of source upper-left corner
int nYOriginSrc = 0, // y-coord of source upper-left corner
int nWidthSrc = 0, // width of source rectangle
int nHeightSrc = 0 // height of source rectangle
);
int EGEAPI putimage_alphafilter(
PIMAGE imgdest, // handle to dest
PCIMAGE imgsrc, // handle to source
int nXOriginDest, // x-coord of destination upper-left corner
int nYOriginDest, // y-coord of destination upper-left corner
PCIMAGE imgalpha, // alpha
int nXOriginSrc, // x-coord of source upper-left corner
int nYOriginSrc, // y-coord of source upper-left corner
int nWidthSrc, // width of source rectangle
int nHeightSrc // height of source rectangle
);
int EGEAPI imagefilter_blurring (
PIMAGE imgdest, // handle to dest
int intensity,
int alpha,
int nXOriginDest = 0,
int nYOriginDest = 0,
int nWidthDest = 0,
int nHeightDest = 0
);
int EGEAPI putimage_rotate(
PIMAGE imgdest,
PCIMAGE imgtexture,
int nXOriginDest,
int nYOriginDest,
float centerx,
float centery,
float radian,
int btransparent = 0, // transparent (1) or not (0)
int alpha = -1, // in range[0, 256], alpha== -1 means no alpha
int smooth = 0
);
int EGEAPI putimage_rotatezoom(
PIMAGE imgdest,
PCIMAGE imgtexture,
int nXOriginDest,
int nYOriginDest,
float centerx,
float centery,
float radian,
float zoom,
int btransparent = 0, // transparent (1) or not (0)
int alpha = -1, // in range[0, 256], alpha== -1 means no alpha
int smooth = 0
);