• R/O
  • SSH

wp2latex: Commit

WP2LaTeX sources.


Commit MetaInfo

Revisionff03dbe9d73f6790b6be18f1431afbe02f0ff381 (tree)
Zeit2022-08-22 14:35:18
AutorFojtik
CommiterFojtik

Log Message

Bitmap used for hatch pattern in WMF is loaded, but not fully used yet.

Ändern Zusammenfassung

Diff

diff -r a8149bf54478 -r ff03dbe9d73f trunk/sources.cc/images/vecimage.cc
--- a/trunk/sources.cc/images/vecimage.cc Sun Aug 21 00:02:43 2022 +0200
+++ b/trunk/sources.cc/images/vecimage.cc Mon Aug 22 07:35:18 2022 +0200
@@ -75,6 +75,7 @@
7575 memset(&PaperBackground, 0, sizeof(PaperBackground));
7676 memset(&FillBackground, 0xFF, sizeof(FillBackground)); //Use white paper.
7777 pPalette = NULL;
78+ pRaster = NULL;
7879 }
7980
8081
@@ -85,6 +86,11 @@
8586 if(pPalette->UsageCount--<=1) delete pPalette;
8687 pPalette = NULL;
8788 }
89+ if(pRaster != NULL)
90+ {
91+ if(pRaster->UsageCount--<=1) delete pRaster;
92+ pRaster = NULL;
93+ }
8894 }
8995
9096
@@ -94,6 +100,7 @@
94100 PaperBackground = OrigPSS.PaperBackground;
95101 FontName = OrigPSS.FontName;
96102 AttachPalette(OrigPSS.pPalette);
103+ AttachRaster(OrigPSS.pRaster);
97104 return *this;
98105 }
99106
@@ -112,6 +119,20 @@
112119 }
113120
114121
122+void PS_State::AttachRaster(Raster2DAbstract *NewRaster)
123+{
124+ if(pRaster!=NULL) // Detach previously attached raster
125+ {
126+ if(pRaster->UsageCount--<=1) delete pRaster;
127+ pRaster = NULL;
128+ }
129+ if(NewRaster!=NULL) // Attach raster now
130+ {
131+ pRaster=NewRaster; pRaster->UsageCount++;
132+ }
133+}
134+
135+
115136
116137 ////////////////////////////////////
117138
@@ -293,6 +314,40 @@
293314
294315 ////////////////////////////////////
295316
317+
318+attrRaster::attrRaster(Raster2DAbstract *iniRaster, APalette *iniPalette)
319+{
320+ pRaster = iniRaster;
321+ if(pRaster!=NULL) pRaster->UsageCount++;
322+ pPalette = iniPalette;
323+ if(pPalette!=NULL) pPalette->UsageCount++;
324+}
325+
326+
327+attrRaster::~attrRaster()
328+{
329+ if(pRaster != NULL)
330+ {
331+ if(pRaster->UsageCount--<=1) delete pRaster;
332+ pRaster = NULL;
333+ }
334+ if(pPalette != NULL)
335+ {
336+ if(pPalette->UsageCount--<=1) delete pPalette;
337+ pPalette = NULL;
338+ }
339+}
340+
341+
342+void attrRaster::prepExport(PS_State *PSS) const
343+{
344+ if(PSS==NULL) return;
345+ PSS->AttachRaster(pRaster);
346+}
347+
348+
349+////////////////////////////////////
350+
296351 vecTransform::vecTransform(void)
297352 {
298353 CenterX = CenterY = TranslateX = TranslateY = 0;
diff -r a8149bf54478 -r ff03dbe9d73f trunk/sources.cc/images/vecimage.h
--- a/trunk/sources.cc/images/vecimage.h Sun Aug 21 00:02:43 2022 +0200
+++ b/trunk/sources.cc/images/vecimage.h Mon Aug 22 07:35:18 2022 +0200
@@ -122,10 +122,12 @@
122122 ~PS_State(void);
123123 PS_State &operator=(const PS_State & OrigPSS);
124124 void AttachPalette(APalette *NewPalette);
125+ void AttachRaster(Raster2DAbstract *NewRaster);
125126
126127 RGB_Record PaperBackground;
127128 string FontName;
128129 APalette *pPalette;
130+ Raster2DAbstract *pRaster;
129131 };
130132
131133
@@ -161,6 +163,7 @@
161163 ATTR_PEN,
162164 ATTR_BRUSH,
163165 ATTR_PALETTE,
166+ ATTR_RASTER,
164167 } ATTRIB_TYPES;
165168
166169
@@ -250,6 +253,19 @@
250253 };
251254
252255
256+class attrRaster: public VectorAttribute
257+{
258+public:
259+ APalette *pPalette;
260+ Raster2DAbstract *pRaster;
261+
262+ attrRaster(Raster2DAbstract *iniRaster, APalette *iniPalette=NULL);
263+ virtual ~attrRaster();
264+ virtual void prepExport(PS_State *PSS) const;
265+ virtual int getAttribType(void) const {return ATTR_PALETTE;};
266+};
267+
268+
253269 class vecTransform
254270 {
255271 public:
diff -r a8149bf54478 -r ff03dbe9d73f trunk/sources.cc/pass1wmf.cc
--- a/trunk/sources.cc/pass1wmf.cc Sun Aug 21 00:02:43 2022 +0200
+++ b/trunk/sources.cc/pass1wmf.cc Mon Aug 22 07:35:18 2022 +0200
@@ -719,8 +719,32 @@
719719 {
720720 static const char ObjName[] = "!DibCreatePatternBrush";
721721
722- ObjTab.AddObject(new FakeAttr());
723- strcpy(ObjType, ObjName);
722+ if(!CheckWmfRecSz(3))
723+ {
724+ ReportCorruptedObj(ObjName+1);
725+ strcpy(ObjType, ObjName);
726+ ObjTab.AddObject(new FakeAttr());
727+ return;
728+ }
729+
730+ WORD Style;
731+ WORD ColorUsage;
732+
733+ Rd_word(wpd, &Style);
734+ Rd_word(wpd, &ColorUsage);
735+
736+ Image Img;
737+ LoadBmpStream(Img, wpd, WmfRec.ParamFilePos+4);
738+ if(Img.Raster != NULL)
739+ {
740+ ObjTab.AddObject(new attrRaster(Img.Raster,Img.Palette));
741+ strcpy(ObjType, ObjName+1);
742+ }
743+ else
744+ {
745+ ObjTab.AddObject(new FakeAttr());
746+ strcpy(ObjType, ObjName);
747+ }
724748 }
725749
726750
Show on old repository browser