修订版 | 2940b2d119f3112ec2368d30c0e8a5cfb93a6f0f (tree) |
---|---|
时间 | 2022-06-03 16:28:25 |
作者 | Fojtik |
Commiter | Fojtik |
Process raster in EMF as "VecRaster", apply world transform to it.
@@ -2271,7 +2271,7 @@ | ||
2271 | 2271 | void parse_SetPolyFillMode(void); |
2272 | 2272 | void parse_SetTextAlign(void); |
2273 | 2273 | void parse_SetTextColor(void); |
2274 | - void parse_StretchDIBits(void); | |
2274 | + void parse_StretchDIBits(VectorList &VectList); | |
2275 | 2275 | |
2276 | 2276 | _EnhancedMetaRecord EmfRec; |
2277 | 2277 | }; |
@@ -2821,7 +2821,8 @@ | ||
2821 | 2821 | Rd_dword(wpd, (DWORD*)&TopRect); |
2822 | 2822 | Rd_dword(wpd, (DWORD*)&RightRect); |
2823 | 2823 | Rd_dword(wpd, (DWORD*)&BottomRect); |
2824 | - | |
2824 | + | |
2825 | + // TODO: Bounding box musí být upraven podle WorldTx. | |
2825 | 2826 | UpdateBBox(bbx, 0, LeftRect, BottomRect, RightRect-LeftRect, TopRect-BottomRect); |
2826 | 2827 | |
2827 | 2828 | const float Scale = GetScale2PSU((TMapMode)MapMode); |
@@ -3097,22 +3098,22 @@ | ||
3097 | 3098 | Rd_dword(wpd, (DWORD*)&LineX); |
3098 | 3099 | Rd_dword(wpd, (DWORD*)&LineY); |
3099 | 3100 | |
3100 | - UpdateBBox(bbx, 0, PositionX, PositionY, LineX-PositionX, LineY-PositionY); | |
3101 | - | |
3102 | 3101 | float *Points = (float*)malloc(4*sizeof(float)); |
3103 | 3102 | if(Points!=NULL) |
3104 | 3103 | { |
3105 | 3104 | const float Scale = GetScale2PSU((TMapMode)MapMode); |
3106 | 3105 | |
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; | |
3111 | 3110 | 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; | |
3112 | 3114 | |
3113 | 3115 | memcpy(&pVecLine->LineColor, &PSS.LineColor, sizeof(PSS.LineColor)); |
3114 | - pVecLine->Close = false; | |
3115 | - pVecLine->Transform(WorldTx); | |
3116 | + pVecLine->Close = false; | |
3116 | 3117 | VectList.AddObject(pVecLine); pVecLine=NULL; |
3117 | 3118 | |
3118 | 3119 | sprintf(ObjType,"%s(%d;%d)", ObjName+1, LineX, LineY); |
@@ -3733,23 +3734,23 @@ | ||
3733 | 3734 | |
3734 | 3735 | if(BIH_biSize!=40) return; |
3735 | 3736 | |
3736 | - fseek(f,ParamFilePos,SEEK_SET); | |
3737 | + fseek(f,ParamFilePos,SEEK_SET); | |
3737 | 3738 | LoadBmpStream(Img,f,0); |
3738 | 3739 | } |
3739 | 3740 | |
3740 | 3741 | |
3741 | -void TconvertedPass1_EMF::parse_StretchDIBits(void) | |
3742 | +void TconvertedPass1_EMF::parse_StretchDIBits(VectorList &VectList) | |
3742 | 3743 | { |
3743 | 3744 | #ifdef DEBUG |
3744 | 3745 | fprintf(log,"\n#TconvertedPass1_EMF::parse_StretchDIBits() ");fflush(log); |
3745 | 3746 | #endif |
3746 | 3747 | static const char ObjName[] = "!STRETCHDIBITS"; |
3747 | -Image *pImg = &Img; | |
3748 | 3748 | SDWORD Bounds[4]; |
3749 | 3749 | SDWORD xDest, yDest, xSrc, ySrc, cxSrc, cySrc; |
3750 | 3750 | DWORD offBmiSrc, cbBmiSrc, offBitsSrc, cbBitsSrc; |
3751 | 3751 | DWORD UsageSrc, BitBltRasterOperation; |
3752 | 3752 | SDWORD cxDest, cyDest; |
3753 | +Image *pImg = &Img; | |
3753 | 3754 | |
3754 | 3755 | //CrackObject(this, ActualPos+EmfRec.Size); |
3755 | 3756 |
@@ -3788,20 +3789,45 @@ | ||
3788 | 3789 | |
3789 | 3790 | // Rewind to the last frame. |
3790 | 3791 | while(pImg->Next!=NULL) |
3791 | - pImg = pImg->Next; | |
3792 | + pImg = pImg->Next; | |
3792 | 3793 | |
3793 | 3794 | if(pImg->Raster==NULL || pImg->Raster->Data2D==NULL) |
3794 | 3795 | { |
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 | + } | |
3801 | 3826 | } |
3802 | 3827 | else |
3803 | 3828 | { |
3804 | 3829 | Image Img2; |
3830 | + | |
3805 | 3831 | EMF_STRETCHDIB(Img2, wpd, offBmiSrc); |
3806 | 3832 | Img2.x = xDest; |
3807 | 3833 | Img2.y = yDest; |
@@ -3951,7 +3977,7 @@ | ||
3951 | 3977 | case EMR_MASKBLT: strcpy(ObjType,"!MASKBLT"); break; // 0x0000004E |
3952 | 3978 | case EMR_PLGBLT: strcpy(ObjType,"!PLGBLT"); break; // 0x0000004F |
3953 | 3979 | 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 | |
3955 | 3981 | case EMR_EXTCREATEFONTINDIRECTW: parse_ExtCreateFontIndirectW(); break; // 0x00000052 |
3956 | 3982 | case EMR_EXTTEXTOUTA: strcpy(ObjType,"!EXTTEXTOUTA"); PleaseReport("EXTTEXTOUTA"); break; // 0x00000053 |
3957 | 3983 | case EMR_EXTTEXTOUTW: parse_ExtTextOutW(VectList); break; // 0x00000054 |
@@ -18,7 +18,7 @@ | ||
18 | 18 | #define LineLength 80 /* Split lines after more than LineLength charcters */ |
19 | 19 | |
20 | 20 | #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 */ | |
22 | 22 | |
23 | 23 | |
24 | 24 | /* Constants for a flag InputPS */ |