リビジョン | 49350998eaae7fe63151043e4bd30d0959a46e32 (tree) |
---|---|
日時 | 2022-05-29 19:23:25 |
作者 | Fojtik |
コミッター | Fojtik |
Attempt to convert WorldTransform in EMF.
@@ -28,12 +28,13 @@ | ||
28 | 28 | |
29 | 29 | #ifdef EXPAND_OPS |
30 | 30 | #ifdef LO_ENDIAN |
31 | - #define RdWORD_LoEnd(num,f) fread((num),1,2,f) | |
32 | - #define RdDWORD_LoEnd(num,f) fread((num),1,4,f) | |
33 | - #define RdQWORD_LoEnd(num,f) fread((num),1,8,f) | |
31 | + #define RdWORD_LoEnd(pnum,f) fread((pnum),1,2,f) | |
32 | + #define RdDWORD_LoEnd(pnum,f) fread((pnum),1,4,f) | |
33 | + #define RdQWORD_LoEnd(pnum,f) fread((pnum),1,8,f) | |
34 | 34 | #define WrWORD_LoEnd(num,f) fwrite((&num),1,2,f) |
35 | 35 | #define WrDWORD_LoEnd(num,f) fwrite((&num),1,4,f) |
36 | 36 | #define WrQWORD_LoEnd(num,f) fwrite((&num),1,8,f) |
37 | + #define RdFLOAT_LoEnd(num,f) fread((pnum),1,4,f) | |
37 | 38 | #endif |
38 | 39 | #ifdef HI_ENDIAN |
39 | 40 | #define RdWORD_HiEnd(num,f) fread((num),1,2,f) |
@@ -86,6 +87,10 @@ | ||
86 | 87 | #endif |
87 | 88 | #endif |
88 | 89 | |
90 | +#ifndef RdFLOAT_LoEnd | |
91 | + int RdFLOAT_LoEnd(float *flt, FILE *f); | |
92 | +#endif | |
93 | + | |
89 | 94 | WORD fil_sreadU16(const BYTE *in); |
90 | 95 | DWORD fil_sreadU32(const BYTE *in); |
91 | 96 |
@@ -159,7 +159,7 @@ | ||
159 | 159 | /* Read a double word from binary file in a HighEndian Format |
160 | 160 | * parameters: FILE *f : binary input file |
161 | 161 | * return: DWORD *num : readed double word */ |
162 | -int RdDWORD_HiEnd( DWORD *num, FILE *f ) | |
162 | +int RdDWORD_HiEnd(DWORD *num, FILE *f) | |
163 | 163 | { |
164 | 164 | #ifdef LO_ENDIAN |
165 | 165 | const int i = fread(num,1,4,f); |
@@ -186,7 +186,7 @@ | ||
186 | 186 | /* Read a quad word from binary file in a HighEndian Format |
187 | 187 | * parameters: FILE *f : binary input file |
188 | 188 | * return: DWORD *num : readed double word */ |
189 | -int RdQWORD_HiEnd(QWORD_ *num, FILE *f ) | |
189 | +int RdQWORD_HiEnd(QWORD_ *num, FILE *f) | |
190 | 190 | { |
191 | 191 | #ifdef LO_ENDIAN |
192 | 192 | const int i = fread(num,1,8,f); |
@@ -261,7 +261,7 @@ | ||
261 | 261 | /* Write a word to the binary file in a HighEndian Format |
262 | 262 | * parameters: FILE *f : binary input file |
263 | 263 | * WORD num : word to be written */ |
264 | -int WrWORD_HiEnd( WORD num, FILE *f ) | |
264 | +int WrWORD_HiEnd(WORD num, FILE *f) | |
265 | 265 | { |
266 | 266 | #ifdef HI_ENDIAN |
267 | 267 | return(fwrite(&num,1,2,f)); |
@@ -279,7 +279,7 @@ | ||
279 | 279 | /* Write a double word to the binary file in a HiEndian Format |
280 | 280 | * parameters: FILE *f : binary input file |
281 | 281 | * DWORD num : double word to be written */ |
282 | -int WrDWORD_HiEnd(DWORD num, FILE *f ) | |
282 | +int WrDWORD_HiEnd(DWORD num, FILE *f) | |
283 | 283 | { |
284 | 284 | #ifdef HI_ENDIAN |
285 | 285 | return(fwrite(&num,1,4,f)); |
@@ -305,7 +305,7 @@ | ||
305 | 305 | /* Write a quad word to the binary file in a HiEndian Format |
306 | 306 | * parameters: FILE *f : binary input file |
307 | 307 | * DWORD num : double word to be written */ |
308 | -int WrQWORD_HiEnd(QWORD_ num, FILE *f ) | |
308 | +int WrQWORD_HiEnd(QWORD_ num, FILE *f) | |
309 | 309 | { |
310 | 310 | #ifdef HI_ENDIAN |
311 | 311 | return(fwrite(&num,1,8,f)); |
@@ -334,7 +334,7 @@ | ||
334 | 334 | /* Write a quad word to the binary file in a LowEndian Format |
335 | 335 | * parameters: FILE *f : binary input file |
336 | 336 | * DWORD num : double word to be written */ |
337 | -int WrQWORD_LoEnd(QWORD_ num, FILE *f ) | |
337 | +int WrQWORD_LoEnd(QWORD_ num, FILE *f) | |
338 | 338 | { |
339 | 339 | #ifdef LO_ENDIAN |
340 | 340 | return(fwrite(&num,1,8,f)); |
@@ -360,7 +360,7 @@ | ||
360 | 360 | |
361 | 361 | |
362 | 362 | /** Read a WORD from byte stream. */ |
363 | -WORD fil_sreadU16 (const BYTE *in) | |
363 | +WORD fil_sreadU16(const BYTE *in) | |
364 | 364 | { |
365 | 365 | #ifdef LO_ENDIAN |
366 | 366 | return *(WORD *)in; |
@@ -372,7 +372,7 @@ | ||
372 | 372 | |
373 | 373 | |
374 | 374 | /** Read a DWORD from byte stream. */ |
375 | -DWORD fil_sreadU32 (const BYTE *in) | |
375 | +DWORD fil_sreadU32(const BYTE *in) | |
376 | 376 | { |
377 | 377 | #ifdef LO_ENDIAN |
378 | 378 | return *(DWORD *)in; |
@@ -498,3 +498,28 @@ | ||
498 | 498 | return(writed); |
499 | 499 | } |
500 | 500 | |
501 | + | |
502 | +#ifndef RdFLOAT_LoEnd | |
503 | +/* Read a double word from binary file in a LowEndian Format into a current endian. | |
504 | + * parameters: FILE *f : binary input file | |
505 | + * return: DWORD *num : readed double word */ | |
506 | +int RdFLOAT_LoEnd(float *pnum, FILE *f) | |
507 | +{ | |
508 | +#ifdef LO_ENDIAN | |
509 | + return(fread(pnum,1,4,f)); | |
510 | +#endif | |
511 | +#ifdef HI_ENDIAN | |
512 | +const int i = fread(pnum,1,4,f); | |
513 | + BYTESWAP_uint32(*pnum); | |
514 | +return i; | |
515 | +#endif | |
516 | +#if !defined(LO_ENDIAN) && !defined(HI_ENDIAN) | |
517 | +unsigned char b; | |
518 | + if(!fread( &b, 1,1,f)) return 0; *(DWORD*)pnum=(DWORD)b; | |
519 | + if(!fread( &b, 1,1,f)) return 1; *(DWORD*)pnum+=(DWORD)b * 256l; | |
520 | + if(!fread( &b, 1,1,f)) return 2; *(DWORD*)pnum+=(DWORD)b * 256l * 256l; | |
521 | + if(!fread( &b, 1,1,f)) return 3; *(DWORD*)pnum+=(DWORD)b * 256l * 256l * 256l; | |
522 | +return 4; | |
523 | +#endif | |
524 | +} | |
525 | +#endif |
@@ -2211,12 +2211,35 @@ | ||
2211 | 2211 | } EMFRECORD; |
2212 | 2212 | |
2213 | 2213 | |
2214 | +/** Functor class for EMF world transform. */ | |
2215 | +class TransformEMF: public AbstractTransformXY | |
2216 | +{ | |
2217 | +public: | |
2218 | + float M11, M12, M21, M22; | |
2219 | + float Dx, Dy; | |
2220 | + | |
2221 | + TransformEMF(void) {M11=M22=1; M21=M12=Dx=Dy=0;} | |
2222 | + | |
2223 | + virtual void ApplyTransform(float &x, float &y) const; | |
2224 | + | |
2225 | + float TopPBottom; | |
2226 | +}; | |
2227 | + | |
2228 | + | |
2229 | +void TransformEMF::ApplyTransform(float &x, float &y) const | |
2230 | +{ | |
2231 | + const float xNew = M11*x + M21*y + Dx; | |
2232 | + y = M12*x + M22*y + Dy; | |
2233 | + x = xNew; | |
2234 | +} | |
2235 | + | |
2214 | 2236 | |
2215 | 2237 | class TconvertedPass1_EMF: public TconvertedPass1_xMF |
2216 | 2238 | { |
2217 | 2239 | public: |
2218 | 2240 | SDWORD PositionX, PositionY; |
2219 | 2241 | CpTranslator *ConvertUnicode; |
2242 | + TransformEMF WorldTx; | |
2220 | 2243 | |
2221 | 2244 | TconvertedPass1_EMF(void) {PositionX = PositionY = 0;} |
2222 | 2245 |
@@ -2231,6 +2254,8 @@ | ||
2231 | 2254 | void parse_ExtCreatePen(void); |
2232 | 2255 | void parse_ExtTextOutW(VectorList &VectList); |
2233 | 2256 | void parse_LineTo(VectorList &VectList); |
2257 | + void parse_ModifyWorldTransform(void); | |
2258 | + void parse_SetWorldTransform(void); | |
2234 | 2259 | void parse_MoveToEX(void); |
2235 | 2260 | void parse_PolyBezier16(VectorList &VectList); |
2236 | 2261 | void parse_Polygon16(VectorList &VectList); |
@@ -2804,6 +2829,7 @@ | ||
2804 | 2829 | VectorEllipse *pVecEllipse = new VectorEllipse(Scale*BottomRect, Scale*TopRect, Scale*RightRect, Scale*LeftRect); |
2805 | 2830 | pVecEllipse->AttribFromPSS(PSS); |
2806 | 2831 | |
2832 | + pVecEllipse->Transform(WorldTx); | |
2807 | 2833 | VectList.AddObject(pVecEllipse); |
2808 | 2834 | |
2809 | 2835 | strcpy(ObjType,ObjName+1); |
@@ -2884,8 +2910,11 @@ | ||
2884 | 2910 | |
2885 | 2911 | if(pTextCont->isEmpty()) |
2886 | 2912 | delete pTextCont; |
2887 | - else | |
2888 | - VectList.AddObject(pTextCont); | |
2913 | + else | |
2914 | + { | |
2915 | + pTextCont->Transform(WorldTx); | |
2916 | + VectList.AddObject(pTextCont); | |
2917 | + } | |
2889 | 2918 | pTextCont = NULL; |
2890 | 2919 | |
2891 | 2920 | /* |
@@ -2970,6 +2999,72 @@ | ||
2970 | 2999 | } |
2971 | 3000 | |
2972 | 3001 | |
3002 | +void TconvertedPass1_EMF::parse_ModifyWorldTransform(void) | |
3003 | +{ | |
3004 | +#ifdef DEBUG | |
3005 | + fprintf(log,"\n#TconvertedPass1_EMF::parse_ModifyWorldTransform() ");fflush(log); | |
3006 | +#endif | |
3007 | +static const char ObjName[] = "!MODIFYWORLDTRANSFORM"; | |
3008 | +float M11b, M12b, M21b, M22b; | |
3009 | +float Dxb, Dyb; | |
3010 | + | |
3011 | + | |
3012 | + if(EmfRec.Size < 8+6*4) | |
3013 | + { | |
3014 | + strcpy(ObjType,ObjName); | |
3015 | + return; | |
3016 | + } | |
3017 | + | |
3018 | + RdFLOAT_LoEnd(&M11b,wpd); | |
3019 | + RdFLOAT_LoEnd(&M12b,wpd); | |
3020 | + RdFLOAT_LoEnd(&M21b,wpd); | |
3021 | + RdFLOAT_LoEnd(&M22b,wpd); | |
3022 | + RdFLOAT_LoEnd(&Dxb,wpd); | |
3023 | + RdFLOAT_LoEnd(&Dyb,wpd); | |
3024 | + | |
3025 | + const float NewM11 = M11b*WorldTx.M11 + M21b*WorldTx.M12; | |
3026 | + const float NewM21 = M11b*WorldTx.M21 + M21b*WorldTx.M22; | |
3027 | + const float NewDx = M11b*WorldTx.Dx + M21b*WorldTx.Dy + Dxb; | |
3028 | + | |
3029 | + const float NewM12 = M12b*WorldTx.M11 + M22b*WorldTx.M12; | |
3030 | + const float NewM22 = M12b*WorldTx.M21 + M22b*WorldTx.M22; | |
3031 | + const float NewDy = M12b*WorldTx.Dx + M22b*WorldTx.Dy + Dyb; | |
3032 | + | |
3033 | + WorldTx.M11 = NewM11; | |
3034 | + WorldTx.M21 = NewM21; | |
3035 | + WorldTx.M12 = NewM12; | |
3036 | + WorldTx.M22 = NewM22; | |
3037 | + WorldTx.Dx = NewDx; | |
3038 | + WorldTx.Dy = NewDy; | |
3039 | + | |
3040 | + strcpy(ObjType,ObjName+1); | |
3041 | +} | |
3042 | + | |
3043 | + | |
3044 | +void TconvertedPass1_EMF::parse_SetWorldTransform(void) | |
3045 | +{ | |
3046 | +#ifdef DEBUG | |
3047 | + fprintf(log,"\n#TconvertedPass1_EMF::parse_SetWorldTransform() ");fflush(log); | |
3048 | +#endif | |
3049 | +static const char ObjName[] = "!SETWORLDTRANSFORM"; | |
3050 | + | |
3051 | + if(EmfRec.Size < 8+6*4) | |
3052 | + { | |
3053 | + strcpy(ObjType,ObjName); | |
3054 | + return; | |
3055 | + } | |
3056 | + | |
3057 | + RdFLOAT_LoEnd(&WorldTx.M11,wpd); | |
3058 | + RdFLOAT_LoEnd(&WorldTx.M12,wpd); | |
3059 | + RdFLOAT_LoEnd(&WorldTx.M21,wpd); | |
3060 | + RdFLOAT_LoEnd(&WorldTx.M22,wpd); | |
3061 | + RdFLOAT_LoEnd(&WorldTx.Dx,wpd); | |
3062 | + RdFLOAT_LoEnd(&WorldTx.Dy,wpd); | |
3063 | + | |
3064 | + strcpy(ObjType,ObjName+1); | |
3065 | +} | |
3066 | + | |
3067 | + | |
2973 | 3068 | void TconvertedPass1_EMF::parse_MoveToEX(void) |
2974 | 3069 | { |
2975 | 3070 | #ifdef DEBUG |
@@ -3017,6 +3112,7 @@ | ||
3017 | 3112 | |
3018 | 3113 | memcpy(&pVecLine->LineColor, &PSS.LineColor, sizeof(PSS.LineColor)); |
3019 | 3114 | pVecLine->Close = false; |
3115 | + pVecLine->Transform(WorldTx); | |
3020 | 3116 | VectList.AddObject(pVecLine); pVecLine=NULL; |
3021 | 3117 | |
3022 | 3118 | sprintf(ObjType,"%s(%d;%d)", ObjName+1, LineX, LineY); |
@@ -3066,6 +3162,7 @@ | ||
3066 | 3162 | Points = NULL; |
3067 | 3163 | pVecPoly->AttribFromPSS(PSS); |
3068 | 3164 | pVecPoly->Close = true; |
3165 | + pVecPoly->Transform(WorldTx); | |
3069 | 3166 | VectList.AddObject(pVecPoly); pVecPoly=NULL; |
3070 | 3167 | |
3071 | 3168 | strcpy(ObjType,ObjName+1); |
@@ -3105,6 +3202,7 @@ | ||
3105 | 3202 | |
3106 | 3203 | pVecPoly->AttribFromPSS(PSS); |
3107 | 3204 | pVecPoly->Close = false; |
3205 | + pVecPoly->Transform(WorldTx); | |
3108 | 3206 | VectList.AddObject(pVecPoly); pVecPoly=NULL; |
3109 | 3207 | |
3110 | 3208 | strcpy(ObjType,ObjName+1); |
@@ -3149,6 +3247,7 @@ | ||
3149 | 3247 | |
3150 | 3248 | pVecCurve->AttribFromPSS(PSS); |
3151 | 3249 | pVecCurve->Close = false; |
3250 | + pVecCurve->Transform(WorldTx); | |
3152 | 3251 | VectList.AddObject(pVecCurve); pVecCurve=NULL; |
3153 | 3252 | |
3154 | 3253 | strcpy(ObjType,ObjName+1); |
@@ -3210,6 +3309,7 @@ | ||
3210 | 3309 | Points = NULL; |
3211 | 3310 | pVecPoly->AttribFromPSS(PSS); |
3212 | 3311 | pVecPoly->Close = true; |
3312 | + pVecPoly->Transform(WorldTx); | |
3213 | 3313 | VectList.AddObject(pVecPoly); pVecPoly=NULL; |
3214 | 3314 | } |
3215 | 3315 |
@@ -3259,6 +3359,7 @@ | ||
3259 | 3359 | |
3260 | 3360 | pVecPoly->AttribFromPSS(PSS); |
3261 | 3361 | pVecPoly->Close = false; |
3362 | + pVecPoly->Transform(WorldTx); | |
3262 | 3363 | VectList.AddObject(pVecPoly); pVecPoly=NULL; |
3263 | 3364 | |
3264 | 3365 | strcpy(ObjType,ObjName+1); |
@@ -3294,8 +3395,9 @@ | ||
3294 | 3395 | const float Scale = GetScale2PSU((TMapMode)MapMode); |
3295 | 3396 | |
3296 | 3397 | VectorRectangle *pVectRec = new VectorRectangle(Scale*BottomRect, Scale*TopRect, Scale*LeftRect, Scale*RightRect); |
3297 | - pVectRec->AttribFromPSS(PSS); | |
3298 | - VectList.AddObject(pVectRec); | |
3398 | + pVectRec->AttribFromPSS(PSS); | |
3399 | + pVectRec->Transform(WorldTx); | |
3400 | + VectList.AddObject(pVectRec); | |
3299 | 3401 | |
3300 | 3402 | strcpy(ObjType,ObjName+1); |
3301 | 3403 | return; |
@@ -3540,6 +3642,7 @@ | ||
3540 | 3642 | pVectRec->FillColor = PixColor; |
3541 | 3643 | pVectRec->BrushStyle = FILL_SOLID; |
3542 | 3644 | pVectRec->LineStyle = 0; |
3645 | + pVectRec->Transform(WorldTx); | |
3543 | 3646 | VectList.AddObject(pVectRec); |
3544 | 3647 | |
3545 | 3648 | strcpy(ObjType,ObjName+1); |
@@ -3804,8 +3907,8 @@ | ||
3804 | 3907 | case EMR_SCALEWINDOWEXTEX: strcpy(ObjType,"!SCALEWINDOWEXTEX"); break; // 0x00000020 |
3805 | 3908 | case EMR_SAVEDC: strcpy(ObjType,"!SAVEDC"); break; // 0x00000021 |
3806 | 3909 | case EMR_RESTOREDC: strcpy(ObjType,"!RESTOREDC"); break; // 0x00000022 |
3807 | - case EMR_SETWORLDTRANSFORM: strcpy(ObjType,"!SETWORLDTRANSFORM"); break; // 0x00000023 | |
3808 | - case EMR_MODIFYWORLDTRANSFORM: strcpy(ObjType,"!MODIFYWORLDTRANSFORM"); break; // 0x00000024 | |
3910 | + case EMR_SETWORLDTRANSFORM: parse_SetWorldTransform(); break; // 0x00000023 | |
3911 | + case EMR_MODIFYWORLDTRANSFORM: parse_ModifyWorldTransform(); break; // 0x00000024 | |
3809 | 3912 | case EMR_SELECTOBJECT: parse_SelectObject(); break; // 0x00000025 |
3810 | 3913 | case EMR_CREATEPEN: parse_CreatePen(); break; // 0x00000026 |
3811 | 3914 | case EMR_CREATEBRUSHINDIRECT: parse_CreateBrushIndirect(); break; // 0x00000027 |
@@ -17,8 +17,8 @@ | ||
17 | 17 | |
18 | 18 | #define LineLength 80 /* Split lines after more than LineLength charcters */ |
19 | 19 | |
20 | -#define VersionWP2L "3.107" | |
21 | -#define VersionDate "24 May 2022" /* day (space) month (space) full year */ | |
20 | +#define VersionWP2L "3.pre108" | |
21 | +#define VersionDate "29 May 2022" /* day (space) month (space) full year */ | |
22 | 22 | |
23 | 23 | |
24 | 24 | /* Constants for a flag InputPS */ |