-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathspEngineDll.cpp
More file actions
1999 lines (1998 loc) · 63.6 KB
/
spEngineDll.cpp
File metadata and controls
1999 lines (1998 loc) · 63.6 KB
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
#include <vcl.h>
#include <windows.h>
#pragma hdrstop
#pragma argsused
#define DLLEXPORT extern "C" __declspec( dllexport )
#include "spEngineWrapper.h"
#include "grapRectangle.h"
#include "spEngineDll.h"
#include "spCommon.h"
//#include "ippFilters.hpp"
#include "spProcessing.h"
#include "spTessellation.h"
#include "ippProcessing.h"
#include "ippAuxiliary.h"
#include "ippStatistics.h"
//global var wrapper
spEngineWrapper gEW;
// prototyping
//void __stdcall speDoUndoStuff(TRect &roiRect);
//---------------------------------------------------------------------------
void __stdcall speSetProperRectangle(TRect *boundRect, TRect &roiRect)
{
if (boundRect)
{
roiRect.left = (boundRect->left < 0) ? 0 : boundRect->left;
roiRect.top = (boundRect->top < 0) ? 0 : boundRect->top;
roiRect.right = (boundRect->right > gEW.Surf->Width) ? gEW.Surf->Width : boundRect->right;
roiRect.bottom = (boundRect->bottom > gEW.Surf->Height) ? gEW.Surf->Height : boundRect->bottom;
}
else
{
roiRect.left = 0;
roiRect.top = 0;
roiRect.right = gEW.Surf->Width;
roiRect.bottom = gEW.Surf->Height;
}
}
//---------------------------------------------------------------------------
/* obsolete
void __stdcall speDoUndoStuff(TRect &roiRect)
{
if (gEW.RenderData->RenderParams->CreateUndo && gEW.Render->CreateUndo)
gEW.CreateUndoBlock(&roiRect);
if (gEW.RenderData->RenderParams->AutoCommit)
gEW.Finish(&roiRect);
}
*/
//---------------------------------------------------------------------------
// exported functions
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speInit(void)
{
// ipp dlls exist
if (FileExists(ExtractFilePath(Application->ExeName)+"\\ipp_custom.dll"))
{
spCommon::ippAlive = true;
ippInit();
}
//
// Engine initialization
//
//int k;
try
{
gEW.Initialize();
return true;
}
catch (...)
{
return false;
}
}
//---------------------------------------------------------------------------
// surface
//---------------------------------------------------------------------------
DLLEXPORT int __stdcall speAddSurface(void)
{
// add new empty surface
return gEW.AddSurface();
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speSetSurfaceId(unsigned long id)
{
// set surface id
return gEW.SetSurfaceId(id);
}
//---------------------------------------------------------------------------
DLLEXPORT int __stdcall speSelectSurfaceByIndex(int sIndex)
{
return gEW.SelectSurfaceByIndex(sIndex);
}
//---------------------------------------------------------------------------
DLLEXPORT int __stdcall speSelectSurfaceById(unsigned long id)
{
return gEW.SelectSurfaceById(id);
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speSetSurface(void *scanOrig, void *scanAlphaOrig, int width, int height, unsigned int scanlineAlignment)
{
// set surface
return gEW.SetSurface(scanOrig, scanAlphaOrig, width, height, scanlineAlignment);
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speSurfaceBegin(int width, int height)
{
// set surface discontiguous
return gEW.SetSurface(width, height);
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speSurfaceAddScanline(void *scanOrig, void *scanAlphaOrig)
{
// add scanlines
return gEW.Surf->AddScanLine(scanOrig, scanAlphaOrig);
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speSurfaceFinish(void)
{
// create surface and close
return gEW.Surf->Close();
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speDeleteSurfaceByIndex(int sIndex)
{
return gEW.DeleteSurfaceByIndex(sIndex);
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speDeleteSurfaceById(int id)
{
return gEW.DeleteSurfaceById(id);
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speSyncBackSurface(void)
{
if (!gEW.Surf)
return false;
gEW.Surf->UpdateImage(imgEdit, 0);
return true;
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speSyncFrontSurface(void)
{
if (!gEW.Surf)
return false;
gEW.Surf->UpdateImage(imgOrig, 0);
return true;
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speSidekickToBackSurface(void)
{
if (!gEW.Surf)
return false;
if (!gEW.Surf->AssSidekick)
return false;
if (gEW.Surf->AssSidekick->Height() != gEW.Surf->Edit->Height || gEW.Surf->AssSidekick->Width() != gEW.Surf->Edit->Width)
return false;
gEW.Surf->Edit->Copy(gEW.Surf->AssSidekick);
return true;
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speCopyToFrontSurface(void *scanOrig, void *scanAlphaOrig)
{
if (!gEW.Surf)
return false;
if (scanOrig)
gEW.Surf->Orig->Copy(scanOrig, orInvert);
if (scanAlphaOrig)
gEW.Surf->AlphaOrig->Copy(scanAlphaOrig, orInvert);
return true;
}
//---------------------------------------------------------------------------
// render
//---------------------------------------------------------------------------
DLLEXPORT Tspe_RenderParams* __stdcall speGetRenderParams(void)
{
return gEW.RenderData->RenderParams;
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speSetAction(TspeActionType actionType)
{
if (!spCommon::ippAlive)
{
if (actionType == spe_actFilterIpp || actionType == spe_actColorTwistIpp)
return false;
}
return (bool)(gEW.SetRenderAction(actionType));
}
//---------------------------------------------------------------------------
DLLEXPORT TspeActionType __stdcall speGetAction(void)
{
return gEW.ActionType;
}
//---------------------------------------------------------------------------
DLLEXPORT Tspe_DrawParams* __stdcall speGetDrawParams(void)
{
return gEW.RenderData->DrawParams;
}
//---------------------------------------------------------------------------
// actions
//---------------------------------------------------------------------------
DLLEXPORT Tspe_ColorParams* __stdcall speGetColorParams(void)
{
//ColorParams->ColorCurve = 0;
//ColorParams->ColorCorrection = 0;
//
return gEW.RenderData->ColorParams;
}
//---------------------------------------------------------------------------
DLLEXPORT Tspe_ShiftParams* __stdcall speGetShiftParams(void)
{
return gEW.RenderData->ShiftParams;
}
//---------------------------------------------------------------------------
DLLEXPORT Tspe_SpreadParams* __stdcall speGetSpreadParams(void)
{
return gEW.RenderData->SpreadParams;
}
//---------------------------------------------------------------------------
DLLEXPORT Tspe_Filter33Params* __stdcall speGetFilter33Params(void)
{
return gEW.RenderData->Filter33Params;
}
//---------------------------------------------------------------------------
DLLEXPORT Tspe_FilterIppParams* __stdcall speGetFilterIppParams(void)
{
return gEW.RenderData->FilterIppParams;
}
//---------------------------------------------------------------------------
DLLEXPORT Tspe_ColorTwistIppParams* __stdcall speGetColorTwistIppParams(void)
{
return gEW.RenderData->ColorTwistIppParams;
}
//---------------------------------------------------------------------------
DLLEXPORT Tspe_CompoundIppParams* __stdcall speGetCompoundIppParams(void)
{
return gEW.RenderData->CompoundIppParams;
}
//---------------------------------------------------------------------------
DLLEXPORT Tspe_NozzleParams* __stdcall speGetNozzleParams(void)
{
return gEW.RenderData->NozzleParams;
}
//---------------------------------------------------------------------------
// shadow
//---------------------------------------------------------------------------
DLLEXPORT Tspe_ShadowParams* __stdcall speGetShadowParams(void)
{
return gEW.RenderData->ShadowParams;
}
//---------------------------------------------------------------------------
// shape
//---------------------------------------------------------------------------
DLLEXPORT TspeShapeType __stdcall speSetShape(TspeShapeType shapeType)
{
// set shape
return (gEW.SetShape(shapeType));
//void *vShape = gEW.SetShape(className);
//return vShape;
}
//---------------------------------------------------------------------------
// brush common
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speSetBrush(TspeBrushType brushType)
{
// set brush
return (bool)(gEW.SetBrush(brushType));
//
//void *vBrush = gEW.SetBrush(className);
//return vBrush;
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speSelectBrush(int bIndex, TspeBrushType &bType)
{
return gEW.SelectBrush(bIndex, bType);
}
//---------------------------------------------------------------------------
DLLEXPORT Tspe_BrushCommonParams* __stdcall speGetBrushCommon(void)
{
if (!gEW.Brush)
return 0;
return gEW.Brush->CommonParams;
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speUpdateBrush(void)
{
if (!gEW.Surf)
return false;
if (!gEW.Brush || !gEW.Surf->Shape)
return false;
gEW.Surf->Brush->ColorParams->SetPrimaryColor(ptRGB(gEW.Surf->Brush->CommonParams->PrimaryColor));
gEW.Surf->Brush->Begin(gEW.Surf->Shape);
return true;
}
//---------------------------------------------------------------------------
// brush specific
//---------------------------------------------------------------------------
DLLEXPORT void* __stdcall speGetBrushSpecific(void)
{
// get brush specific params
return gEW.GetBrushSpecific();
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speSetBrushSpecific(void *vBsp)
{
if (!vBsp)
return false;
// set brush specific params
gEW.SetBrushSpecific(vBsp);
return true;
}
//---------------------------------------------------------------------------
// brush stamp
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speSetStamp(void *buffer, int width, int height, unsigned int scanlineAlignement, bool shared)
{
return gEW.SetStamp(buffer, width, height, scanlineAlignement, shared);
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speClearStamp(void)
{
return gEW.ClearStamp();
}
//---------------------------------------------------------------------------
// brush nozzle
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speAddPumpImage(void *buffer, int width, int height, unsigned int scanlineAlignement, bool shared)
{
return gEW.AddPumpImage(buffer, width, height, scanlineAlignement, shared);
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speSelectPumpImage(int idx)
{
return gEW.SelectPumpImage(idx);
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speDeselectPump(void)
{
return gEW.DeselectPump();
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speClearPump(void)
{
return gEW.ClearPump();
}
//---------------------------------------------------------------------------
// brush textures
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speSetTexture(void *buffer, int width, int height, unsigned int scanlineAlignement)
{
if (!gEW.Brush)
return false;
gEW.Brush->ColorParams->SetTexture(buffer, width, height, scanlineAlignement);
return true;
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speDeleteTexture(void)
{
if (!gEW.Brush)
return false;
gEW.Brush->ColorParams->ClearTexture();
return true;
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speSetBackgroundTile(void *buffer, int width, int height, unsigned int scanlineAlignement)
{
if (!gEW.Brush)
return false;
gEW.Brush->ColorParams->SetBackgroundTile(buffer, width, height, scanlineAlignement);
return true;
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speDeleteBackgroundTile(void)
{
if (!gEW.Brush)
return false;
gEW.Brush->ColorParams->ClearBackgroundTile();
return true;
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speSetPolyTexture(void *buffer, int width, int height, unsigned int scanlineAlignement)
{
if (!gEW.Brush)
return false;
gEW.Brush->ColorParams->SetPolyTexture(buffer, width, height, scanlineAlignement);
return true;
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speDeletePolyTexture(void)
{
if (!gEW.Brush)
return false;
gEW.Brush->ColorParams->ClearPolyTexture();
return true;
}
//---------------------------------------------------------------------------
// brush palette
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speSetPalette3C(unsigned int c1, unsigned int c2, unsigned int c3)
{
if (!gEW.Brush)
return false;
gEW.Brush->ColorParams->SetPalette3C(c1, c2, c3);
return true;
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speSetPalette255C(unsigned int *pal)
{
if (!gEW.Brush)
return false;
for (int k = 0; k < 256; k++)
gEW.Brush->ColorParams->PalEntry[k] = ptRGB(pal[k]);
return true;
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speSetPaletteFromShortPal(unsigned int *pal, int count)
{
if (!gEW.Brush)
return false;
gEW.Brush->ColorParams->SetPaletteShortPalC(pal, count);
return true;
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speSetShortPalette(unsigned int *pal, int count)
{
gEW.RenderData->GlobalColorParams->ShortPalCount = count;
for (int k = 0; k < count; k++)
gEW.RenderData->GlobalColorParams->ShortPalEntry[k] = ptRGB(pal[k]);
return true;
}
//---------------------------------------------------------------------------
DLLEXPORT unsigned int __stdcall speGetShortPaletteColor(int pIndex)
{
if (pIndex >= gEW.RenderData->GlobalColorParams->ShortPalCount)
pIndex = 0;
return spCommon::ptRGB2Color(gEW.RenderData->GlobalColorParams->ShortPalEntry[pIndex]);
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speGetPalette(unsigned int *pal)
{
if (!gEW.Brush)
return false;
if (!pal)
return false;
for (int k = 0; k < 256; k++)
pal[k] = spCommon::ptRGB2Color(gEW.Brush->ColorParams->PalEntry[k]);
return true;
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speDrawRectangleRect(TRect &objRect, Tspe_Geometry &geometry, bool usePresetShape = true)
{
if (!gEW.Brush)
return false;
if (usePresetShape)
{
if (gEW.ShapeType == spe_shpRectangle)
{
return gEW.DrawObjectRect(objRect, geometry);
}
}
TspeShapeType prevShapeType = gEW.ShapeType;
gEW.SetShape(spe_shpRectangle);
gEW.DrawObjectRect(objRect, geometry);
gEW.SetShape(prevShapeType);
return true;
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speDrawRectangle(int x1, int y1, int x2, int y2, Tspe_Geometry &geometry, bool usePresetShape = true)
{
if (!gEW.Brush)
return false;
TRect objRect;
objRect.left = x1;
objRect.top = y1;
objRect.right = x2;
objRect.bottom = y2;
speDrawRectangleRect(objRect, geometry, usePresetShape);
return true;
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speDrawEllipseRect(TRect &objRect, Tspe_Geometry &geometry, bool usePresetShape = true)
{
if (!gEW.Brush)
return false;
if (usePresetShape)
{
if (gEW.ShapeType == spe_shpEllipse)
{
gEW.DrawObjectRect(objRect, geometry);
return true;
}
}
TspeShapeType prevShapeType = gEW.ShapeType;
gEW.SetShape(spe_shpEllipse);
if (geometry.SimplifyPolyline)
gEW.Surf->Shape->SetSimplifyRule(true, geometry.SimplifyDPTolerance, geometry.SimplifyMaxPts);
gEW.DrawObjectRect(objRect, geometry);
gEW.SetShape(prevShapeType);
return true;
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speDrawEllipse(int x1, int y1, int x2, int y2, Tspe_Geometry &geometry, bool usePresetShape = true)
{
if (!gEW.Brush)
return false;
TRect objRect;
objRect.left = x1;
objRect.top = y1;
objRect.right = x2;
objRect.bottom = y2;
speDrawEllipseRect(objRect, geometry, usePresetShape);
return true;
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speDrawPoly(TPoint *pts, int ptsCount, Tspe_Geometry &geometry, bool usePresetShape = true)
{
if (!gEW.Brush)
return false;
if (usePresetShape)
{
if (gEW.ShapeType == spe_shpPoly)
{
return gEW.DrawObjectPoly(pts, ptsCount, geometry);
}
}
TspeShapeType prevShapeType = gEW.ShapeType;
gEW.SetShape(spe_shpPoly);
gEW.DrawObjectPoly(pts, ptsCount, geometry);
gEW.SetShape(prevShapeType);
return true;
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speDrawPolySimple(TPoint *pts, int ptsCount, bool usePresetShape = true)
{
if (!gEW.Brush)
return false;
bool lPreset = false;
if (usePresetShape)
{
if (gEW.ShapeType == spe_shpLine)
lPreset = true;
}
TspeShapeType prevShapeType = gEW.ShapeType;
if (!lPreset)
gEW.SetShape(spe_shpLine);
TRect objRect;
gEW.Surf->Brush->Begin(gEW.Surf->Shape);
gEW.Surf->Shape->Reset();
gEW.Surf->Shape->DrawPoly(&objRect, pts, ptsCount);
gEW.Render->Begin(pts[0].x, pts[0].y);
gEW.Surf->Brush->PreparePoints(false);
gEW.Surf->Brush->State->wpRealStepper = gEW.Surf->Brush->State->cpRealStepper;
gEW.Render->Execute(objRect.left, objRect.top,
objRect.right, objRect.bottom);
gEW.Render->FinishRender();
// TODO: bigbound
TRect boundRect = gEW.Render->End(objRect.left, objRect.top,
objRect.right, objRect.bottom);
gEW.DoUndoStuff(boundRect);
if (!lPreset)
gEW.SetShape(prevShapeType);
/*
gEW.Surf->Brush->Begin(gEW.Surf->Shape);
gEW.Brush->State->wpRealStepper = gEW.Brush->State->cpRealStepper;
gEW.Render->Begin(pts[0].x, pts[0].y);
for (int i = 1; i < ptsCount; i++)
{
gEW.Shape->Reset();
gEW.Shape->DrawCoords(pts[i-1].x, pts[i-1].y, pts[i].x, pts[i].y);
gEW.Brush->PreparePoints(false);
//gEW.Surf->realStepper = gEW.Brush->State->cpRealStepper;
gEW.Render->Execute(pts[i-1].x, pts[i-1].y, pts[i].x, pts[i].y);
gEW.Render->FinishRender();
}
// TODO: bigbound
TRect boundRect = gEW.Render->End(pts[0].x, pts[0].y, pts[1].x, pts[1].y);
gEW.DoUndoStuff(boundRect);
if (!lPreset)
gEW.SetShape(prevShapeType);
*/
return true;
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speDrawSpline(TPoint *pts, int ptsCount, Tspe_Geometry &geometry, bool usePresetShape = true)
{
if (!gEW.Brush)
return false;
if (usePresetShape)
{
if (gEW.ShapeType == spe_shpSplineCR)
{
return gEW.DrawObjectPoly(pts, ptsCount, geometry);
}
}
TspeShapeType prevShapeType = gEW.ShapeType;
gEW.SetShape(spe_shpSplineCR);
gEW.DrawObjectPoly(pts, ptsCount, geometry);
gEW.SetShape(prevShapeType);
return true;
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speDrawSplineSimple(TPoint *pts, int ptsCount, bool usePresetShape = true)
{
if (!gEW.Brush)
return false;
bool lPreset = false;
if (usePresetShape)
{
if (gEW.ShapeType == spe_shpSplineCR)
lPreset = true;
}
TspeShapeType prevShapeType = gEW.ShapeType;
if (!lPreset)
gEW.SetShape(spe_shpSplineCR);
TRect objRect;
gEW.Surf->Brush->Begin(gEW.Surf->Shape);
gEW.Surf->Shape->Reset();
gEW.Surf->Shape->DrawPoly(&objRect, pts, ptsCount);
gEW.Render->Begin(pts[0].x, pts[0].y);
gEW.Surf->Brush->PreparePoints(false);
gEW.Surf->Brush->State->wpRealStepper = gEW.Surf->Brush->State->cpRealStepper;
gEW.Render->Execute(objRect.left, objRect.top,
objRect.right, objRect.bottom);
gEW.Render->FinishRender();
// TODO: bigbound
TRect boundRect = gEW.Render->End(objRect.left, objRect.top,
objRect.right, objRect.bottom);
gEW.DoUndoStuff(boundRect);
if (!lPreset)
gEW.SetShape(prevShapeType);
return true;
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speDrawLine(int x1, int y1, int x2, int y2, bool usePresetShape = true)
{
if (!gEW.Brush)
return false;
bool lPreset = false;
if (usePresetShape)
{
if (gEW.ShapeType == spe_shpLine)
lPreset = true;
}
TspeShapeType prevShapeType = gEW.ShapeType;
if (!lPreset)
gEW.SetShape(spe_shpLine);
/*
TRect objRect;
objRect.left = x1;
objRect.right = x2;
objRect.top = y1;
objRect.bottom = y2;
objRect.Normalize();
*/
gEW.Surf->Brush->Begin(gEW.Surf->Shape);
gEW.Shape->Reset();
gEW.Shape->DrawCoords(x1, y1, x2, y2);
gEW.Render->Begin(x1, y1);
//
gEW.Brush->PreparePoints(false);
//gEW.Surf->realStepper = gEW.Brush->State->cpRealStepper;
gEW.Brush->State->wpRealStepper = gEW.Brush->State->cpRealStepper;
gEW.Render->Execute(x1, y1, x2, y2);
gEW.Render->FinishRender();
//TODO: dodati EndObject(Trect* )
TRect boundRect = gEW.Render->End(x1, y1, x2, y2);
gEW.DoUndoStuff(boundRect);
if (!lPreset)
gEW.SetShape(prevShapeType);
return true;
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speGetMouseData(Tspe_MouseData &md)
{
// save mouse data
if (!gEW.Shape)
return false;
md.X_down = gEW.Shape->MouseData.X_down;
md.Y_down = gEW.Shape->MouseData.Y_down;
md.X_up = gEW.Shape->MouseData.X_up;
md.Y_up = gEW.Shape->MouseData.Y_up;
md.X_move_from = gEW.Shape->MouseData.X_move_from;
md.Y_move_from = gEW.Shape->MouseData.Y_move_from;
md.X_move_to = gEW.Shape->MouseData.X_move_to;
md.Y_move_to = gEW.Shape->MouseData.Y_move_to;
md.X_min = gEW.Shape->MouseData.X_min;
md.Y_min = gEW.Shape->MouseData.Y_min;
md.X_max = gEW.Shape->MouseData.X_max;
md.Y_max = gEW.Shape->MouseData.Y_max;
md.X_wrap_from = gEW.Shape->MouseData.X_wrap_from;
md.Y_wrap_from = gEW.Shape->MouseData.Y_wrap_from;
md.X_wrap_to = gEW.Shape->MouseData.X_wrap_to;
md.Y_wrap_to = gEW.Shape->MouseData.Y_wrap_to;
md.MouseButtonDown = gEW.Shape->MouseData.MouseButtonDown;
md.Shift = gEW.Shape->MouseData.Shift;
return true;
}
//---------------------------------------------------------------------------
// NOT exported
/*obsolete
void __stdcall spePolyMouseUp(TShiftState Shift, int X, int Y)
{
TRect boundRect;
gEW.Render->Execute(gEW.Shape->MouseData.X_min, gEW.Shape->MouseData.Y_min,
gEW.Shape->MouseData.X_max, gEW.Shape->MouseData.Y_max);
gEW.Render->FinishRender();
boundRect = gEW.Render->End(gEW.Shape->MouseData.X_min, gEW.Shape->MouseData.Y_min,
gEW.Shape->MouseData.X_max, gEW.Shape->MouseData.Y_max);
gEW.DoUndoStuff(boundRect);
}
*/
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speHandMouseDown(TShiftState Shift, int X, int Y)
{
return gEW.WMouseDown(Shift, X, Y);
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speHandMouseMove(TShiftState Shift, int X, int Y)
{
return gEW.WMouseMove(Shift, X, Y);
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speHandMouseUp(TShiftState Shift, int X, int Y)
{
return gEW.WMouseUp(Shift, X, Y);
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speSetSizeEnvelope(wchar_t* str)
{
if (!gEW.Brush)
return false;
gEW.Brush->SetSizeEnvelope(str);
return true;
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speSetCapacityEnvelope(wchar_t* str)
{
if (!gEW.Brush)
return false;
gEW.Brush->SetCapacityEnvelope(str);
return true;
}
//---------------------------------------------------------------------------
/* obsolete -> set through parameters
DLLEXPORT bool __stdcall speSetScaleColors(unsigned int botVal, unsigned int topVal)
{
return gEW.SetScaleColors(botVal, topVal);
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speResetScaleColors(void)
{
return gEW.SetScaleColors(0x00000000, 0x00ffffff);
}
// ovo gore eventualno radi panic momenta
*/
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speSetCloneImage(void *buffer, int width, int height, unsigned int scanlineAlignement, bool shared)
{
if (!gEW.RenderData)
return false;
return gEW.SetClone(buffer, width, height, scanlineAlignement, shared);
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speSetClonePosition(int X, int Y)
{
if (!gEW.RenderData)
return false;
gEW.RenderData->GlobalColorParams->CloneStartX = X;
gEW.RenderData->GlobalColorParams->CloneStartY = Y;
gEW.RenderData->GlobalColorParams->Clone_XS = X;
gEW.RenderData->GlobalColorParams->Clone_YS = Y;
gEW.RenderData->GlobalColorParams->Clone_X = X;
gEW.RenderData->GlobalColorParams->Clone_Y = Y;
gEW.RenderData->GlobalColorParams->Clone_Started = false;
return true;
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speDeleteCloneImage(void)
{
if (!gEW.RenderData)
return false;
return gEW.DeleteClone();
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speCloneSelf(TspeCloneType type)
{
if (!gEW.Surf)
return false;
if (!gEW.RenderData)
return false;
if (type == spe_cltDirect) // clone original
gEW.Surf->CloneSelf = gEW.Surf->Orig;
else if (type == spe_cltBuffered) // clone edit
gEW.Surf->CloneSelf = gEW.Surf->Edit;
else // do not use self cloning - use external image
gEW.Surf->CloneSelf = 0;
return true;
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speSetStencil(void *buffer, int width, int height, unsigned int scanlineAlignement, bool shared)
{
return gEW.SetAssImage(0, buffer, width, height, scanlineAlignement, shared);
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speSetStencilPositionStatus(int X, int Y, bool alive)
{
if (!gEW.Surf)
return false;
gEW.Surf->Stencil_i = Y;
gEW.Surf->Stencil_j = X;
gEW.Surf->StencilAlive = alive;
return true;
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speDeleteStencil(void)
{
return gEW.DeleteAssImage(0);
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speInvertStencil(void)
{
return gEW.InvertAssImage(0);
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speSetContour(void *buffer, bool shared)
{
if (!gEW.Surf)
return false;
return gEW.SetAssImage(1, buffer, gEW.Surf->Width, gEW.Surf->Height, gEW.Surf->Orig->Alignment(), shared);
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speDeleteContour(void)
{
return gEW.DeleteAssImage(1);
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speInvertContour(void)
{
return gEW.InvertAssImage(1);
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speSetMask(void *buffer, bool shared)
{
if (!gEW.Surf)
return false;
return gEW.SetAssImage(2, buffer, gEW.Surf->Width, gEW.Surf->Height, gEW.Surf->Orig->Alignment(), shared);
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speDeleteMask(void)
{
return gEW.DeleteAssImage(2);
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speInvertMask(void)
{
return gEW.InvertAssImage(2);
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speInternalToMask(TspeInternalMaskType imt)
{
if (!gEW.Surf)
return false;
if (!gEW.Surf->AssMask)
return false;
if (imt == spe_RightMask)
gEW.Surf->AssMask->Copy(gEW.Surf->MaskRight);
else
gEW.Surf->AssMask->Copy(gEW.Surf->MaskLeft);
return true;
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speSetSidekick(void *buffer, bool shared)
{
if (!gEW.Surf)
return false;
return gEW.SetAssImage(4, buffer, gEW.Surf->Width, gEW.Surf->Height, gEW.Surf->Orig->Alignment(), shared);
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speDeleteSidekick(void)
{
return gEW.DeleteAssImage(4);
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speInvertSidekick(void)
{
return gEW.InvertAssImage(4);
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speSetNozzle(void *buffer, void *alpha, int width, int height, unsigned int scanlineAlignement, bool shared)
{
if (!gEW.RenderData)
return false;
return gEW.SetNozzle(buffer, alpha, width, height, scanlineAlignement, shared);
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speDeleteNozzle(void)
{
if (!gEW.RenderData)
return false;
return gEW.DeleteNozzle();
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speSetSelection(void *buffer, bool shared)
{
if (!gEW.Surf)
return false;
//gEW.Surf->Selection = new spImage<ptGray>(buffer, gEW.Surf->Width, gEW.Surf->Height, gEW.Surf->Orig->Alignment(), shared, orInvert);
return gEW.SetSelection(buffer, shared);
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speDeleteSelection(void)
{
if (!gEW.Surf)
return false;
return gEW.DeleteSelection();
}
//---------------------------------------------------------------------------
/* obsolete
DLLEXPORT bool __stdcall speSelectionClipping(bool clip)
{
if (!gEW.Surf)
return false;
gEW.Surf->SelClipping = clip;
return true;
}
*/
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speCheckMarker(int width, int height)
{
if (!gEW.Surf)
return false;
if (gEW.Surf->AssMarker)
return (gEW.Surf->AssMarker->Width() == width && gEW.Surf->AssMarker->Height() == height);
return false;
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speSetMarker(void *buffer, bool shared)
{
if (!gEW.Surf)
return false;
bool lRet = gEW.SetAssImage(3, buffer, gEW.Surf->Width, gEW.Surf->Height, gEW.Surf->Orig->Alignment(), shared);
if (lRet)
{
gEW.Surf->MaskLeft->Copy(gEW.Surf->AssMarker);
gEW.Surf->MaskRight->Copy(gEW.Surf->AssMarker);
gEW.RenderData->RenderParams->CreateUndo = false;
gEW.RenderData->RenderParams->AutoCommit = false;
gEW.RenderData->RenderParams->ClearImoc = false;
}
return lRet;
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speDeleteMarker(void)
{
if (!gEW.Surf)
return false;
gEW.Surf->MaskLeft->Zero();
gEW.Surf->MaskRight->Zero();
gEW.RenderData->RenderParams->CreateUndo = true;
gEW.RenderData->RenderParams->AutoCommit = true;
gEW.RenderData->RenderParams->ClearImoc = true;
return gEW.DeleteAssImage(3);
}
//---------------------------------------------------------------------------
// get image pixel from surface
DLLEXPORT bool __stdcall speGetPixelRGB(const int &y, const int &x, Byte &r, Byte &g, Byte &b)
{
if (!gEW.Surf)
return false;
ptRGB *pix = &(gEW.Surf->Edit->Pix[y][x]);
b = pix->ch[0];
g = pix->ch[1];
r = pix->ch[2];
return true;
}
//---------------------------------------------------------------------------
// get image pixel from surface
DLLEXPORT bool __stdcall speGetPixelColor(const int &y, const int &x, unsigned int &color)
{
if (!gEW.Surf)
return false;
ptRGB *pix = &(gEW.Surf->Edit->Pix[y][x]);
color = (unsigned int)RGB(pix->ch[2], pix->ch[1], pix->ch[0]);
return true;
}
//---------------------------------------------------------------------------
DLLEXPORT bool __stdcall speSetColorCurve(Byte **LUTCurveEntry)
{
return gEW.SetColorCurve(LUTCurveEntry);
}
//---------------------------------------------------------------------------
// apply action on complete image or roi (or selection if any)
DLLEXPORT bool __stdcall speApplyOnImage(TRect *boundRect, TspeApplyType appType)
{
if (!gEW.Surf)
return false;
bool selClip = gEW.RenderData->RenderParams->SelectionClipping;
if (appType == spe_appSelection)
{
if (!gEW.Surf->Selection)
return false;
gEW.RenderData->RenderParams->SelectionClipping = true;