-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtestbed_pmf.c
2929 lines (2575 loc) · 129 KB
/
testbed_pmf.c
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
/**
Example progam used for exercising the libUEMF functions.
Produces a single output file: test_libuemf_p.emf
Single command line parameter, hexadecimal bit flag.
1 Disable tests that block EMF import into PowerPoint (dotted lines)
2 Enable tests that block EMF being displayed in Windows Preview (currently, GradientFill)
4 Use a rotated, scaled, offset world transform
8 Disable clipping tests.
Default is 0, no option set.
Compile with
gcc -g -O0 -o testbed_pmf -std=c99 -Wall -pedantic -I. testbed_pmf.c uemf.c uemf_endian.c uemf_utf.c upmf.c upmf.h -lm
or
gcc -g -O0 -o testbed_pmf -std=c99 -DU_VALGRIND -Wall -pedantic -I. testbed_pmf.c uemf.c uemf_endian.c uemf_utf.c upmf.c upmf.h -lm
The latter from enables code which lets valgrind check each record for
uninitialized data.
*/
/* If Version or Date are changed also edit the text labels for the output.
File: testbed_pmf.c
Version: 0.0.7
Date: 13-MAY-2020
Author: David Mathog, Biology Division, Caltech
email: [email protected]
Copyright: 2020 David Mathog and California Institute of Technology (Caltech)
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stddef.h>
#include <math.h>
#include "upmf.h"
#define PPT_BLOCKERS 1
#define PREVIEW_BLOCKERS 2
#define WORLDXFORM_TEST 4
#define NO_CLIP_TEST 8
#define ALPHA_YES 1
#define ALPHA_NO 0
#define CMP_IMG_YES 1
#define CMP_IMG_NO 0
/* definitions for slots in the object table */
#define OBJ_FONT_TCOMMENT 2
#define OBJ_FONT_OTHER 3
#define OBJ_SF_TCOMMENT 4
#define OBJ_SF_OTHER 5
#define OBJ_PEN_GROUP1 20 /* variable */
#define OBJ_PEN_GROUP2 21 /* variable */
#define OBJ_PEN_BLACK_1 22 /* fixed */
#define OBJ_PEN_FUCHSIA_1 23 /* variable */
#define OBJ_PEN_RED_10 24 /* fixed */
#define OBJ_PEN_BLACK_20 25 /* variable */
#define OBJ_PEN_RED_1 26 /* fixed */
#define OBJ_BRUSH_GROUP1 30 /* variable */
#define OBJ_PATH_1 40 /* variable */
#define OBJ_IMG_1 50 /* variable */
#define OBJ_IA 51 /* variable */
#define OBJ_REGION_1 60 /* variable */
#define STRALLOC 64
void printf_and_flush(const char *string){
printf(string);
fflush(stdout);
}
void IfNullPtr(void *po, int LineNo, char *text){
if(!po){
printf("Line:%d %s",LineNo,text);
fflush(stdout);
exit(EXIT_FAILURE);
}
}
void IfNotTrue(int Val, int LineNo, char *text){
if(!Val){
printf("Line:%d %s",LineNo,text);
fflush(stdout);
exit(EXIT_FAILURE);
}
}
/* use this to find uninitialized data*/
void DumpPo(U_PSEUDO_OBJ *po, char *text){
unsigned int i;
unsigned long int us,uu;
uint8_t *ptr = (uint8_t *)po->Data;
printf("DEBUG %s\n", text); fflush(stdout);
us = po->Size; /* printing size_t portably is a pain, this avoids the issue */
uu = po->Used;
printf("DEBUG Data:%p Size:%lu Used:%lu",po->Data, us, uu);fflush(stdout);
for(i=0; i < po->Used; i++, ptr++){
printf("DEBUG %5.5d %2.2X\n",i,*ptr); fflush(stdout);
}
}
// noa special conditions:
// 1 then s2 is expected to have zero in the "a" channel
// 2 then s2 is expected to have zero in the "a" channel AND only top 5 bits are meaningful
int rgba_diff(char *s1, char *s2, uint32_t size, int noa){
for( ; size ; size--, s1++, s2++){
if(noa==1){
if(*s1 != *s2){
if(noa && !(*s2) && (1 == size % 4))continue;
return(1);
}
}
if(noa==2){
if((0xF8 & *s1) != (0xF8 &*s2)){
if(noa && !(*s2) && (1 == size % 4))continue;
return(1);
}
}
else {
if(*s1 != *s2)return(1);
}
}
return(0);
}
void taf(char *rec,EMFTRACK *et, char *text){ // Test, append, free
if(!rec){ printf("%s failed",text); }
else { printf("%s recsize: %d",text,U_EMRSIZE(rec)); }
(void) emf_append((PU_ENHMETARECORD)rec, et, 1);
printf("\n");
#ifdef U_VALGRIND
fflush(stdout); // helps keep lines ordered within Valgrind
#endif
}
/* accept the load of an EMF+ record, pack it into an EMF comment record, and append it */
void paf(EMFTRACK *et, U_PSEUDO_OBJ *sum, U_PSEUDO_OBJ *po, char *text){ // Test, append, free
unsigned long int uu;
char *rec;
uu = po->Used; /* printing size_t portably is a pain, this avoids the issue */
if(!po){ printf("%s failed",text); }
else { printf("%s recsize: %lu",text, uu + 16); }
sum->Used = 0; /* clean it out, retaining allocated memory */
sum = U_PO_append(sum, "EMF+", 4); /* indicates that this comment holds an EMF+ record */
sum = U_PO_append(sum, po->Data, po->Used); /* the EMF+ record itself */
U_PO_free(&po); /* delete the PseudoObject */
rec = U_EMRCOMMENT_set(sum->Used, sum->Data); /* stuff it into the EMF comment */
(void) emf_append((PU_ENHMETARECORD)rec, et, 1);
printf("\n");
#ifdef U_VALGRIND
fflush(stdout); // helps keep lines ordered within Valgrind
#endif
}
/* Call this to figure out where a missing piece of memory is */
void findhole(char *rec, char *text){ // Test
int i,length;
unsigned char uc;
if(!rec){ printf("%s failed",text); }
else {
length = U_EMRSIZE(rec);
printf("%s recsize: %d",text,length);
for(i=0;i<length;i++){
uc = (unsigned char) rec[i];
printf("byte:%d value:%X\n",i,uc);
fflush(stdout); // helps keep lines ordered within Valgrind
}
}
}
uint32_t makeindex(int i, int j, int w, int h, uint32_t colortype){
uint32_t index = 0;
float scale;
switch(colortype){
case U_BCBM_MONOCHROME: //! 2 colors. bmiColors array has two entries
scale=1;
break;
case U_BCBM_COLOR4: //! 2^4 colors. bmiColors array has 16 entries
scale=15;
break;
case U_BCBM_COLOR8: //! 2^8 colors. bmiColors array has 256 entries
scale=255;
break;
case U_BCBM_COLOR16: //! 2^16 colors. (Several different index methods))
scale=65535;
break;
case U_BCBM_COLOR24: //! 2^24 colors. bmiColors is not used. Pixels are U_RGBTRIPLE.
case U_BCBM_COLOR32: //! 2^32 colors. bmiColors is not used. Pixels are U_RGBQUAD.
case U_BCBM_EXPLICIT: //! Derinved from JPG or PNG compressed image or ?
default:
exit(EXIT_FAILURE);
}
if(scale > w*h-1)scale=w*h-1; // color table will not have more entries than the size of the image
index = U_ROUND(scale * ( (float) i * (float)w + (float)j ) / ((float)w * (float)h));
return(index);
}
/*
Fill a rectangular RGBA image with gradients. Used for testing DIB operations.
*/
void FillImage(char *px, int w, int h, int stride, int alpha){
int i,j;
int xp,xm,yp,ym; // color weighting factors
int r,g,b,a;
int pad;
U_COLORREF color;
pad = stride - w*4; // end of row padding in bytes (may be zero)
for(j=0; j<h; j++){
yp = (255 * j) / (h-1);
ym = 255 - yp;
for(i=0; i<w; i++, px+=4){
xp = (255 * i)/ (w-1);
xm = 255 - xp;
r = (xm > ym ? ym : xm);
g = (xp > ym ? ym : xp);
b = (xp > yp ? yp : xp);
if(alpha){ a = (xm > yp ? yp : xm); }
else{ a = 255; }
color = U_RGBA(r,g,b,a);
memcpy(px,&color,4);
}
px += pad;
}
}
/*
Draw a colored rectangle onto an RGBA image.
Used for testing ImageEffects operations.
*/
void DrawImageRect(char *px, int stride, int ulx, int uly, int rw, int rh, U_COLORREF color){
int j,i;
char *lpx;
px += stride * uly;
for(j=0; j<rh; j++, px += stride){
lpx = px + 4*ulx;
for(i=0; i<rw; i++, lpx+=4){
memcpy(lpx, &color, 4);
}
}
}
/*
Fill a rectangular RGBA image with gradients then draw some sharp rectangles on top of it.
Used for testing ImageEffects operations.
*/
void FillImage2(char *px, int w, int h, int stride, int alpha){
int lh,ly;
double dw = 2;
double dk = 255.0;
uint8_t k;
FillImage(px, w, h, stride, alpha);
ly = h/32;
lh = 0;
for(; lh + ly < h; ly += lh+3){
k = U_ROUND(dk);
lh = U_ROUND(dw);
DrawImageRect(px, stride, w/4, ly, w/2, lh, U_RGBA(k,k,k,255));
dw *= 1.25;
dk /= 1.4;
}
}
void draw_textrect(int xul, int yul, int width, int height, char *string, int size, EMFTRACK *et){
char *rec;
char *rec2;
uint16_t *text16;
int slen;
uint32_t *dx;
U_RECTL rclBox;
rclBox = rectl_set(pointl_set(xul,yul),pointl_set(xul + width, yul + height));
rec = U_EMRRECTANGLE_set(rclBox); taf(rec,et,"U_EMRRECTANGLE_set");
text16 = U_Utf8ToUtf16le(string, 0, NULL);
slen = wchar16len(text16);
dx = dx_set(-size, U_FW_NORMAL, slen);
rec2 = emrtext_set( pointl_set(xul+width/2,yul + height/2), slen, 2, text16, U_ETO_NONE, U_RCL_DEF, dx);
free(text16);
free(dx);
rec = U_EMREXTTEXTOUTW_set(U_RCL_DEF,U_GM_COMPATIBLE,1.0,1.0,(PU_EMRTEXT)rec2);
taf(rec,et,"U_EMREXTTEXTOUTW_set");
free(rec2);
}
void textlabel(U_PSEUDO_OBJ *sum, U_FLOAT size, const char *string, uint32_t x, uint32_t y,
int ax, int ay, U_PSEUDO_OBJ *poColor, EMFTRACK *et){
uint16_t *FontName;
uint16_t *text16;
int slen;
U_PSEUDO_OBJ *po;
U_PSEUDO_OBJ *poRect;
U_PSEUDO_OBJ *poFont;
U_FLOAT rx,ry,rw,rh;
FontName = U_Utf8ToUtf16le("Courier New", 0, NULL); // Helvetica originally, but that does not work
slen = strlen("Courier New");
poFont = U_PMF_FONT_set(U_PMF_GRAPHICSVERSIONOBJ_set(2), size, U_UT_Pixel, U_FS_None, slen, FontName);
IfNullPtr(poFont,__LINE__,"OOPS on U_PMF_FONT_set\n");
free(FontName);
po = U_PMR_OBJECT_PO_set(OBJ_FONT_TCOMMENT, poFont); /* font to use */
IfNullPtr(po,__LINE__,"OOPS on U_PMR_OBJECT_PO_set\n");
paf(et, sum, po, "set font in textlabel");
U_PO_free(&poFont);
rw = 4*size*slen; /* This could probably be any value */
rh = size;
switch (ax){
case U_SA_Far: rx = x-rw; break;
case U_SA_Center: rx = x-rw/2.0; break;
case U_SA_Near:
default: rx = x; break;
}
switch (ay){
case U_SA_Far: ry = y+rh; break;
case U_SA_Center: ry = y+rh/2.0; break;
case U_SA_Near:
default: ry = y; break;
}
poRect = U_PMF_RECTF4_set(rx, ry, rw, rh);
text16 = U_Utf8ToUtf16le(string, 0, NULL);
slen = strlen(string);
po = U_PMR_DRAWSTRING_set(OBJ_FONT_TCOMMENT, poColor, OBJ_SF_TCOMMENT, slen, poRect, text16);
IfNullPtr(po,__LINE__,"OOPS on U_PMR_DRAWSTRING_set\n");
paf(et, sum, po, "U_PMR_DRAWSTRING_set in textlabel");
U_PO_free(&poRect);
free(text16);
}
void spintext(U_PSEUDO_OBJ *sum, U_FLOAT size, U_FLOAT x, U_FLOAT y, int ax, int ay, U_PSEUDO_OBJ *poColor, EMFTRACK *et){
int i;
char *string;
U_FLOAT Angle;
U_PSEUDO_OBJ *po;
string = malloc(STRALLOC);
for(i=0; i<360; i+=30){
Angle = i;
po = U_PMR_ROTATEWORLDTRANSFORM_set(U_XM_PostX, Angle);
paf(et, sum, po, "U_PMR_ROTATEWORLDTRANSFORM_set in spintext");
po = U_PMR_TRANSLATEWORLDTRANSFORM_set(U_XM_PostX, x, y);
paf(et, sum, po, "U_PMR_TRANSLATEWORLDTRANSFORM_set in spintext");
sprintf(string,"....Degrees:%d",i);
textlabel(sum, size, string, 0,0, ax, ay, poColor, et);
po = U_PMR_TRANSLATEWORLDTRANSFORM_set(U_XM_PostX, -x, -y);
paf(et, sum, po, "U_PMR_TRANSLATEWORLDTRANSFORM_set in spintext");
po = U_PMR_ROTATEWORLDTRANSFORM_set(U_XM_PostX, -Angle);
paf(et, sum, po, "U_PMR_ROTATEWORLDTRANSFORM_set in spintext");
}
free(string);
}
void label_column(U_PSEUDO_OBJ *sum, int x1, int y1, int ax, int ay, U_PSEUDO_OBJ *poColor, EMFTRACK *et){
textlabel(sum, 40, "STRETCHDIBITS 1", x1, y1, ax, ay, poColor, et); y1 += 220;
textlabel(sum, 40, "BITBLT 1", x1, y1, ax, ay, poColor, et); y1 += 220;
textlabel(sum, 40, "STRETCHBLT 1", x1, y1, ax, ay, poColor, et); y1 += 240;
textlabel(sum, 40, "STRETCHDIBITS 2", x1, y1, ax, ay, poColor, et); y1 += 220;
textlabel(sum, 40, "BITBLT 2", x1, y1, ax, ay, poColor, et); y1 += 220;
textlabel(sum, 40, "STRETCHBLT 2", x1, y1, ax, ay, poColor, et); y1 += 240;
textlabel(sum, 40, "STRETCHDIBITS 3", x1, y1, ax, ay, poColor, et); y1 += 220;
textlabel(sum, 40, "BITBLT 3", x1, y1, ax, ay, poColor, et); y1 += 220;
textlabel(sum, 40, "STRETCHBLT 3", x1, y1, ax, ay, poColor, et); y1 += 240;
textlabel(sum, 40, "STRETCHDIBITS 4", x1, y1, ax, ay, poColor, et); y1 += 220;
textlabel(sum, 40, "BITBLT 4", x1, y1, ax, ay, poColor, et); y1 += 220;
textlabel(sum, 40, "STRETCHBLT 4", x1, y1, ax, ay, poColor, et); // y1 += 220;// clang static analyzer does not like this
return;
}
void label_row(U_PSEUDO_OBJ *sum, int x1, int y1, int ax, int ay, U_PSEUDO_OBJ *poColor, EMFTRACK *et){
textlabel(sum, 30, "+COLOR32 ", x1, y1, ax, ay, poColor, et); x1 += 220;
textlabel(sum, 30, "+COLOR24 ", x1, y1, ax, ay, poColor, et); x1 += 220;
textlabel(sum, 30, "+COLOR16 ", x1, y1, ax, ay, poColor, et); x1 += 220;
textlabel(sum, 30, "-COLOR16 ", x1, y1, ax, ay, poColor, et); x1 += 220;
textlabel(sum, 30, "+COLOR8 ", x1, y1, ax, ay, poColor, et); x1 += 220;
textlabel(sum, 30, "+COLOR4 ", x1, y1, ax, ay, poColor, et); x1 += 220;
textlabel(sum, 30, "+MONO ", x1, y1, ax, ay, poColor, et); x1 += 220;
textlabel(sum, 30, "-MONO ", x1, y1, ax, ay, poColor, et); x1 += 220;
textlabel(sum, 30, "+COLOR8 0", x1, y1, ax, ay, poColor, et); x1 += 220;
textlabel(sum, 30, "+COLOR4 0", x1, y1, ax, ay, poColor, et); x1 += 220;
textlabel(sum, 30, "+MONO 0", x1, y1, ax, ay, poColor, et); // x1 += 220;// clang static analyzer does not like this
return;
}
void image_column(EMFTRACK *et, int x1, int y1, int w, int h, int IsCompressed, U_PMF_BITMAP *Bs, int numCt, U_PMF_ARGB *ct, uint32_t cbPx, char *px, U_PSEUDO_OBJ *poac){
int step=0;
U_PSEUDO_OBJ *po;
U_PSEUDO_OBJ *poPal;
U_PSEUDO_OBJ *poBm;
U_PSEUDO_OBJ *poBmd;
U_PSEUDO_OBJ *poImg;
U_PSEUDO_OBJ *poIa;
U_PSEUDO_OBJ *poRectf;
U_PSEUDO_OBJ *poRectfs;
U_PSEUDO_OBJ *poPoints;
U_PMF_POINTF pl3[3];
U_PMF_POINTF *points;
uint32_t Version = U_PMF_GRAPHICSVERSIONOBJ_set(2);
int flags;
/* Set up the Image, Image Attributes */
if(Bs->PxFormat == U_PF_16bppGrayScale){ flags = U_PLTS_GrayScale; }
else { flags = U_PLTS_None; }
poPal = U_PMF_PALETTE_set(flags, numCt, ct);
/* poPal will be NULL if there is no palette */
if(IsCompressed){
poBmd = U_PMF_COMPRESSEDIMAGE_set(cbPx, px);
IfNullPtr(poBmd,__LINE__,"OOPS on U_PMF_BITMAPDATA_set\n");
poRectfs = U_PMF_RECTF4_set(0, 0, 10, 10);
IfNullPtr(poRectfs,__LINE__,"OOPS on U_PMF_RECTF4_set\n");
}
else {
poBmd = U_PMF_BITMAPDATA_set(poPal, cbPx, px);
IfNullPtr(poBmd,__LINE__,"OOPS on U_PMF_BITMAPDATA_set\n");
poRectfs = U_PMF_RECTF4_set(0, 0, Bs->Width, Bs->Height);
IfNullPtr(poRectfs,__LINE__,"OOPS on U_PMF_RECTF4_set\n");
}
poBm = U_PMF_BITMAP_set(Bs, poBmd);
IfNullPtr(poBm,__LINE__,"OOPS on U_PMF_BITMAP_set\n");
poImg = U_PMF_IMAGE_set(Version, poBm);
IfNullPtr(poImg,__LINE__,"OOPS on U_PMF_IMAGE_set\n");
po = U_PMR_OBJECT_PO_set(OBJ_IMG_1, poImg);
IfNullPtr(po,__LINE__,"OOPS on U_PMR_OBJECT_PO_set\n");
paf(et, poac, po, "U_PMR_OBJECT_PO_set OBJ_IMG_1");
U_PO_free(&poImg);
U_PO_free(&poBm);
U_PO_free(&poBmd);
U_PO_free(&poPal);
// Make an image attribute object
poIa = U_PMF_IMAGEATTRIBUTES_set(Version, U_WM_Tile, 0, 0);
IfNullPtr(poIa,__LINE__,"OOPS on U_PMF_BITMAP_set\n");
po = U_PMR_OBJECT_PO_set(OBJ_IA, poIa);
IfNullPtr(po,__LINE__,"OOPS on U_PMR_OBJECT_PO_set\n");
paf(et, poac, po, "U_PMR_OBJECT_PO_set OBJ_IA");
U_PO_free(&poIa);
// all methods use this
// Draw the image: method 1
poRectf = U_PMF_RECTF4_set(x1, y1, w, h);
IfNullPtr(poRectf,__LINE__,"OOPS on U_PMF_RECTF4_set\n");
po = U_PMR_DRAWIMAGE_set(OBJ_IMG_1, OBJ_IA, U_UT_World, poRectfs, poRectf);
paf(et, poac, po, "U_PMR_DRAWIMAGE_set");
U_PO_free(&poRectf);
step += 220;
// Draw the image: method 2
pl3[0] = (U_PMF_POINTF) { 0,0 };
pl3[1] = (U_PMF_POINTF) { w,0 };
pl3[2] = (U_PMF_POINTF) { 0,h };
points = pointfs_transform(pl3, 3, xform_alt_set(1.0, 1.0, 0.0, 0.0, x1, y1 + step));
poPoints = U_PMF_POINTF_set(3, points);
IfNullPtr(poPoints,__LINE__,"OOPS on U_PMF_POINTF_set\n");
po = U_PMR_DRAWIMAGEPOINTS_set(OBJ_IMG_1, U_FILTER_IGNORE, OBJ_IA, U_UT_World, poRectfs, poPoints);
paf(et, poac, po, "U_PMR_DRAWIMAGE_set");
U_PO_free(&poPoints);
free(points);
step += 220;
// Draw the image: method 3
points = pointfs_transform(pl3, 3, xform_alt_set(1.0, 1.0, 90.0, 0.0, x1, y1 + step + h));
poPoints = U_PMF_POINTF_set(3, points);
IfNullPtr(poPoints,__LINE__,"OOPS on U_PMF_POINTF_set\n");
po = U_PMR_DRAWIMAGEPOINTS_set(OBJ_IMG_1, U_FILTER_IGNORE, OBJ_IA, U_UT_World, poRectfs, poPoints);
paf(et, poac, po, "U_PMR_DRAWIMAGE_set");
U_PO_free(&poPoints);
free(points);
// finally done with this
U_PO_free(&poRectfs);
}
/* this tests image effects
WARNING! Windows XP Preview does not show filter effects, whether or not U_PPF_E is set. They are visible if the EMF+
file is inserted as an image into PowerPoint.
*/
void image_column2(EMFTRACK *et, int x1, int y1, int w, int h, int IsCompressed, U_PMF_BITMAP *Bs, int numCt, U_PMF_ARGB *ct, uint32_t cbPx, char *px, U_PSEUDO_OBJ *poac){
int step=0;
U_PSEUDO_OBJ *po;
U_PSEUDO_OBJ *poPal;
U_PSEUDO_OBJ *poBm;
U_PSEUDO_OBJ *poBmd;
U_PSEUDO_OBJ *poImg;
U_PSEUDO_OBJ *poIa;
U_PSEUDO_OBJ *poIe;
U_PSEUDO_OBJ *poRectfs;
U_PSEUDO_OBJ *poPoints;
U_PMF_POINTF pl3[3];
U_PMF_POINTF *points;
uint32_t Version = U_PMF_GRAPHICSVERSIONOBJ_set(2);
int flags;
/* Set up the Image, Image Attributes */
if(Bs->PxFormat == U_PF_16bppGrayScale){ flags = U_PLTS_GrayScale; }
else { flags = U_PLTS_None; }
poPal = U_PMF_PALETTE_set(flags, numCt, ct);
/* poPal will be NULL if there is no palette */
if(IsCompressed){
poBmd = U_PMF_COMPRESSEDIMAGE_set(cbPx, px);
IfNullPtr(poBmd,__LINE__,"OOPS on U_PMF_BITMAPDATA_set\n");
poRectfs = U_PMF_RECTF4_set(0, 0, 10, 10);
IfNullPtr(poRectfs,__LINE__,"OOPS on U_PMF_RECTF4_set\n");
}
else {
poBmd = U_PMF_BITMAPDATA_set(poPal, cbPx, px);
IfNullPtr(poBmd,__LINE__,"OOPS on U_PMF_BITMAPDATA_set\n");
poRectfs = U_PMF_RECTF4_set(0, 0, Bs->Width, Bs->Height);
IfNullPtr(poRectfs,__LINE__,"OOPS on U_PMF_RECTF4_set\n");
}
poBm = U_PMF_BITMAP_set(Bs, poBmd);
IfNullPtr(poBm,__LINE__,"OOPS on U_PMF_BITMAP_set\n");
poImg = U_PMF_IMAGE_set(Version, poBm);
IfNullPtr(poImg,__LINE__,"OOPS on U_PMF_IMAGE_set\n");
po = U_PMR_OBJECT_PO_set(OBJ_IMG_1, poImg);
IfNullPtr(po,__LINE__,"OOPS on U_PMR_OBJECT_PO_set\n");
paf(et, poac, po, "U_PMR_OBJECT_PO_set OBJ_IMG_1");
U_PO_free(&poImg);
U_PO_free(&poBm);
U_PO_free(&poBmd);
U_PO_free(&poPal);
// Make an image attribute object
poIa = U_PMF_IMAGEATTRIBUTES_set(Version, U_WM_Tile, 0, 0);
IfNullPtr(poIa,__LINE__,"OOPS on U_PMF_BITMAP_set\n");
po = U_PMR_OBJECT_PO_set(OBJ_IA, poIa);
IfNullPtr(po,__LINE__,"OOPS on U_PMR_OBJECT_PO_set\n");
paf(et, poac, po, "U_PMR_OBJECT_PO_set OBJ_IA");
U_PO_free(&poIa);
pl3[0] = (U_PMF_POINTF) { 0,0 };
pl3[1] = (U_PMF_POINTF) { w,0 };
pl3[2] = (U_PMF_POINTF) { 0,h };
// Draw the image, no image effects
points = pointfs_transform(pl3, 3, xform_alt_set(1.0, 1.0, 0.0, 0.0, x1, y1 + step));
poPoints = U_PMF_POINTF_set(3, points);
IfNullPtr(poPoints,__LINE__,"OOPS on U_PMF_POINTF_set\n");
po = U_PMR_DRAWIMAGEPOINTS_set(OBJ_IMG_1, U_FILTER_IGNORE, OBJ_IA, U_UT_World, poRectfs, poPoints);
paf(et, poac, po, "U_PMR_DRAWIMAGE_set");
U_PO_free(&poPoints);
free(points);
step += 220;
// Draw the image, blur effects
poIe = U_PMF_IE_BLUR_set(15.0,0);
IfNullPtr(po,__LINE__,"OOPS on U_PMF_IE_BLUR_set\n");
po = U_PMR_SERIALIZABLEOBJECT_set(poIe);
paf(et, poac, po, "U_PMR_SERIALIZABLEOBJECT_set");
U_PO_free(&poIe);
points = pointfs_transform(pl3, 3, xform_alt_set(1.0, 1.0, 0.0, 0.0, x1, y1 + step));
poPoints = U_PMF_POINTF_set(3, points);
IfNullPtr(poPoints,__LINE__,"OOPS on U_PMF_POINTF_set\n");
po = U_PMR_DRAWIMAGEPOINTS_set(OBJ_IMG_1, U_FILTER_APPLY, OBJ_IA, U_UT_World, poRectfs, poPoints);
paf(et, poac, po, "U_PMR_DRAWIMAGE_set");
U_PO_free(&poPoints);
free(points);
step += 220;
// Draw the image, brightness/contrast effects
poIe = U_PMF_IE_BRIGHTNESSCONTRAST_set(255, 100);
IfNullPtr(po,__LINE__,"OOPS on U_PMF_IE_BRIGHTNESSCONTRAST_set\n");
po = U_PMR_SERIALIZABLEOBJECT_set(poIe);
paf(et, poac, po, "U_PMR_SERIALIZABLEOBJECT_set");
U_PO_free(&poIe);
points = pointfs_transform(pl3, 3, xform_alt_set(1.0, 1.0, 0.0, 0.0, x1, y1 + step));
poPoints = U_PMF_POINTF_set(3, points);
IfNullPtr(poPoints,__LINE__,"OOPS on U_PMF_POINTF_set\n");
po = U_PMR_DRAWIMAGEPOINTS_set(OBJ_IMG_1, U_FILTER_APPLY, OBJ_IA, U_UT_World, poRectfs, poPoints);
paf(et, poac, po, "U_PMR_DRAWIMAGE_set");
U_PO_free(&poPoints);
free(points);
//step += 220; // clang static analyzer does not like this
// finally done with this
U_PO_free(&poRectfs);
}
void grad_star(EMFTRACK *et, int x, int y, int options, U_PSEUDO_OBJ *poac){
U_PMF_POINTF Pointfs[] = {
{593,688},
{381,501},
{166,684},
{278,425},
{ 38,276},
{319,303},
{386, 28},
{447,304},
{729,283},
{486,427}
};
U_PMF_POINTF Centerf = {383.5,358.0};
U_PMF_ARGB SurColors[] = {
{0xFF,0x00,0x00,0xFF},{0x00,0xFF,0x00,0xFF},
{0x00,0x00,0xFF,0xFF},{0x00,0xFF,0x00,0xFF},
{0xFF,0x00,0x00,0xFF},{0x00,0xFF,0x00,0xFF},
{0x00,0x00,0xFF,0xFF},{0x00,0xFF,0x00,0xFF},
{0xFF,0x00,0xFF,0xFF},{0x00,0xFF,0x00,0xFF}
};
U_PMF_POINTF *points;
U_PMF_POINTF *center;
U_PMF_TRANSFORMMATRIX Tm;
U_PSEUDO_OBJ *poTm;
U_PSEUDO_OBJ *poGradient;
U_PSEUDO_OBJ *poPath;
U_PSEUDO_OBJ *poBPath;
U_PSEUDO_OBJ *poPGBOD;
U_PSEUDO_OBJ *poPGBD;
U_PSEUDO_OBJ *poBrush;
U_PSEUDO_OBJ *poBrushID;
U_PSEUDO_OBJ *poColor;
U_PSEUDO_OBJ *po;
U_DPSEUDO_OBJ *dpath=NULL;
uint32_t Flags = U_BD_Transform;
poColor = U_PMF_ARGB_set(255,0,0,0);
textlabel(poac, 40, "Text_____Beneath______Star____Test1", x -30 , y + 250, U_SA_Near, U_SA_Near, poColor, et);
poBrushID = U_PMF_4NUM_set(OBJ_BRUSH_GROUP1);
IfNullPtr(poBrushID,__LINE__,"OOPS on U_PMF_4NUM_set\n");
points = pointfs_transform( Pointfs, 10, xform_alt_set(1.0, 1.0, 0.0, 0.0, x, y));
center = pointfs_transform(&Centerf, 1, xform_alt_set(1.0, 1.0, 0.0, 0.0, x, y));
dpath = U_PATH_create(0, NULL, 0, 0); /* create an empty path*/
IfNotTrue(U_PATH_polylineto(dpath, 10, points, U_PTP_None, U_SEG_NEW),__LINE__, "OOPS on U_PATH_polylineto\n");
IfNotTrue(U_PATH_closepath((dpath)), __LINE__, "OOPS on U_PATH_closepath\n");
poPath = U_PMF_PATH_set3(U_PMF_GRAPHICSVERSIONOBJ_set(2), dpath);
IfNullPtr(poPath,__LINE__,"OOPS U_PMF_PATH_set3\n");
po = U_PMR_OBJECT_PO_set(OBJ_PATH_1, poPath);
IfNullPtr(po,__LINE__,"OOPS on U_PMR_OBJECT_PO_set\n");
paf(et, poac, po, "U_PMR_OBJECT_PO_set");
if(!options){
Flags |= U_BD_Path;
poBPath = U_PMF_BOUNDARYPATHDATA_set(poPath);
IfNullPtr(poBPath,__LINE__,"OOPS U_PMF_BOUNDARYPATHDATA_set\n");
}
else {
/* U_BD_Path is not set for points */
poBPath = U_PMF_BOUNDARYPOINTDATA_set(10,points);
IfNullPtr(poBPath,__LINE__,"OOPS U_PMF_BOUNDARYPOINTDATA_set\n");
}
poGradient = U_PMF_ARGBN_set(10, SurColors);
IfNullPtr(poGradient,__LINE__,"OOPS on U_PMF_ARGBN_set\n");
Tm = (U_PMF_TRANSFORMMATRIX){1 , 0, 0, 1, 0, 0};
poTm = U_PMF_TRANSFORMMATRIX_set(&Tm);
IfNullPtr(poTm,__LINE__,"OOPS on U_PMF_TRANSFORMMATRIX_set\n");
poPGBOD = U_PMF_PATHGRADIENTBRUSHOPTIONALDATA_set(Flags, poTm, NULL, NULL);
IfNullPtr(poPGBOD,__LINE__,"OOPS on U_PMF_PATHGRADIENTBRUSHOPTIONALDATA_set\n");
poPGBD = U_PMF_PATHGRADIENTBRUSHDATA_set(Flags, U_WM_Tile, (U_PMF_ARGB) {0x00,0x00,0x00,0xFF},
*center, poGradient, poBPath, poPGBOD);
IfNullPtr(poPGBD,__LINE__,"OOPS on U_PMF_PATHGRADIENTBRUSHDATA_set\n");
poBrush = U_PMF_BRUSH_set(U_PMF_GRAPHICSVERSIONOBJ_set(2), poPGBD);
IfNullPtr(poBrush,__LINE__,"OOPS on U_PMF_BRUSH_set\n");
po = U_PMR_OBJECT_PO_set(OBJ_BRUSH_GROUP1, poBrush);
IfNullPtr(po,__LINE__,"OOPS on U_PMR_OBJECT_PO_set\n");
paf(et, poac, po, "U_PMR_OBJECT_PO_set");
po = U_PMR_FILLPATH_set(OBJ_PATH_1, poBrushID);
IfNullPtr(po,__LINE__,"OOPS on U_PMR_FILLPATH_set\n");
paf(et, poac, po, "U_PMR_FILLPATH_set");
textlabel(poac, 40, "Text_____Above________Star____Test2", x -30 , y + 450, U_SA_Near, U_SA_Near, poColor, et);
U_PO_free(&poTm);
U_PO_free(&poPGBOD);
U_PO_free(&poBrush);
U_PO_free(&poPGBD);
U_PO_free(&poBPath);
U_PO_free(&poGradient);
U_PO_free(&poPath);
free(center);
free(points);
U_PO_free(&poBrushID);
U_PO_free(&poColor);
U_DPO_free(&dpath);
}
void test_clips(EMFTRACK *et, int x, int y, U_PSEUDO_OBJ *poac){
U_PSEUDO_OBJ *po;
U_PSEUDO_OBJ *poBrushID;
U_PSEUDO_OBJ *poColor;
U_PSEUDO_OBJ *poPath;
U_PSEUDO_OBJ *poRectfs;
U_PSEUDO_OBJ *poRectfs2;
U_PSEUDO_OBJ *poRegion;
U_PSEUDO_OBJ *poRNPath;
U_PSEUDO_OBJ *poRNode;
U_PSEUDO_OBJ *poLNode;
U_PSEUDO_OBJ *poCNodes;
U_PSEUDO_OBJ *poNode;
U_PSEUDO_OBJ *poTm;
U_PMF_RECTF Rectfs[2];
int i;
U_DPSEUDO_OBJ *dpath=NULL;
U_PMF_TRANSFORMMATRIX Tm;
char string[STRALLOC];
poColor = U_PMF_ARGB_set(255,0,0,0);
IfNullPtr(poColor,__LINE__,"OOPS on U_PMF_ARGB_set\n");
/* no clipping */
grad_star(et, x, y, 0, poac);
grad_star(et, x, y+700, 1, poac);
textlabel(poac, 40, "NoClip", x+200 , y - 60, U_SA_Near, U_SA_Near, poColor, et);
/* rectangle clipping */
x += 800;
Rectfs[0] = (U_PMF_RECTF){x+200, y, 200, 1500};
poRectfs = U_PMF_RECTFN_set(1,Rectfs);
IfNullPtr(poRectfs,__LINE__,"OOPS on U_PMF_RECTFN_set\n");
po = U_PMR_DRAWRECTS_set(OBJ_PEN_RED_1, poRectfs);
IfNullPtr(po,__LINE__,"OOPS on U_PMR_DRAWRECTS_set\n");
paf(et, poac, po, "U_PMR_DRAWRECTS_set");
po = U_PMR_SETCLIPRECT_set(U_CM_Replace, poRectfs);
IfNullPtr(po,__LINE__,"OOPS on U_PMR_SETCLIPRECT_set\n");
paf(et, poac, po, "U_PMR_SETCLIPRECT_set");
U_PO_free(&poRectfs);
grad_star(et, x, y, 0, poac);
grad_star(et, x, y+700, 1, poac);
po = U_PMR_RESETCLIP_set();
IfNullPtr(po,__LINE__,"OOPS on U_PMR_RESETCLIP\n");
paf(et, poac, po, "U_PMR_RESETCLIP");
textlabel(poac, 40, "Clip", x+200 , y - 60, U_SA_Near, U_SA_Near, poColor, et);
for(i=U_CM_Intersect ; i<= U_CM_Complement; i++){
/* two rectangle clipping, various combine operations */
x += 800;
Rectfs[0] = (U_PMF_RECTF){x+200, y, 200, 1500};
Rectfs[1] = (U_PMF_RECTF){x+300, y+100, 200, 600};
dpath = U_PATH_create(0, NULL, 0, 0); /* create an empty path*/
U_PATH_moveto(dpath, (U_PMF_POINTF){x+250,y+ 350}, U_PTP_None);
U_PATH_lineto(dpath, (U_PMF_POINTF){x+550,y+ 250}, U_PTP_None);
U_PATH_lineto(dpath, (U_PMF_POINTF){x+550,y+1200}, U_PTP_None);
U_PATH_lineto(dpath, (U_PMF_POINTF){x+250,y+1300}, U_PTP_None);
U_PATH_closepath(dpath);
/* draw first and second rects and path */
poRectfs = U_PMF_RECTFN_set(1, &Rectfs[0]);
IfNullPtr(poRectfs,__LINE__,"OOPS on U_PMF_RECTFN_set\n");
po = U_PMR_DRAWRECTS_set(OBJ_PEN_RED_1, poRectfs);
IfNullPtr(po,__LINE__,"OOPS on U_PMR_DRAWRECTS_set\n");
paf(et, poac, po, "U_PMR_DRAWRECTS_set");
poRectfs2 = U_PMF_RECTFN_set(1, &Rectfs[1]);
IfNullPtr(poRectfs,__LINE__,"OOPS on U_PMF_RECTFN_set\n");
po = U_PMR_DRAWRECTS_set(OBJ_PEN_RED_1, poRectfs2);
IfNullPtr(po,__LINE__,"OOPS on U_PMR_DRAWRECTS_set\n");
paf(et, poac, po, "U_PMR_DRAWRECTS_set");
poPath = U_PMF_PATH_set3(U_PMF_GRAPHICSVERSIONOBJ_set(2), dpath);
IfNullPtr(poPath,__LINE__,"OOPS U_PMF_PATH_set3\n");
po = U_PMR_OBJECT_PO_set(OBJ_PATH_1, poPath);
IfNullPtr(po,__LINE__,"OOPS on U_PMR_OBJECT_PO_set\n");
paf(et, poac, po, "U_PMR_OBJECT_PO_set");
po = U_PMR_DRAWPATH_set(OBJ_PATH_1, OBJ_PEN_RED_1);
IfNullPtr(po,__LINE__,"OOPS on U_PMR_DRAWPATH_set\n");
paf(et, poac, po, "U_PMR_DRAWPATH_set");
/* set clip with first and second rects and path */
po = U_PMR_SETCLIPRECT_set(U_CM_Replace, poRectfs);
IfNullPtr(po,__LINE__,"OOPS on U_PMR_SETCLIPRECT_set\n");
paf(et, poac, po, "U_PMR_SETCLIPRECT_set");
po = U_PMR_SETCLIPRECT_set(i, poRectfs2);
IfNullPtr(po,__LINE__,"OOPS on U_PMR_SETCLIPRECT_set\n");
paf(et, poac, po, "U_PMR_SETCLIPRECT_set");
po = U_PMR_SETCLIPPATH_set(OBJ_PATH_1, i);
IfNullPtr(po,__LINE__,"OOPS on U_PMR_SETCLIPPATH_set\n");
paf(et, poac, po, "U_PMR_SETCLIPPATH_set");
/* stars */
grad_star(et, x, y, 0, poac);
grad_star(et, x, y+700, 1, poac);
po = U_PMR_RESETCLIP_set();
IfNullPtr(po,__LINE__,"OOPS on U_PMR_RESETCLIP\n");
paf(et, poac, po, "U_PMR_RESETCLIP");
switch(i){
case U_CM_Replace: strcpy(string,"Clip Replace "); break;
case U_CM_Intersect: strcpy(string,"Clip Intersect "); break;
case U_CM_Union: strcpy(string,"Clip Union "); break;
case U_CM_XOR: strcpy(string,"Clip XOR "); break;
case U_CM_Exclude: strcpy(string,"Clip Exclude "); break;
case U_CM_Complement: strcpy(string,"Clip Complement"); break;
}
textlabel(poac, 40, string, x+200 , y - 60, U_SA_Near, U_SA_Near, poColor, et);
U_PO_free(&poRectfs);
U_PO_free(&poRectfs2);
U_PO_free(&poPath);
U_DPO_free(&dpath);
}
/* test one with a rectangle and two regions. This is done twice, the left most one uses the
raw clipping region, and the rightmost one uses offset clip */
x += 800;
Rectfs[0] = (U_PMF_RECTF){x+200, y, 200, 1500};
Rectfs[1] = (U_PMF_RECTF){x+250, y+600, 300, 850};
dpath = U_PATH_create(0, NULL, 0, 0); /* create an empty path*/
U_PATH_moveto(dpath, (U_PMF_POINTF){x+250,y+ 50}, U_PTP_None);
U_PATH_lineto(dpath, (U_PMF_POINTF){x+550,y+ 150}, U_PTP_None);
U_PATH_lineto(dpath, (U_PMF_POINTF){x+550,y+ 400}, U_PTP_None);
U_PATH_lineto(dpath, (U_PMF_POINTF){x+250,y+ 500}, U_PTP_None);
U_PATH_closepath(dpath);
U_PATH_moveto(dpath, (U_PMF_POINTF){x+250,y+ 950}, U_PTP_None);
U_PATH_lineto(dpath, (U_PMF_POINTF){x+550,y+ 850}, U_PTP_None);
U_PATH_lineto(dpath, (U_PMF_POINTF){x+550,y+1400}, U_PTP_None);
U_PATH_lineto(dpath, (U_PMF_POINTF){x+250,y+1300}, U_PTP_None);
U_PATH_closepath(dpath);
poPath = U_PMF_PATH_set2(U_PMF_GRAPHICSVERSIONOBJ_set(2), dpath);
IfNullPtr(poPath,__LINE__,"OOPS U_PMF_PATH_set3\n");
po = U_PMR_OBJECT_PO_set(OBJ_PATH_1, poPath);
IfNullPtr(po,__LINE__,"OOPS on U_PMR_OBJECT_PO_set\n");
paf(et, poac, po, "U_PMR_OBJECT_PO_set");
/* set up the rect and region PseudoObjeccts */
poRectfs = U_PMF_RECTF_set(&Rectfs[0]);
IfNullPtr(poRectfs,__LINE__,"OOPS on U_PMF_RECTFN_set\n");
poRectfs2 = U_PMF_RECTF_set(&Rectfs[1]);
IfNullPtr(poRectfs2,__LINE__,"OOPS on U_PMF_RECTFN_set\n");
poRNPath = U_PMF_REGIONNODEPATH_set(poPath);
IfNullPtr(poRNPath,__LINE__,"OOPS U_PMF_REGIONNODEPATH_set\n");
poRNode = U_PMF_REGIONNODE_set(U_RNDT_Path, poRNPath); /* make a U_PMF_REGIONNODE_OID from a path, 1st child node */
IfNullPtr(poRNode,__LINE__,"OOPS U_PMF_REGIONNODE_set\n");
poLNode = U_PMF_REGIONNODE_set(U_RNDT_Rect, poRectfs2); /* make a U_PMF_REGIONNODE_OID from a rect, 2nd child node */
IfNullPtr(poLNode,__LINE__,"OOPS U_PMF_REGIONNODE_set\n");
poCNodes = U_PMF_REGIONNODECHILDNODES_set(poLNode, poRNode); /* make a U_PMF_REGIONNODECHILDNODES_OID from two U_PMF_REGIONNODE_OID */
IfNullPtr(poCNodes,__LINE__,"OOPS U_PMF_REGIONNODECHILDNODES_set\n");
poNode = U_PMF_REGIONNODE_set(U_RNDT_Or, poCNodes); /* make a U_PMF_REGIONNODE_OID from a U_PMF_REGIONNODECHILDNODES_OID */
IfNullPtr(poNode,__LINE__,"OOPS U_PMF_REGIONNODE_set\n");
poRegion = U_PMF_REGION_set(U_PMF_GRAPHICSVERSIONOBJ_set(2), 2, poNode); /* number of CHILD nodes (only count U_PMF_REGIONNODE nodes), here two, as shown above */
IfNullPtr(poRegion,__LINE__,"OOPS U_PMF_REGION_set\n");
po = U_PMR_OBJECT_PO_set(OBJ_REGION_1, poRegion);
IfNullPtr(po,__LINE__,"OOPS on U_PMR_OBJECT_PO_set\n");
paf(et, poac, po, "U_PMR_OBJECT_PO_set OBJ_REGION_1");
/* draw rect and region (region has to be fill) */
/* first draw then where they are for the left set */
/* second draw them through a worldtransform matrix for the right set */
poBrushID = U_PMF_ARGB_set(255, 128, 128, 128);
IfNullPtr(poBrushID,__LINE__,"OOPS on U_PMF_ARGB_set\n");
for(i=0;i<2;i++){
po = U_PMR_DRAWRECTS_set(OBJ_PEN_RED_1, poRectfs);
IfNullPtr(po,__LINE__,"OOPS on U_PMR_DRAWRECTS_set\n");
paf(et, poac, po, "U_PMR_DRAWRECTS_set");
po = U_PMR_FILLREGION_set(OBJ_REGION_1, poBrushID);
IfNullPtr(po,__LINE__,"OOPS on U_PMR_FILLREGION_set\n");
paf(et, poac, po, "U_PMR_FILLREGION_set");
if(i==0){
strcpy(string,"Clip Region");
textlabel(poac, 40, string, x+200 , y - 60, U_SA_Near, U_SA_Near, poColor, et);
Tm = (U_PMF_TRANSFORMMATRIX){1,0,0,1,800,0};
poTm = U_PMF_TRANSFORMMATRIX_set(&Tm);
IfNullPtr(poTm,__LINE__,"OOPS on U_PMF_TRANSFORMMATRIX_set\n");
po = U_PMR_MULTIPLYWORLDTRANSFORM_set(U_XM_PostX, poTm);
IfNullPtr(po,__LINE__,"OOPS on U_PMR_SETWORLDTRANSFORM_set\n");
U_PO_free(&poTm);
paf(et, poac, po, "U_PMR_MULTIPLYWORLDTRANSFORM_set");
}
else {
strcpy(string,"Clip Offset {100,50}"); /* actually it is 900,50, but subtract the 800 instance offset*/
textlabel(poac, 40, string, x+200 , y - 60, U_SA_Near, U_SA_Near, poColor, et);
po = U_PMR_RESETWORLDTRANSFORM_set();
IfNullPtr(po,__LINE__,"OOPS on U_PMR_RESETWORLDTRANSFORM_set\n");
paf(et, poac, po, "U_PMR_RESETWORLDTRANSFORM_set");
}
}
/* set clip with one rect and the region */
po = U_PMR_SETCLIPRECT_set(U_CM_Replace, poRectfs);
IfNullPtr(po,__LINE__,"OOPS on U_PMR_SETCLIPRECT_set\n");
paf(et, poac, po, "U_PMR_SETCLIPRECT_set");
po = U_PMR_SETCLIPREGION_set(OBJ_REGION_1, U_CM_Union);
IfNullPtr(po,__LINE__,"OOPS on U_PMR_SETCLIPREGION_set\n");
paf(et, poac, po, "U_PMR_SETCLIPREGION_set");
/* stars */
grad_star(et, x, y, 0, poac);
grad_star(et, x, y+700, 1, poac);
/* DO NOT reset clip. Use OffsetClip moved over by 100 */
po = U_PMR_OFFSETCLIP_set(900,50);
IfNullPtr(po,__LINE__,"OOPS on U_PMR_OFFSETCLIP_set\n");
paf(et, poac, po, "U_PMR_OFFSETCLIP_set");
/* stars */
grad_star(et, x+800, y, 0, poac);
grad_star(et, x+800, y+700, 1, poac);
/* NOW reset the clipping */
po = U_PMR_RESETCLIP_set();
IfNullPtr(po,__LINE__,"OOPS on U_PMR_RESETCLIP\n");
paf(et, poac, po, "U_PMR_RESETCLIP");
U_PO_free(&poBrushID);
U_PO_free(&poRNPath);
U_PO_free(&poRNode);
U_PO_free(&poLNode);
U_PO_free(&poCNodes);
U_PO_free(&poNode);
U_PO_free(&poRegion);
U_PO_free(&poRectfs);
U_PO_free(&poRectfs2);
U_PO_free(&poPath);
U_PO_free(&poColor);
U_DPO_free(&dpath);
}
void gradient_column(EMFTRACK *et, int x1, int y1, int w, int h, U_PSEUDO_OBJ *poac){
int elements = 4;
U_PMF_RECTF Rectfs[3];
uint32_t Version = U_PMF_GRAPHICSVERSIONOBJ_set(2);
U_PMF_LINEARGRADIENTBRUSHDATA Lgbd;
U_PMF_TRANSFORMMATRIX Tm;
U_PSEUDO_OBJ *poBrushID;
U_PSEUDO_OBJ *poTm0;
U_PSEUDO_OBJ *poTm45=NULL;
U_PSEUDO_OBJ *poLgbod;
U_PSEUDO_OBJ *poBd;
U_PSEUDO_OBJ *poBrush;
U_PSEUDO_OBJ *po;
U_PSEUDO_OBJ *poRectfs;
U_PSEUDO_OBJ *poBf;
U_PSEUDO_OBJ *poBc;
int i,j;
U_PSEUDO_OBJ *tpoTm,*tpoBc,*tpoBfH,*tpoBfV;
Rectfs[0] = (U_PMF_RECTF){x1, y1, w, h}; // notice, here the same as rect in the gradient
elements = 3;
Lgbd = (U_PMF_LINEARGRADIENTBRUSHDATA){
0, // BrushData flags, this is the only field that varies, below
U_WM_Tile, // WrapMode enumeration
Rectfs[0], // Gradient area, gradients will stay "tiled" to this location
(U_PMF_ARGB){255,0,0,255}, // U_PMF_ARGB BLUE Gradient start color
(U_PMF_ARGB){0,0,255,255}, // U_PMF_ARGB RED Gradient end color
0, // manuals says to ignore, call will replicate the start/end colors
0 //
};
poBrushID = U_PMF_4NUM_set(OBJ_BRUSH_GROUP1);
IfNullPtr(poBrushID,__LINE__,"OOPS on U_PMF_4NUM_set\n");
Tm = (U_PMF_TRANSFORMMATRIX){1 , 0, 0, 1, 0, 0};
poTm0 = U_PMF_TRANSFORMMATRIX_set(&Tm);
IfNullPtr(poTm0,__LINE__,"OOPS on U_PMF_TRANSFORMMATRIX_set\n");
poBf = U_PMF_BLENDFACTORS_linear_set(elements, 0.7, 0.3); //works
IfNullPtr(poBf,__LINE__,"OOPS U_PMF_BLENDFACTORS_linear_set\n");
/* blend from purple to green */
poBc = U_PMF_BLENDCOLORS_linear_set(elements, (U_PMF_ARGB){255,0,255,255}, (U_PMF_ARGB){0,255,0,255});
IfNullPtr(poBc,__LINE__,"OOPS U_PMF_BLENDCOLORS_linear_set\n");
for(j=0;j<3;j++){ /* Tm: none, norot, 45 degrees */
for(i=0;i<5;i++){ /* none, BlendColors, BlendFactors:H, V, H+V */
switch(j){
case 0: tpoTm = NULL; break;
case 1: tpoTm = poTm0; break;
case 2:
default:
Tm = tm_for_gradrect(45.0, w, h, Rectfs[0].X, Rectfs[0].Y,1.0);
// Tm = (U_PMF_TRANSFORMMATRIX){1.0, -1.0, 1.0, 1.0, Rectfs[0].X, Rectfs[0].Y + h}; // scale it so that gradient will reach from corner to corner of square
poTm45 = U_PMF_TRANSFORMMATRIX_set(&Tm);
IfNullPtr(poTm0,__LINE__,"OOPS on U_PMF_TRANSFORMMATRIX_set\n");
tpoTm = poTm45;
break;
}
switch(i){