Skip to content

Commit

Permalink
Added rectangle support (by mastintin)
Browse files Browse the repository at this point in the history
  • Loading branch information
APerricone committed May 8, 2019
1 parent ea61a24 commit a675453
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
32 changes: 32 additions & 0 deletions Emf2Pdf.cpp
Expand Up @@ -1212,6 +1212,7 @@ size_t Emf2Pdf::Ellipse()
{
RECTL bound;
fread(&bound, 4, 4, f);
PRINT_DBG(" (%ix%i)-(%ix%i) \r\n", bound.right, bound.bottom, bound.left, bound.top);
float x = (bound.right + bound.left) * xScale / 2;
float y = currHeight - (bound.top + bound.bottom) * xScale / 2;
float rx = (bound.right - bound.left) * xScale / 2;
Expand All @@ -1234,6 +1235,36 @@ size_t Emf2Pdf::Ellipse()
return 16;
}

size_t Emf2Pdf::Rectangle()
{
RECTL bound;
fread(&bound, 4, 4, f);
PRINT_DBG(" (%ix%i)-(%ix%i) \r\n", bound.right, bound.bottom, bound.left, bound.top);
float x = bound.left * xScale;
float y = currHeight - bound.bottom * yScale;
float rx = (bound.right - bound.left) * xScale;
float ry = (bound.bottom - bound.top) * yScale;

HPDF_Page_Rectangle(page, x, y, rx, ry);


if (currentPen.width > 0 && currentBrush.solid)
{
HPDF_Page_FillStroke(page);
}
else if (currentPen.width > 0)
{
HPDF_Page_Stroke(page);
}
else if (currentBrush.solid)
{
HPDF_Page_Fill(page);
}

return 16;
}



void Emf2Pdf::ParseFile()
{
Expand Down Expand Up @@ -1276,6 +1307,7 @@ void Emf2Pdf::ParseFile()
case EMR_ELLIPSE: nRead += Ellipse(); break;
case EMR_SETBKCOLOR: nRead += SetBkColor(); break;
case EMR_SETBKMODE: nRead += SetBkMode(); break;
case EMR_RECTANGLE: nRead += Rectangle(); break;
case EMR_EOF: return;
}
fseek(f, (long)(size - nRead), SEEK_CUR);
Expand Down
3 changes: 2 additions & 1 deletion Emf2Pdf.h
Expand Up @@ -110,7 +110,8 @@ class Emf2Pdf
size_t Polygon(unsigned long code);
size_t Ellipse();
size_t SetBkColor();
size_t SetBkMode ();
size_t SetBkMode();
size_t Rectangle();

void ParseFile();
};

0 comments on commit a675453

Please sign in to comment.