• R/O
  • SSH

wp2latex: 提交

WP2LaTeX sources.


Commit MetaInfo

修订版2940b2d119f3112ec2368d30c0e8a5cfb93a6f0f (tree)
时间2022-06-03 16:28:25
作者Fojtik
CommiterFojtik

Log Message

Process raster in EMF as "VecRaster", apply world transform to it.

更改概述

差异

diff -r ffbc46817673 -r 2940b2d119f3 trunk/sources.cc/pass1wmf.cc
--- a/trunk/sources.cc/pass1wmf.cc Thu Jun 02 00:40:03 2022 +0200
+++ b/trunk/sources.cc/pass1wmf.cc Fri Jun 03 09:28:25 2022 +0200
@@ -2271,7 +2271,7 @@
22712271 void parse_SetPolyFillMode(void);
22722272 void parse_SetTextAlign(void);
22732273 void parse_SetTextColor(void);
2274- void parse_StretchDIBits(void);
2274+ void parse_StretchDIBits(VectorList &VectList);
22752275
22762276 _EnhancedMetaRecord EmfRec;
22772277 };
@@ -2821,7 +2821,8 @@
28212821 Rd_dword(wpd, (DWORD*)&TopRect);
28222822 Rd_dword(wpd, (DWORD*)&RightRect);
28232823 Rd_dword(wpd, (DWORD*)&BottomRect);
2824-
2824+
2825+ // TODO: Bounding box musí být upraven podle WorldTx.
28252826 UpdateBBox(bbx, 0, LeftRect, BottomRect, RightRect-LeftRect, TopRect-BottomRect);
28262827
28272828 const float Scale = GetScale2PSU((TMapMode)MapMode);
@@ -3097,22 +3098,22 @@
30973098 Rd_dword(wpd, (DWORD*)&LineX);
30983099 Rd_dword(wpd, (DWORD*)&LineY);
30993100
3100- UpdateBBox(bbx, 0, PositionX, PositionY, LineX-PositionX, LineY-PositionY);
3101-
31023101 float *Points = (float*)malloc(4*sizeof(float));
31033102 if(Points!=NULL)
31043103 {
31053104 const float Scale = GetScale2PSU((TMapMode)MapMode);
31063105
3107- Points[0] = PositionX * Scale;
3108- Points[1] = PositionY * Scale;
3109- Points[2] = LineX * Scale;
3110- Points[3] = LineY * Scale;
3106+ Points[0] = PositionX;
3107+ Points[1] = PositionY;
3108+ Points[2] = LineX;
3109+ Points[3] = LineY;
31113110 VectorLine *pVecLine = new VectorLine(Points, 2);
3111+ pVecLine->Transform(WorldTx);
3112+ UpdateBBox(bbx, 0, Points[0], Points[1], Points[3]-Points[0], Points[2]-Points[1]); // Update BBox after world transform.
3113+ for(int i=0; i<4; i++) Points[i]*=Scale;
31123114
31133115 memcpy(&pVecLine->LineColor, &PSS.LineColor, sizeof(PSS.LineColor));
3114- pVecLine->Close = false;
3115- pVecLine->Transform(WorldTx);
3116+ pVecLine->Close = false;
31163117 VectList.AddObject(pVecLine); pVecLine=NULL;
31173118
31183119 sprintf(ObjType,"%s(%d;%d)", ObjName+1, LineX, LineY);
@@ -3733,23 +3734,23 @@
37333734
37343735 if(BIH_biSize!=40) return;
37353736
3736- fseek(f,ParamFilePos,SEEK_SET);
3737+ fseek(f,ParamFilePos,SEEK_SET);
37373738 LoadBmpStream(Img,f,0);
37383739 }
37393740
37403741
3741-void TconvertedPass1_EMF::parse_StretchDIBits(void)
3742+void TconvertedPass1_EMF::parse_StretchDIBits(VectorList &VectList)
37423743 {
37433744 #ifdef DEBUG
37443745 fprintf(log,"\n#TconvertedPass1_EMF::parse_StretchDIBits() ");fflush(log);
37453746 #endif
37463747 static const char ObjName[] = "!STRETCHDIBITS";
3747-Image *pImg = &Img;
37483748 SDWORD Bounds[4];
37493749 SDWORD xDest, yDest, xSrc, ySrc, cxSrc, cySrc;
37503750 DWORD offBmiSrc, cbBmiSrc, offBitsSrc, cbBitsSrc;
37513751 DWORD UsageSrc, BitBltRasterOperation;
37523752 SDWORD cxDest, cyDest;
3753+Image *pImg = &Img;
37533754
37543755 //CrackObject(this, ActualPos+EmfRec.Size);
37553756
@@ -3788,20 +3789,45 @@
37883789
37893790 // Rewind to the last frame.
37903791 while(pImg->Next!=NULL)
3791- pImg = pImg->Next;
3792+ pImg = pImg->Next;
37923793
37933794 if(pImg->Raster==NULL || pImg->Raster->Data2D==NULL)
37943795 {
3795- EMF_STRETCHDIB(*pImg, wpd, offBmiSrc);
3796- pImg->x = xDest;
3797- pImg->y = yDest;
3798- pImg->dx = cxDest;
3799- pImg->dy = cyDest;
3800- if(pImg->Raster!=NULL && pImg->Palette==NULL) pImg->AttachPalette(PSS.pPalette);
3796+ Image Img2;
3797+ EMF_STRETCHDIB(Img2, wpd, offBmiSrc);
3798+ if(Img2.Raster != NULL)
3799+ {
3800+ VectorRaster *vr;
3801+ if(fabs(Img2.RotAngle) > 1e-5)
3802+ vr = new VectorRaster(xDest+cxDest/2, yDest+cyDest/2, cxDest, cyDest, Img2.RotAngle);
3803+ else
3804+ vr = new VectorRaster(yDest, yDest+cyDest, xDest+cxDest, xDest);
3805+ vr->AttachRaster(Img2.Raster);
3806+ if(Img2.Palette != NULL)
3807+ vr->AttachPalette(Img2.Palette);
3808+ else
3809+ {
3810+ if(pImg->Palette==NULL)
3811+ vr->AttachPalette(PSS.pPalette);
3812+ else
3813+ vr->AttachPalette(Img2.Palette);
3814+ }
3815+ vr->Transform(WorldTx);
3816+
3817+ float dx = vr->RightCenterX - vr->CenterX;
3818+ float dy = vr->RightCenterY - vr->CenterY;
3819+ UpdateBBox(bbx, 0, vr->CenterX-dx, vr->CenterY-dy, 2*dx, 2*dy);
3820+ dx = vr->TopCenterX - vr->CenterX;
3821+ dy = vr->TopCenterY - vr->CenterY;
3822+ UpdateBBox(bbx, 0, vr->CenterX-dx, vr->CenterY-dy, 2*dx, 2*dy);
3823+
3824+ VectList.AddObject(vr);
3825+ }
38013826 }
38023827 else
38033828 {
38043829 Image Img2;
3830+
38053831 EMF_STRETCHDIB(Img2, wpd, offBmiSrc);
38063832 Img2.x = xDest;
38073833 Img2.y = yDest;
@@ -3951,7 +3977,7 @@
39513977 case EMR_MASKBLT: strcpy(ObjType,"!MASKBLT"); break; // 0x0000004E
39523978 case EMR_PLGBLT: strcpy(ObjType,"!PLGBLT"); break; // 0x0000004F
39533979 case EMR_SETDIBITSTODEVICE: strcpy(ObjType,"!SETDIBITSTODEVICE"); break; // 0x00000050
3954- case EMR_STRETCHDIBITS: parse_StretchDIBits(); break; // 0x00000051
3980+ case EMR_STRETCHDIBITS: parse_StretchDIBits(VectList); break; // 0x00000051
39553981 case EMR_EXTCREATEFONTINDIRECTW: parse_ExtCreateFontIndirectW(); break; // 0x00000052
39563982 case EMR_EXTTEXTOUTA: strcpy(ObjType,"!EXTTEXTOUTA"); PleaseReport("EXTTEXTOUTA"); break; // 0x00000053
39573983 case EMR_EXTTEXTOUTW: parse_ExtTextOutW(VectList); break; // 0x00000054
diff -r ffbc46817673 -r 2940b2d119f3 trunk/sources.cc/wp2latex.h
--- a/trunk/sources.cc/wp2latex.h Thu Jun 02 00:40:03 2022 +0200
+++ b/trunk/sources.cc/wp2latex.h Fri Jun 03 09:28:25 2022 +0200
@@ -18,7 +18,7 @@
1818 #define LineLength 80 /* Split lines after more than LineLength charcters */
1919
2020 #define VersionWP2L "3.pre108"
21-#define VersionDate "29 May 2022" /* day (space) month (space) full year */
21+#define VersionDate "3 Jun 2022" /* day (space) month (space) full year */
2222
2323
2424 /* Constants for a flag InputPS */
Show on old repository browser