diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2014-01-18 09:11:04 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2014-01-18 09:11:04 +0000 |
| commit | f12d6a57fe5cc18be5afd164061578d8e00d75ce (patch) | |
| tree | 7fd1a501a8a545fbf2326ead48cd041928699c5e /src | |
| parent | update to trunk (diff) | |
| parent | Fix missing embeded image condition, kindly caught by suv in bug #1270334 (diff) | |
| download | inkscape-f12d6a57fe5cc18be5afd164061578d8e00d75ce.tar.gz inkscape-f12d6a57fe5cc18be5afd164061578d8e00d75ce.zip | |
update to trunk
(bzr r11950.1.235)
Diffstat (limited to 'src')
116 files changed, 20215 insertions, 3519 deletions
diff --git a/src/2geom/Makefile_insert b/src/2geom/Makefile_insert index 07e066df5..e77f413cb 100644 --- a/src/2geom/Makefile_insert +++ b/src/2geom/Makefile_insert @@ -71,6 +71,8 @@ 2geom/path.h \ 2geom/path-intersection.cpp \ 2geom/path-intersection.h \ + 2geom/path-sink.cpp \ + 2geom/path-sink.h \ 2geom/pathvector.cpp \ 2geom/pathvector.h \ 2geom/piecewise.cpp \ @@ -110,8 +112,6 @@ 2geom/solver.h \ 2geom/svg-elliptical-arc.cpp \ 2geom/svg-elliptical-arc.h \ - 2geom/svg-path.cpp \ - 2geom/svg-path.h \ 2geom/svg-path-parser.cpp \ 2geom/svg-path-parser.h \ 2geom/sweep.cpp \ diff --git a/src/2geom/affine.cpp b/src/2geom/affine.cpp index 0ef6d2708..738d0fc48 100644 --- a/src/2geom/affine.cpp +++ b/src/2geom/affine.cpp @@ -454,8 +454,7 @@ Eigen::Eigen(Affine const &m) { } } -static void quadratic_roots(double q0, double q1, double q2, int &n, double&r0, double&r1) { - std::vector<double> r; +static void quadratic_roots(const double q0, const double q1, const double q2, int &n, double&r0, double&r1) { if(q2 == 0) { if(q1 == 0) { // zero or infinite roots n = 0; diff --git a/src/2geom/affine.h b/src/2geom/affine.h index b17da1887..af7b39360 100644 --- a/src/2geom/affine.h +++ b/src/2geom/affine.h @@ -75,12 +75,6 @@ public: _c[1] = _c[2] = _c[4] = _c[5] = 0; } - Affine(Affine const &m) { - for(int i = 0; i < 6; i++) { - _c[i] = m[i]; - } - } - /** @brief Create a matrix from its coefficient values. * It's rather inconvenient to directly create matrices in this way. Use transform classes * if your transformation has a geometric interpretation. @@ -88,19 +82,14 @@ public: * @see Scale * @see Rotate * @see HShear - * @see VShear */ + * @see VShear + * @see Zoom */ Affine(Coord c0, Coord c1, Coord c2, Coord c3, Coord c4, Coord c5) { _c[0] = c0; _c[1] = c1; _c[2] = c2; _c[3] = c3; _c[4] = c4; _c[5] = c5; } - Affine &operator=(Affine const &m) { - for(int i = 0; i < 6; i++) - _c[i] = m._c[i]; - return *this; - } - /** @brief Access a coefficient by its index. */ inline Coord operator[](unsigned i) const { return _c[i]; } inline Coord &operator[](unsigned i) { return _c[i]; } diff --git a/src/2geom/angle.h b/src/2geom/angle.h index bdf546989..1faf63c3f 100644 --- a/src/2geom/angle.h +++ b/src/2geom/angle.h @@ -48,6 +48,9 @@ namespace Geom { #ifndef M_PI # define M_PI 3.14159265358979323846 #endif +#ifndef M_1_2PI +# define M_1_2PI 0.159154943091895335768883763373 +#endif /** @brief Wrapper for angular values. * @@ -64,6 +67,7 @@ class Angle > > { public: + Angle() : _angle(0) {} //added default constructor because of cython Angle(Coord v) : _angle(v) { _normalize(); } // this can be called implicitly explicit Angle(Point p) : _angle(atan2(p)) { _normalize(); } Angle(Point a, Point b) : _angle(angle_between(a, b)) { _normalize(); } @@ -85,7 +89,7 @@ public: /** @brief Get the angle as radians. * @return Number in range \f$[-\pi, \pi)\f$. */ Coord radians() const { - return _angle > M_PI ? _angle - 2*M_PI : _angle; + return _angle >= M_PI ? _angle - 2*M_PI : _angle; } /** @brief Get the angle as positive radians. * @return Number in range \f$[0, 2\pi)\f$. */ @@ -95,7 +99,7 @@ public: /** @brief Get the angle as degrees in math convention. * @return Number in range [-180, 180) obtained by scaling the result of radians() * by \f$180/\pi\f$. */ - Coord degrees() const { return radians() / M_PI * 180.0; } + Coord degrees() const { return radians() * (180.0 / M_PI); } /** @brief Get the angle as degrees in clock convention. * This method converts the angle to the "clock convention": angles start from the +Y axis * and grow clockwise. This means that 0 corresponds to \f$\pi/2\f$ radians, @@ -103,7 +107,7 @@ public: * @return A number in the range [0, 360). */ Coord degreesClock() const { - Coord ret = 90.0 - _angle / M_PI * 180.0; + Coord ret = 90.0 - _angle * (180.0 / M_PI); if (ret < 0) ret += 360; return ret; } @@ -114,7 +118,7 @@ public: } /** @brief Create an angle from its measure in degrees. */ static Angle from_degrees(Coord d) { - Angle a(d * M_PI / 180); + Angle a(d * (M_PI / 180.0)); return a; } /** @brief Create an angle from its measure in degrees in clock convention. @@ -123,16 +127,16 @@ public: // first make sure d is in [0, 360) d = std::fmod(d, 360.0); if (d < 0) d += 360.0; - Coord rad = M_PI/2 - d * M_PI / 180.0; + Coord rad = M_PI/2 - d * (M_PI / 180.0); if (rad < 0) rad += 2*M_PI; Angle a; a._angle = rad; return a; } private: - Angle() {} + void _normalize() { - _angle -= floor(_angle / (2*M_PI)) * 2*M_PI; + _angle -= floor(_angle * (1.0/(2*M_PI))) * 2*M_PI; } Coord _angle; // this is always in [0, 2pi) friend class AngleInterval; diff --git a/src/2geom/basic-intersection.cpp b/src/2geom/basic-intersection.cpp index 544bf0dd1..379ec597c 100644 --- a/src/2geom/basic-intersection.cpp +++ b/src/2geom/basic-intersection.cpp @@ -64,15 +64,13 @@ void find_intersections(std::vector< std::pair<double, double> > & xs, void split(vector<Point> const &p, double t, vector<Point> &left, vector<Point> &right) { const unsigned sz = p.size(); - - Geom::Point **Vtemp = new Geom::Point* [sz]; - - for (unsigned int i = 0; i < sz; ++i) { - Vtemp[i] = new Geom::Point[sz]; - } + //Geom::Point Vtemp[sz][sz]; + vector<vector<Point> > Vtemp(sz); + for ( size_t i = 0; i < sz; ++i ) + Vtemp[i].reserve(sz); /* Copy control points */ - std::copy(p.begin(), p.end(), Vtemp[0]); + std::copy(p.begin(), p.end(), Vtemp[0].begin()); /* Triangle computation */ for (unsigned i = 1; i < sz; i++) { @@ -87,11 +85,6 @@ void split(vector<Point> const &p, double t, left[j] = Vtemp[j][0]; for (unsigned j = 0; j < sz; j++) right[j] = Vtemp[sz-1-j][j]; - - for (unsigned int i = 0; i < sz; ++i) - delete[] Vtemp[i]; - - delete[] Vtemp; } diff --git a/src/2geom/bezier-clipping.cpp b/src/2geom/bezier-clipping.cpp index fe925cf28..9a055204f 100644 --- a/src/2geom/bezier-clipping.cpp +++ b/src/2geom/bezier-clipping.cpp @@ -473,10 +473,9 @@ void fat_line_bounds (Interval& bound, { bound[0] = 0; bound[1] = 0; - double d; for (size_t i = 0; i < c.size(); ++i) { - d = distance(c[i], l); + const double d = distance(c[i], l); if (bound[0] > d) bound[0] = d; if (bound[1] < d) bound[1] = d; } @@ -509,10 +508,9 @@ void clip_interval (Interval& dom, double n = B.size() - 1; // number of sub-intervals std::vector<Point> D; // distance curve control points D.reserve (B.size()); - double d; for (size_t i = 0; i < B.size(); ++i) { - d = distance (B[i], l); + const double d = distance (B[i], l); D.push_back (Point(i/n, d)); } //print(D); @@ -699,8 +697,8 @@ void distance_control_points (std::vector<Point> & D, for (size_t j = 0; j < F.size(); ++j) dBF(i,j) = dot (dB[i], F[j]); - size_t k0, kn, l; - double bc, bri; + size_t l; + double bc; Point dij; std::vector<double> d(F.size()); for (size_t i = 0; i <= r; ++i) @@ -709,9 +707,9 @@ void distance_control_points (std::vector<Point> & D, { d[j] = 0; } - k0 = std::max(i, n) - n; - kn = std::min(i, n-1); - bri = n / binomial(r,i); + const size_t k0 = std::max(i, n) - n; + const size_t kn = std::min(i, n-1); + const double bri = n / binomial(r,i); for (size_t k = k0; k <= kn; ++k) { //if (k > i || (i-k) > n) continue; diff --git a/src/2geom/bezier-utils.cpp b/src/2geom/bezier-utils.cpp index af07db707..ec17f6869 100644 --- a/src/2geom/bezier-utils.cpp +++ b/src/2geom/bezier-utils.cpp @@ -194,8 +194,6 @@ bezier_fit_cubic_full(Point bezier[], int split_points[], Point const &tHat1, Point const &tHat2, double const error, unsigned const max_beziers) { - int const maxIterations = 4; /* std::max times to try iterating */ - if(!(bezier != NULL) || !(data != NULL) || !(len > 0) || @@ -257,6 +255,7 @@ bezier_fit_cubic_full(Point bezier[], int split_points[], /* If error not too large, then try some reparameterization and iteration. */ if ( 0.0 <= maxErrorRatio && maxErrorRatio <= 3.0 ) { + int const maxIterations = 4; /* std::max times to try iterating */ for (int i = 0; i < maxIterations; i++) { generate_bezier(bezier, data, u, len, tHat1, tHat2, error); reparameterize(data, len, u, bezier); diff --git a/src/2geom/circle.cpp b/src/2geom/circle.cpp index 06eb4c2a1..d021882ea 100644 --- a/src/2geom/circle.cpp +++ b/src/2geom/circle.cpp @@ -88,7 +88,9 @@ void Circle::set(std::vector<Point> const& points) model.instance(*this, fitter.result(z)); } - +/** + @param inner a point whose angle with the circle center is inside the angle that the arc spans + */ EllipticalArc * Circle::arc(Point const& initial, Point const& inner, Point const& final, bool _svg_compliant) @@ -98,10 +100,8 @@ Circle::arc(Point const& initial, Point const& inner, Point const& final, return e.arc(initial, inner, final, _svg_compliant); } -void -Circle::getPath(std::vector<Path> &path_out) { - Path pb; - +D2<SBasis> Circle::toSBasis() +{ D2<SBasis> B; Linear bo = Linear(0, 2 * M_PI); @@ -110,6 +110,15 @@ Circle::getPath(std::vector<Path> &path_out) { B = B * m_ray + m_centre; + return B; +} + +void +Circle::getPath(std::vector<Path> &path_out) { + Path pb; + + D2<SBasis> B = toSBasis(); + pb.append(SBasisCurve(B)); path_out.push_back(pb); diff --git a/src/2geom/circle.h b/src/2geom/circle.h index 67a638437..ca9241047 100644 --- a/src/2geom/circle.h +++ b/src/2geom/circle.h @@ -89,6 +89,7 @@ class Circle arc(Point const& initial, Point const& inner, Point const& final, bool _svg_compliant = true); + D2<SBasis> toSBasis(); void getPath(std::vector<Path> &path_out); Point center() const diff --git a/src/2geom/conicsec.cpp b/src/2geom/conicsec.cpp index 7625df2fb..367dc2503 100644 --- a/src/2geom/conicsec.cpp +++ b/src/2geom/conicsec.cpp @@ -211,8 +211,6 @@ RatQuad RatQuad::fromPointsTangents(Point P0, Point dP0, } RatQuad RatQuad::circularArc(Point P0, Point P1, Point P2) { - Line Line0 = Line::from_origin_and_versor(P0, P1 - P0); - Line Line2 = Line::from_origin_and_versor(P2, P1 - P2); return RatQuad(P0, P1, P2, dot(unit_vector(P0 - P1), unit_vector(P0 - P2))); } @@ -583,7 +581,7 @@ xAx xAx::operator*(double const &b) const { LineSegment ls = intersection(Line::from_origin_and_versor(A, dA), bnd); return RatQuad::fromPointsTangents(A, dA, ls.pointAt(0.5), ls[1], dA); } - else if(crs.size() >= 2 and crs.size() < 4) { + else if(crs.size() >= 2 && crs.size() < 4) { Point A = crs[0]; Point C = crs[1]; if(crs.size() == 3) { @@ -607,7 +605,7 @@ xAx xAx::operator*(double const &b) const { Point dA = gradient(A); Point dC = gradient(C); - if(L2sq(dA) <= 1e-10 or L2sq(dC) <= 1e-10) { + if(L2sq(dA) <= 1e-10 || L2sq(dC) <= 1e-10) { return RatQuad::fromPointsTangents(A, C-A, B, C, A-C); } @@ -710,7 +708,7 @@ boost::optional<Point> xAx::bottom() const { } Interval xAx::extrema(Rect r) const { - if (c[0] == 0 and c[1] == 0 and c[2] == 0) { + if (c[0] == 0 && c[1] == 0 && c[2] == 0) { Interval ext(valueAt(r.corner(0))); for(int i = 1; i < 4; i++) ext |= Interval(valueAt(r.corner(i))); @@ -725,7 +723,7 @@ Interval xAx::extrema(Rect r) const { k = r[1][1]; ext |= quad_ex(c[0], c[1]*k+c[3], (c[2]*k + c[4])*k + c[5], r[0]); boost::optional<Point> B0 = bottom(); - if (B0 and r.contains(*B0)) + if (B0 && r.contains(*B0)) ext.expandTo(0); return ext; } diff --git a/src/2geom/convex-cover.cpp b/src/2geom/convex-cover.cpp index 306060f7c..5e599fdde 100644 --- a/src/2geom/convex-cover.cpp +++ b/src/2geom/convex-cover.cpp @@ -433,7 +433,7 @@ bool same_side(Point L[2], Point xs[4]) { int side = 0; for(int i = 0; i < 4; i++) { int sn = sgn(SignedTriangleArea(L[0], L[1], xs[i])); - if(sn and not side) + if(sn && !side) side = sn; else if(sn != side) return false; } @@ -455,7 +455,7 @@ std::vector<pair<int, int> > bridges(ConvexHull a, ConvexHull b) { double ap_angle = atan2(a[ai+1] - a[ai]); double bp_angle = atan2(b[bi+1] - b[bi]); Point L[2] = {a[ai], b[bi]}; - while(ai < int(a.size()) or bi < int(b.size())) { + while(ai < int(a.size()) || bi < int(b.size())) { if(ap_angle == bp_angle) { // In the case of parallel support lines, we must consider all four pairs of copodal points { @@ -478,7 +478,7 @@ std::vector<pair<int, int> > bridges(ConvexHull a, ConvexHull b) { bi++; bp_angle += angle_between(b[bi] - b[bi-1], b[bi+1] - b[bi]); L[1] = b[bi]; - //std::cout << "parallel\n"; + std::cout << "parallel\n"; } else if(ap_angle < bp_angle) { ai++; ap_angle += angle_between(a[ai] - a[ai-1], a[ai+1] - a[ai]); @@ -559,7 +559,7 @@ T idx_to_pair(pair<T, T> p, int idx) { ConvexHull merge(ConvexHull a, ConvexHull b) { ConvexHull ret; - //std::cout << "---\n"; + std::cout << "---\n"; std::vector<pair<int, int> > bpair = bridges(a, b); // Given our list of bridges {(pb1, qb1), ..., (pbk, qbk)} @@ -574,10 +574,10 @@ ConvexHull merge(ConvexHull a, ConvexHull b) { for(unsigned k = 0; k < bpair.size(); k++) { unsigned limit = idx_to_pair(bpair[k], state); - /*std::cout << bpair[k].first << " , " << bpair[k].second << "; " + std::cout << bpair[k].first << " , " << bpair[k].second << "; " << idx << ", " << limit << ", s: " << state - << " \n";*/ + << " \n"; while(idx <= limit) { ret.boundary.push_back(chs[state][idx++]); } @@ -681,7 +681,7 @@ Point const * ConvexHull::furthest(Point direction) const { // is currently n*O(furthest) double ConvexHull::narrowest_diameter(Point &a, Point &b, Point &c) { Point tb = boundary.back(); - double d = INFINITY; + double d = std::numeric_limits<double>::max(); for(unsigned i = 0; i < boundary.size(); i++) { Point tc = boundary[i]; Point n = -rot90(tb-tc); diff --git a/src/2geom/convex-cover.h b/src/2geom/convex-cover.h index a5f95a5fb..d290b7e80 100644 --- a/src/2geom/convex-cover.h +++ b/src/2geom/convex-cover.h @@ -84,8 +84,9 @@ public: public: ConvexHull() {} - ConvexHull(std::vector<Point> const & points) { - boundary = points; + ConvexHull(std::vector<Point> const & points) : + boundary (points) + { graham(); } @@ -163,7 +164,7 @@ unsigned find_bottom_right(ConvexHull const &a); /*** Arbitrary transform operator. * Take a convex hull and apply an arbitrary convexity preserving transform. - * we should be concerned about singular transforms here. + * we should be concerned about singular tranforms here. */ template <class T> ConvexHull operator*(ConvexHull const &p, T const &m) { ConvexHull pr; diff --git a/src/2geom/crossing.cpp b/src/2geom/crossing.cpp index 379eb4b00..13affa8e9 100644 --- a/src/2geom/crossing.cpp +++ b/src/2geom/crossing.cpp @@ -154,7 +154,7 @@ Crossings reverse_tb(Crossings const &cr, unsigned split, std::vector<double> ma Crossings ret; for(Crossings::const_iterator i = cr.begin(); i != cr.end(); ++i) { double mx = max[i->b - split]; - //std::cout << i->b << "\n"; + std::cout << i->b << "\n"; ret.push_back(Crossing(i->ta, i->tb > mx+0.01 ? (1 - (i->tb - mx) + mx) : mx - i->tb, !i->dir)); } diff --git a/src/2geom/d2.h b/src/2geom/d2.h index ef88b2d68..5fc955854 100644 --- a/src/2geom/d2.h +++ b/src/2geom/d2.h @@ -150,7 +150,7 @@ template <typename T> inline bool are_near(D2<T> const &a, D2<T> const &b, double tol) { boost::function_requires<NearConcept<T> >(); - return are_near(a[0], b[0]) && are_near(a[1], b[1]); + return are_near(a[0], b[0], tol) && are_near(a[1], b[1], tol); } //IMPL: AddableConcept diff --git a/src/2geom/ellipse.h b/src/2geom/ellipse.h index 297254366..c971c6065 100644 --- a/src/2geom/ellipse.h +++ b/src/2geom/ellipse.h @@ -49,7 +49,10 @@ class Circle; class Ellipse { public: - Ellipse() + Ellipse(): + m_centre(), + m_ray(), + m_angle(0) {} Ellipse(double cx, double cy, double rx, double ry, double a) diff --git a/src/2geom/elliptical-arc.cpp b/src/2geom/elliptical-arc.cpp index d2cb0b707..c96d5f1a6 100644 --- a/src/2geom/elliptical-arc.cpp +++ b/src/2geom/elliptical-arc.cpp @@ -115,9 +115,11 @@ Rect EllipticalArc::boundsExact() const if ( arc_extremes[2] < arc_extremes[3] ) std::swap(arc_extremes[2], arc_extremes[3]); - for (unsigned i = 0; i < 4; ++i) { - if (containsAngle(extremes[i])) { - arc_extremes[i] = valueAtAngle(extremes[i], (i >> 1) ? Y : X); + if ( !are_near(initialPoint(), finalPoint()) ) { + for (unsigned i = 0; i < 4; ++i) { + if (containsAngle(extremes[i])) { + arc_extremes[i] = valueAtAngle(extremes[i], (i >> 1) ? Y : X); + } } } @@ -264,7 +266,7 @@ std::vector<Coord> EllipticalArc::roots(Coord v, Dim2 d) const } double rotx, roty; - sincos(_rot_angle, roty, rotx); + sincos(_rot_angle, roty, rotx); /// \todo sin and cos are calculated in many places in this function, optimize this a bit! if (d == X) roty = -roty; double rxrotx = ray(X) * rotx; @@ -569,7 +571,7 @@ std::vector<double> EllipticalArc::allNearestPoints( Point const& p, double from double mindistsq1 = std::numeric_limits<double>::max(); double mindistsq2 = std::numeric_limits<double>::max(); double dsq; - unsigned int mi1, mi2; + unsigned int mi1 = 0, mi2 = 0; for ( unsigned int i = 0; i < real_sol.size(); ++i ) { dsq = distanceSq(p, pointAtAngle(real_sol[i])); diff --git a/src/2geom/generic-rect.h b/src/2geom/generic-rect.h index eb9705a4b..bb6f2d2b8 100644 --- a/src/2geom/generic-rect.h +++ b/src/2geom/generic-rect.h @@ -261,7 +261,7 @@ public: expandBy(amount, amount); } /** @brief Expand the rectangle in both directions. - * Note that this is different from scaling. Negative values will shrink the + * Note that this is different from scaling. Negative values wil shrink the * rectangle. If <code>-x</code> is larger than * half of the width, the X interval will contain only the X coordinate * of the midpoint; same for height. */ diff --git a/src/2geom/interval.h b/src/2geom/interval.h index b1fac04d9..1714435be 100644 --- a/src/2geom/interval.h +++ b/src/2geom/interval.h @@ -114,9 +114,9 @@ public: /** @brief Check whether the interior of the interval includes the given interval. * Interior means all numbers in the interval except its ends. */ bool interiorContains(Interval const &val) const { return min() < val.min() && val.max() < max(); } - /** @brief Check whether the interiors of the intervals have any common elements. */ + /** @brief Check whether the interiors of the intervals have any common elements. A single point in common is not considered an intersection. */ bool interiorIntersects(Interval const &val) const { - return interiorContains(val.min()) || interiorContains(val.max()) || val.interiorContains(*this); + return std::max(min(), val.min()) < std::min(max(), val.max()); } /// @} diff --git a/src/2geom/linear.h b/src/2geom/linear.h index 6e5132e12..8c154364e 100644 --- a/src/2geom/linear.h +++ b/src/2geom/linear.h @@ -55,7 +55,7 @@ class SBasis; class Linear{ public: double a[2]; - Linear() {} + Linear() {a[0]=0; a[1]=0;} Linear(double aa, double b) {a[0] = aa; a[1] = b;} Linear(double aa) {a[0] = aa; a[1] = aa;} diff --git a/src/2geom/math-utils.h b/src/2geom/math-utils.h index 77280aa50..83c7b4f5e 100644 --- a/src/2geom/math-utils.h +++ b/src/2geom/math-utils.h @@ -40,6 +40,7 @@ #include <math.h> // sincos is usually only available in math.h #include <cmath> #include <utility> // for std::pair +#include <boost/math/special_functions/fpclassify.hpp> namespace Geom { @@ -49,6 +50,8 @@ namespace Geom { * @return -1 when x is negative, 1 when positive, and 0 if equal to 0. */ template <class T> inline int sgn(const T& x) { return (x < 0 ? -1 : (x > 0 ? 1 : 0) ); +// can we 'optimize' this with: +// return ( (T(0) < x) - (x < T(0)) ); } template <class T> inline T sqr(const T& x) {return x * x;} @@ -111,7 +114,7 @@ inline void sincos(double angle, double &sin_, double &cos_) { #elif defined (SOLARIS_2_8) && __GNUC__ == 3 && __GNUC_MINOR__ == 2 # define IS_NAN(_a) (isnan(_a)) /* GNU definition */ #else -# define IS_NAN(_a) (std::isnan(_a)) +# define IS_NAN(_a) (boost::math::isnan(_a)) #endif /* If the above doesn't work, then try (a != a). */ @@ -130,7 +133,7 @@ inline void sincos(double angle, double &sin_, double &cos_) { #include <ieeefp.h> #define IS_FINITE(_a) (finite(_a) && !IS_NAN(_a)) #else -# define IS_FINITE(_a) (std::isfinite(_a)) +# define IS_FINITE(_a) (boost::math::isfinite(_a)) #endif } // end namespace Geom diff --git a/src/2geom/nearest-point.cpp b/src/2geom/nearest-point.cpp index 68a863434..c5dfc133c 100644 --- a/src/2geom/nearest-point.cpp +++ b/src/2geom/nearest-point.cpp @@ -66,10 +66,9 @@ double nearest_point( Point const& p, double closest = from; double min_dist_sq = L2sq(c(from) - p); - double distsq; - for ( unsigned int i = 0; i < zeros.size(); ++i ) + for ( size_t i = 0; i < zeros.size(); ++i ) { - distsq = L2sq(c(zeros[i]) - p); + double distsq = L2sq(c(zeros[i]) - p); if ( min_dist_sq > L2sq(c(zeros[i]) - p) ) { closest = zeros[i]; diff --git a/src/2geom/ord.h b/src/2geom/ord.h index ce524ebf7..0add83da4 100644 --- a/src/2geom/ord.h +++ b/src/2geom/ord.h @@ -43,7 +43,7 @@ enum Cmp { EQUAL_TO=0 }; -inline Cmp operator-(Cmp x) { +static inline Cmp operator-(Cmp x) { switch(x) { case LESS_THAN: return GREATER_THAN; diff --git a/src/2geom/path-intersection.cpp b/src/2geom/path-intersection.cpp index 494a25843..ff24b92eb 100644 --- a/src/2geom/path-intersection.cpp +++ b/src/2geom/path-intersection.cpp @@ -113,11 +113,12 @@ int winding(Path const &path, Point p) { */ bool path_direction(Path const &p) { if(p.empty()) return false; + + /*goto doh; //could probably be more efficient, but this is a quick job double y = p.initialPoint()[Y]; double x = p.initialPoint()[X]; Cmp res = cmp(p[0].finalPoint()[Y], y); - /*goto doh; for(unsigned i = 1; i < p.size(); i++) { Cmp final_to_ray = cmp(p[i].finalPoint()[Y], y); Cmp initial_to_ray = cmp(p[i].initialPoint()[Y], y); @@ -271,9 +272,9 @@ intersect_polish_root (Curve const &A, double &s, Curve const &B, double &t) } #ifdef HAVE_GSL - int status; - size_t iter = 0; if(0) { // the GSL version is more accurate, but taints this with GPL + int status; + size_t iter = 0; const size_t n = 2; struct rparams p = {A, B}; gsl_multiroot_function f = {&intersect_polish_f, n, &p}; diff --git a/src/2geom/svg-path.cpp b/src/2geom/path-sink.cpp index d459b3e1b..6acd9508c 100644 --- a/src/2geom/svg-path.cpp +++ b/src/2geom/path-sink.cpp @@ -29,45 +29,45 @@ */ #include <2geom/sbasis-to-bezier.h> -#include <2geom/svg-path.h> +#include <2geom/path-sink.h> #include <2geom/exception.h> namespace Geom { -void output(Curve const &curve, SVGPathSink &sink) { +void output(Curve const &curve, PathSink &sink) { std::vector<Point> pts; sbasis_to_bezier(pts, curve.toSBasis(), 2); //TODO: use something better! sink.curveTo(pts[0], pts[1], pts[2]); } -void output(HLineSegment const &curve, SVGPathSink &sink) { +void output(HLineSegment const &curve, PathSink &sink) { sink.hlineTo(curve.finalPoint()[X]); } -void output(VLineSegment const &curve, SVGPathSink &sink) { +void output(VLineSegment const &curve, PathSink &sink) { sink.vlineTo(curve.finalPoint()[Y]); } -void output(LineSegment const &curve, SVGPathSink &sink) { +void output(LineSegment const &curve, PathSink &sink) { sink.lineTo(curve[1]); } -void output(CubicBezier const &curve, SVGPathSink &sink) { +void output(CubicBezier const &curve, PathSink &sink) { sink.curveTo(curve[1], curve[2], curve[3]); } -void output(QuadraticBezier const &curve, SVGPathSink &sink) { +void output(QuadraticBezier const &curve, PathSink &sink) { sink.quadTo(curve[1], curve[2]); } -void output(SVGEllipticalArc const &curve, SVGPathSink &sink) { +void output(SVGEllipticalArc const &curve, PathSink &sink) { sink.arcTo( curve.ray(X), curve.ray(Y), curve.rotationAngle(), curve.largeArc(), curve.sweep(), curve.finalPoint() ); } template <typename T> -bool output_as(Curve const &curve, SVGPathSink &sink) { +bool output_as(Curve const &curve, PathSink &sink) { T const *t = dynamic_cast<T const *>(&curve); if (t) { output(*t, sink); @@ -77,24 +77,32 @@ bool output_as(Curve const &curve, SVGPathSink &sink) { } } -void output_svg_path(Path &path, SVGPathSink &sink) { - sink.moveTo(path.front().initialPoint()); - - Path::iterator iter; - for ( iter = path.begin() ; iter != path.end() ; ++iter ) { - output_as<HLineSegment>(*iter, sink) || - output_as<VLineSegment>(*iter, sink) || - output_as<LineSegment>(*iter, sink) || - output_as<CubicBezier>(*iter, sink) || - output_as<QuadraticBezier>(*iter, sink) || - output_as<SVGEllipticalArc>(*iter, sink) || - output_as<Curve>(*iter, sink); +void PathSink::path(Path const &path) { + flush(); + moveTo(path.front().initialPoint()); + + Path::const_iterator iter; + for (iter = path.begin(); iter != path.end(); ++iter) { + output_as<HLineSegment>(*iter, *this) || + output_as<VLineSegment>(*iter, *this) || + output_as<LineSegment>(*iter, *this) || + output_as<CubicBezier>(*iter, *this) || + output_as<QuadraticBezier>(*iter, *this) || + output_as<SVGEllipticalArc>(*iter, *this) || + output_as<Curve>(*iter, *this); } if (path.closed()) { - sink.closePath(); + closePath(); + } + flush(); +} + +void PathSink::pathvector(PathVector const &pv) { + flush(); + for (PathVector::const_iterator i = pv.begin(); i != pv.end(); ++i) { + path(*i); } - sink.finish(); } } diff --git a/src/2geom/svg-path.h b/src/2geom/path-sink.h index c22f65d11..949369b80 100644 --- a/src/2geom/svg-path.h +++ b/src/2geom/path-sink.h @@ -1,7 +1,7 @@ /** * \file * \brief callback interface for SVG path data - * + *//* * Copyright 2007 MenTaLguY <mental@rydia.net> * * This library is free software; you can redistribute it and/or @@ -32,41 +32,78 @@ #ifndef SEEN_SVG_PATH_H #define SEEN_SVG_PATH_H -#include <2geom/path.h> +#include <2geom/pathvector.h> #include <2geom/curves.h> #include <iterator> namespace Geom { -class SVGPathSink { + +/** @brief Callback interface for processing path data. + * + * PathSink provides an interface that allows one to easily write + * code which processes path data, for instance when converting + * between path formats used by different graphics libraries. + * + * To store a path in a new format, implement the virtual methods + * for segments in a derived class and call path() or pathvector(). + */ +class PathSink { public: - virtual void moveTo(Point p) = 0; + /** Move to a different point without creating a segment. + * Usually starts a new subpath. */ + virtual void moveTo(Point const &p) = 0; + /// Output a horizontal line segment. Only the X coordinate of the final point is given. virtual void hlineTo(Coord v) = 0; + /// Output a vertical line segment. Only the Y coordinate of the final point is given. virtual void vlineTo(Coord v) = 0; - virtual void lineTo(Point p) = 0; - virtual void curveTo(Point c0, Point c1, Point p) = 0; - virtual void quadTo(Point c, Point p) = 0; + /// Output a line segment. + virtual void lineTo(Point const &p) = 0; + /// Output a quadratic Bezier segment. + virtual void curveTo(Point const &c0, Point const &c1, Point const &p) = 0; + /// Output a cubic Bezier segment. + virtual void quadTo(Point const &c, Point const &p) = 0; + /** Output an elliptical arc segment. + * See the EllipticalArc class for the documentation of parameters. */ virtual void arcTo(double rx, double ry, double angle, - bool large_arc, bool sweep, Point p) = 0; - - /** Undo the last lineTo, curveTo, etc. call. */ - virtual void backspace() = 0; + bool large_arc, bool sweep, Point const &p) = 0; + /// Close the current path with a line segment. virtual void closePath() = 0; - virtual void finish() = 0; - virtual ~SVGPathSink() {} + /** Flush any internal state of the generator. + * + * This call should implicitly finish the current subpath. + * Calling this method should be idempotent, because the default + * implementations of path() and pathvector() will be call it + * multiple times in a row. */ + virtual void flush() = 0; + + /** Undo the last segment. + * This method is optional. + * @return true true if a segment was erased, false otherwise. */ + virtual bool backspace() { return false; } + + // these have a default implementation + /** Output a subpath. + * Calls the appropriate segment methods according to the contents + * of the passed subpath. You can override this function. */ + virtual void path(Path const &p); + /** Output a path. + * Calls the appropriate segment methods according to the contents + * of the passed path. You can override this function. */ + virtual void pathvector(PathVector const &v); + + virtual ~PathSink() {} }; -void output_svg_path(Path &path, SVGPathSink &sink); - template <typename OutputIterator> -class SVGPathGenerator : public SVGPathSink { +class PathIteratorSink : public PathSink { public: - explicit SVGPathGenerator(OutputIterator out) + explicit PathIteratorSink(OutputIterator out) : _in_path(false), _out(out) {} - void moveTo(Point p) { - finish(); + void moveTo(Point const &p) { + flush(); _path.start(p); _start_p = p; _in_path = true; @@ -89,7 +126,7 @@ public: _path.template appendNew<VLineSegment>(Point(_path.finalPoint()[X], v)); } - void lineTo(Point p) { + void lineTo(Point const &p) { // check for implicit moveto, like in: "M 1,1 L 2,2 z l 2,2 z" if (!_in_path) { moveTo(_start_p); @@ -97,7 +134,7 @@ public: _path.template appendNew<LineSegment>(p); } - void quadTo(Point c, Point p) { + void quadTo(Point const &c, Point const &p) { // check for implicit moveto, like in: "M 1,1 L 2,2 z l 2,2 z" if (!_in_path) { moveTo(_start_p); @@ -105,7 +142,7 @@ public: _path.template appendNew<QuadraticBezier>(c, p); } - void curveTo(Point c0, Point c1, Point p) { + void curveTo(Point const &c0, Point const &c1, Point const &p) { // check for implicit moveto, like in: "M 1,1 L 2,2 z l 2,2 z" if (!_in_path) { moveTo(_start_p); @@ -114,7 +151,7 @@ public: } void arcTo(double rx, double ry, double angle, - bool large_arc, bool sweep, Point p) + bool large_arc, bool sweep, Point const &p) { // check for implicit moveto, like in: "M 1,1 L 2,2 z l 2,2 z" if (!_in_path) { @@ -124,11 +161,13 @@ public: large_arc, sweep, p); } - void backspace() + bool backspace() { if (_in_path && _path.size() > 0) { _path.erase_last(); + return true; } + return false; } void append(Path const &other, Path::Stitching stitching = Path::NO_STITCHING) @@ -141,18 +180,24 @@ public: void closePath() { _path.close(); - finish(); + flush(); } - void finish() { + void flush() { if (_in_path) { _in_path = false; - *_out = _path; + *_out++ = _path; _path.clear(); _path.close(false); } } + void path(Path const &other) + { + flush(); + *_out++ = other; + } + protected: bool _in_path; OutputIterator _out; @@ -162,11 +207,11 @@ protected: typedef std::back_insert_iterator<std::vector<Path> > iter; -class PathBuilder : public SVGPathGenerator<iter> { +class PathBuilder : public PathIteratorSink<iter> { private: std::vector<Path> _pathset; public: - PathBuilder() : SVGPathGenerator<iter>(iter(_pathset)) {} + PathBuilder() : PathIteratorSink<iter>(iter(_pathset)) {} std::vector<Path> const &peek() const {return _pathset;} }; diff --git a/src/2geom/path.cpp b/src/2geom/path.cpp index 857028ccd..93def6c55 100644 --- a/src/2geom/path.cpp +++ b/src/2geom/path.cpp @@ -347,16 +347,15 @@ void Path::do_update(Sequence::iterator first_replaced, } void Path::do_append(Curve *c) { - boost::shared_ptr<Curve> curve(c); if ( get_curves().front().get() == final_ ) { - final_->setPoint(1, curve->initialPoint()); + final_->setPoint(1, c->initialPoint()); } else { - if (curve->initialPoint() != finalPoint()) { + if (c->initialPoint() != finalPoint()) { THROW_CONTINUITYERROR(); } } - get_curves().insert(get_curves().end()-1, curve); - final_->setPoint(0, curve->finalPoint()); + get_curves().insert(get_curves().end()-1, boost::shared_ptr<Curve>(c)); + final_->setPoint(0, c->finalPoint()); } void Path::stitch(Sequence::iterator first_replaced, diff --git a/src/2geom/pathvector.h b/src/2geom/pathvector.h index 791cb0703..e875e915f 100644 --- a/src/2geom/pathvector.h +++ b/src/2geom/pathvector.h @@ -108,7 +108,10 @@ struct PathVectorPosition { // pathvector[path_nr].pointAt(t) is the position unsigned int path_nr; double t; - PathVectorPosition() {} + PathVectorPosition() : + path_nr(0), + t(0) + {} PathVectorPosition(unsigned int path_nr, double t) : path_nr(path_nr), t(t) {} }; diff --git a/src/2geom/piecewise.h b/src/2geom/piecewise.h index e3b4d3456..ab8417254 100644 --- a/src/2geom/piecewise.h +++ b/src/2geom/piecewise.h @@ -34,6 +34,7 @@ #include <vector> #include <map> +#include <utility> #include <boost/concept_check.hpp> #include <2geom/concepts.h> #include <2geom/math-utils.h> @@ -92,8 +93,8 @@ class Piecewise { inline void reserve(unsigned i) { segs.reserve(i); cuts.reserve(i + 1); } - inline T operator[](unsigned i) const { return segs[i]; } - inline T &operator[](unsigned i) { return segs[i]; } + inline T const& operator[](unsigned i) const { return segs[i]; } + inline T& operator[](unsigned i) { return segs[i]; } inline output_type operator()(double t) const { return valueAt(t); } inline output_type valueAt(double t) const { unsigned n = segN(t); @@ -139,6 +140,13 @@ class Piecewise { push_seg(s); push_cut(to); } +#ifdef CPP11 + inline void push(T &&s, double to) { + assert(cuts.size() - segs.size() == 1); + push_seg(s); + push_cut(to); + } +#endif //Convenience/implementation hiding function to add cuts. inline void push_cut(double c) { ASSERT_INVARIANTS(cuts.empty() || c > cuts.back()); @@ -146,6 +154,9 @@ class Piecewise { } //Convenience/implementation hiding function to add segments. inline void push_seg(const T &s) { segs.push_back(s); } +#ifdef CPP11 + inline void push_seg(T &&s) { segs.emplace_back(s); } +#endif /**Returns the segment index which corresponds to a 'global' piecewise time. * Also takes optional low/high parameters to expedite the search for the segment. diff --git a/src/2geom/point.cpp b/src/2geom/point.cpp index 3ad9dd1fd..b0b00b5da 100644 --- a/src/2geom/point.cpp +++ b/src/2geom/point.cpp @@ -57,11 +57,10 @@ namespace Geom { * @code p += q; p -= q; r = p + q; r = p - q; p *= s; p /= s; q = p * s; q = s * p; q = p / s; - p *= m; p /= m; q = p * m; q = m * p; q = p / m; + p *= m; q = p * m; q = m * p; @endcode * It is possible to left-multiply a point by a matrix, even though mathematically speaking * this is undefined. The result is a point identical to that obtained by right-multiplying. - * Division of points by matrices is defined as multiplication by their inverses. * * @ingroup Primitives */ @@ -127,7 +126,7 @@ Coord L1(Point const &p) { } /** @brief Compute the infinity norm (maximum norm) of @a p. - * @return \f$\max(p_X, p_Y)\f$ + * @return \f$\max(|p_X|, |p_Y|)\f$ * @relates Point */ Coord LInfty(Point const &p) { Coord const a(fabs(p[0])); @@ -231,7 +230,7 @@ Point constrain_angle(Point const &A, Point const &B, unsigned int n, Point cons return A + dir * Rotate(k * 2.0 * M_PI / (double)n) * L2(diff); } -} //namespace Geom +} // end namespace Geom /* Local Variables: diff --git a/src/2geom/point.h b/src/2geom/point.h index 0eb771874..23dcfd54f 100644 --- a/src/2geom/point.h +++ b/src/2geom/point.h @@ -78,15 +78,6 @@ public: _pt[X] = p[X]; _pt[Y] = p[Y]; } - Point(Point const &p) { - for (unsigned i = 0; i < 2; ++i) - _pt[i] = p._pt[i]; - } - Point &operator=(Point const &p) { - for (unsigned i = 0; i < 2; ++i) - _pt[i] = p._pt[i]; - return *this; - } /** @brief Construct a point from its polar coordinates. * The angle is specified in radians, in the mathematical convention (increasing * counter-clockwise from +X). */ diff --git a/src/2geom/recursive-bezier-intersection.cpp b/src/2geom/recursive-bezier-intersection.cpp index 7db0438a7..0c7977970 100644 --- a/src/2geom/recursive-bezier-intersection.cpp +++ b/src/2geom/recursive-bezier-intersection.cpp @@ -81,14 +81,13 @@ const double INV_EPS = (1L<<14); */ void OldBezier::split(double t, OldBezier &left, OldBezier &right) const { const unsigned sz = p.size(); - - Geom::Point **Vtemp = new Geom::Point* [sz]; - - for (unsigned int i = 0; i < sz; ++i) - Vtemp[i] = new Geom::Point[sz]; + //Geom::Point Vtemp[sz][sz]; + std::vector< std::vector< Geom::Point > > Vtemp; + for (size_t i = 0; i < sz; ++i ) + Vtemp[i].reserve(sz); /* Copy control points */ - std::copy(p.begin(), p.end(), Vtemp[0]); + std::copy(p.begin(), p.end(), Vtemp[0].begin()); /* Triangle computation */ for (unsigned i = 1; i < sz; i++) { @@ -103,11 +102,6 @@ void OldBezier::split(double t, OldBezier &left, OldBezier &right) const { left.p[j] = Vtemp[j][0]; for (unsigned j = 0; j < sz; j++) right.p[j] = Vtemp[sz-1-j][j]; - - for (unsigned int i = 0; i < sz; ++i) - delete[] Vtemp[i]; - - delete[] Vtemp; } #if 0 @@ -134,17 +128,15 @@ Point OldBezier::operator()(double t) const { #endif // suggested by Sederberg. -Point OldBezier::operator()(double t) const { - int n = p.size()-1; - double u, bc, tn, tmp; - int i; +Point OldBezier::operator()(double const t) const { + size_t const n = p.size()-1; Point r; for(int dim = 0; dim < 2; dim++) { - u = 1.0 - t; - bc = 1; - tn = 1; - tmp = p[0][dim]*u; - for(i=1; i<n; i++){ + double const u = 1.0 - t; + double bc = 1; + double tn = 1; + double tmp = p[0][dim]*u; + for(size_t i=1; i<n; i++){ tn = tn*t; bc = bc*(n-i+1)/i; tmp = (tmp + tn*bc*p[i][dim])*u; @@ -183,8 +175,8 @@ bool intersect_BB( OldBezier a, OldBezier b ) { b.bounds(minbx, maxbx, minby, maxby); // Test bounding box of b against bounding box of a // Not >= : need boundary case - return not( ( minax > maxbx ) || ( minay > maxby ) - || ( minbx > maxax ) || ( minby > maxay ) ); + return !( ( minax > maxbx ) || ( minay > maxby ) + || ( minbx > maxax ) || ( minby > maxay ) ); } /* diff --git a/src/2geom/sbasis-geometric.cpp b/src/2geom/sbasis-geometric.cpp index 74827e27c..4c474f7f0 100644 --- a/src/2geom/sbasis-geometric.cpp +++ b/src/2geom/sbasis-geometric.cpp @@ -1,4 +1,5 @@ /** Geometric operators on D2<SBasis> (1D->2D). + * Copyright 2012 JBC Engelen * Copyright 2007 JF Barraud * Copyright 2007 N Hurst * @@ -18,7 +19,6 @@ #include <2geom/sbasis-geometric.h> #include <2geom/sbasis.h> #include <2geom/sbasis-math.h> -//#include <2geom/solver.h> #include <2geom/sbasis-geometric.h> //namespace Geom{ @@ -363,7 +363,6 @@ Geom::length(Piecewise<D2<SBasis> > const &M, Piecewise<SBasis> Geom::curvature(D2<SBasis> const &M, double tol) { D2<SBasis> dM=derivative(M); - Piecewise<SBasis> result; Piecewise<D2<SBasis> > unitv = unitVector(dM,tol); Piecewise<SBasis> dMlength = dot(Piecewise<D2<SBasis> >(dM),unitv); Piecewise<SBasis> k = cross(derivative(unitv),unitv); @@ -436,11 +435,10 @@ Geom::arc_length_parametrization(Piecewise<D2<SBasis> > const &M, unsigned order, double tol){ Piecewise<D2<SBasis> > result; - for (unsigned i=0; i<M.size(); i++ ){ - Piecewise<D2<SBasis> > uniform_seg=arc_length_parametrization(M[i],order,tol); - result.concat(uniform_seg); + for (unsigned i=0; i<M.size(); i++) { + result.concat( arc_length_parametrization(M[i],order,tol) ); } - return(result); + return result; } #include <gsl/gsl_integration.h> diff --git a/src/2geom/sbasis-to-bezier.cpp b/src/2geom/sbasis-to-bezier.cpp index 8e47580ce..bd88f93c0 100644 --- a/src/2geom/sbasis-to-bezier.cpp +++ b/src/2geom/sbasis-to-bezier.cpp @@ -35,7 +35,7 @@ #include <2geom/sbasis-to-bezier.h> #include <2geom/d2.h> #include <2geom/choose.h> -#include <2geom/svg-path.h> +#include <2geom/path-sink.h> #include <2geom/exception.h> #include <iostream> @@ -180,6 +180,118 @@ void sbasis_to_bezier (std::vector<Point> & bz, D2<SBasis> const& sb, size_t sz) } } +/** Changes the basis of p to be Bernstein. + \param p the D2 Symmetric basis polynomial + \returns the D2 Bernstein basis cubic polynomial + +Bezier is always cubic. +For general asymmetric case, fit the SBasis function value at midpoint +For parallel, symmetric case, find the point of closest approach to the midpoint +For parallel, anti-symmetric case, fit the SBasis slope at midpoint +*/ +void sbasis_to_cubic_bezier (std::vector<Point> & bz, D2<SBasis> const& sb) +{ + double delx[2], dely[2]; + double xprime[2], yprime[2]; + double midx = 0; + double midy = 0; + double numer; + double denom; + double div; + + if ((sb[X].size() == 0) || (sb[Y].size() == 0)) { + THROW_RANGEERROR("size of sb is too small"); + } + + bz.resize(4, Point(0,0)); + bz[0][X] = sb[X][0][0]; + bz[0][Y] = sb[Y][0][0]; + bz[3][X] = sb[X][0][1]; + bz[3][Y] = sb[Y][0][1]; + +// calculate first derivatives of x and y wrt t + + for (int i = 0; i < 2; ++i) { + xprime[i] = sb[X][0][1] - sb[X][0][0]; + yprime[i] = sb[Y][0][1] - sb[Y][0][0]; + } + if (sb[X].size() > 0) { + xprime[0] += sb[X][1][0]; + xprime[1] -= sb[X][1][1]; + } + if (sb[Y].size() > 0) { + yprime[0] += sb[Y][1][0]; + yprime[1] -= sb[Y][1][1]; + } + +// calculate midpoint at t = 0.5 + + div = 2; + for (size_t i = 0; i < sb[X].size(); ++i) { + midx += (sb[X][i][0] + sb[X][i][1])/div; + div *= 4; + } + midx = 8*midx - 4*bz[0][X] - 4*bz[3][X]; + + div = 2; + for (size_t i = 0; i < sb[Y].size(); ++i) { + midy += (sb[Y][i][0] + sb[Y][i][1])/div; + div *= 4; + } + midy = 8*midy - 4*bz[0][Y] - 4*bz[3][Y]; + +// calculate Bezier control arms + + if (std::abs(xprime[1]*yprime[0] - yprime[1]*xprime[0]) > 1.e-5) { // general case : fit mid fxn value + denom = xprime[1]*yprime[0] - yprime[1]*xprime[0]; + for (int i = 0; i < 2; ++i) { + numer = xprime[1 - i]*midy - yprime[1 - i]*midx; + delx[i] = xprime[i]*numer/denom/3; + dely[i] = yprime[i]*numer/denom/3; + } + } + else if ((xprime[0]*xprime[1] < 0) || (yprime[0]*yprime[1] < 0)) { // symmetric case : use distance of closest approach + numer = midx*xprime[0] + midy*yprime[0]; + denom = 6.0*(xprime[0]*xprime[0] + yprime[0]*yprime[0]); + delx[0] = xprime[0]*numer/denom; + dely[0] = yprime[0]*numer/denom; + delx[1] = -delx[0]; + dely[1] = -dely[0]; + } + else { // anti-symmetric case : fit mid slope + // calculate slope at t = 0.5 + midx = 0; + div = 1; + for (size_t i = 0; i < sb[X].size(); ++i) { + midx += (sb[X][i][1] - sb[X][i][0])/div; + div *= 4; + } + midy = 0; + div = 1; + for (size_t i = 0; i < sb[Y].size(); ++i) { + midy += (sb[Y][i][1] - sb[Y][i][0])/div; + div *= 4; + } + if (midx*yprime[0] != midy*xprime[0]) { + denom = midx*yprime[0] - midy*xprime[0]; + numer = midx*(bz[3][Y] - bz[0][Y]) - midy*(bz[3][X] - bz[0][X]); + for (int i = 0; i < 2; ++i) { + delx[i] = xprime[0]*numer/denom; + dely[i] = yprime[0]*numer/denom; + } + } + else { // linear case + for (int i = 0; i < 2; ++i) { + delx[i] = (bz[3][X] - bz[0][X])/3; + dely[i] = (bz[3][Y] - bz[0][Y])/3; + } + } + } + bz[1][X] = bz[0][X] + delx[0]; + bz[1][Y] = bz[0][Y] + dely[0]; + bz[2][X] = bz[3][X] - delx[1]; + bz[2][Y] = bz[3][Y] - dely[1]; +} /** Changes the basis of p to be sbasis. \param p the Bernstein basis polynomial @@ -347,12 +459,13 @@ void build_from_sbasis(Geom::PathBuilder &pb, D2<SBasis> const &B, double tol, b if (!B.isFinite()) { THROW_EXCEPTION("assertion failed: B.isFinite()"); } - if(tail_error(B, 2) < tol || sbasis_size(B) == 2) { // nearly cubic enough + if(tail_error(B, 3) < tol || sbasis_size(B) == 2) { // nearly cubic enough if( !only_cubicbeziers && (sbasis_size(B) <= 1) ) { pb.lineTo(B.at1()); } else { std::vector<Geom::Point> bez; - sbasis_to_bezier(bez, B, 4); +// sbasis_to_bezier(bez, B, 4); + sbasis_to_cubic_bezier(bez, B); pb.curveTo(bez[1], bez[2], bez[3]); } } else { @@ -372,7 +485,7 @@ path_from_sbasis(D2<SBasis> const &B, double tol, bool only_cubicbeziers) { PathBuilder pb; pb.moveTo(B.at0()); build_from_sbasis(pb, B, tol, only_cubicbeziers); - pb.finish(); + pb.flush(); return pb.peek().front(); } @@ -414,7 +527,7 @@ path_from_piecewise(Geom::Piecewise<Geom::D2<Geom::SBasis> > const &B, double to build_from_sbasis(pb, B[i], tol, only_cubicbeziers); } } - pb.finish(); + pb.flush(); return pb.peek(); } diff --git a/src/2geom/sbasis-to-bezier.h b/src/2geom/sbasis-to-bezier.h index b386bd520..07511f4a4 100644 --- a/src/2geom/sbasis-to-bezier.h +++ b/src/2geom/sbasis-to-bezier.h @@ -46,6 +46,7 @@ class PathBuilder; void sbasis_to_bezier (Bezier & bz, SBasis const& sb, size_t sz = 0); void sbasis_to_bezier (std::vector<Point> & bz, D2<SBasis> const& sb, size_t sz = 0); +void sbasis_to_cubic_bezier (std::vector<Point> & bz, D2<SBasis> const& sb); void bezier_to_sbasis (SBasis & sb, Bezier const& bz); void bezier_to_sbasis (D2<SBasis> & sb, std::vector<Point> const& bz); void build_from_sbasis(PathBuilder &pb, D2<SBasis> const &B, double tol, bool only_cubicbeziers); diff --git a/src/2geom/solve-bezier-one-d.cpp b/src/2geom/solve-bezier-one-d.cpp index f14f701d0..3d87d4926 100644 --- a/src/2geom/solve-bezier-one-d.cpp +++ b/src/2geom/solve-bezier-one-d.cpp @@ -92,11 +92,10 @@ void Bernsteins::find_bernstein_roots(double const *w, /* The control points */ int old_sign = SGN(w[0]); //std::cout << "w[0] = " << w[0] << std::endl; - int sign; for (size_t i = 1; i < N; i++) { //std::cout << "w[" << i << "] = " << w[i] << std::endl; - sign = SGN(w[i]); + int sign = SGN(w[i]); if (sign != 0) { if (sign != old_sign && old_sign != 0) @@ -128,14 +127,14 @@ void Bernsteins::find_bernstein_roots(double const *w, /* The control points */ double s = 0, t = 1; double e = 1e-10; int side = 0; - double r, fr, fs = w[0], ft = w[degree]; + double r, fs = w[0], ft = w[degree]; for (size_t n = 0; n < 100; ++n) { r = (fs*t - ft*s) / (fs - ft); if (fabs(t-s) < e * fabs(t+s)) break; - fr = horner(w, r); + double fr = horner(w, r); if (fr * ft > 0) { diff --git a/src/2geom/solve-bezier-parametric.cpp b/src/2geom/solve-bezier-parametric.cpp index ed693c584..9b0feaee4 100644 --- a/src/2geom/solve-bezier-parametric.cpp +++ b/src/2geom/solve-bezier-parametric.cpp @@ -68,20 +68,16 @@ find_parametric_bezier_roots(Geom::Point const *w, /* The control points */ break; } - /* - * Otherwise, solve recursively after subdividing control polygon - * New left and right control polygons - */ - Geom::Point *Left = new Geom::Point[degree+1]; - Geom::Point *Right = new Geom::Point[degree+1]; - - Bezier(w, degree, 0.5, Left, Right); - total_subs ++; - find_parametric_bezier_roots(Left, degree, solutions, depth+1); - find_parametric_bezier_roots(Right, degree, solutions, depth+1); + /* Otherwise, solve recursively after subdividing control polygon */ + + //Geom::Point Left[degree+1], /* New left and right */ + // Right[degree+1]; /* control polygons */ + std::vector<Geom::Point> Left( degree+1 ), Right(degree+1); - delete[] Left; - delete[] Right; + Bezier(w, degree, 0.5, Left.data(), Right.data()); + total_subs ++; + find_parametric_bezier_roots(Left.data(), degree, solutions, depth+1); + find_parametric_bezier_roots(Right.data(), degree, solutions, depth+1); } @@ -130,7 +126,8 @@ control_poly_flat_enough(Geom::Point const *V, /* Control points */ const double abSquared = (a * a) + (b * b); - double distance[degree]; /* Distances from pts to line */ + //double distance[degree]; /* Distances from pts to line */ + std::vector<double> distance(degree); /* Distances from pts to line */ for (unsigned i = 1; i < degree; i++) { /* Compute distance from each of the points to that line */ double & dist(distance[i-1]); @@ -198,13 +195,13 @@ Bezier(Geom::Point const *V, /* Control pts */ Geom::Point *Left, /* RETURN left half ctl pts */ Geom::Point *Right) /* RETURN right half ctl pts */ { - Geom::Point **Vtemp = new Geom::Point* [degree+1]; - - for (unsigned int i = 0; i < degree+1; ++i) - Vtemp[i] = new Geom::Point[degree+1]; + //Geom::Point Vtemp[degree+1][degree+1]; + std::vector<std::vector<Geom::Point> > Vtemp(degree+1); + for ( size_t i = 0; i < degree + 1; ++i ) + Vtemp.reserve(degree+1); /* Copy control points */ - std::copy(V, V+degree+1, Vtemp[0]); + std::copy(V, V+degree+1, Vtemp[0].begin()); /* Triangle computation */ for (unsigned i = 1; i <= degree; i++) { @@ -218,14 +215,7 @@ Bezier(Geom::Point const *V, /* Control pts */ for (unsigned j = 0; j <= degree; j++) Right[j] = Vtemp[degree-j][j]; - Geom::Point return_value = Vtemp[degree][0]; - - for (unsigned int i = 0; i < degree+1; ++i) - delete[] Vtemp[i]; - - delete[] Vtemp; - - return return_value; + return (Vtemp[degree][0]); } }; diff --git a/src/2geom/solve-bezier.cpp b/src/2geom/solve-bezier.cpp index 09f8d9289..adf3c9ac0 100644 --- a/src/2geom/solve-bezier.cpp +++ b/src/2geom/solve-bezier.cpp @@ -80,7 +80,7 @@ void convex_hull_marching(Bezier src_bz, Bezier bz, double left_t, double right_t) { - while(bz.order() > 0 and bz[0] == 0) { + while(bz.order() > 0 && bz[0] == 0) { std::cout << "deflate\n"; bz = bz.deflate(); solutions.push_back(left_t); @@ -89,12 +89,11 @@ void convex_hull_marching(Bezier src_bz, Bezier bz, int old_sign = SGN(bz[0]); - int sign; double left_bound = 0; double dt = 0; for (size_t i = 1; i < bz.size(); i++) { - sign = SGN(bz[i]); + int sign = SGN(bz[i]); if (sign != old_sign) { dt = double(i) / bz.order(); @@ -113,7 +112,7 @@ void convex_hull_marching(Bezier src_bz, Bezier bz, double new_left_t = left_bound * (right_t - left_t) + left_t; std::cout << "new_left_t = " << new_left_t << std::endl; Bezier bzr = subRight(src_bz, new_left_t); - while(bzr.order() > 0 and bzr[0] == 0) { + while(bzr.order() > 0 && bzr[0] == 0) { std::cout << "deflate\n"; bzr = bzr.deflate(); solutions.push_back(new_left_t); @@ -124,7 +123,7 @@ void convex_hull_marching(Bezier src_bz, Bezier bz, new_left_t, right_t); } else { std::cout << "epsilon reached\n"; - while(bzr.order() > 0 and fabs(bzr[0]) <= 1e-10) { + while(bzr.order() > 0 && fabs(bzr[0]) <= 1e-10) { std::cout << "deflate\n"; bzr = bzr.deflate(); std::cout << bzr << std::endl; @@ -182,11 +181,10 @@ void Bernsteins::find_bernstein_roots(Bezier bz, int old_sign = SGN(bz[0]); //std::cout << "w[0] = " << bz[0] << std::endl; - int sign; for (size_t i = 1; i < bz.size(); i++) { //std::cout << "w[" << i << "] = " << w[i] << std::endl; - sign = SGN(bz[i]); + int sign = SGN(bz[i]); if (sign != 0) { if (sign != old_sign && old_sign != 0) @@ -259,7 +257,7 @@ void Bernsteins::find_bernstein_roots(Bezier bz, debug(std::cout << "Solution is exactly on the subdivision point.\n"); debug(std::cout << Left << " , " << Right << std::endl); Left = reverse(Left); - while(Right.order() > 0 and fabs(Right[0]) <= 1e-10) { + while(Right.order() > 0 && fabs(Right[0]) <= 1e-10) { debug(std::cout << "deflate\n"); Right = Right.deflate(); Left = Left.deflate(); @@ -293,7 +291,7 @@ double Bernsteins::secant(Bezier bz) { double s = 0, t = 1; double e = 1e-14; int side = 0; - double r, fr, fs = bz.at0(), ft = bz.at1(); + double r, fs = bz.at0(), ft = bz.at1(); for (size_t n = 0; n < 100; ++n) { @@ -305,7 +303,7 @@ double Bernsteins::secant(Bezier bz) { return r; } - fr = horner(bz, r); + double fr = horner(bz, r); if (fr * ft > 0) { diff --git a/src/2geom/svg-elliptical-arc.cpp b/src/2geom/svg-elliptical-arc.cpp index 14a4b4f16..96a4f99d8 100644 --- a/src/2geom/svg-elliptical-arc.cpp +++ b/src/2geom/svg-elliptical-arc.cpp @@ -218,15 +218,23 @@ bool make_elliptical_arc::make_elliptiarc() if (svg_compliant_flag()) { +#ifdef CPP11 + std::unique_ptr<EllipticalArc> arc( e.arc(initial_point, inner_point, final_point, true) ); +#else std::auto_ptr<EllipticalArc> arc( e.arc(initial_point, inner_point, final_point, true) ); +#endif ea = *arc; } else { try { - std::auto_ptr<EllipticalArc> eap( - e.arc(initial_point, inner_point, final_point, false) ); +#ifdef CPP11 + std::unique_ptr<EllipticalArc> +#else + std::auto_ptr<EllipticalArc> +#endif + eap( e.arc(initial_point, inner_point, final_point, false) ); ea = *eap; } catch(RangeError const &exc) diff --git a/src/2geom/svg-path-parser.cpp b/src/2geom/svg-path-parser.cpp index 60a734ece..fa31b57b5 100644 --- a/src/2geom/svg-path-parser.cpp +++ b/src/2geom/svg-path-parser.cpp @@ -1,4 +1,5 @@ -#line 1 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" + +#line 1 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" /** * \file * \brief parse SVG path specifications @@ -46,7 +47,7 @@ namespace { class Parser { public: - Parser(SVGPathSink &sink) : _absolute(false), _sink(sink) {} + Parser(PathSink &sink) : _absolute(false), _sink(sink) {} void parse(char const *str) throw(SVGPathParseError); @@ -57,7 +58,7 @@ private: Point _cubic_tangent; Point _quad_tangent; std::vector<double> _params; - SVGPathSink &_sink; + PathSink &_sink; void _reset() { _absolute = false; @@ -140,7 +141,7 @@ private: }; -#line 144 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.cpp" +#line 145 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.cpp" static const char _svg_path_actions[] = { 0, 1, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 15, 1, @@ -956,7 +957,7 @@ static const short _svg_path_indicies[] = { 1, 0 }; -static const short _svg_path_trans_targs_wi[] = { +static const short _svg_path_trans_targs[] = { 270, 0, 1, 2, 193, 3, 4, 5, 194, 3, 4, 5, 194, 5, 194, 6, 7, 8, 195, 9, 204, 7, 8, 195, @@ -1048,7 +1049,7 @@ static const short _svg_path_trans_targs_wi[] = { 268, 269 }; -static const char _svg_path_trans_actions_wi[] = { +static const char _svg_path_trans_actions[] = { 15, 0, 0, 0, 0, 9, 47, 47, 47, 0, 1, 1, 1, 0, 0, 0, 3, 17, 3, 17, 0, 0, 1, 0, @@ -1145,7 +1146,8 @@ static const int svg_path_first_final = 270; static const int svg_path_en_main = 1; -#line 144 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" + +#line 144 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" void Parser::parse(char const *str) @@ -1158,12 +1160,12 @@ throw(SVGPathParseError) _reset(); -#line 1162 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.cpp" +#line 1164 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.cpp" { cs = svg_path_start; } -#line 1167 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.cpp" +#line 1169 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.cpp" { int _klen; unsigned int _trans; @@ -1192,7 +1194,7 @@ _resume: else if ( (*p) > *_mid ) _lower = _mid + 1; else { - _trans += (_mid - _keys); + _trans += (unsigned int)(_mid - _keys); goto _match; } } @@ -1215,7 +1217,7 @@ _resume: else if ( (*p) > _mid[1] ) _lower = _mid + 2; else { - _trans += ((_mid - _keys)>>1); + _trans += (unsigned int)((_mid - _keys)>>1); goto _match; } } @@ -1224,25 +1226,25 @@ _resume: _match: _trans = _svg_path_indicies[_trans]; - cs = _svg_path_trans_targs_wi[_trans]; + cs = _svg_path_trans_targs[_trans]; - if ( _svg_path_trans_actions_wi[_trans] == 0 ) + if ( _svg_path_trans_actions[_trans] == 0 ) goto _again; - _acts = _svg_path_actions + _svg_path_trans_actions_wi[_trans]; + _acts = _svg_path_actions + _svg_path_trans_actions[_trans]; _nacts = (unsigned int) *_acts++; while ( _nacts-- > 0 ) { switch ( *_acts++ ) { case 0: -#line 156 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" +#line 156 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" { start = p; } break; case 1: -#line 160 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" +#line 160 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" { char const *end=p; std::string buf(start, end); @@ -1251,55 +1253,55 @@ _match: } break; case 2: -#line 167 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" +#line 167 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" { _push(1.0); } break; case 3: -#line 171 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" +#line 171 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" { _push(0.0); } break; case 4: -#line 175 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" +#line 175 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" { _absolute = true; } break; case 5: -#line 179 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" +#line 179 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" { _absolute = false; } break; case 6: -#line 183 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" +#line 183 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" { _moveTo(_pop_point()); } break; case 7: -#line 187 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" +#line 187 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" { _lineTo(_pop_point()); } break; case 8: -#line 191 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" +#line 191 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" { _hlineTo(Point(_pop_coord(X), _current[Y])); } break; case 9: -#line 195 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" +#line 195 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" { _vlineTo(Point(_current[X], _pop_coord(Y))); } break; case 10: -#line 199 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" +#line 199 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" { Point p = _pop_point(); Point c1 = _pop_point(); @@ -1308,7 +1310,7 @@ _match: } break; case 11: -#line 206 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" +#line 206 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" { Point p = _pop_point(); Point c1 = _pop_point(); @@ -1316,7 +1318,7 @@ _match: } break; case 12: -#line 212 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" +#line 212 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" { Point p = _pop_point(); Point c = _pop_point(); @@ -1324,14 +1326,14 @@ _match: } break; case 13: -#line 218 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" +#line 218 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" { Point p = _pop_point(); _quadTo(_quad_tangent, p); } break; case 14: -#line 223 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" +#line 223 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" { Point point = _pop_point(); bool sweep = _pop_flag(); @@ -1344,16 +1346,16 @@ _match: } break; case 15: -#line 234 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" +#line 234 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" { _closePath(); } break; case 16: -#line 370 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" - {goto _out;} +#line 370 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" + {{p++; goto _out; }} break; -#line 1357 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.cpp" +#line 1359 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.cpp" } } @@ -1364,7 +1366,8 @@ _again: goto _resume; _out: {} } -#line 380 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" + +#line 380 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" if ( cs < svg_path_first_final ) { @@ -1374,12 +1377,12 @@ _again: } -void parse_svg_path(char const *str, SVGPathSink &sink) +void parse_svg_path(char const *str, PathSink &sink) throw(SVGPathParseError) { Parser parser(sink); parser.parse(str); - sink.finish(); + sink.flush(); } } @@ -1393,4 +1396,4 @@ throw(SVGPathParseError) fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/2geom/svg-path-parser.h b/src/2geom/svg-path-parser.h index 365287d8c..163fbe5c4 100644 --- a/src/2geom/svg-path-parser.h +++ b/src/2geom/svg-path-parser.h @@ -38,11 +38,11 @@ #include <stdexcept> #include <2geom/exception.h> #include <2geom/point.h> -#include <2geom/svg-path.h> +#include <2geom/path-sink.h> namespace Geom { -void parse_svg_path(char const *str, SVGPathSink &sink) throw(SVGPathParseError); +void parse_svg_path(char const *str, PathSink &sink) throw(SVGPathParseError); inline std::vector<Path> parse_svg_path(char const *str) throw(SVGPathParseError) { typedef std::vector<Path> Subpaths; @@ -50,13 +50,14 @@ inline std::vector<Path> parse_svg_path(char const *str) throw(SVGPathParseError Subpaths subpaths; Inserter iter(subpaths); - SVGPathGenerator<Inserter> generator(iter); + PathIteratorSink<Inserter> generator(iter); parse_svg_path(str, generator); return subpaths; } inline std::vector<Path> read_svgd_f(FILE * fi) throw(SVGPathParseError) { + /// @bug The 10kB length limit should be removed char input[1024 * 10]; fgets(input, 1024 * 10, fi); return parse_svg_path(input); diff --git a/src/2geom/toposweep.h b/src/2geom/toposweep.h index 428115dd3..b6a55b154 100644 --- a/src/2geom/toposweep.h +++ b/src/2geom/toposweep.h @@ -193,7 +193,7 @@ Areas filter_areas(PathVector const &ps, Areas const & areas, Z const &z) { if(areas[i].size() < 2) continue; //find a representative section unsigned rj = 0; - bool rev = are_near(areas[i][0]->fp, areas[i][1]->tp); + //bool rev = are_near(areas[i][0]->fp, areas[i][1]->tp); for(unsigned j = 1; j < areas[i].size(); j++) if(sorty(*areas[i][rj], *areas[i][j])) rj = j; if(sortx(*areas[i][rj], *areas[i][(rj+areas[i].size() - 1) % areas[i].size()])) { diff --git a/src/2geom/transforms.cpp b/src/2geom/transforms.cpp index 65df9b22f..091079d5a 100644 --- a/src/2geom/transforms.cpp +++ b/src/2geom/transforms.cpp @@ -164,6 +164,7 @@ void check_transforms() // notice that the first column is always the same and enumerates all transform types, // while the second one changes to each transform type in turn. + // cppcheck-suppress redundantAssignment m = t * t; m = t * s; m = t * r; m = t * h; m = t * v; m = t * z; m = s * t; m = s * s; m = s * r; m = s * h; m = s * v; m = s * z; m = r * t; m = r * s; m = r * r; m = r * h; m = r * v; m = r * z; diff --git a/src/2geom/utils.cpp b/src/2geom/utils.cpp index a40b7253d..83d93cc87 100644 --- a/src/2geom/utils.cpp +++ b/src/2geom/utils.cpp @@ -37,16 +37,15 @@ namespace Geom { // return a vector that contains all the binomial coefficients of degree n -void binomial_coefficients(std::vector<size_t>& bc, size_t n) +void binomial_coefficients(std::vector<size_t>& bc, std::size_t n) { size_t s = n+1; bc.clear(); bc.resize(s); bc[0] = 1; - size_t k; for (size_t i = 1; i < n; ++i) { - k = i >> 1; + size_t k = i >> 1; if (i & 1u) { bc[k+1] = bc[k] << 1; diff --git a/src/2geom/utils.h b/src/2geom/utils.h index 6a72d42c4..fe955dd41 100644 --- a/src/2geom/utils.h +++ b/src/2geom/utils.h @@ -41,7 +41,7 @@ namespace Geom { // proper logical xor inline bool logical_xor (bool a, bool b) { return (a || b) && !(a && b); } -void binomial_coefficients(std::vector<size_t>& bc, size_t n); +void binomial_coefficients(std::vector<size_t>& bc, std::size_t n); struct EmptyClass {}; diff --git a/src/Makefile.am b/src/Makefile.am index 2f91c3c24..7fbc135c5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -223,7 +223,7 @@ endif # someone updates the BZR working directory. inkscape-version.cpp: $(inkscape_version_deps) VER_PREFIX="$(VERSION)";\ - VER_BZRREV=" r`bzr revno`"; \ + VER_BZRREV=" r`bzr revno --tree`"; \ if test ! -z "`bzr status -S -V $(srcdir)`"; then \ VER_CUSTOM=" custom"; \ fi; \ diff --git a/src/desktop.cpp b/src/desktop.cpp index 195127ca1..bf3b70d43 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -657,19 +657,25 @@ SPDesktop::change_document (SPDocument *theDocument) /** * Replaces the currently active tool with a new one. */ -void SPDesktop::set_event_context2(const std::string& toolName) { - Inkscape::UI::Tools::ToolBase* new_tool = ToolFactory::instance().createObject(toolName); - new_tool->desktop = this; - new_tool->message_context = new Inkscape::MessageContext(this->messageStack()); - +void SPDesktop::set_event_context2(const std::string& toolName) +{ Inkscape::UI::Tools::ToolBase* old_tool = event_context; - event_context = new_tool; - - if (old_tool) { - old_tool->finish(); - delete old_tool; - } + if (old_tool) { + if (toolName.compare(old_tool->pref_observer->observed_path) != 0) { + //g_message("Old tool: %s", old_tool->pref_observer->observed_path.c_str()); + //g_message("New tool: %s", toolName.c_str()); + old_tool->finish(); + delete old_tool; + } else { + return; + } + } + + Inkscape::UI::Tools::ToolBase* new_tool = ToolFactory::instance().createObject(toolName); + new_tool->desktop = this; + new_tool->message_context = new Inkscape::MessageContext(this->messageStack()); + event_context = new_tool; new_tool->setup(); // Make sure no delayed snapping events are carried over after switching tools @@ -677,7 +683,7 @@ void SPDesktop::set_event_context2(const std::string& toolName) { // tool should take care of this by itself) sp_event_context_discard_delayed_snap_event(event_context); - _event_context_changed_signal.emit(this, event_context); + _event_context_changed_signal.emit(this, event_context); } /** diff --git a/src/display/drawing-shape.cpp b/src/display/drawing-shape.cpp index e80f12486..03d7f51b5 100644 --- a/src/display/drawing-shape.cpp +++ b/src/display/drawing-shape.cpp @@ -12,7 +12,7 @@ #include <glib.h> #include <2geom/curves.h> #include <2geom/pathvector.h> -#include <2geom/svg-path.h> +#include <2geom/path-sink.h> #include <2geom/svg-path-parser.h> #include "display/cairo-utils.h" diff --git a/src/display/nr-filter-component-transfer.cpp b/src/display/nr-filter-component-transfer.cpp index 3bc00d2d7..dd90193fe 100644 --- a/src/display/nr-filter-component-transfer.cpp +++ b/src/display/nr-filter-component-transfer.cpp @@ -254,16 +254,21 @@ void FilterComponentTransfer::render_cairo(FilterSlot &slot) // parameters: R = 0, G = 1, B = 2, A = 3 // Cairo: R = 2, G = 1, B = 0, A = 3 + // If tableValues is empty, use identity. for (unsigned i = 0; i < 3; ++i) { guint32 color = 2 - i; switch (type[i]) { case COMPONENTTRANSFER_TYPE_TABLE: - ink_cairo_surface_filter(out, out, - ComponentTransferTable<false>(color, tableValues[i])); + if(!tableValues[i].empty()) { + ink_cairo_surface_filter(out, out, + ComponentTransferTable<false>(color, tableValues[i])); + } break; case COMPONENTTRANSFER_TYPE_DISCRETE: - ink_cairo_surface_filter(out, out, - ComponentTransferDiscrete<false>(color, tableValues[i])); + if(!tableValues[i].empty()) { + ink_cairo_surface_filter(out, out, + ComponentTransferDiscrete<false>(color, tableValues[i])); + } break; case COMPONENTTRANSFER_TYPE_LINEAR: ink_cairo_surface_filter(out, out, @@ -284,12 +289,16 @@ void FilterComponentTransfer::render_cairo(FilterSlot &slot) // fast paths for alpha channel switch (type[3]) { case COMPONENTTRANSFER_TYPE_TABLE: - ink_cairo_surface_filter(out, out, - ComponentTransferTable<true>(tableValues[3])); + if(!tableValues[3].empty()) { + ink_cairo_surface_filter(out, out, + ComponentTransferTable<true>(tableValues[3])); + } break; case COMPONENTTRANSFER_TYPE_DISCRETE: - ink_cairo_surface_filter(out, out, - ComponentTransferDiscrete<true>(tableValues[3])); + if(!tableValues[3].empty()) { + ink_cairo_surface_filter(out, out, + ComponentTransferDiscrete<true>(tableValues[3])); + } break; case COMPONENTTRANSFER_TYPE_LINEAR: ink_cairo_surface_filter(out, out, diff --git a/src/display/sodipodi-ctrlrect.cpp b/src/display/sodipodi-ctrlrect.cpp index c350e4614..e6e427047 100644 --- a/src/display/sodipodi-ctrlrect.cpp +++ b/src/display/sodipodi-ctrlrect.cpp @@ -142,7 +142,18 @@ void CtrlRect::render(SPCanvasBuf *buf) ink_cairo_set_source_rgba32(buf->ct, _border_color); cairo_stroke(buf->ct); - if (_shadow_size > 0) { + if (_shadow_size == 1) { // highlight the border by drawing it in _shadow_color + if (_dashed) { + cairo_set_dash(buf->ct, dashes, 2, 4); + cairo_rectangle(buf->ct, 0.5 + area[X].min(), 0.5 + area[Y].min(), + area[X].max() - area[X].min(), area[Y].max() - area[Y].min()); + } else { + cairo_rectangle(buf->ct, -0.5 + area[X].min(), -0.5 + area[Y].min(), + area[X].max() - area[X].min(), area[Y].max() - area[Y].min()); + } + ink_cairo_set_source_rgba32(buf->ct, _shadow_color); + cairo_stroke(buf->ct); + } else if (_shadow_size > 1) { // fill the shadow ink_cairo_set_source_rgba32(buf->ct, _shadow_color); cairo_rectangle(buf->ct, 1 + area[X].max(), area[Y].min() + _shadow_size, _shadow_size, area[Y].max() - area[Y].min() + 1); // right shadow diff --git a/src/extension/CMakeLists.txt b/src/extension/CMakeLists.txt index 6310ceaea..9bc30a592 100644 --- a/src/extension/CMakeLists.txt +++ b/src/extension/CMakeLists.txt @@ -45,6 +45,7 @@ set(extension_SRC internal/image-resolution.cpp internal/latex-pstricks.cpp internal/latex-pstricks-out.cpp + internal/metafile-inout.cpp internal/metafile-print.cpp internal/odf.cpp internal/latex-text-renderer.cpp diff --git a/src/extension/internal/Makefile_insert b/src/extension/internal/Makefile_insert index 726bca28f..a31843114 100644 --- a/src/extension/internal/Makefile_insert +++ b/src/extension/internal/Makefile_insert @@ -162,6 +162,8 @@ ink_common_sources += \ extension/internal/emf-print.cpp \ extension/internal/emf-inout.h \ extension/internal/emf-inout.cpp \ + extension/internal/metafile-inout.h \ + extension/internal/metafile-inout.cpp \ extension/internal/metafile-print.h \ extension/internal/metafile-print.cpp \ extension/internal/wmf-print.h \ diff --git a/src/extension/internal/cairo-ps-out.cpp b/src/extension/internal/cairo-ps-out.cpp index 5f535dc64..055a30add 100644 --- a/src/extension/internal/cairo-ps-out.cpp +++ b/src/extension/internal/cairo-ps-out.cpp @@ -328,9 +328,7 @@ CairoPsOutput::init (void) "<id>" SP_MODULE_KEY_PRINT_CAIRO_PS "</id>\n" "<param name=\"PSlevel\" gui-text=\"" N_("Restrict to PS level:") "\" type=\"enum\" >\n" "<_item value='PS3'>" N_("PostScript level 3") "</_item>\n" -#if (CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 5, 2)) "<_item value='PS2'>" N_("PostScript level 2") "</_item>\n" -#endif "</param>\n" "<param name=\"textToPath\" gui-text=\"" N_("Convert texts to paths") "\" type=\"boolean\">false</param>\n" "<param name=\"textToLaTeX\" gui-text=\"" N_("PS+LaTeX: Omit text in PS, and create LaTeX file") "\" type=\"boolean\">false</param>\n" @@ -369,9 +367,7 @@ CairoEpsOutput::init (void) "<id>" SP_MODULE_KEY_PRINT_CAIRO_EPS "</id>\n" "<param name=\"PSlevel\" gui-text=\"" N_("Restrict to PS level:") "\" type=\"enum\" >\n" "<_item value='PS3'>" N_("PostScript level 3") "</_item>\n" -#if (CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 5, 2)) "<_item value='PS2'>" N_("PostScript level 2") "</_item>\n" -#endif "</param>\n" "<param name=\"textToPath\" gui-text=\"" N_("Convert texts to paths") "\" type=\"boolean\">false</param>\n" "<param name=\"textToLaTeX\" gui-text=\"" N_("EPS+LaTeX: Omit text in EPS, and create LaTeX file") "\" type=\"boolean\">false</param>\n" diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index 4f9273cbb..47de62ac0 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -803,9 +803,7 @@ CairoRenderContext::setupSurface(double width, double height) #ifdef CAIRO_HAS_PDF_SURFACE case CAIRO_SURFACE_TYPE_PDF: surface = cairo_pdf_surface_create_for_stream(Inkscape::Extension::Internal::_write_callback, _stream, width, height); -#if (CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 10, 0)) cairo_pdf_surface_restrict_to_version(surface, (cairo_pdf_version_t)_pdf_level); -#endif break; #endif #ifdef CAIRO_HAS_PS_SURFACE @@ -814,10 +812,8 @@ CairoRenderContext::setupSurface(double width, double height) if(CAIRO_STATUS_SUCCESS != cairo_surface_status(surface)) { return FALSE; } -#if (CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 5, 2)) cairo_ps_surface_restrict_to_level(surface, (cairo_ps_level_t)_ps_level); cairo_ps_surface_set_eps(surface, (cairo_bool_t) _eps); -#endif // Cairo calculates the bounding box itself, however we want to override this. See Launchpad bug #380501 #if (CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 11, 2)) // cairo_ps_dsc_comment(surface, os_bbox.str().c_str()); diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index 0a4c86f0b..6fbc85c05 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -580,9 +580,9 @@ void CairoRenderer::renderItem(CairoRenderContext *ctx, SPItem *item) setStateForItem(ctx, item); CairoRenderState *state = ctx->getCurrentState(); - state->need_layer = ( state->mask || state->opacity != 1.0 ); + state->need_layer = ( state->mask || state->clip_path || state->opacity != 1.0 ); - // Draw item on a temporary surface so a mask or opacity can be applied to it. + // Draw item on a temporary surface so a mask, clip-path, or opacity can be applied to it. if (state->need_layer) { state->merge_opacity = FALSE; ctx->pushLayer(); @@ -591,7 +591,7 @@ void CairoRenderer::renderItem(CairoRenderContext *ctx, SPItem *item) sp_item_invoke_render(item, ctx); if (state->need_layer) - ctx->popLayer(); + ctx->popLayer(); // This applies clipping/masking ctx->popState(); } diff --git a/src/extension/internal/emf-inout.cpp b/src/extension/internal/emf-inout.cpp index c8c708051..cca541c5b 100644 --- a/src/extension/internal/emf-inout.cpp +++ b/src/extension/internal/emf-inout.cpp @@ -26,7 +26,7 @@ # include "config.h" #endif -#include <png.h> //This must precede text_reassemble.h or it blows up in pngconf.h when compiling +//#include <png.h> //This must precede text_reassemble.h or it blows up in pngconf.h when compiling #include <stdio.h> #include <stdlib.h> #include <stdint.h> @@ -69,154 +69,6 @@ static bool clipset = false; static uint32_t ICMmode = 0; // not used yet, but code to read it from EMF implemented static uint32_t BLTmode = 0; -/** Construct a PNG in memory from an RGB from the EMF file - -from: -http://www.lemoda.net/c/write-png/ - -which was based on: -http://stackoverflow.com/questions/1821806/how-to-encode-png-to-buffer-using-libpng - -gcc -Wall -o testpng testpng.c -lpng - -Originally here, but moved up - -#include <png.h> -#include <stdio.h> -#include <stdlib.h> -#include <stdint.h> -*/ - - -/* Given "bitmap", this returns the pixel of bitmap at the point - ("x", "y"). */ - -pixel_t * Emf::pixel_at (bitmap_t * bitmap, int x, int y) -{ - return bitmap->pixels + bitmap->width * y + x; -} - - -/* Write "bitmap" to a PNG file specified by "path"; returns 0 on - success, non-zero on error. */ - -void -Emf::my_png_write_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - PMEMPNG p=(PMEMPNG)png_get_io_ptr(png_ptr); - - size_t nsize = p->size + length; - - /* allocate or grow buffer */ - if(p->buffer){ p->buffer = (char *) realloc(p->buffer, nsize); } - else{ p->buffer = (char *) malloc(nsize); } - - if(!p->buffer){ png_error(png_ptr, "Write Error"); } - - /* copy new bytes to end of buffer */ - memcpy(p->buffer + p->size, data, length); - p->size += length; -} - -void Emf::toPNG(PMEMPNG accum, int width, int height, const char *px){ - bitmap_t bmStore; - bitmap_t *bitmap = &bmStore; - accum->buffer=NULL; // PNG constructed in memory will end up here, caller must free(). - accum->size=0; - bitmap->pixels=(pixel_t *)px; - bitmap->width = width; - bitmap->height = height; - - png_structp png_ptr = NULL; - png_infop info_ptr = NULL; - size_t x, y; - png_byte ** row_pointers = NULL; - /* The following number is set by trial and error only. I cannot - see where it it is documented in the libpng manual. - */ - int pixel_size = 3; - int depth = 8; - - png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if (png_ptr == NULL){ - accum->buffer=NULL; - return; - } - - info_ptr = png_create_info_struct (png_ptr); - if (info_ptr == NULL){ - png_destroy_write_struct (&png_ptr, &info_ptr); - accum->buffer=NULL; - return; - } - - /* Set up error handling. */ - - if (setjmp (png_jmpbuf (png_ptr))) { - png_destroy_write_struct (&png_ptr, &info_ptr); - accum->buffer=NULL; - return; - } - - /* Set image attributes. */ - - png_set_IHDR ( - png_ptr, - info_ptr, - bitmap->width, - bitmap->height, - depth, - PNG_COLOR_TYPE_RGB, - PNG_INTERLACE_NONE, - PNG_COMPRESSION_TYPE_DEFAULT, - PNG_FILTER_TYPE_DEFAULT - ); - - /* Initialize rows of PNG. */ - - row_pointers = (png_byte **) png_malloc (png_ptr, bitmap->height * sizeof (png_byte *)); - for (y = 0; y < bitmap->height; ++y) { - png_byte *row = - (png_byte *) png_malloc (png_ptr, sizeof (uint8_t) * bitmap->width * pixel_size); - row_pointers[bitmap->height - y - 1] = row; // Row order in EMF is reversed. - for (x = 0; x < bitmap->width; ++x) { - pixel_t * pixel = pixel_at (bitmap, x, y); - *row++ = pixel->red; // R & B channels were set correctly by DIB_to_RGB - *row++ = pixel->green; - *row++ = pixel->blue; - } - } - - /* Write the image data to memory */ - - png_set_rows (png_ptr, info_ptr, row_pointers); - - png_set_write_fn(png_ptr, accum, my_png_write_data, NULL); - - png_write_png (png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, NULL); - - for (y = 0; y < bitmap->height; y++) { - png_free (png_ptr, row_pointers[y]); - } - png_free (png_ptr, row_pointers); - png_destroy_write_struct(&png_ptr, &info_ptr); - -} - - -/* convert an EMF RGB(A) color to 0RGB -inverse of gethexcolor() in emf-print.cpp -*/ -uint32_t Emf::sethexcolor(U_COLORREF color){ - - uint32_t out; - out = (U_RGBAGetR(color) << 16) + - (U_RGBAGetG(color) << 8 ) + - (U_RGBAGetB(color) ); - return(out); -} - - Emf::Emf (void) // The null constructor { return; @@ -298,6 +150,7 @@ Emf::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar const *filena // reserve FixPPT2 for opacity bug. Currently EMF does not export opacity values bool new_FixPPTDashLine = mod->get_param_bool("FixPPTDashLine"); // dashed line bug bool new_FixPPTGrad2Polys = mod->get_param_bool("FixPPTGrad2Polys"); // gradient bug + bool new_FixPPTLinGrad = mod->get_param_bool("FixPPTLinGrad"); // allow native rectangular linear gradient bool new_FixPPTPatternAsHatch = mod->get_param_bool("FixPPTPatternAsHatch"); // force all patterns as standard EMF hatch bool new_FixImageRot = mod->get_param_bool("FixImageRot"); // remove rotations on images @@ -311,6 +164,7 @@ Emf::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar const *filena ext->set_param_bool("FixPPTCharPos",new_FixPPTCharPos); // Remember to add any new ones to PrintEmf::init or a mysterious failure will result! ext->set_param_bool("FixPPTDashLine",new_FixPPTDashLine); ext->set_param_bool("FixPPTGrad2Polys",new_FixPPTGrad2Polys); + ext->set_param_bool("FixPPTLinGrad",new_FixPPTLinGrad); ext->set_param_bool("FixPPTPatternAsHatch",new_FixPPTPatternAsHatch); ext->set_param_bool("FixImageRot",new_FixImageRot); ext->set_param_bool("textToPath", new_val); @@ -615,10 +469,10 @@ uint32_t Emf::add_image(PEMF_CALLBACK_DATA d, void *pEmr, uint32_t cbBits, uint uint32_t iUsage, uint32_t offBits, uint32_t offBmi){ uint32_t idx; - char imagename[64]; // big enough - char imrotname[64]; // big enough - char xywh[64]; // big enough - int dibparams; + char imagename[64]; // big enough + char imrotname[64]; // big enough + char xywh[64]; // big enough + int dibparams = U_BI_UNKNOWN; // type of image not yet determined MEMPNG mempng; // PNG in memory comes back in this mempng.buffer = NULL; @@ -627,74 +481,60 @@ uint32_t Emf::add_image(PEMF_CALLBACK_DATA d, void *pEmr, uint32_t cbBits, uint const char *px = NULL; // DIB pixels const U_RGBQUAD *ct = NULL; // DIB color table U_RGBQUAD ct2[2]; - uint32_t width, height, colortype, numCt, invert; - if( !cbBits || - !cbBmi || - (iUsage != U_DIB_RGB_COLORS) || - !(dibparams = get_DIB_params( // this returns pointers and values, but allocates no memory - pEmr, - offBits, - offBmi, - &px, - (const U_RGBQUAD **) &ct, - &numCt, - &width, - &height, - &colortype, - &invert - )) - ){ + uint32_t width, height, colortype, numCt, invert; // if needed these values will be set in get_DIB_params + if(cbBits && cbBmi && (iUsage == U_DIB_RGB_COLORS)){ + // next call returns pointers and values, but allocates no memory + dibparams = get_DIB_params(pEmr, offBits, offBmi, &px, (const U_RGBQUAD **) &ct, + &numCt, &width, &height, &colortype, &invert); + if(dibparams ==U_BI_RGB){ + // U_EMRCREATEMONOBRUSH uses text/bk colors instead of what is in the color map. + if(((PU_EMR)pEmr)->iType == U_EMR_CREATEMONOBRUSH){ + if(numCt==2){ + ct2[0] = U_RGB2BGR(d->dc[d->level].textColor); + ct2[1] = U_RGB2BGR(d->dc[d->level].bkColor); + ct = &ct2[0]; + } + else { // This record is invalid, nothing more to do here, let caller handle it + return(U_EMR_INVALID); + } + } - // U_EMRCREATEMONOBRUSH uses text/bk colors instead of what is in the color map. - if(((PU_EMR)pEmr)->iType == U_EMR_CREATEMONOBRUSH){ - if(numCt==2){ - ct2[0] = U_RGB2BGR(d->dc[d->level].textColor); - ct2[1] = U_RGB2BGR(d->dc[d->level].bkColor); - ct = &ct2[0]; - } - else { // createmonobrush renders on other platforms this way - return(0xFFFFFFFF); - } - } - - if(!DIB_to_RGBA( - px, // DIB pixel array - ct, // DIB color table - numCt, // DIB color table number of entries - &rgba_px, // U_RGBA pixel array (32 bits), created by this routine, caller must free. - width, // Width of pixel array in record - height, // Height of pixel array in record - colortype, // DIB BitCount Enumeration - numCt, // Color table used if not 0 - invert // If DIB rows are in opposite order from RGBA rows - ) && - rgba_px - ){ - toPNG( // Get the image from the RGBA px into mempng - &mempng, - width, height, // of the SRC bitmap - rgba_px - ); - free(rgba_px); + if(!DIB_to_RGBA( + px, // DIB pixel array + ct, // DIB color table + numCt, // DIB color table number of entries + &rgba_px, // U_RGBA pixel array (32 bits), created by this routine, caller must free. + width, // Width of pixel array in record + height, // Height of pixel array in record + colortype, // DIB BitCount Enumeration + numCt, // Color table used if not 0 + invert // If DIB rows are in opposite order from RGBA rows + )){ + toPNG( // Get the image from the RGBA px into mempng + &mempng, + width, height, // of the SRC bitmap + rgba_px + ); + free(rgba_px); + } } } - gchar *base64String; - if(dibparams == U_BI_JPEG || dibparams==U_BI_PNG){ + + gchar *base64String=NULL; + if(dibparams == U_BI_JPEG || dibparams==U_BI_PNG){ // image was binary png or jpg in source file base64String = g_base64_encode((guchar*) px, numCt ); - idx = in_images(d, (char *) base64String); } - else if(mempng.buffer){ + else if(mempng.buffer){ // image was DIB in source file, converted to png in this routine base64String = g_base64_encode((guchar*) mempng.buffer, mempng.size ); free(mempng.buffer); - idx = in_images(d, (char *) base64String); } - else { - // insert a random 3x4 blotch otherwise + else { // unknown or unsupported image type or failed conversion, insert the common bad image picture width = 3; height = 4; - base64String = g_strdup("iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAIAAAA7ljmRAAAAA3NCSVQICAjb4U/gAAAALElEQVQImQXBQQ2AMAAAsUJQMSWI2H8qME1yMshojwrvGB8XcHKvR1XtOTc/8HENumHCsOMAAAAASUVORK5CYII="); - idx = in_images(d, (char *) base64String); + base64String = bad_image_png(); } + + idx = in_images(d, (char *) base64String); if(!idx){ // add it if not already present - we looked at the actual data for comparison if(d->images.count == d->images.size){ enlarge_images(d); } idx = d->images.count; @@ -732,7 +572,7 @@ uint32_t Emf::add_image(PEMF_CALLBACK_DATA d, void *pEmr, uint32_t cbBits, uint *(d->defs) += " "; *(d->defs) += " </pattern>\n"; } - g_free(base64String); + g_free(base64String);//wait until this point to free because it might be a duplicate image /* image allows the inner image to be rotated nicely, load this one second only if needed imagename retained from above @@ -772,6 +612,115 @@ uint32_t Emf::add_image(PEMF_CALLBACK_DATA d, void *pEmr, uint32_t cbBits, uint return(idx-1); } +/* Add another 100 blank slots to the gradients array. +*/ +void Emf::enlarge_gradients(PEMF_CALLBACK_DATA d){ + d->gradients.size += 100; + d->gradients.strings = (char **) realloc(d->gradients.strings,d->gradients.size * sizeof(char *)); +} + +/* See if the gradient name is already in the list. If it is return its position (1->n, not 1-n-1) +*/ +int Emf::in_gradients(PEMF_CALLBACK_DATA d, char *test){ + int i; + for(i=0; i<d->gradients.count; i++){ + if(strcmp(test,d->gradients.strings[i])==0)return(i+1); + } + return(0); +} + +U_COLORREF trivertex_to_colorref(U_TRIVERTEX tv){ + U_COLORREF uc; + uc.Red = tv.Red >> 8; + uc.Green = tv.Green >> 8; + uc.Blue = tv.Blue >> 8; + uc.Reserved = tv.Alpha >> 8; // Not used + return(uc); +} + +/* (Conditionally) add a gradient. If a matching gradient already exists nothing happens. If one + does not exist it is added to the gradients list and also entered into <defs>. + Only call this with H or V gradient, not a triangle. +*/ +uint32_t Emf::add_gradient(PEMF_CALLBACK_DATA d, uint32_t gradientType, U_TRIVERTEX tv1, U_TRIVERTEX tv2){ + char hgradname[64]; // big enough + char tmpcolor1[8]; + char tmpcolor2[8]; + char gradc; + uint32_t idx; + std::string x2,y2; + + U_COLORREF gradientColor1 = trivertex_to_colorref(tv1); + U_COLORREF gradientColor2 = trivertex_to_colorref(tv2); + + + sprintf(tmpcolor1,"%6.6X",sethexcolor(gradientColor1)); + sprintf(tmpcolor2,"%6.6X",sethexcolor(gradientColor2)); + switch(gradientType){ + case U_GRADIENT_FILL_RECT_H: + gradc='H'; + x2="100"; + y2="0"; + break; + case U_GRADIENT_FILL_RECT_V: + gradc='V'; + x2="0"; + y2="100"; + break; + default: // this should never happen, but fill these in to avoid compiler warnings + gradc='!'; + x2="0"; + y2="0"; + break; + } + + /* Even though the gradient was defined as Horizontal or Vertical if the rectangle is rotated it needs to + be at some other alignment, and that needs gradienttransform. Set the name using the same sort of hack + as for add_image. + */ + int tangle = round(current_rotation(d)*1000000.0); + sprintf(hgradname,"LinGrd%c_%s_%s_%d",gradc,tmpcolor1,tmpcolor2,tangle); + + idx = in_gradients(d,hgradname); + if(!idx){ // gradient does not yet exist + if(d->gradients.count == d->gradients.size){ enlarge_gradients(d); } + d->gradients.strings[d->gradients.count++]=strdup(hgradname); + idx = d->gradients.count; + SVGOStringStream stmp; + stmp << " <linearGradient id=\""; + stmp << hgradname; + stmp << "\" x1=\""; + stmp << pix_to_x_point(d, tv1.x , tv1.y); + stmp << "\" y1=\""; + stmp << pix_to_y_point(d, tv1.x , tv1.y); + stmp << "\" x2=\""; + if(gradc=='H'){ // UR corner + stmp << pix_to_x_point(d, tv2.x , tv1.y); + stmp << "\" y2=\""; + stmp << pix_to_y_point(d, tv2.x , tv1.y); + } + else { // LL corner + stmp << pix_to_x_point(d, tv1.x , tv2.y); + stmp << "\" y2=\""; + stmp << pix_to_y_point(d, tv1.x , tv2.y); + } + stmp << "\" gradientTransform=\"(1,0,0,1,0,0)\""; + stmp << " gradientUnits=\"userSpaceOnUse\"\n"; + stmp << ">\n"; + stmp << " <stop offset=\"0\" style=\"stop-color:#"; + stmp << tmpcolor1; + stmp << ";stop-opacity:1\" />\n"; + stmp << " <stop offset=\"1\" style=\"stop-color:#"; + stmp << tmpcolor2; + stmp << ";stop-opacity:1\" />\n"; + stmp << " </linearGradient>\n"; + *(d->defs) += stmp.str().c_str(); + } + + return(idx-1); +} + + void Emf::output_style(PEMF_CALLBACK_DATA d, int iType) @@ -871,10 +820,11 @@ Emf::output_style(PEMF_CALLBACK_DATA d, int iType) snprintf(tmp, 1023, "fill:url(#%s); ",d->hatches.strings[d->dc[d->level].fill_idx]); tmp_style << tmp; break; - case DRAW_IMAGE: + case DRAW_IMAGE: snprintf(tmp, 1023, "fill:url(#EMFimage%d_ref); ",d->dc[d->level].fill_idx); tmp_style << tmp; break; + case DRAW_LINEAR_GRADIENT: case DRAW_PAINT: default: // <-- this should never happen, but just in case... snprintf( @@ -927,6 +877,7 @@ Emf::output_style(PEMF_CALLBACK_DATA d, int iType) snprintf(tmp, 1023, "stroke:url(#EMFimage%d_ref); ",d->dc[d->level].stroke_idx); tmp_style << tmp; break; + case DRAW_LINEAR_GRADIENT: case DRAW_PAINT: default: // <-- this should never happen, but just in case... snprintf( @@ -1343,7 +1294,7 @@ Emf::select_brush(PEMF_CALLBACK_DATA d, int index) else if(iType == U_EMR_CREATEDIBPATTERNBRUSHPT || iType == U_EMR_CREATEMONOBRUSH){ PU_EMRCREATEDIBPATTERNBRUSHPT pEmr = (PU_EMRCREATEDIBPATTERNBRUSHPT) d->emf_obj[index].lpEMFR; tidx = add_image(d, (void *) pEmr, pEmr->cbBits, pEmr->cbBmi, pEmr->iUsage, pEmr->offBits, pEmr->offBmi); - if(tidx == 0xFFFFFFFF){ // This happens if createmonobrush has a DIB that isn't monochrome + if(tidx == U_EMR_INVALID){ // This happens if createmonobrush has a DIB that isn't monochrome double r, g, b; r = SP_COLOR_U_TO_F( U_RGBAGetR(d->dc[d->level].textColor)); g = SP_COLOR_U_TO_F( U_RGBAGetG(d->dc[d->level].textColor)); @@ -1502,13 +1453,11 @@ void Emf::common_image_extraction(PEMF_CALLBACK_DATA d, void *pEmr, uint32_t iUsage, uint32_t offBits, uint32_t cbBits, uint32_t offBmi, uint32_t cbBmi){ SVGOStringStream tmp_image; - int dibparams; + int dibparams = U_BI_UNKNOWN; // type of image not yet determined + tmp_image << "\n\t <image\n"; tmp_image << " y=\"" << dy << "\"\n x=\"" << dx <<"\"\n "; - // The image ID is filled in much later when tmp_image is converted - - MEMPNG mempng; // PNG in memory comes back in this mempng.buffer = NULL; @@ -1516,91 +1465,74 @@ void Emf::common_image_extraction(PEMF_CALLBACK_DATA d, void *pEmr, char *sub_px = NULL; // RGBA pixels, subarray const char *px = NULL; // DIB pixels const U_RGBQUAD *ct = NULL; // DIB color table - uint32_t width, height, colortype, numCt, invert; - if(!cbBits || - !cbBmi || - (iUsage != U_DIB_RGB_COLORS) || - !(dibparams = get_DIB_params( // this returns pointers and values, but allocates no memory - pEmr, - offBits, - offBmi, - &px, - (const U_RGBQUAD **) &ct, - &numCt, - &width, - &height, - &colortype, - &invert - )) - ){ - if(sw == 0 || sh == 0){ - sw = width; - sh = height; - } - - if(!DIB_to_RGBA( - px, // DIB pixel array - ct, // DIB color table - numCt, // DIB color table number of entries - &rgba_px, // U_RGBA pixel array (32 bits), created by this routine, caller must free. - width, // Width of pixel array - height, // Height of pixel array - colortype, // DIB BitCount Enumeration - numCt, // Color table used if not 0 - invert // If DIB rows are in opposite order from RGBA rows - ) && - rgba_px - ){ - sub_px = RGBA_to_RGBA( - rgba_px, // full pixel array from DIB + uint32_t width, height, colortype, numCt, invert; // if needed these values will be set in get_DIB_params + if(cbBits && cbBmi && (iUsage == U_DIB_RGB_COLORS)){ + // next call returns pointers and values, but allocates no memory + dibparams = get_DIB_params(pEmr, offBits, offBmi, &px, (const U_RGBQUAD **) &ct, + &numCt, &width, &height, &colortype, &invert); + if(dibparams ==U_BI_RGB){ + if(sw == 0 || sh == 0){ + sw = width; + sh = height; + } + + if(!DIB_to_RGBA( + px, // DIB pixel array + ct, // DIB color table + numCt, // DIB color table number of entries + &rgba_px, // U_RGBA pixel array (32 bits), created by this routine, caller must free. width, // Width of pixel array height, // Height of pixel array - sx,sy, // starting point in pixel array - &sw,&sh // columns/rows to extract from the pixel array (output array size) - ); - - if(!sub_px)sub_px=rgba_px; - toPNG( // Get the image from the RGBA px into mempng - &mempng, - sw, sh, // size of the extracted pixel array - sub_px - ); - free(sub_px); + colortype, // DIB BitCount Enumeration + numCt, // Color table used if not 0 + invert // If DIB rows are in opposite order from RGBA rows + )){ + sub_px = RGBA_to_RGBA( // returns either a subset (side effect: frees rgba_px) or NULL (for subset == entire image) + rgba_px, // full pixel array from DIB + width, // Width of pixel array + height, // Height of pixel array + sx,sy, // starting point in pixel array + &sw,&sh // columns/rows to extract from the pixel array (output array size) + ); + + if(!sub_px)sub_px=rgba_px; + toPNG( // Get the image from the RGBA px into mempng + &mempng, + sw, sh, // size of the extracted pixel array + sub_px + ); + free(sub_px); + } } } - gchar *base64String; - if(dibparams == U_BI_JPEG){ + + gchar *base64String=NULL; + if(dibparams == U_BI_JPEG){ // image was binary jpg in source file tmp_image << " xlink:href=\"data:image/jpeg;base64,"; base64String = g_base64_encode((guchar*) px, numCt ); - tmp_image << base64String ; - g_free(base64String); } - else if(dibparams==U_BI_PNG){ + else if(dibparams==U_BI_PNG){ // image was binary png in source file tmp_image << " xlink:href=\"data:image/png;base64,"; base64String = g_base64_encode((guchar*) px, numCt ); - tmp_image << base64String ; - g_free(base64String); } - else if(mempng.buffer){ + else if(mempng.buffer){ // image was DIB in source file, converted to png in this routine tmp_image << " xlink:href=\"data:image/png;base64,"; - gchar *base64String = g_base64_encode((guchar*) mempng.buffer, mempng.size ); + base64String = g_base64_encode((guchar*) mempng.buffer, mempng.size ); free(mempng.buffer); - tmp_image << base64String ; - g_free(base64String); } - else { + else { // unknown or unsupported image type or failed conversion, insert the common bad image picture tmp_image << " xlink:href=\"data:image/png;base64,"; - // insert a random 3x4 blotch otherwise - tmp_image << "iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAIAAAA7ljmRAAAAA3NCSVQICAjb4U/gAAAALElEQVQImQXBQQ2AMAAAsUJQMSWI2H8qME1yMshojwrvGB8XcHKvR1XtOTc/8HENumHCsOMAAAAASUVORK5CYII="; + base64String = bad_image_png(); } + tmp_image << base64String; + g_free(base64String); tmp_image << "\"\n height=\"" << dh << "\"\n width=\"" << dw << "\"\n"; tmp_image << " transform=" << current_matrix(d, dx, dy, 1); // calculate appropriate offset - *(d->outsvg) += "\n\t <image\n"; - *(d->outsvg) += tmp_image.str().c_str(); + tmp_image << "/> \n"; - *(d->outsvg) += "/> \n"; + *(d->outsvg) += tmp_image.str().c_str(); *(d->path) = ""; } @@ -1664,7 +1596,7 @@ int Emf::myEnhMetaFileProc(char *contents, unsigned int length, PEMF_CALLBACK_DA // incompatible change to text drawing detected (color or background change) forces out existing text // OR // next record is valid type and forces pending text to be drawn immediately - if ((d->dc[d->level].dirty & DIRTY_TEXT) || ((emr_mask != 0xFFFFFFFF) && (emr_mask & U_DRAW_TEXT) && d->tri->dirty)){ + if ((d->dc[d->level].dirty & DIRTY_TEXT) || ((emr_mask != U_EMR_INVALID) && (emr_mask & U_DRAW_TEXT) && d->tri->dirty)){ TR_layout_analyze(d->tri); TR_layout_2_svg(d->tri); SVGOStringStream ts; @@ -1711,7 +1643,7 @@ std::cout << "BEFORE DRAW" */ if( - (emr_mask != 0xFFFFFFFF) && // next record is valid type + (emr_mask != U_EMR_INVALID) && // next record is valid type (d->mask & U_DRAW_VISIBLE) && // Current set of objects are drawable ( (d->mask & U_DRAW_FORCE) || // This draw is forced by STROKE/FILL/STROKEANDFILL PATH @@ -1726,7 +1658,7 @@ std::cout << "BEFORE DRAW" ) ){ // std::cout << "PATH DRAW at TOP" << std::endl; - *(d->outsvg) += " <path "; // this is the ONLY place <path should be used!!!! + *(d->outsvg) += " <path "; // this is the ONLY place <path should be used!!! One exception, gradientfill. if(d->drawtype){ // explicit draw type EMR record output_style(d, d->drawtype); } @@ -1737,7 +1669,7 @@ std::cout << "BEFORE DRAW" output_style(d, U_EMR_STROKEPATH); } *(d->outsvg) += "\n\t"; - *(d->outsvg) += "\n\td=\""; // this is the ONLY place d=" should be used!!!! + *(d->outsvg) += "\n\td=\""; // this is the ONLY place d=" should be used!!!! One exception, gradientfill. *(d->outsvg) += *(d->path); *(d->outsvg) += " \" /> \n"; *(d->path) = ""; @@ -2625,7 +2557,7 @@ std::cout << "BEFORE DRAW" int stat = emr_arc_points( lpEMFR, &f1, f2, ¢er, &start, &end, &size); if(!stat){ tmp_path << "\n\tM " << pix_to_xy(d, start.x, start.y); - tmp_path << " A " << pix_to_abs_size(d, size.x)/2.0 << "," << pix_to_abs_size(d, size.y)/2.0 ; + tmp_path << " A " << pix_to_abs_size(d, size.x)/2.0 << "," << pix_to_abs_size(d, size.y)/2.0; tmp_path << " "; tmp_path << 180.0 * current_rotation(d)/M_PI; tmp_path << " "; @@ -2646,7 +2578,7 @@ std::cout << "BEFORE DRAW" int f2 = (d->arcdir == U_AD_COUNTERCLOCKWISE ? 0 : 1); if(!emr_arc_points( lpEMFR, &f1, f2, ¢er, &start, &end, &size)){ tmp_path << "\n\tM " << pix_to_xy(d, start.x, start.y); - tmp_path << " A " << pix_to_abs_size(d, size.x)/2.0 << "," << pix_to_abs_size(d, size.y)/2.0 ; + tmp_path << " A " << pix_to_abs_size(d, size.x)/2.0 << "," << pix_to_abs_size(d, size.y)/2.0; tmp_path << " "; tmp_path << 180.0 * current_rotation(d)/M_PI; tmp_path << " "; @@ -2669,7 +2601,7 @@ std::cout << "BEFORE DRAW" if(!emr_arc_points( lpEMFR, &f1, f2, ¢er, &start, &end, &size)){ tmp_path << "\n\tM " << pix_to_xy(d, center.x, center.y); tmp_path << "\n\tL " << pix_to_xy(d, start.x, start.y); - tmp_path << " A " << pix_to_abs_size(d, size.x)/2.0 << "," << pix_to_abs_size(d, size.y)/2.0 ; + tmp_path << " A " << pix_to_abs_size(d, size.x)/2.0 << "," << pix_to_abs_size(d, size.y)/2.0; tmp_path << " "; tmp_path << 180.0 * current_rotation(d)/M_PI; tmp_path << " "; @@ -2710,7 +2642,7 @@ std::cout << "BEFORE DRAW" if(!emr_arc_points( lpEMFR, &f1, f2, ¢er, &start, &end, &size)){ // draw a line from current position to start, arc from there tmp_path << "\n\tL " << pix_to_xy(d, start.x, start.y); - tmp_path << " A " << pix_to_abs_size(d, size.x)/2.0 << "," << pix_to_abs_size(d, size.y)/2.0 ; + tmp_path << " A " << pix_to_abs_size(d, size.x)/2.0 << "," << pix_to_abs_size(d, size.y)/2.0; tmp_path << " "; tmp_path << 180.0 * current_rotation(d)/M_PI; tmp_path << " "; @@ -3332,13 +3264,64 @@ std::cout << "BEFORE DRAW" case U_EMR_SETLAYOUT: dbg_str << "<!-- U_EMR_SETLAYOUT -->\n"; break; case U_EMR_TRANSPARENTBLT: dbg_str << "<!-- U_EMR_TRANSPARENTBLT -->\n"; break; case U_EMR_UNDEF117: dbg_str << "<!-- U_EMR_UNDEF117 -->\n"; break; - case U_EMR_GRADIENTFILL: dbg_str << "<!-- U_EMR_GRADIENTFILL -->\n"; break; - /* Gradient fill is doable for rectangles because those correspond to linear gradients. However, - the general case for the triangle fill, with a different color in each corner of the triangle, - has no SVG equivalent and cannot be easily emulated with SVG gradients. Except that so far - I (DM) have not been able to make an EMF with a rectangular gradientfill record which is not - completely toxic to other EMF readers. So far now, do nothing. - */ + case U_EMR_GRADIENTFILL: + { + /* Gradient fill is doable for rectangles because those correspond to linear gradients. However, + the general case for the triangle fill, with a different color in each corner of the triangle, + has no SVG equivalent and cannot be easily emulated with SVG gradients. So the linear gradient + is implemented, and the triangle fill just paints with the color of the first corner. + + This record can hold a series of gradients so we are forced to add path elements directly here, + it cannot wait for the top of the main loop. Any existing path is erased. + + */ + dbg_str << "<!-- U_EMR_GRADIENTFILL -->\n"; + PU_EMRGRADIENTFILL pEmr = (PU_EMRGRADIENTFILL) lpEMFR; + int nV = pEmr->nTriVert; // Number of TriVertex objects + int nG = pEmr->nGradObj; // Number of gradient triangle/rectangle objects + U_TRIVERTEX *tv = (U_TRIVERTEX *)(((char *)lpEMFR) + sizeof(U_EMRGRADIENTFILL)); + if( pEmr->ulMode == U_GRADIENT_FILL_RECT_H || + pEmr->ulMode == U_GRADIENT_FILL_RECT_V + ){ + SVGOStringStream tmp_rectangle; + int i,fill_idx; + U_GRADIENT4 *rcs = (U_GRADIENT4 *)(((char *)lpEMFR) + sizeof(U_EMRGRADIENTFILL) + sizeof(U_TRIVERTEX)*nV); + for(i=0;i<nG;i++){ + tmp_rectangle << "\n<path d=\""; + fill_idx = add_gradient(d, pEmr->ulMode, tv[rcs[i].UpperLeft], tv[rcs[i].LowerRight]); + tmp_rectangle << "\n\tM " << pix_to_xy( d, tv[rcs[i].UpperLeft ].x , tv[rcs[i].UpperLeft ].y ) << " "; + tmp_rectangle << "\n\tL " << pix_to_xy( d, tv[rcs[i].LowerRight].x , tv[rcs[i].UpperLeft ].y ) << " "; + tmp_rectangle << "\n\tL " << pix_to_xy( d, tv[rcs[i].LowerRight].x , tv[rcs[i].LowerRight].y ) << " "; + tmp_rectangle << "\n\tL " << pix_to_xy( d, tv[rcs[i].UpperLeft ].x , tv[rcs[i].LowerRight].y ) << " "; + tmp_rectangle << "\n\tz\""; + tmp_rectangle << "\n\tstyle=\"stroke:none;fill:url(#"; + tmp_rectangle << d->gradients.strings[fill_idx]; + tmp_rectangle << ");\"\n/>\n"; + } + *(d->outsvg) += tmp_rectangle.str().c_str(); + } + else if(pEmr->ulMode == U_GRADIENT_FILL_TRIANGLE){ + SVGOStringStream tmp_triangle; + char tmpcolor[8]; + int i; + U_GRADIENT3 *tris = (U_GRADIENT3 *)(((char *)lpEMFR) + sizeof(U_EMRGRADIENTFILL) + sizeof(U_TRIVERTEX)*nV); + for(i=0;i<nG;i++){ + tmp_triangle << "\n<path d=\""; + sprintf(tmpcolor,"%6.6X",sethexcolor(trivertex_to_colorref(tv[tris[i].Vertex1]))); + tmp_triangle << "\n\tM " << pix_to_xy( d, tv[tris[i].Vertex1].x , tv[tris[i].Vertex1].y ) << " "; + tmp_triangle << "\n\tL " << pix_to_xy( d, tv[tris[i].Vertex2].x , tv[tris[i].Vertex2].y ) << " "; + tmp_triangle << "\n\tL " << pix_to_xy( d, tv[tris[i].Vertex3].x , tv[tris[i].Vertex3].y ) << " "; + tmp_triangle << "\n\tz\""; + tmp_triangle << "\n\tstyle=\"stroke:none;fill:#"; + tmp_triangle << tmpcolor; + tmp_triangle << ";\"\n/>\n"; + } + *(d->outsvg) += tmp_triangle.str().c_str(); + } + *(d->path) = ""; + // if it is anything else the record is bogus, so ignore it + break; + } case U_EMR_SETLINKEDUFIS: dbg_str << "<!-- U_EMR_SETLINKEDUFIS -->\n"; break; case U_EMR_SETTEXTJUSTIFICATION: dbg_str << "<!-- U_EMR_SETTEXTJUSTIFICATION -->\n"; break; case U_EMR_COLORMATCHTOTARGETW: dbg_str << "<!-- U_EMR_COLORMATCHTOTARGETW -->\n"; break; @@ -3354,37 +3337,12 @@ std::cout << "BEFORE DRAW" } //end of while // When testing, uncomment the following to show the final SVG derived from the EMF -//std::cout << *(d->outsvg) << std::endl; +// std::cout << *(d->outsvg) << std::endl; (void) emr_properties(U_EMR_INVALID); // force the release of the lookup table memory, returned value is irrelevant return 1; } - -// Aldus Placeable Header =================================================== -// Since we are a 32bit app, we have to be sure this structure compiles to -// be identical to a 16 bit app's version. To do this, we use the #pragma -// to adjust packing, we use a uint16_t for the hmf handle, and a SMALL_RECT -// for the bbox rectangle. -#pragma pack( push ) -#pragma pack( 2 ) -typedef struct _SMALL_RECT { - int16_t Left; - int16_t Top; - int16_t Right; - int16_t Bottom; -} SMALL_RECT, *PSMALL_RECT; -typedef struct -{ - uint32_t dwKey; - uint16_t hmf; - SMALL_RECT bbox; - uint16_t wInch; - uint32_t dwReserved; - uint16_t wCheckSum; -} APMHEADER, *PAPMHEADER; -#pragma pack( pop ) - void Emf::free_emf_strings(EMF_STRINGS name){ if(name.count){ for(int i=0; i< name.count; i++){ free(name.strings[i]); } @@ -3438,6 +3396,9 @@ Emf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) d.images.size = 0; d.images.count = 0; d.images.strings = NULL; + d.gradients.size = 0; + d.gradients.count = 0; + d.gradients.strings = NULL; // set up the size default for patterns in defs. This might not be referenced if there are no patterns defined in the drawing. @@ -3478,6 +3439,7 @@ Emf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) delete d.defs; free_emf_strings(d.hatches); free_emf_strings(d.images); + free_emf_strings(d.gradients); if (d.emf_obj) { int i; @@ -3516,7 +3478,14 @@ Emf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) // Scale and translate objects double scale = Inkscape::Util::Quantity::convert(1, "px", doc_unit); ShapeEditor::blockSetItem(true); - doc->getRoot()->scaleChildItemsRec(Geom::Scale(scale), Geom::Point(0, doc->getHeight().value("px"))); + double dh; + if(SP_ACTIVE_DOCUMENT){ // for file menu open or import, or paste from clipboard + dh = SP_ACTIVE_DOCUMENT->getHeight().value("px"); + } + else { // for open via --file on command line + dh = doc->getHeight().value("px"); + } + doc->getRoot()->scaleChildItemsRec(Geom::Scale(scale), Geom::Point(0, dh)); ShapeEditor::blockSetItem(false); Inkscape::DocumentUndo::setUndoSensitive(doc, saved); @@ -3556,6 +3525,7 @@ Emf::init (void) "<param name=\"FixPPTCharPos\" gui-text=\"" N_("Compensate for PPT font bug") "\" type=\"boolean\">false</param>\n" "<param name=\"FixPPTDashLine\" gui-text=\"" N_("Convert dashed/dotted lines to single lines") "\" type=\"boolean\">false</param>\n" "<param name=\"FixPPTGrad2Polys\" gui-text=\"" N_("Convert gradients to colored polygon series") "\" type=\"boolean\">false</param>\n" + "<param name=\"FixPPTLinGrad\" gui-text=\"" N_("Use native rectangular linear gradients") "\" type=\"boolean\">false</param>\n" "<param name=\"FixPPTPatternAsHatch\" gui-text=\"" N_("Map all fill patterns to standard EMF hatches") "\" type=\"boolean\">false</param>\n" "<param name=\"FixImageRot\" gui-text=\"" N_("Ignore image rotations") "\" type=\"boolean\">false</param>\n" "<output>\n" diff --git a/src/extension/internal/emf-inout.h b/src/extension/internal/emf-inout.h index 787a2fdb3..97f93e71b 100644 --- a/src/extension/internal/emf-inout.h +++ b/src/extension/internal/emf-inout.h @@ -11,9 +11,8 @@ #ifndef SEEN_EXTENSION_INTERNAL_EMF_H #define SEEN_EXTENSION_INTERNAL_EMF_H -#define PNG_SKIP_SETJMP_CHECK // else any further png.h include blows up in the compiler -#include <png.h> #include <libuemf/uemf.h> +#include "extension/internal/metafile-inout.h" // picks up PNG #include "extension/implementation/implementation.h" #include "style.h" #include "text_reassemble.h" @@ -67,34 +66,6 @@ typedef struct emf_device_context { #define EMF_MAX_DC 128 -/* - both emf-inout.h and wmf-inout.h are included by init.cpp, so whichever one goes in first defines these ommon types -*/ -#ifndef SEEN_EXTENSION_INTERNAL_METAFILECOMMON_ -#define SEEN_EXTENSION_INTERNAL_METAFILECOMMON_ -/* A coloured pixel. */ -typedef struct { - uint8_t red; - uint8_t green; - uint8_t blue; - uint8_t opacity; -} pixel_t; - -/* A picture. */ - -typedef struct { - pixel_t *pixels; - size_t width; - size_t height; -} bitmap_t; - -/* structure to store PNG image bytes */ -typedef struct { - char *buffer; - size_t size; -} MEMPNG, *PMEMPNG; -#endif - typedef struct { Glib::ustring *outsvg; Glib::ustring *path; @@ -126,6 +97,7 @@ typedef struct { // both of these end up in <defs> under the names shown here. These structures allow duplicates to be avoided. EMF_STRINGS hatches; // hold pattern names, all like EMFhatch#_$$$$$$ where # is the EMF hatch code and $$$$$$ is the color EMF_STRINGS images; // hold images, all like Image#, where # is the slot the image lives. + EMF_STRINGS gradients; // hold gradient names, all like EMF[HV]_$$$$$$_$$$$$$ where $$$$$$ are the colors TR_INFO *tri; // Text Reassembly data structure @@ -133,7 +105,8 @@ typedef struct { PEMF_OBJECT emf_obj; } EMF_CALLBACK_DATA, *PEMF_CALLBACK_DATA; -class Emf : Inkscape::Extension::Implementation::Implementation { //This is a derived class +class Emf : public Metafile +{ public: @@ -155,11 +128,6 @@ public: private: protected: - - static pixel_t *pixel_at (bitmap_t * bitmap, int x, int y); - static void my_png_write_data(png_structp png_ptr, png_bytep data, png_size_t length); - static void toPNG(PMEMPNG accum, int width, int height, const char *px); - static uint32_t sethexcolor(U_COLORREF color); static void print_document_to_file(SPDocument *doc, const gchar *filename); static double current_scale(PEMF_CALLBACK_DATA d); static std::string current_matrix(PEMF_CALLBACK_DATA d, double x, double y, int useoffset); @@ -171,6 +139,9 @@ protected: static int in_images(PEMF_CALLBACK_DATA d, char *test); static uint32_t add_image(PEMF_CALLBACK_DATA d, void *pEmr, uint32_t cbBits, uint32_t cbBmi, uint32_t iUsage, uint32_t offBits, uint32_t offBmi); + static void enlarge_gradients(PEMF_CALLBACK_DATA d); + static int in_gradients(PEMF_CALLBACK_DATA d, char *test); + static uint32_t add_gradient(PEMF_CALLBACK_DATA d, uint32_t gradientType, U_TRIVERTEX tv1, U_TRIVERTEX tv2); static void output_style(PEMF_CALLBACK_DATA d, int iType); static double _pix_x_to_point(PEMF_CALLBACK_DATA d, double px); static double _pix_y_to_point(PEMF_CALLBACK_DATA d, double py); diff --git a/src/extension/internal/emf-print.cpp b/src/extension/internal/emf-print.cpp index 0df643130..3c27ac1b8 100644 --- a/src/extension/internal/emf-print.cpp +++ b/src/extension/internal/emf-print.cpp @@ -70,9 +70,8 @@ namespace Internal { /* globals */ -static double PX2WORLD = 20.0f; -static U_XFORM worldTransform; -static bool FixPPTCharPos, FixPPTDashLine, FixPPTGrad2Polys, FixPPTPatternAsHatch, FixImageRot; +static double PX2WORLD; +static bool FixPPTCharPos, FixPPTDashLine, FixPPTGrad2Polys, FixPPTLinGrad, FixPPTPatternAsHatch, FixImageRot; static EMFTRACK *et = NULL; static EMFHANDLES *eht = NULL; @@ -125,9 +124,12 @@ unsigned int PrintEmf::begin(Inkscape::Extension::Print *mod, SPDocument *doc) char *rec; gchar const *utf8_fn = mod->get_param_string("destination"); + // Typially PX2WORLD is 1200/90, using inkscape's default dpi + PX2WORLD = 1200.0 / Inkscape::Util::Quantity::convert(1.0, "in", "px"); FixPPTCharPos = mod->get_param_bool("FixPPTCharPos"); FixPPTDashLine = mod->get_param_bool("FixPPTDashLine"); FixPPTGrad2Polys = mod->get_param_bool("FixPPTGrad2Polys"); + FixPPTLinGrad = mod->get_param_bool("FixPPTLinGrad"); FixPPTPatternAsHatch = mod->get_param_bool("FixPPTPatternAsHatch"); FixImageRot = mod->get_param_bool("FixImageRot"); @@ -179,12 +181,12 @@ unsigned int PrintEmf::begin(Inkscape::Extension::Print *mod, SPDocument *doc) float dwInchesX = d.width(); float dwInchesY = d.height(); - // dwInchesX x dwInchesY in micrometer units, dpi=90 -> 3543.3 dpm - (void) drawing_size((int) ceil(dwInchesX * 25.4), (int) ceil(dwInchesY * 25.4), 3.543307, &rclBounds, &rclFrame); + // dwInchesX x dwInchesY in micrometer units, 1200 dpi/25.4 -> dpmm + (void) drawing_size((int) ceil(dwInchesX * 25.4), (int) ceil(dwInchesY * 25.4),1200.0/25.4, &rclBounds, &rclFrame); // set up the reference device as 100 X A4 horizontal, (1200 dpi/25.4 -> dpmm). Extra digits maintain dpi better in EMF - int MMX = 21600; - int MMY = 27900; + int MMX = 216; + int MMY = 279; (void) device_size(MMX, MMY, 1200.0 / 25.4, &szlDev, &szlMm); int PixelsX = szlDev.cx; int PixelsY = szlDev.cy; @@ -220,13 +222,16 @@ unsigned int PrintEmf::begin(Inkscape::Extension::Print *mod, SPDocument *doc) } - // Correct for dpi in EMF (1200) vs dpi in Inkscape (always 90). - // Also correct for the scaling in PX2WORLD, which is set to 20. + // In earlier versions this was used to scale from inkscape's dpi of 90 to + // the files 1200 dpi, taking into account PX2WORLD which was 20. Now PX2WORLD + // is set so that this matrix is unitary. The usual value of PX2WORLD is 1200/90, + // but might be different if the internal dpi is changed. - worldTransform.eM11 = 1200. / (90.0 * PX2WORLD); + U_XFORM worldTransform; + worldTransform.eM11 = 1.0; worldTransform.eM12 = 0.0; worldTransform.eM21 = 0.0; - worldTransform.eM22 = 1200. / (90.0 * PX2WORLD); + worldTransform.eM22 = 1.0; worldTransform.eDx = 0; worldTransform.eDy = 0; @@ -420,7 +425,7 @@ int PrintEmf::create_brush(SPStyle const *style, PU_COLORREF fcolor) hatchColor = avg_stop_color(rg); } } else if (lg) { - if (FixPPTGrad2Polys) { + if (FixPPTGrad2Polys || FixPPTLinGrad) { return hold_gradient(lg, fill_mode); } else { hatchColor = avg_stop_color(lg); @@ -696,7 +701,7 @@ int PrintEmf::create_pen(SPStyle const *style, const Geom::Affine &transform) n_dash = style->stroke_dash.n_dash; dash = new uint32_t[n_dash]; for (i = 0; i < style->stroke_dash.n_dash; i++) { - dash[i] = (uint32_t)(style->stroke_dash.dash[i]); + dash[i] = (uint32_t)(Inkscape::Util::Quantity::convert(1, "mm", "px") * style->stroke_dash.dash[i]); } } } @@ -780,6 +785,182 @@ void PrintEmf::destroy_pen() } } +/* Return a Path consisting of just the corner points of the single path in a a PathVector. If the +PathVector has more than one path, or that one path is open, or any of its segments are curved, then the +returned PathVector is . If the input path is already just straight lines and vertices the output will be the +same as the sole path in the input. */ + +Geom::Path PrintEmf::pathv_to_simple_polygon(Geom::PathVector const &pathv, int *vertices) +{ + Geom::Point P1_trail; + Geom::Point P1; + Geom::Point P1_lead; + Geom::Point v1,v2; + Geom::Path output; + Geom::Path bad; + Geom::PathVector pv = pathv_to_linear_and_cubic_beziers(pathv); + Geom::PathVector::const_iterator pit = pv.begin(); + Geom::PathVector::const_iterator pit2 = pv.begin(); + ++pit2; + *vertices = 0; + if(pit->end_closed() != pit->end_default())return(bad); // path must be closed + if(pit2 != pv.end())return(bad); // there may only be one path + P1_trail = pit->finalPoint(); + Geom::Path::const_iterator cit = pit->begin(); + P1 = cit->initialPoint(); + for(;cit != pit->end_closed();++cit) { + if (!is_straight_curve(*cit)) { + *vertices = 0; + return(bad); + } + P1_lead = cit->finalPoint(); + if(Geom::are_near(P1_lead,P1))continue; // duplicate points at the same coordinate + v1 = unit_vector(P1 - P1_trail); + v2 = unit_vector(P1_lead - P1 ); + if(Geom::are_near(dot(v1,v2),1.0)){ // P1 is within a straight line + P1 = P1_lead; + continue; + } + // P1 is the center point of a turn of some angle + if(!*vertices){ + output.start( P1 ); + output.close( pit->closed() ); + } + *vertices += 1; + Geom::LineSegment ls(P1_trail, P1); + output.append(ls); + P1_trail = P1; + P1 = P1_lead; + } + return(output); +} + +/* Returns the simplified PathVector (no matter what). + Sets is_rect if it is a rectangle. + Sets angle that will rotate side closest to horizontal onto horizontal. +*/ +Geom::Path PrintEmf::pathv_to_rect(Geom::PathVector const &pathv, bool *is_rect, double *angle) +{ + Geom::Point P1_trail; + Geom::Point P1; + Geom::Point P1_lead; + Geom::Point v1,v2; + int vertices; + Geom::Path pR = pathv_to_simple_polygon(pathv, &vertices); + *is_rect = false; + if(vertices==4){ // or else it cannot be a rectangle rectangle + int vertex_count=0; + /* Get the ends of the LAST line segment. + Find minimum rotation to align rectangle with X,Y axes. (Very degenerate if it is rotated 45 degrees.) */ + *angle = 10.0; /* must be > than the actual angle in radians. */ + for(Geom::Path::const_iterator cit = pR.begin(); cit != pR.end_open(); ++cit){ + P1_trail = cit->initialPoint(); + P1 = cit->finalPoint(); + v1 = unit_vector(P1 - P1_trail); + if(v1[Geom::X] > 0){ // only check the 1 or 2 points on vectors aimed the same direction as unit X + double ang = asin(v1[Geom::Y]); // because component is rotation by ang of {1,0| vector + if(fabs(ang) < fabs(*angle))*angle = -ang; // y increases down, flips sign on angle + } + } + + for(Geom::Path::const_iterator cit = pR.begin(); cit != pR.end_open();++cit) { + P1_lead = cit->finalPoint(); + v1 = unit_vector(P1 - P1_trail); + v2 = unit_vector(P1_lead - P1 ); + if(!Geom::are_near(dot(v1,v2),0.0))break; // P1 is center of a turn that is not 90 degrees + P1_trail = P1; + P1 = P1_lead; + vertex_count++; + } + if(vertex_count == 4){ + *is_rect=true; + } + } + return(pR); +} + +/* Compare a vector with a rectangle's orientation (angle needed to rotate side(s) + closest to horizontal to exactly horizontal) and return: + 0 none of the following + 1 parallel to horizontal + 2 parallel to vertical + 3 antiparallel to horizontal + 4 antiparallel to vertical +*/ +int PrintEmf::vector_rect_alignment(double angle, Geom::Point vtest){ + int stat = 0; + Geom::Point v1 = Geom::unit_vector(vtest); // unit vector to test alignment + Geom::Point v2 = Geom::Point(1,0) * Geom::Rotate(-angle); // unit horizontal side (sign change because Y increases DOWN) + if( Geom::are_near(dot(v1,v2), 1.0)){ stat = 1; } + else if(Geom::are_near(dot(v1,v2),-1.0)){ stat = 2; } + if(!stat){ + v2 = Geom::Point(0,1) * Geom::Rotate(-angle); // unit vertical side + if( Geom::are_near(dot(v1,v2), 1.0)){ stat = 3; } + else if(Geom::are_near(dot(v1,v2),-1.0)){ stat = 4; } + } + return(stat); +} + +/* retrieve the point at the indicated corner: + 0 UL (and default) + 1 UR + 2 LR + 3 LL + Needed because the start can be any point, and the direction could run either + clockwise or counterclockwise. This should work even if the corners of the rectangle + are slightly displaced. +*/ +Geom::Point PrintEmf::get_pathrect_corner(Geom::Path pathRect, double angle, int corner){ + Geom::Point v1 = Geom::Point(1,0) * Geom::Rotate(-angle); // unit horizontal side (sign change because Y increases DOWN) + Geom::Point v2 = Geom::Point(0,1) * Geom::Rotate(-angle); // unit vertical side (sign change because Y increases DOWN) + Geom::Point center, P1; + int LR; // 1 if Left, 0 if Right + int UL; // 1 if Lower, 0 if Upper (as viewed on screen, y coordinates increase downwards) + center = Geom::Point(0,0); + Geom::Path::const_iterator cit = pathRect.begin(); + for(; cit != pathRect.end_open();++cit) { + center += cit->initialPoint()/4.0; + } + + switch(corner){ + case 1: //UR + LR = 0; + UL = 0; + break; + case 2: //LR + LR = 0; + UL = 1; + break; + case 3: //LL + LR = 1; + UL = 1; + break; + default: //UL + LR = 1; + UL = 0; + break; + } + cit = pathRect.begin(); + for(int i; cit != pathRect.end_open();++cit,i++) { + P1 = cit->initialPoint(); + if((LR == (dot(P1 - center,v1)> 0 ? 0 : 1)) && + (UL == (dot(P1 - center,v2)> 0 ? 1 : 0)))break; + } + return(P1); +} + +U_TRIVERTEX PrintEmf::make_trivertex(Geom::Point Pt, U_COLORREF uc){ + U_TRIVERTEX tv; + using Geom::X; + using Geom::Y; + tv.x = (int32_t) round(Pt[X]); + tv.y = (int32_t) round(Pt[Y]); + tv.Red = uc.Red << 8; + tv.Green = uc.Green << 8; + tv.Blue = uc.Blue << 8; + tv.Alpha = uc.Reserved << 8; // EMF will ignore this + return(tv); +} unsigned int PrintEmf::fill( Inkscape::Extension::Print * /*mod*/, @@ -795,8 +976,27 @@ unsigned int PrintEmf::fill( use_stroke = false; fill_transform = tf; + + int brush_stat = create_brush(style, NULL); + + /* native linear gradients are only used if the object is a rectangle AND the gradient is parallel to the sides of the object */ + bool is_Rect = false; + double angle; + int rectDir=0; + Geom::Path pathRect; + if(FixPPTLinGrad && brush_stat && gv.mode == DRAW_LINEAR_GRADIENT){ + pathRect = pathv_to_rect(pathv, &is_Rect, &angle); + if(is_Rect){ + /* Gradientfill records can only be used if the gradient is parallel to the sides of the rectangle. + That must be checked here so that we can fall back to another form of gradient fill if it is not + the case. */ + rectDir = vector_rect_alignment(angle, gv.p2 - gv.p1); + if(!rectDir)is_Rect = false; + } + if(!is_Rect && !FixPPTGrad2Polys)brush_stat=0; // fall all the way back to a solid fill + } - if (create_brush(style, NULL)) { // only happens if the style is a gradient + if (brush_stat) { // only happens if the style is a gradient /* Handle gradients. Uses modified livarot as 2geom boolops is currently broken. Can handle gradients with multiple stops. @@ -819,10 +1019,10 @@ unsigned int PrintEmf::fill( SPRadialGradient *tg = (SPRadialGradient *)(gv.grad); // linear/radial are the same here nstops = tg->vector.stops.size(); sp_color_get_rgb_floatv(&tg->vector.stops[0].color, rgb); - opa = tg->vector.stops[0].opacity; + opa = tg->vector.stops[0].opacity; // first stop c1 = U_RGBA(255 * rgb[0], 255 * rgb[1], 255 * rgb[2], 255 * opa); sp_color_get_rgb_floatv(&tg->vector.stops[nstops - 1].color, rgb); - opa = tg->vector.stops[nstops - 1].opacity; + opa = tg->vector.stops[nstops - 1].opacity; // last stop c2 = U_RGBA(255 * rgb[0], 255 * rgb[1], 255 * rgb[2], 255 * opa); doff = 0.0; @@ -868,9 +1068,10 @@ unsigned int PrintEmf::fill( pathvr = sp_pathvector_boolop(pathvc, pathv, bool_op_inters, (FillRule) fill_nonZero, frb); print_pathv(pathvr, fill_transform); // show the intersection - if (doff >= doff_range - doff_base) { + if (doff >= doff_range) { istop++; if (istop >= nstops) { + istop = nstops - 1; continue; // could happen on a rounding error } doff_base = doff_range; @@ -882,56 +1083,145 @@ unsigned int PrintEmf::fill( } } } else if (gv.mode == DRAW_LINEAR_GRADIENT) { - Geom::Point uv = Geom::unit_vector(gv.p2 - gv.p1); // unit vector - Geom::Point puv = uv.cw(); // perp. to unit vector - double range = Geom::distance(gv.p1, gv.p2); // length along the gradient - double step = range / divisions; // adequate approximation for gradient - double overlap = step / 4.0; // overlap slices slightly - double start; - double stop; - Geom::PathVector pathvc, pathvr; - - /* before lower end of gradient, overlap first slice position */ - wc = weight_opacity(c1); - (void) create_brush(style, &wc); - pathvc = rect_cutter(gv.p1, uv * (overlap), uv * (-50000.0), puv * 50000.0); - pathvr = sp_pathvector_boolop(pathvc, pathv, bool_op_inters, (FillRule) fill_nonZero, frb); - print_pathv(pathvr, fill_transform); - - /* after high end of gradient, overlap last slice poosition */ - wc = weight_opacity(c2); - (void) create_brush(style, &wc); - pathvc = rect_cutter(gv.p2, uv * (-overlap), uv * (50000.0), puv * 50000.0); - pathvr = sp_pathvector_boolop(pathvc, pathv, bool_op_inters, (FillRule) fill_nonZero, frb); - print_pathv(pathvr, fill_transform); + if(is_Rect){ + char *rec; + int gMode; + Geom::Point ul, ur, lr; + Geom::Point outUL, outLR; // UL,LR corners of a stop rectangle, in OUTPUT coordinates + U_TRIVERTEX ut[2]; + U_GRADIENT4 ug4; + U_RECTL rcb; + Geom::Affine tf2; + U_XFORM tmpTransform; + double wRect, hRect; + + /* coordinates, w,h and transform for the ENTIRE retangle */ + ul = get_pathrect_corner(pathRect, angle, 0) * fill_transform * PX2WORLD; + ur = get_pathrect_corner(pathRect, angle, 1) * fill_transform * PX2WORLD; + lr = get_pathrect_corner(pathRect, angle, 2) * fill_transform * PX2WORLD; + wRect = Geom::distance(ul,ur); + hRect = Geom::distance(ur,lr); + + /* The basic rectangle for all of these is placed with its UL corner at 0,0 with a size wRect,hRect. + Apply a world transform to place/scale it into the appropriate position on the drawing. + Actual gradientfill records are either this entire rectangle or slices of it as defined by the stops. + */ + + tf2 = Geom::Rotate(-angle); + tmpTransform.eM11 = tf2[0]; + tmpTransform.eM12 = tf2[1]; + tmpTransform.eM21 = tf2[2]; + tmpTransform.eM22 = tf2[3]; + tmpTransform.eDx = (ul)[Geom::X]; + tmpTransform.eDy = (ul)[Geom::Y]; + + rec = U_EMRSAVEDC_set(); + if (!rec || emf_append((PU_ENHMETARECORD)rec, et, U_REC_FREE)) { + g_error("Fatal programming error in PrintEmf::image at U_EMRSAVEDC_set"); + } - sp_color_get_rgb_floatv(&tg->vector.stops[istop].color, rgb); - opa = tg->vector.stops[istop].opacity; - c2 = U_RGBA(255 * rgb[0], 255 * rgb[1], 255 * rgb[2], 255 * opa); + rec = U_EMRMODIFYWORLDTRANSFORM_set(tmpTransform, U_MWT_LEFTMULTIPLY); + if (!rec || emf_append((PU_ENHMETARECORD)rec, et, U_REC_FREE)) { + g_error("Fatal programming error in PrintEmf::image at EMRMODIFYWORLDTRANSFORM"); + } + + for(;istop<nstops;istop++){ + doff_range = tg->vector.stops[istop].offset; // next or last stop + if(rectDir == 1 || rectDir == 2){ + outUL = Geom::Point(doff_base *wRect, 0 ); + outLR = Geom::Point(doff_range*wRect, hRect); + gMode = U_GRADIENT_FILL_RECT_H; + } + else { + outUL = Geom::Point(0, doff_base *hRect); + outLR = Geom::Point(wRect,doff_range*hRect); + gMode = U_GRADIENT_FILL_RECT_V; + } + doff_base = doff_range; + rcb.left = outUL[X]; + rcb.top = outUL[Y]; + rcb.right = outLR[X]; + rcb.bottom = outLR[Y]; + sp_color_get_rgb_floatv(&tg->vector.stops[istop].color, rgb); + opa = tg->vector.stops[istop].opacity; + c2 = U_RGBA(255 * rgb[0], 255 * rgb[1], 255 * rgb[2], 255 * opa); + + if(rectDir == 2 || rectDir == 4){ // gradient is reversed, so swap colors + ut[0] = make_trivertex(outUL, c2); + ut[1] = make_trivertex(outLR, c1); + } + else { + ut[0] = make_trivertex(outUL, c1); + ut[1] = make_trivertex(outLR, c2); + } + c1 = c2; // for next stop + ug4.UpperLeft = 0; + ug4.LowerRight= 1; + /* NEED to push world transform here for rotations */ + rec = U_EMRGRADIENTFILL_set(rcb, 2, 1, gMode, ut, (uint32_t *) &ug4 ); + if (!rec || emf_append((PU_ENHMETARECORD)rec, et, U_REC_FREE)) { + g_error("Fatal programming error in PrintEmf::fill at U_EMRGRADIENTFILL_set"); + } + } - for (start = 0.0; start < range; start += step, doff += 1. / divisions) { - stop = start + step + overlap; - if (stop > range) { - stop = range; + rec = U_EMRRESTOREDC_set(-1); + if (!rec || emf_append((PU_ENHMETARECORD)rec, et, U_REC_FREE)) { + g_error("Fatal programming error in PrintEmf::fill at U_EMRRESTOREDC_set"); } - pathvc = rect_cutter(gv.p1, uv * start, uv * stop, puv * 50000.0); + } + else { + Geom::Point uv = Geom::unit_vector(gv.p2 - gv.p1); // unit vector + Geom::Point puv = uv.cw(); // perp. to unit vector + double range = Geom::distance(gv.p1, gv.p2); // length along the gradient + double step = range / divisions; // adequate approximation for gradient + double overlap = step / 4.0; // overlap slices slightly + double start; + double stop; + Geom::PathVector pathvc, pathvr; + + /* before lower end of gradient, overlap first slice position */ + wc = weight_opacity(c1); + (void) create_brush(style, &wc); + pathvc = rect_cutter(gv.p1, uv * (overlap), uv * (-50000.0), puv * 50000.0); + pathvr = sp_pathvector_boolop(pathvc, pathv, bool_op_inters, (FillRule) fill_nonZero, frb); + print_pathv(pathvr, fill_transform); - wc = weight_colors(c1, c2, (doff - doff_base) / (doff_range - doff_base)); + /* after high end of gradient, overlap last slice position */ + wc = weight_opacity(c2); (void) create_brush(style, &wc); - Geom::PathVector pathvr = sp_pathvector_boolop(pathvc, pathv, bool_op_inters, (FillRule) fill_nonZero, frb); - print_pathv(pathvr, fill_transform); // show the intersection + pathvc = rect_cutter(gv.p2, uv * (-overlap), uv * (50000.0), puv * 50000.0); + pathvr = sp_pathvector_boolop(pathvc, pathv, bool_op_inters, (FillRule) fill_nonZero, frb); + print_pathv(pathvr, fill_transform); - if (doff >= doff_range - doff_base) { - istop++; - if (istop >= nstops) { - continue; // could happen on a rounding error + sp_color_get_rgb_floatv(&tg->vector.stops[istop].color, rgb); + opa = tg->vector.stops[istop].opacity; + c2 = U_RGBA(255 * rgb[0], 255 * rgb[1], 255 * rgb[2], 255 * opa); + + for (start = 0.0; start < range; start += step, doff += 1. / divisions) { + stop = start + step + overlap; + if (stop > range) { + stop = range; + } + pathvc = rect_cutter(gv.p1, uv * start, uv * stop, puv * 50000.0); + + wc = weight_colors(c1, c2, (doff - doff_base) / (doff_range - doff_base)); + (void) create_brush(style, &wc); + Geom::PathVector pathvr = sp_pathvector_boolop(pathvc, pathv, bool_op_inters, (FillRule) fill_nonZero, frb); + print_pathv(pathvr, fill_transform); // show the intersection + + if (doff >= doff_range) { + istop++; + if (istop >= nstops) { + istop = nstops - 1; + continue; // could happen on a rounding error + } + doff_base = doff_range; + doff_range = tg->vector.stops[istop].offset; // next or last stop + c1 = c2; + sp_color_get_rgb_floatv(&tg->vector.stops[istop].color, rgb); + opa = tg->vector.stops[istop].opacity; + c2 = U_RGBA(255 * rgb[0], 255 * rgb[1], 255 * rgb[2], 255 * opa); } - doff_base = doff_range; - doff_range = tg->vector.stops[istop].offset; // next or last stop - c1 = c2; - sp_color_get_rgb_floatv(&tg->vector.stops[istop].color, rgb); - opa = tg->vector.stops[istop].opacity; - c2 = U_RGBA(255 * rgb[0], 255 * rgb[1], 255 * rgb[2], 255 * opa); } } } else { @@ -1301,6 +1591,10 @@ unsigned int PrintEmf::image( U_POINTL cDest = pointl_set(round(dw * PX2WORLD), round(dh * PX2WORLD)); U_POINTL Src = pointl_set(0, 0); U_POINTL cSrc = pointl_set(w, h); + /* map the integer Dest coordinates back into pLL2, so that the rounded part does not destabilize the transform offset below */ + pLL2[Geom::X] = Dest.x; + pLL2[Geom::Y] = Dest.y; + pLL2 /= PX2WORLD; if (!FixImageRot) { /* Rotate images - some programs cannot read them in correctly if they are rotated */ tf[4] = tf[5] = 0.0; // get rid of the offset in the transform Geom::Point pLL2prime = pLL2 * tf; @@ -1309,7 +1603,7 @@ unsigned int PrintEmf::image( tmpTransform.eM12 = tf[1]; tmpTransform.eM21 = tf[2]; tmpTransform.eM22 = tf[3]; - tmpTransform.eDx = (pLL2[Geom::X] - pLL2prime[Geom::X]) * PX2WORLD; //map pLL2 (now in EMF coordinates) back onto itself after the rotation + tmpTransform.eDx = (pLL2[Geom::X] - pLL2prime[Geom::X]) * PX2WORLD; tmpTransform.eDy = (pLL2[Geom::Y] - pLL2prime[Geom::Y]) * PX2WORLD; rec = U_EMRSAVEDC_set(); @@ -1734,6 +2028,7 @@ void PrintEmf::init(void) "<param name=\"FixPPTCharPos\" type=\"boolean\">false</param>\n" "<param name=\"FixPPTDashLine\" type=\"boolean\">false</param>\n" "<param name=\"FixPPTGrad2Polys\" type=\"boolean\">false</param>\n" + "<param name=\"FixPPTLinGrad\" type=\"boolean\">false</param>\n" "<param name=\"FixPPTPatternAsHatch\" type=\"boolean\">false</param>\n" "<param name=\"FixImageRot\" type=\"boolean\">false</param>\n" "<print/>\n" diff --git a/src/extension/internal/emf-print.h b/src/extension/internal/emf-print.h index 1546fcaea..8fc9908e3 100644 --- a/src/extension/internal/emf-print.h +++ b/src/extension/internal/emf-print.h @@ -68,6 +68,11 @@ public: protected: static void smuggle_adxkyrtl_out(const char *string, uint32_t **adx, double *ky, int *rtl, int *ndx, float scale); + Geom::Path pathv_to_simple_polygon(Geom::PathVector const &pathv, int *vertices); + Geom::Path pathv_to_rect(Geom::PathVector const &pathv, bool *is_rect, double *angle); + Geom::Point get_pathrect_corner(Geom::Path pathRect, double angle, int corner); + U_TRIVERTEX make_trivertex(Geom::Point Pt, U_COLORREF uc); + int vector_rect_alignment(double angle, Geom::Point vtest); int create_brush(SPStyle const *style, PU_COLORREF fcolor); void destroy_brush(); int create_pen(SPStyle const *style, const Geom::Affine &transform); diff --git a/src/extension/internal/metafile-inout.cpp b/src/extension/internal/metafile-inout.cpp new file mode 100644 index 000000000..c7ae53370 --- /dev/null +++ b/src/extension/internal/metafile-inout.cpp @@ -0,0 +1,210 @@ +/** @file + * @brief Metafile input - common routines + *//* + * Authors: + * David Mathog + * + * Copyright (C) 2013 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <cstring> +#include <fstream> +#include <glib.h> +#include <glibmm/miscutils.h> + +#include "extension/internal/metafile-inout.h" // picks up PNG +#include "extension/print.h" +#include "path-prefix.h" +#include "sp-gradient.h" +#include "sp-image.h" +#include "sp-linear-gradient.h" +#include "sp-pattern.h" +#include "sp-radial-gradient.h" +#include "style.h" + +namespace Inkscape { +namespace Extension { +namespace Internal { + +Metafile::~Metafile() +{ + return; +} + +/** Construct a PNG in memory from an RGB from the EMF file + +from: +http://www.lemoda.net/c/write-png/ + +which was based on: +http://stackoverflow.com/questions/1821806/how-to-encode-png-to-buffer-using-libpng + +gcc -Wall -o testpng testpng.c -lpng + +Originally here, but moved up + +#include <png.h> +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +*/ + + +/* Given "bitmap", this returns the pixel of bitmap at the point + ("x", "y"). */ + +pixel_t * Metafile::pixel_at (bitmap_t * bitmap, int x, int y) +{ + return bitmap->pixels + bitmap->width * y + x; +} + + +/* Write "bitmap" to a PNG file specified by "path"; returns 0 on + success, non-zero on error. */ + +void +Metafile::my_png_write_data(png_structp png_ptr, png_bytep data, png_size_t length) +{ + PMEMPNG p=(PMEMPNG)png_get_io_ptr(png_ptr); + + size_t nsize = p->size + length; + + /* allocate or grow buffer */ + if(p->buffer){ p->buffer = (char *) realloc(p->buffer, nsize); } + else{ p->buffer = (char *) malloc(nsize); } + + if(!p->buffer){ png_error(png_ptr, "Write Error"); } + + /* copy new bytes to end of buffer */ + memcpy(p->buffer + p->size, data, length); + p->size += length; +} + +void Metafile::toPNG(PMEMPNG accum, int width, int height, const char *px){ + bitmap_t bmStore; + bitmap_t *bitmap = &bmStore; + accum->buffer=NULL; // PNG constructed in memory will end up here, caller must free(). + accum->size=0; + bitmap->pixels=(pixel_t *)px; + bitmap->width = width; + bitmap->height = height; + + png_structp png_ptr = NULL; + png_infop info_ptr = NULL; + size_t x, y; + png_byte ** row_pointers = NULL; + /* The following number is set by trial and error only. I cannot + see where it it is documented in the libpng manual. + */ + int pixel_size = 3; + int depth = 8; + + png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + if (png_ptr == NULL){ + accum->buffer=NULL; + return; + } + + info_ptr = png_create_info_struct (png_ptr); + if (info_ptr == NULL){ + png_destroy_write_struct (&png_ptr, &info_ptr); + accum->buffer=NULL; + return; + } + + /* Set up error handling. */ + + if (setjmp (png_jmpbuf (png_ptr))) { + png_destroy_write_struct (&png_ptr, &info_ptr); + accum->buffer=NULL; + return; + } + + /* Set image attributes. */ + + png_set_IHDR ( + png_ptr, + info_ptr, + bitmap->width, + bitmap->height, + depth, + PNG_COLOR_TYPE_RGB, + PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_DEFAULT, + PNG_FILTER_TYPE_DEFAULT + ); + + /* Initialize rows of PNG. */ + + row_pointers = (png_byte **) png_malloc (png_ptr, bitmap->height * sizeof (png_byte *)); + for (y = 0; y < bitmap->height; ++y) { + png_byte *row = + (png_byte *) png_malloc (png_ptr, sizeof (uint8_t) * bitmap->width * pixel_size); + row_pointers[bitmap->height - y - 1] = row; // Row order in EMF is reversed. + for (x = 0; x < bitmap->width; ++x) { + pixel_t * pixel = pixel_at (bitmap, x, y); + *row++ = pixel->red; // R & B channels were set correctly by DIB_to_RGB + *row++ = pixel->green; + *row++ = pixel->blue; + } + } + + /* Write the image data to memory */ + + png_set_rows (png_ptr, info_ptr, row_pointers); + + png_set_write_fn(png_ptr, accum, my_png_write_data, NULL); + + png_write_png (png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, NULL); + + for (y = 0; y < bitmap->height; y++) { + png_free (png_ptr, row_pointers[y]); + } + png_free (png_ptr, row_pointers); + png_destroy_write_struct(&png_ptr, &info_ptr); + +} + + +/* convert an EMF RGB(A) color to 0RGB +inverse of gethexcolor() in emf-print.cpp +*/ +uint32_t Metafile::sethexcolor(U_COLORREF color){ + + uint32_t out; + out = (U_RGBAGetR(color) << 16) + + (U_RGBAGetG(color) << 8 ) + + (U_RGBAGetB(color) ); + return(out); +} + +/* Return the base64 encoded png which is shown for all bad images. +Currently a random 3x4 blotch. +Caller must free. +*/ +gchar *Metafile::bad_image_png(void){ + gchar *gstring = g_strdup("iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAIAAAA7ljmRAAAAA3NCSVQICAjb4U/gAAAALElEQVQImQXBQQ2AMAAAsUJQMSWI2H8qME1yMshojwrvGB8XcHKvR1XtOTc/8HENumHCsOMAAAAASUVORK5CYII="); + return(gstring); +} + + + +} // namespace Internal +} // namespace Extension +} // namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/extension/internal/metafile-inout.h b/src/extension/internal/metafile-inout.h new file mode 100644 index 000000000..968773a3a --- /dev/null +++ b/src/extension/internal/metafile-inout.h @@ -0,0 +1,93 @@ +/** @file + * @brief Metafile input - common functions + *//* + * Authors: + * David Mathog + * + * Copyright (C) 2013 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_METAFILE_INOUT_H +#define SEEN_INKSCAPE_EXTENSION_INTERNAL_METAFILE_INOUT_H + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#define PNG_SKIP_SETJMP_CHECK // else any further png.h include blows up in the compiler +#include <png.h> +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <map> +#include <stack> +#include <glibmm/ustring.h> +#include <libuemf/uemf.h> +#include <2geom/affine.h> +#include <2geom/pathvector.h> + +#include "extension/implementation/implementation.h" + +class SPObject; + +namespace Inkscape { +class Pixbuf; + +namespace Extension { +namespace Internal { + +/* A coloured pixel. */ +typedef struct { + uint8_t red; + uint8_t green; + uint8_t blue; + uint8_t opacity; +} pixel_t; + +/* A picture. */ + typedef struct { + pixel_t *pixels; + size_t width; + size_t height; +} bitmap_t; + +/* structure to store PNG image bytes */ +typedef struct { + char *buffer; + size_t size; +} MEMPNG, *PMEMPNG; + +class Metafile + : public Inkscape::Extension::Implementation::Implementation +{ +public: + Metafile() {} + ~Metafile(); + +protected: + static uint32_t sethexcolor(U_COLORREF color); + static pixel_t *pixel_at (bitmap_t * bitmap, int x, int y); + static void my_png_write_data(png_structp png_ptr, png_bytep data, png_size_t length); + static void toPNG(PMEMPNG accum, int width, int height, const char *px); + static gchar *bad_image_png(void); + + +private: +}; + +} // namespace Internal +} // namespace Extension +} // namespace Inkscape + +#endif // SEEN_INKSCAPE_EXTENSION_INTERNAL_METAFILE_INOUT_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ diff --git a/src/extension/internal/metafile-print.cpp b/src/extension/internal/metafile-print.cpp index 1e7735410..73d63f27d 100644 --- a/src/extension/internal/metafile-print.cpp +++ b/src/extension/internal/metafile-print.cpp @@ -187,7 +187,6 @@ U_COLORREF PrintMetafile::avg_stop_color(SPGradient *gr) return cr; } -#define clrweight(a,b,t) ((1-t)*((double) a) + (t)*((double) b)) U_COLORREF PrintMetafile::weight_opacity(U_COLORREF c1) { float opa = c1.Reserved / 255.0; @@ -199,9 +198,12 @@ U_COLORREF PrintMetafile::weight_opacity(U_COLORREF c1) return result; } +/* t between 0 and 1, values outside that range use the nearest limit */ U_COLORREF PrintMetafile::weight_colors(U_COLORREF c1, U_COLORREF c2, double t) { +#define clrweight(a,b,t) ((1-t)*((double) a) + (t)*((double) b)) U_COLORREF result; + t = ( t > 1.0 ? 1.0 : ( t < 0.0 ? 0.0 : t)); result.Red = clrweight(c1.Red, c2.Red, t); result.Green = clrweight(c1.Green, c2.Green, t); result.Blue = clrweight(c1.Blue, c2.Blue, t); diff --git a/src/extension/internal/wmf-inout.cpp b/src/extension/internal/wmf-inout.cpp index 870e4061c..a72c16a88 100644 --- a/src/extension/internal/wmf-inout.cpp +++ b/src/extension/internal/wmf-inout.cpp @@ -26,7 +26,7 @@ # include "config.h" #endif -#include <png.h> //This must precede text_reassemble.h or it blows up in pngconf.h when compiling +//#include <png.h> //This must precede text_reassemble.h or it blows up in pngconf.h when compiling #include <stdio.h> #include <stdlib.h> #include <stdint.h> @@ -70,154 +70,6 @@ static U_RECT16 rc_old; static bool clipset = false; static uint32_t BLTmode=0; -/** Construct a PNG in memory from an RGB from the WMF file - -from: -http://www.lemoda.net/c/write-png/ - -which was based on: -http://stackoverflow.com/questions/1821806/how-to-encode-png-to-buffer-using-libpng - -gcc -Wall -o testpng testpng.c -lpng - -Originally here, but moved up - -#include <png.h> -#include <stdio.h> -#include <stdlib.h> -#include <stdint.h> -*/ - - -/* Given "bitmap", this returns the pixel of bitmap at the point - ("x", "y"). */ - -pixel_t * Wmf::pixel_at (bitmap_t * bitmap, int x, int y) -{ - return bitmap->pixels + bitmap->width * y + x; -} - - -/* Write "bitmap" to a PNG file specified by "path"; returns 0 on - success, non-zero on error. */ - -void -Wmf::my_png_write_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - PMEMPNG p=(PMEMPNG)png_get_io_ptr(png_ptr); - - size_t nsize = p->size + length; - - /* allocate or grow buffer */ - if(p->buffer){ p->buffer = (char *) realloc(p->buffer, nsize); } - else{ p->buffer = (char *) malloc(nsize); } - - if(!p->buffer){ png_error(png_ptr, "Write Error"); } - - /* copy new bytes to end of buffer */ - memcpy(p->buffer + p->size, data, length); - p->size += length; -} - -void Wmf::toPNG(PMEMPNG accum, int width, int height, const char *px){ - bitmap_t bmStore; - bitmap_t *bitmap = &bmStore; - accum->buffer=NULL; // PNG constructed in memory will end up here, caller must free(). - accum->size=0; - bitmap->pixels=(pixel_t *)px; - bitmap->width = width; - bitmap->height = height; - - png_structp png_ptr = NULL; - png_infop info_ptr = NULL; - size_t x, y; - png_byte ** row_pointers = NULL; - /* The following number is set by trial and error only. I cannot - see where it it is documented in the libpng manual. - */ - int pixel_size = 3; - int depth = 8; - - png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if (png_ptr == NULL){ - accum->buffer=NULL; - return; - } - - info_ptr = png_create_info_struct (png_ptr); - if (info_ptr == NULL){ - png_destroy_write_struct (&png_ptr, &info_ptr); - accum->buffer=NULL; - return; - } - - /* Set up error handling. */ - - if (setjmp (png_jmpbuf (png_ptr))) { - png_destroy_write_struct (&png_ptr, &info_ptr); - accum->buffer=NULL; - return; - } - - /* Set image attributes. */ - - png_set_IHDR ( - png_ptr, - info_ptr, - bitmap->width, - bitmap->height, - depth, - PNG_COLOR_TYPE_RGB, - PNG_INTERLACE_NONE, - PNG_COMPRESSION_TYPE_DEFAULT, - PNG_FILTER_TYPE_DEFAULT - ); - - /* Initialize rows of PNG. */ - - row_pointers = (png_byte **) png_malloc (png_ptr, bitmap->height * sizeof (png_byte *)); - for (y = 0; y < bitmap->height; ++y) { - png_byte *row = - (png_byte *) png_malloc (png_ptr, sizeof (uint8_t) * bitmap->width * pixel_size); - row_pointers[bitmap->height - y - 1] = row; // Row order in WMF is reversed. - for (x = 0; x < bitmap->width; ++x) { - pixel_t * pixel = pixel_at (bitmap, x, y); - *row++ = pixel->red; // R & B channels were set correctly by DIB_to_RGB - *row++ = pixel->green; - *row++ = pixel->blue; - } - } - - /* Write the image data to memory */ - - png_set_rows (png_ptr, info_ptr, row_pointers); - - png_set_write_fn(png_ptr, accum, my_png_write_data, NULL); - - png_write_png (png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, NULL); - - for (y = 0; y < bitmap->height; y++) { - png_free (png_ptr, row_pointers[y]); - } - png_free (png_ptr, row_pointers); - png_destroy_write_struct(&png_ptr, &info_ptr); - -} - - -/* convert an WMF RGB(A) color to 0RGB -inverse of gethexcolor() in emf-print.cpp -*/ -uint32_t Wmf::sethexcolor(U_COLORREF color){ - - uint32_t out; - out = (U_RGBAGetR(color) << 16) + - (U_RGBAGetG(color) << 8 ) + - (U_RGBAGetB(color) ); - return(out); -} - - Wmf::Wmf (void) // The null constructor { return; diff --git a/src/extension/internal/wmf-inout.h b/src/extension/internal/wmf-inout.h index 90f424c46..3d23ca749 100644 --- a/src/extension/internal/wmf-inout.h +++ b/src/extension/internal/wmf-inout.h @@ -11,9 +11,8 @@ #ifndef SEEN_EXTENSION_INTERNAL_WMF_H #define SEEN_EXTENSION_INTERNAL_WMF_H -#define PNG_SKIP_SETJMP_CHECK // else any further png.h include blows up in the compiler -#include <png.h> #include <libuemf/uwmf.h> +#include "extension/internal/metafile-inout.h" // picks up PNG #include "extension/implementation/implementation.h" #include "style.h" #include "text_reassemble.h" @@ -69,35 +68,6 @@ typedef struct wmf_device_context { #define WMF_MAX_DC 128 -/* - both emf-inout.h and wmf-inout.h are included by init.cpp, so whichever one goes in first defines these ommon types -*/ -#ifndef SEEN_EXTENSION_INTERNAL_METAFILECOMMON_ -#define SEEN_EXTENSION_INTERNAL_METAFILECOMMON_ -/* A coloured pixel. */ -typedef struct { - uint8_t red; - uint8_t green; - uint8_t blue; - uint8_t opacity; -} pixel_t; - -/* A picture. */ - -typedef struct { - pixel_t *pixels; - size_t width; - size_t height; -} bitmap_t; - -/* structure to store PNG image bytes */ -typedef struct { - char *buffer; - size_t size; -} MEMPNG, *PMEMPNG; -#endif - - // like this causes a mysterious crash on the return from Wmf::open //typedef struct emf_callback_data { @@ -138,7 +108,8 @@ typedef struct { PWMF_OBJECT wmf_obj; } WMF_CALLBACK_DATA, *PWMF_CALLBACK_DATA; -class Wmf : Inkscape::Extension::Implementation::Implementation { //This is a derived class +class Wmf : public Metafile +{ public: Wmf(); // Empty constructor @@ -158,10 +129,6 @@ public: private: protected: - static pixel_t *pixel_at (bitmap_t * bitmap, int x, int y); - static void my_png_write_data(png_structp png_ptr, png_bytep data, png_size_t length); - static void toPNG(PMEMPNG accum, int width, int height, const char *px); - static uint32_t sethexcolor(U_COLORREF color); static void print_document_to_file(SPDocument *doc, const gchar *filename); static double current_scale(PWMF_CALLBACK_DATA d); static std::string current_matrix(PWMF_CALLBACK_DATA d, double x, double y, int useoffset); diff --git a/src/extension/internal/wmf-print.cpp b/src/extension/internal/wmf-print.cpp index d60b2adf7..1c7b42c82 100644 --- a/src/extension/internal/wmf-print.cpp +++ b/src/extension/internal/wmf-print.cpp @@ -76,7 +76,7 @@ namespace Internal { /* globals */ -static double PX2WORLD = 1200.0 / 90.0; // inkscape is 90 dpi, WMF file is 1200 +static double PX2WORLD; // value set in begin() static bool FixPPTCharPos, FixPPTDashLine, FixPPTGrad2Polys, FixPPTPatternAsHatch; static WMFTRACK *wt = NULL; static WMFHANDLES *wht = NULL; @@ -128,6 +128,8 @@ unsigned int PrintWmf::begin(Inkscape::Extension::Print *mod, SPDocument *doc) char *rec; gchar const *utf8_fn = mod->get_param_string("destination"); + // Typically PX2WORLD is 1200/90, using inkscape's default dpi + PX2WORLD = 1200.0 / Inkscape::Util::Quantity::convert(1.0, "in", "px"); FixPPTCharPos = mod->get_param_bool("FixPPTCharPos"); FixPPTDashLine = mod->get_param_bool("FixPPTDashLine"); FixPPTGrad2Polys = mod->get_param_bool("FixPPTGrad2Polys"); @@ -188,39 +190,39 @@ unsigned int PrintWmf::begin(Inkscape::Extension::Print *mod, SPDocument *doc) int dwPxY = round(d.height() * 1200.0); #endif - PU_PAIRF ps = U_PAIRF_set(dwInchesX, dwInchesY); + U_PAIRF *ps = U_PAIRF_set(dwInchesX, dwInchesY); rec = U_WMRHEADER_set(ps, 1200); // Example: drawing is A4 horizontal, 1200 dpi if (!rec) { g_error("Fatal programming error in PrintWmf::begin at WMRSETMAPMODE"); } - (void) wmf_header_append((PU_METARECORD)rec, wt, 1); + (void) wmf_header_append((U_METARECORD *)rec, wt, 1); free(ps); rec = U_WMRSETWINDOWEXT_set(point16_set(dwPxX, dwPxY)); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::begin at WMRSETWINDOWEXT"); } rec = U_WMRSETWINDOWORG_set(point16_set(0, 0)); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::begin at WMRSETWINDOWORG"); } rec = U_WMRSETMAPMODE_set(U_MM_ANISOTROPIC); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::begin at WMRSETMAPMODE"); } /* set some parameters, else the program that reads the WMF may default to other values */ rec = U_WMRSETBKMODE_set(U_TRANSPARENT); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::begin at U_WMRSETBKMODE"); } hpolyfillmode = U_WINDING; rec = U_WMRSETPOLYFILLMODE_set(U_WINDING); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::begin at U_WMRSETPOLYFILLMODE"); } @@ -229,24 +231,24 @@ unsigned int PrintWmf::begin(Inkscape::Extension::Print *mod, SPDocument *doc) // actually starts, and already takes into account the text object's alignment; // - for this reason, the WMF text alignment must always be TA_BASELINE|TA_LEFT. rec = U_WMRSETTEXTALIGN_set(U_TA_BASELINE | U_TA_LEFT); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::begin at U_WMRSETTEXTALIGN_set"); } htextcolor_rgb[0] = htextcolor_rgb[1] = htextcolor_rgb[2] = 0.0; rec = U_WMRSETTEXTCOLOR_set(U_RGB(0, 0, 0)); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::begin at U_WMRSETTEXTCOLOR_set"); } rec = U_WMRSETROP2_set(U_R2_COPYPEN); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::begin at U_WMRSETROP2"); } hmiterlimit = 5; rec = wmiterlimit_set(5); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::begin at wmiterlimit_set"); } @@ -255,14 +257,14 @@ unsigned int PrintWmf::begin(Inkscape::Extension::Print *mod, SPDocument *doc) U_PEN up = U_PEN_set(U_PS_SOLID, 1, colorref_set(0, 0, 0)); uint32_t Pen; rec = wcreatepenindirect_set(&Pen, wht, up); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::begin at wcreatepenindirect_set"); } // create a null pen. If no specific pen is set, this is used up = U_PEN_set(U_PS_NULL, 1, colorref_set(0, 0, 0)); rec = wcreatepenindirect_set(&hpen_null, wht, up); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::begin at wcreatepenindirect_set"); } destroy_pen(); // make this pen active @@ -270,7 +272,7 @@ unsigned int PrintWmf::begin(Inkscape::Extension::Print *mod, SPDocument *doc) // create a null brush. If no specific brush is set, this is used U_WLOGBRUSH lb = U_WLOGBRUSH_set(U_BS_NULL, U_RGB(0, 0, 0), U_HS_HORIZONTAL); rec = wcreatebrushindirect_set(&hbrush_null, wht, lb); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::begin at wcreatebrushindirect_set"); } destroy_brush(); // make this brush active @@ -288,25 +290,25 @@ unsigned int PrintWmf::finish(Inkscape::Extension::Print * /*mod*/) // get rid of null brush rec = wdeleteobject_set(&hbrush_null, wht); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::finish at wdeleteobject_set null brush"); } // get rid of null pen rec = wdeleteobject_set(&hpen_null, wht); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::finish at wdeleteobject_set null pen"); } // get rid of object 0, which was a pen that was used to shift the other object indices to >=1. hpen = 0; rec = wdeleteobject_set(&hpen, wht); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::finish at wdeleteobject_set filler object"); } rec = U_WMREOF_set(); // generate the EOF record - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::finish"); } (void) wmf_finish(wt); // Finalize and write out the WMF @@ -330,7 +332,7 @@ unsigned int PrintWmf::comment(Inkscape::Extension::Print * /*module*/, const ch // fcolor is defined when gradients are being expanded, it is the color of one stripe or ring. -int PrintWmf::create_brush(SPStyle const *style, PU_COLORREF fcolor) +int PrintWmf::create_brush(SPStyle const *style, U_COLORREF *fcolor) { float rgb[3]; char *rec; @@ -442,17 +444,17 @@ int PrintWmf::create_brush(SPStyle const *style, PU_COLORREF fcolor) // SVG text has no background attribute, so OPAQUE mode ALWAYS cancels after the next draw, otherwise it would mess up future text output. if (usebk) { rec = U_WMRSETBKCOLOR_set(bkColor); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::create_brush at U_WMRSETBKCOLOR_set"); } rec = U_WMRSETBKMODE_set(U_OPAQUE); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::create_brush at U_WMRSETBKMODE_set"); } } lb = U_WLOGBRUSH_set(brushStyle, hatchColor, hatchType); rec = wcreatebrushindirect_set(&brush, wht, lb); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::create_brush at createbrushindirect_set"); } break; @@ -461,10 +463,10 @@ int PrintWmf::create_brush(SPStyle const *style, PU_COLORREF fcolor) char *rgba_px; uint32_t cbPx; uint32_t colortype; - PU_RGBQUAD ct; + U_RGBQUAD *ct; int numCt; U_BITMAPINFOHEADER Bmih; - PU_BITMAPINFO Bmi; + U_BITMAPINFO *Bmi; rgba_px = (char *) pixbuf->pixels(); // Do NOT free this!!! colortype = U_BCBM_COLOR32; (void) RGBA_to_DIB(&px, &cbPx, &ct, &numCt, rgba_px, width, height, width * 4, colortype, 0, 1); @@ -474,7 +476,7 @@ int PrintWmf::create_brush(SPStyle const *style, PU_COLORREF fcolor) Bmih = bitmapinfoheader_set(width, height, 1, colortype, U_BI_RGB, 0, PXPERMETER, PXPERMETER, numCt, 0); Bmi = bitmapinfo_set(Bmih, ct); rec = wcreatedibpatternbrush_srcdib_set(&brush, wht, U_DIB_RGB_COLORS, Bmi, cbPx, px); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::create_brush at createdibpatternbrushpt_set"); } free(px); @@ -484,14 +486,14 @@ int PrintWmf::create_brush(SPStyle const *style, PU_COLORREF fcolor) hbrush = brush; // need this later for destroy_brush rec = wselectobject_set(brush, wht); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::create_brush at wselectobject_set"); } if (fmode != hpolyfillmode) { hpolyfillmode = fmode; rec = U_WMRSETPOLYFILLMODE_set(fmode); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::create_brush at U_WMRSETPOLYFILLMODE_set"); } } @@ -506,7 +508,7 @@ void PrintWmf::destroy_brush() // WMF lets any object be deleted whenever, and the chips fall where they may... if (hbrush) { rec = wdeleteobject_set(&hbrush, wht); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::destroy_brush"); } hbrush = 0; @@ -515,7 +517,7 @@ void PrintWmf::destroy_brush() // (re)select the null brush rec = wselectobject_set(hbrush_null, wht); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::destroy_brush"); } } @@ -583,7 +585,7 @@ int PrintWmf::create_pen(SPStyle const *style, const Geom::Affine &transform) if ((uint32_t)miterlimit != hmiterlimit) { hmiterlimit = (uint32_t)miterlimit; rec = wmiterlimit_set((uint32_t) miterlimit); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::create_pen at wmiterlimit_set"); } } @@ -605,12 +607,12 @@ int PrintWmf::create_pen(SPStyle const *style, const Geom::Affine &transform) up = U_PEN_set(penstyle | modstyle, linewidth, penColor); rec = wcreatepenindirect_set(&pen, wht, up); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::create_pen at wcreatepenindirect_set"); } rec = wselectobject_set(pen, wht); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::create_pen at wselectobject_set"); } hpen = pen; // need this later for destroy_pen @@ -625,7 +627,7 @@ void PrintWmf::destroy_pen() // WMF lets any object be deleted whenever, and the chips fall where they may... if (hpen) { rec = wdeleteobject_set(&hpen, wht); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::destroy_pen"); } hpen = 0; @@ -634,7 +636,7 @@ void PrintWmf::destroy_pen() // (re)select the null pen rec = wselectobject_set(hpen_null, wht); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::destroy_pen"); } } @@ -757,7 +759,7 @@ unsigned int PrintWmf::fill( pathvr = sp_pathvector_boolop(pathvc, pathv, bool_op_inters, (FillRule) fill_nonZero, frb); print_pathv(pathvr, fill_transform); - /* after high end of gradient, overlap last slice poosition */ + /* after high end of gradient, overlap last slice position */ wc = weight_opacity(c2); (void) create_brush(style, &wc); pathvc = rect_cutter(gv.p2, uv * (-overlap), uv * (50000.0), puv * 50000.0); @@ -898,7 +900,7 @@ unsigned int PrintWmf::stroke( if (usebk) { // OPAQUE was set, revert to TRANSPARENT usebk = false; rec = U_WMRSETBKMODE_set(U_TRANSPARENT); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::stroke at U_WMRSETBKMODE_set"); } } @@ -1066,7 +1068,7 @@ bool PrintWmf::print_simple_shape(Geom::PathVector const &pathv, const Geom::Aff }); rec = U_WMRELLIPSE_set(rcl); } - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::print_simple_shape at retangle/ellipse/polygon"); } @@ -1109,7 +1111,7 @@ unsigned int PrintWmf::image( Geom::Affine tf = m_tr_stack.top(); rec = U_WMRSETSTRETCHBLTMODE_set(U_COLORONCOLOR); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::image at EMRHEADER"); } @@ -1126,10 +1128,10 @@ unsigned int PrintWmf::image( char *px; uint32_t cbPx; uint32_t colortype; - PU_RGBQUAD ct; + U_RGBQUAD *ct; int numCt; U_BITMAPINFOHEADER Bmih; - PU_BITMAPINFO Bmi; + U_BITMAPINFO *Bmi; colortype = U_BCBM_COLOR32; (void) RGBA_to_DIB(&px, &cbPx, &ct, &numCt, (char *) rgba_px, w, h, w * 4, colortype, 0, 1); Bmih = bitmapinfoheader_set(w, h, 1, colortype, U_BI_RGB, 0, PXPERMETER, PXPERMETER, numCt, 0); @@ -1150,7 +1152,7 @@ unsigned int PrintWmf::image( h * rs, //! size in bytes of px px //! (Optional) bitmapbuffer (U_BITMAPINFO section) ); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::image at U_WMRSTRETCHDIB_set"); } free(px); @@ -1165,7 +1167,7 @@ unsigned int PrintWmf::image( unsigned int PrintWmf::print_pathv(Geom::PathVector const &pathv, const Geom::Affine &transform) { char *rec = NULL; - PU_POINT16 pt16hold, pt16ptr; + U_POINT16 *pt16hold, *pt16ptr; uint16_t *n16hold; uint16_t *n16ptr; @@ -1199,7 +1201,7 @@ unsigned int PrintWmf::print_pathv(Geom::PathVector const &pathv, const Geom::Af } if (nPolys > 1) { // a single polypolygon, a single polygon falls through to the else - pt16hold = pt16ptr = (PU_POINT16) malloc(totPoints * sizeof(U_POINT16)); + pt16hold = pt16ptr = (U_POINT16 *) malloc(totPoints * sizeof(U_POINT16)); if (!pt16ptr) { return(false); } @@ -1235,7 +1237,7 @@ unsigned int PrintWmf::print_pathv(Geom::PathVector const &pathv, const Geom::Af } rec = U_WMRPOLYPOLYGON_set(nPolys, n16hold, pt16hold); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::print_pathv at U_WMRPOLYPOLYGON_set"); } free(pt16hold); @@ -1256,7 +1258,7 @@ unsigned int PrintWmf::print_pathv(Geom::PathVector const &pathv, const Geom::Af */ int nPoints = 1 + pit->size_default(); - pt16hold = pt16ptr = (PU_POINT16) malloc(nPoints * sizeof(U_POINT16)); + pt16hold = pt16ptr = (U_POINT16 *) malloc(nPoints * sizeof(U_POINT16)); if (!pt16ptr) { break; } @@ -1280,21 +1282,21 @@ unsigned int PrintWmf::print_pathv(Geom::PathVector const &pathv, const Geom::Af if (pit->end_default() == pit->end_closed()) { rec = U_WMRPOLYGON_set(nPoints, pt16hold); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::print_pathv at U_WMRPOLYGON_set"); } } else if (nPoints > 2) { rec = U_WMRPOLYLINE_set(nPoints, pt16hold); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::print_pathv at U_POLYLINE_set"); } } else if (nPoints == 2) { rec = U_WMRMOVETO_set(pt16hold[0]); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::print_pathv at U_WMRMOVETO_set"); } rec = U_WMRLINETO_set(pt16hold[1]); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::print_pathv at U_WMRLINETO_set"); } } @@ -1348,7 +1350,7 @@ unsigned int PrintWmf::text(Inkscape::Extension::Print * /*mod*/, char const *te if (textalignment != htextalignment) { htextalignment = textalignment; rec = U_WMRSETTEXTALIGN_set(textalignment); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::text at U_WMRSETTEXTALIGN_set"); } } @@ -1420,7 +1422,7 @@ unsigned int PrintWmf::text(Inkscape::Extension::Print * /*mod*/, char const *te // it was streteched asymmetrically.) Few applications support text from WMF which is scaled // differently by height/width, so leave lfWidth alone. - PU_FONT puf = U_FONT_set( + U_FONT *puf = U_FONT_set( textheight, 0, round(rot), @@ -1438,14 +1440,14 @@ unsigned int PrintWmf::text(Inkscape::Extension::Print * /*mod*/, char const *te free(facename); rec = wcreatefontindirect_set(&hfont, wht, puf); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::text at wcreatefontindirect_set"); } free(puf); } rec = wselectobject_set(hfont, wht); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::text at wselectobject_set"); } @@ -1455,7 +1457,7 @@ unsigned int PrintWmf::text(Inkscape::Extension::Print * /*mod*/, char const *te if (memcmp(htextcolor_rgb, rgb, 3 * sizeof(float))) { memcpy(htextcolor_rgb, rgb, 3 * sizeof(float)); rec = U_WMRSETTEXTCOLOR_set(U_RGB(255 * rgb[0], 255 * rgb[1], 255 * rgb[2])); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::text at U_WMRSETTEXTCOLOR_set"); } } @@ -1522,12 +1524,12 @@ unsigned int PrintWmf::text(Inkscape::Extension::Print * /*mod*/, char const *te } free(latin1_text); free(adx); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::text at U_WMREXTTEXTOUTW_set"); } rec = wdeleteobject_set(&hfont, wht); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::text at wdeleteobject_set"); } diff --git a/src/filters/componenttransfer-funcnode.cpp b/src/filters/componenttransfer-funcnode.cpp index 7c7375802..d8c5b0d49 100644 --- a/src/filters/componenttransfer-funcnode.cpp +++ b/src/filters/componenttransfer-funcnode.cpp @@ -205,14 +205,18 @@ void SPFeFuncNode::set(unsigned int key, gchar const *value) { } /** - * * Receives update notifications. - * */ + * Receives update notifications. + */ void SPFeFuncNode::update(SPCtx *ctx, guint flags) { + std::cout << "SPFeFuncNode::update" << std::endl; if (flags & SP_OBJECT_MODIFIED_FLAG) { - /* do something to trigger redisplay, updates? */ - //TODO - //this->readAttr( "azimuth" ); - //this->readAttr( "elevation" ); + this->readAttr( "type" ); + this->readAttr( "tableValues" ); + this->readAttr( "slope" ); + this->readAttr( "intercept" ); + this->readAttr( "amplitude" ); + this->readAttr( "exponent" ); + this->readAttr( "offset" ); } SPObject::update(ctx, flags); @@ -222,18 +226,11 @@ void SPFeFuncNode::update(SPCtx *ctx, guint flags) { * Writes its settings to an incoming repr object, if any. */ Inkscape::XML::Node* SPFeFuncNode::write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { + std::cout << "SPFeFuncNode::write" << std::endl; if (!repr) { repr = this->getRepr()->duplicate(doc); } - /* - TODO: I'm not sure what to do here... - - if (fefuncnode->azimuth_set) - sp_repr_set_css_double(repr, "azimuth", fefuncnode->azimuth); - if (fefuncnode->elevation_set) - sp_repr_set_css_double(repr, "elevation", fefuncnode->elevation);*/ - SPObject::write(doc, repr, flags); return repr; diff --git a/src/filters/mergenode.cpp b/src/filters/mergenode.cpp index 1b06db706..ba237c776 100644 --- a/src/filters/mergenode.cpp +++ b/src/filters/mergenode.cpp @@ -45,7 +45,7 @@ SPFeMergeNode::~SPFeMergeNode() { * our name must be associated with a repr via "sp_object_type_register". Best done through * sp-object-repr.cpp's repr_name_entries array. */ -void SPFeMergeNode::build(SPDocument *document, Inkscape::XML::Node *repr) { +void SPFeMergeNode::build(SPDocument */*document*/, Inkscape::XML::Node */*repr*/) { this->readAttr( "in" ); } diff --git a/src/gc-core.h b/src/gc-core.h index 85fbada60..3957bda1a 100644 --- a/src/gc-core.h +++ b/src/gc-core.h @@ -57,7 +57,7 @@ struct Ops { CleanupFunc *old_func, void **old_data); int (*general_register_disappearing_link)(void **p_ptr, - void *base); + void const *base); int (*unregister_disappearing_link)(void **p_ptr); std::size_t (*get_heap_size)(); std::size_t (*get_free_bytes)(); diff --git a/src/gc.cpp b/src/gc.cpp index 9c59691cb..280a8b1dc 100644 --- a/src/gc.cpp +++ b/src/gc.cpp @@ -70,9 +70,13 @@ void *debug_base(void *ptr) { return base + debug_base_fixup(); } -int debug_general_register_disappearing_link(void **p_ptr, void *base) { - char *real_base=reinterpret_cast<char *>(base) - debug_base_fixup(); +int debug_general_register_disappearing_link(void **p_ptr, void const *base) { + char const *real_base = reinterpret_cast<char const *>(base) - debug_base_fixup(); +#if (GC_MAJOR_VERSION >= 7 && GC_MINOR_VERSION >= 4) return GC_general_register_disappearing_link(p_ptr, real_base); +#else // compatibility with older Boehm GC versions + return GC_general_register_disappearing_link(p_ptr, const_cast<char *>(real_base)); +#endif } void dummy_do_init() {} @@ -90,7 +94,7 @@ void dummy_register_finalizer(void *, CleanupFunc, void *, } } -int dummy_general_register_disappearing_link(void **, void *) { return false; } +int dummy_general_register_disappearing_link(void **, void const *) { return false; } int dummy_unregister_disappearing_link(void **/*link*/) { return false; } @@ -112,7 +116,11 @@ Ops enabled_ops = { &GC_malloc_atomic_uncollectable, &GC_base, &GC_register_finalizer_ignore_self, - &GC_general_register_disappearing_link, +#if (GC_MAJOR_VERSION >= 7 && GC_MINOR_VERSION >= 4) + &GC_general_register_disappearing_link, +#else // compatibility with older Boehm GC versions + (int (*)(void**, const void*))(&GC_general_register_disappearing_link), +#endif &GC_unregister_disappearing_link, &GC_get_heap_size, &GC_get_free_bytes, @@ -202,7 +210,7 @@ void stub_register_finalizer_ignore_self(void *, CleanupFunc, void *, die_because_not_initialized(); } -int stub_general_register_disappearing_link(void **, void *) { +int stub_general_register_disappearing_link(void **, void const *) { die_because_not_initialized(); return 0; } diff --git a/src/libnrtype/FontInstance.cpp b/src/libnrtype/FontInstance.cpp index 38a105459..434f3ee47 100644 --- a/src/libnrtype/FontInstance.cpp +++ b/src/libnrtype/FontInstance.cpp @@ -21,7 +21,7 @@ #include FT_TRUETYPE_TABLES_H #include <pango/pangoft2.h> #include <2geom/pathvector.h> -#include <2geom/svg-path.h> +#include <2geom/path-sink.h> #include "libnrtype/font-glyph.h" #include "libnrtype/font-instance.h" #include "livarot/Path.h" @@ -618,7 +618,7 @@ void font_instance::LoadGlyph(int glyph_id) doAdd=true; } #endif - path_builder.finish(); + path_builder.flush(); if ( doAdd ) { Geom::PathVector pv = path_builder.peek(); diff --git a/src/libuemf/CMakeLists.txt b/src/libuemf/CMakeLists.txt index dbf9fb36c..f5a97f212 100644 --- a/src/libuemf/CMakeLists.txt +++ b/src/libuemf/CMakeLists.txt @@ -8,6 +8,8 @@ set(libuemf_SRC uwmf.c uwmf_endian.c uwmf_print.c + upmf.c + upmf_print.c # ------- # Headers @@ -19,6 +21,8 @@ set(libuemf_SRC uwmf.h uwmf_endian.h uwmf_print.h + upmf.h + upmf_print.h ) add_inkscape_lib(uemf_LIB "${libuemf_SRC}") diff --git a/src/libuemf/Makefile_insert b/src/libuemf/Makefile_insert index ca14ed19f..004c56dfc 100644 --- a/src/libuemf/Makefile_insert +++ b/src/libuemf/Makefile_insert @@ -20,5 +20,9 @@ libuemf_libuemf_a_SOURCES = \ libuemf/uwmf_endian.h \ libuemf/uwmf_print.c \ libuemf/uwmf_print.h \ + libuemf/upmf.c \ + libuemf/upmf.h \ + libuemf/upmf_print.c \ + libuemf/upmf_print.h \ libuemf/symbol_convert.c \ libuemf/symbol_convert.h diff --git a/src/libuemf/README b/src/libuemf/README index 53e2469e3..4c23cdd52 100644 --- a/src/libuemf/README +++ b/src/libuemf/README @@ -1,5 +1,477 @@ -Theis directory contains the libUEMF library, -a cross-platform library for Windows Metafile and Enhanced Metafile -handling, created by David Mathog. +Overview: -http://sourceforge.net/projects/libuemf/ +libUEMF is a portable C99 implementation for reading/writing Enhanced Metafile (EMF) +and Windows Metafile (WMF) files. libUEMF avoids collisions with with Microsoft defined +functions and values, so portable programs which use it, and have a Windows version, do +not require any conditional logic to separate the native GDI support from the WMF/EMF support +proviced by libUEMF. To accomplish this libUEMF does not implement GDI calls. Instead, +for each WMR/EMR record type, and each object type incorporated into such a record, it provides +corresponding *_set, *_print, and *_swap functions. (For WMF there are also *_get functions, see below.) +For example, for the U_EMRBITBLT record there are corresponding functions: +U_EMRBITBLT_set, U_EMRBITBLT_print, and U_EMRBITBLT_swap. A few additional functions are provided for +assembling the EMF in memory, debugging, and converting the EMF file to/from Little Endian representation. +(EMF files' internal data representation is always Little Endian.) + +This code has been tested on 32 bit Ubuntu (LE), 32 bit Mingw, 64 bit Manriva, and 64 bit Solaris (BE). + +libUEMF is released under the GPL 2 license, read the file 'COPYING' for more information + +Version 0.1.10, released January 15, 2014. + +To report bugs or provide feedback send email to David Mathog, mathog@caltech.edu. + +-------------------------------------------------------------------------------------------- +Sources: + +EMF file Record structure information has been derived from Mingw, Wine, and libEMF +header files, and from Microsoft's EMF Information pdf, release date March 28,2012, +link from here: + + http://msdn2.microsoft.com/en-us/library/cc230514.aspx + +If the direct link fails the document may be found +by searching the web for: "[MS-EMF]: Enhanced Metafile Format". + +WMF file Record structure information is from some of the same sources, as well as: + http://msdn2.microsoft.com/en-us/library/250370.aspx + +If the direct link fails the document may be found +by searching the web for: "[MS-WMF]: Windows Metafile Format" + +EMF+ file Record structure is from many helpful responses from Microsoft documentation support +and from: + http://msdn.microsoft.com/en-us/library/cc230724.aspx + +If the direct link fails the document may be found +by searching the web for: "[MS-EMFPLUS]: Enhanced Metafile Format Plus Extensions" + + +Files: + +README This file. + +COPYING GPL V2 license file. + +DOXYFILE Doxygen configuration file, for generating documentation from the source files. + +testbuild.sh Small bash script to build all programs. Modify as needed for target platform. + +testit.sh Small bash script that generates all test files and compares + them with referencess supplied. This script should be edited + to match your test system before it is run! + +uemf.c Contains the *_set functions needed to construct an EMF file. + Also contains auxilliary functions for debugging and constructing + EMF files in memory. + +uemf.h Definitions and structures for EMF records and objects. + Prototypes for *_set and construction functions. + +uemf_print.c Contains the *_print functions needed to print the contents of EMF records and objects. + +uemf_print.h Prototypes for *_print functions. + +uemf_endian.c Contains the *_swap functions needed to rearrange bytes between Big and Little Endian. + U_emf_endian() is the only function here that user could should call. + +uemf_endian.h Prototype for U_emf_endian() and definitions for Endian type of the local machine. + + +upmf.c Contains the *_set and *_get functions needed to construct or read an EMF+ file. + Also contains auxilliary functions for debugging and constructing + EMF+ files in memory. + +upmf.h Definitions and structures for EMF+ records and objects. + Prototypes for *_set, *_get and construction functions. + +upmf_print.c Contains the *_print functions needed to print the contents of EMF+ records and objects. + +upmf_print.h Prototypes for *_print functions. + + +uwmf.c Contains the *_set and *_get functions needed to construct or read a WMF file. + Also contains auxilliary functions for debugging and constructing + WMF files in memory. + +uwmf.h Definitions and structures for WMF records and objects. + Prototypes for *_set, *_get and construction functions. + +uwmf_print.c Contains the *_print functions needed to print the contents of WMF records and objects. + +uwmf_print.h Prototypes for *_print functions. + +uwmf_endian.c Contains the *_swap functions needed to rearrange bytes between Big and Little Endian. + U_wmf_endian() is the only function here that user could should call. + +uwmf_endian.h Prototype for U_wmf_endian() and definitions for Endian type of the local machine. + + +testbed_emf.c Program used for testing emf functions in libUEMF. Run it like: testbed_emf flags. + Run with no argument to see what the bit flag values are. + It creates a test file "test_libuemf.emf" which should be identical to + test_libuemf_ref.emf. (This file cannot be imported from EMF into PowerPoint + because it contains dotted lines. Use "testbed_emf 1" to generate a file without + any dotted lines. ) + +testbed_pmf.c Program used for testing EMF+ functions in libUEMF. Similar to testbed_emf. + +testbed_wmf.c Program used for testing wmf functions in libUEMF. Similar to testbed_emf. + +test_mapmodes_emf.c + Program used for testing emf functions in libUEMF. Generates one test file + in each MAPMODE, MM_TEXT through MM_ANISOTROPIC, optionally with offsets to the + bounds and with particular Viewport origin. (Bounds offset + Viewport Origin + sets the Window origin.) + +test_mapmodes_wmf.c + Program used for testing wmf functions in libUEMF. Similar to test_mapmodes_emf. + +reademf.c Utility that that reads an EMF file and emits its contents in text form. + Also processes EMF+ files. + Run it like: reademf target_file.emf + +readwmf.c Utility that that reads an WMF file and emits its contents in text form. + Run it like: reademf target_file.wmf + +cutemf.c Utility for removing specific records from an EMF file. + Run it like: cutemf '2,10,12...13' src_file.emf dst_file.emf + +pmfdual2single.c Utility for reducing dual-mode EMF+ file to single mode. Removes all + nonessential EMF records. + Run it like: pmfdual2single dual_mode.emf single_mode.emf + + +test_libuemf_ref.emf + Example output from: testbed_emf 0 +test_libuemf_p_ref.emf + Example output from: testbed_pmf 0 +test_libuemf_ref30.emf + Example output from: testbed_emf 4 +test_libuemf_ref.wmf + Example output from: testbed_wmf 0 + +test_libuemf_ref_emf.txt + Example output from: reademf test_libuemf_ref.emf +test_libuemf_ref_wmf.txt + Example output from: readwmf test_libuemf_ref.wmf + +test_mm_<modes>_ref.emf + Example output from: test_mapmodes_emf -vX 2000 -vY 1000 + +emf-inout.cpp,example +emf-inout.h.example +emf-print.cpp.example +emf-print.h.example + Example code from Inkscape demonstrate how to integrate libUEMF with another program. + +-------------------------------------------------------------------------------------------- +How to Build: + +In Linux/Unix like environments (omit -g flag for production versions): + + Build and install a shared library (example, details may vary) and then build and link + the example programs to the shared library: + gcc -std=c99 -pedantic -Wall -fPIC -g -c uemf.c + gcc -std=c99 -pedantic -Wall -fPIC -g -c uemf_print.c + gcc -std=c99 -pedantic -Wall -fPIC -g -c uemf_endian.c + gcc -std=c99 -pedantic -Wall -fPIC -g -c uemf_utf.c + gcc -std=c99 -pedantic -Wall -fPIC -g -c uwmf.c + gcc -std=c99 -pedantic -Wall -fPIC -g -c uwmf_print.c + gcc -std=c99 -pedantic -Wall -fPIC -g -c uwmf_endian.c + gcc -std=c99 -pedantic -Wall -fPIC -g -c upmf.c + gcc -std=c99 -pedantic -Wall -fPIC -g -c upmf_print.c + gcc -shared -Wl,-soname,libuemf.so.0 \ + -o libuemf.so.0.0.3 uemf.o uemf_utf.o uemf_print.o uemf_endian.o uwmf.o uwmf_print.o uwmf_endian.o upmf.o upmf_print.o -lc + ln -s libuemf.so.0.0.3 libuemf.so.0 + ln -s libuemf.so.0 libuemf.so + /bin/cp -f libuemf.so* /usr/local/lib + ldconfig + gcc -std=c99 -pedantic -Wall -g -o cutemf cutemf.c -luemf -lm + gcc -std=c99 -pedantic -Wall -g -o pmfdual2single pmfdual2single.c -luemf -lm + gcc -std=c99 -pedantic -Wall -g -o reademf reademf.c -luemf -lm + gcc -std=c99 -pedantic -Wall -g -o readwmf readwmf.c -luemf -lm + gcc -std=c99 -pedantic -Wall -g -o testbed_emf testbed_emf.c -luemf -lm + gcc -std=c99 -pedantic -Wall -g -o testbed_emf testbed_wmf.c -luemf -lm + gcc -std=c99 -pedantic -Wall -g -o test_mapmodes_emf test_mapmodes_emf.c -luemf -lm + + For simple development work just build the example programs statically linked: + gcc -std=c99 -pedantic -Wall -g -o cutemf cutemf.c uemf.c uemf_endian.c uemf_utf.c -lm + gcc -std=c99 -pedantic -Wall -g -o pmfdual2single pmfdual2single.c uemf.c uemf_endian.c uemf_utf.c upmf.c -lm + gcc -std=c99 -pedantic -Wall -g -o reademf reademf.c uemf.c uemf_endian.c uemf_utf.c uemf_print.c upmf.c upmf_print.c -lm + gcc -std=c99 -pedantic -Wall -g -o readwmf readwmf.c uemf.c uemf_endian.c uemf_utf.c uemf_print.c uwmf.c uwmf_endian.c uwmf_print.c upmf.c upmf_print.c -lm + gcc -std=c99 -pedantic -Wall -g -o testbed_emf testbed_emf.c uemf.c uemf_endian.c uemf_utf.c -lm + gcc -std=c99 -pedantic -Wall -g -o testbed_pmf testbed_pmf.c uemf.c uemf_endian.c uemf_utf.c upmf.c upmf.h -lm + gcc -std=c99 -pedantic -Wall -g -o testbed_wmf testbed_wmf.c uemf.c uemf_endian.c uemf_utf.c uwmf.c uwmf_endian.c -lm + gcc -std=c99 -pedantic -Wall -g -o test_mapmodes_emf test_mapmodes_emf.c uemf.c uemf_endian.c uemf_utf.c -lm + +Extra debugging on linux may be enabled in testbed for use under Valgrind. To build that way do instead: + + gcc -std=c99 -pedantic -Wall -g -DU_VALGRIND -o testbed_emf testbed_emf.c uemf.c uemf_endian.c uemf_print.c uemf_utf.c -lm + +Sparc Solaris 8 and 9 are Big Endian, and to work around some minor incompatibilities with more recent systems, +assuming gcc is installed in /opt/csw and PATH is set correctly to use it: + + gcc -DSOL8 -DWORDS_BIGENDIAN -std=c99 -pedantic -Wall -g -o cutemf cutemf.c uemf.c uemf_endian.c uemf_utf.c -lm -L/opt/csw/lib -liconv + gcc -DSOL8 -DWORDS_BIGENDIAN -std=c99 -pedantic -Wall -g -o pmfdual2single pmfdual2single.c uemf.c uemf_endian.c uemf_utf.c upmf.c -lm -L/opt/csw/lib -liconv + gcc -DSOL8 -DWORDS_BIGENDIAN -std=c99 -pedantic -Wall -g -o reademf reademf.c uemf.c uemf_endian.c uemf_utf.c uemf_print.c upmf.c upmf_print.c -lm -L/opt/csw/lib -liconv + gcc -DSOL8 -DWORDS_BIGENDIAN -std=c99 -pedantic -Wall -g -o readwmf readwmf.c uemf.c uemf_endian.c uemf_utf.c uemf_print.c uwmf.c uwmf_endian.c uwmf_print.c upmf.c upmf_print.c -lm -L/opt/csw/lib -liconv + gcc -DSOL8 -DWORDS_BIGENDIAN -std=c99 -pedantic -Wall -g -o testbed_emf testbed_emf.c uemf.c uemf_endian.c uemf_utf.c -lm -L/opt/csw/lib -liconv + gcc -DSOL8 -DWORDS_BIGENDIAN -std=c99 -pedantic -Wall -g -o testbed_pmf testbed_pmf.c uemf.c uemf_endian.c uemf_utf.c upmf.c upmf.h -lm -L/opt/csw/lib -liconv + gcc -DSOL8 -DWORDS_BIGENDIAN -std=c99 -pedantic -Wall -g -o testbed_wmf testbed_wmf.c uemf.c uemf_endian.c uemf_utf.c uwmf.c uwmf_endian.c -lm -L/opt/csw/lib -liconv + gcc -DSOL8 -DWORDS_BIGENDIAN -std=c99 -pedantic -Wall -g -o test_mapmodes_emf test_mapmodes_emf.c uemf.c uemf_endian.c uemf_utf.c -lm -L/opt/csw/lib -liconv + +(Note: WORDS_BIGENDIAN would also be produced by autconf's configure, if that was used.) + +Define WIN32 when compiling for Windows. This uses _wfopen() instead of fopen(), with +filename translation from UTF-8 to UTF-16LE. This will allow file opens to utilize unicode +names. If WIN32 is omitted on Windows file names must be all ASCII. To build on mingw use: + + gcc -DWIN32 -std=c99 -pedantic -Wall -g -o cutemf cutemf.c uemf.c uemf_endian.c uemf_utf.c -lm -liconv + gcc -DWIN32 -std=c99 -pedantic -Wall -g -o pmfdual2single pmfdual2single.c uemf.c uemf_endian.c uemf_utf.c upmf.c -lm -liconv + gcc -DWIN32 -std=c99 -pedantic -Wall -g -o reademf reademf.c uemf.c uemf_endian.c uemf_utf.c uemf_print.c upmf.c upmf_print.c -lm -liconv + gcc -DWIN32 -std=c99 -pedantic -Wall -g -o readwmf readwmf.c uemf.c uemf_endian.c uemf_utf.c uemf_print.c uwmf.c uwmf_endian.c uwmf_print.c upmf.c upmf_print.c -lm -liconv + gcc -DWIN32 -std=c99 -pedantic -Wall -g -o testbed_emf testbed_emf.c uemf.c uemf_endian.c uemf_utf.c -lm -liconv + gcc -DWIN32 -std=c99 -pedantic -Wall -g -o testbed_pmf testbed_pmf.c uemf.c uemf_endian.c uemf_utf.c upmf.c upmf.h -lm -liconv + gcc -DWIN32 -std=c99 -pedantic -Wall -g -o testbed_wmf testbed_wmf.c uemf.c uemf_endian.c uemf_utf.c uwmf.c uwmf_endian.c -lm -liconv + gcc -DWIN32 -std=c99 -pedantic -Wall -g -o test_mapmodes_emf test_mapmodes_emf.c uemf.c uemf_endian.c uemf_utf.c -lm -liconv + +Dependencies: + libiconv (if not built into your compiler) + libpng (in the Inkscape examples) + +-------------------------------------------------------------------------------------------- +Testing + +All modules must also compile without warning under the more restrictive: + + ls -1 *.c \ + | extract -fmt 'gcc -Werror=format-security -Wall -Wformat -Wformat-security -W -Wno-pointer-sign -O2 -c -o deleteme.o [1,]' \ + | execinput + +-------------------------------------------------------------------------------------------- +Using libUEMF: + +To write an EMF file the code first runs two initialization functions: emf_start() and htable_create(). +Then a U_EMRHEADER record is created. This and all subsequent records are appended to the EMF file in +memory with emf_append(). Whichever other EMR records are desired are also added. The last EMR record +added must be the single instance of U_EMREOF. Then the code calls emf_finish(), emf_free(), and +htable_free(). Conversion of byte order on Big Endian machines to Little Endian is carried out +automatically in emf_finish(), if it is required. + +To input an EMF file it is is opened and the data read into a buffer in memory with emf_readdata(). On a +Big Endian machine this will also swap machine dependent byte orders as needed. At that point end user code +generally has to do something with the data in each record. The simplest case is to just print it, as shown +in reademf.c. More typically it must map the operations into its own graphics model, as shown in the +emf32*.*.example files from Inkscape. Basically the processing program needs to enter a loop, processing +one record at a time, pulling the record size and type from the first two uint32_t values present in each +record. It then enters a switch statement with one case for each EMR record type. Each case: statement +will generally define a pointer to that type of data object. Accessing the data from that pointer is +illustrated in the code for the corresponding *_print function. + +While libUEMF implements _print and _swap functions for all supported EMR records, end user code would +never call any of these directly. Instead it should either pass a single EMR record +to U_emf_onerec_print() (see reademf.c) or the entire completed EMF file in memory buffer to U_emf_endian() +(see testbed.c). + +WMF support is similar, except the functions are wmf_start(), wmf_readdata(), and so forth. It is a good +idea to separate end user WMF and EMF generating code into different modules, in order to avoid accidentally +writing EMR records to a WMF file and vice versa. WHile EMF objects are aligned in memory and so may be +accessed using the supplied structs, the ones for WMF files are not usually aligned and so must be accessed +using the supplied *_get functions. (The difference may not be evident on an x86 platform, but on RISC directly +trying to access objects in memory will result in access violations.) + +Things to be aware of in EMF files: + +The usual idea when employing a graphics file type like EMF is to copy a description of the objects in a +drawing from one program to another. Many of the record types in an EMF file can be thought of as objects, +they are lines or shapes or bitmaps or text. However, Microsoft's GDI implements binary and ternary raster +operations (see the descriptions in uemf.h) and most of these operations are not object like, instead they +combine things on the drawing surface. (There is in each case a copy operation which is object like.) +Consequently, EMF files which use these other raster operations are not particularly easy to import as +graphic objects. For instance, when PowerPoint rotates an image and saves it in an EMF the result is not +a single rotated image object. Instead there is an image containing the rotated image, which is followed by +masking operations to make the regions outside of the image transparent. There appears to be no standard +for when and where these subsequent operations will be applied. That is, there is no equivalent of +"begin path" and "end path" to delineate the start and end of such a compound operation. So a program +reading such a file has no easy way of figuring out which previous object is being modified by a subsequent +raster operation. The testbed program provided in this package generates a region which applies all +binary raster operations in vertical slices to two images. The expected result appears in Windows "Preview", +but if that region is imported into PowerPoint and converted to objects within that program the result looks +nothing like what Preview shows. + +Support for U_EMREXTTEXTOUTW is much more common than for U_EMRSMALLTEXT. The latter is easier to use, +since it does not require a Dx array for each text string, but the objects will not import into PowerPoint, +for instance. + +There are two types of dotted/dashed lines. The first uses a set of predefined flags to set the pattern +and the latter is end user user defined. Both are restricted to lines of width 1. These built in types are +problematic as key applications cannot handle them properly. PowerPoint cannot convert either type to its +internal object format. The first form loses the pattern and comes through as solid lines. The second type +is toxic - even a single dotted line of the second type will prevent the entire EMF from being converted. +The safest choice is to avoid these patterned line styles entirely. Convert all dots and dashes to separate +line draws before writing those into the EMF file. libUEMF has no problem reading these records, so code +should accept them for input. + +As with most graphics file formats there is no single object representation of a complex text string (varying +font size, super/sub script, bold, italic,.etc.). Such text must be decomposed into multiple text strings, +each with its own formatting. It is unlikely that a subsequent program reading these records from the EMF +will be able to reassemble them back into a single complex text string. + +If a font used in an EMF file is not present on both the sending and receiving systems text will not look the +same on both. Font substitution is usually silent in most programs, so it may not be evident why the text looks +a little odd. However, if text is simple, that is, consists of just one line of text without size, color, +or other changes, then it will look approximately correct after font substitution. + +Things to be aware of in WMF files: + +WMF graphics are quite limited when compared to EMF graphics. When reading a WMF file it is essential that +end user code always create a specified object, even if that object is just a placeholder with no real +function. If any "create" operation presented by the WMF file is not handled then the object indices used +further along in the WMF file will be off, with very bad results! WMF "regions" are not supported by libUEMF, +however, if an operation creates regions, this type of placeholder must still be created. + +In theory WMF supports mapmodes other than Anisotropic. However, since many programs do not handle +these other modes it is strongly suggested that any WMF files generated use Anisotropic. For this +reason there is no test_mapmodes_wmf program - windows XP preview did not show anything when WMF +files in the other modes were produced. With no positive control there was no way to verify that they +were valid. + +Things to be aware of in EMF+ files: + +EMF+ files are usually stored in files with an ".emf" file extension. In this package EMF+ programs, +functions, and definitions use PMF or PMR to distinguish them from the EMF and WMF material. ("EMF+" +is not an allowed variable or function name in C.) Dual mode EMF+ files contain both EMF and +EMF+ records. HOWEVER, those generated by PowerPoint are defective in that they drop all text +information from the drawing in the EMF+ representation. There is no simple way to line up the +EMF and EMF+ records in their representations to determine which ones correspond to which drawing +object. So it is generally not possible to see which elements are represented in both +representations, or which are missing in one representation. The example file generated by this library +has only EMF+ records plus the few EMF records needed to wrap them. + +Text in EMF+ is placed not from the baseline, as in EMF, but from the upper left corner of the Em square. +Use the utility function U_PMR_drawstring() to draw text onto a baseline. Font +substitutions result in badly placed text because even fonts that look similar on the screen may have +different font metrics. Specifically, font substitutions look worse in EMF+ files than they do +in EMF files. There is no way to embed fonts, or their font information in the EMF+ file. +Consequently the text representation within an EMF+ file is not very portable between systems - it will +only render correctly if the second system has all of the fonts used in the document. The testbed_pmf.c +program contains some metrics for common fonts which may be used with U_PMR_drawstring() +to accurately place text. + + + +-------------------------------------------------------------------------------------------- +History + + (Note, version numbers in files represent the libUEMF release where it was last modified, so not + all files will show the same version numbers in each release.) + +0.1.10 2014-01-14 + Slight changes in documentation for uemf.h. + Fixed typo in uemf_endian.c. + Fixed a tiny bug in uemf.c (if memory allocation failed a struct would have + been deleted before the struct itself. + +0.1.9 2013-12-02 + Added U_PMF_DASHEDLINEDATA_set3 (dot/dash pattern from bits in a uint32_t). + Finally was able to make linear gradient gradientfill records work. Updated + testbed_emf.c to include that. + +0.1.8 2013-11-28 + Fixed a bug in U_PMF_REGIONNODEPATH_print(), returned size was 4 too small. + Changed formatting of U_PMF_REGIONNODECHILDNODES_print() output to improve readability + of nested region structures in reademf. + +0.1.7 2013-11-20 + Added EMF+ support. + Converted U_RGA and similar from defines to functions, because the method being used + in the define (from C99) was not exactly compatible with C++ compilation. + Fixed error in test_mapmodes_emf.c where truncation float to integer was used where round + have been, resulting in an off by 1 error on some platforms. + Eliminated PU_W* pointers. + Cleaned up Doxygen comments. + +0.1.6. 2013-04-18 + Added tests which vary background mode, background color, and text color. + Slight modification to testit.sh. + Updated example files. + +0.1.5. 2013-02-13 + Added missing parameter for WMF RESTOREDC_set/get. + Replaced all sizeof() in uwmf.c that referred to UWMF structures with their + U_SIZE_* equivalents. + Added DIB related WMF _get functions. (Which were missing). These are U_BITMAPCOREHEADER_get, + U_BITMAPINFOHEADER_get, wget_dib_params + Added const where appropriate to wmf _get functions. + Added comprehensive cap,join,miter tests to testbeds. + Fixed bug in gradient4_swap(). + Fixed bug in emr_arc_points_common(), used vector where unit vectors were + needed, sometimes flipped direction for arcs/chords. + Fixed bug in U_WMFTEXTOUT_get(). + Changed all dst->Dst and src->Src as call variables in WMF code. + Denigrated htable_*() for emf, these become emf_htable_*(), to match naming convention + used for wmf_table_*(). +0.1.4 2013-02-04 + Added code to handle DIB formats that use clrUsed=0 to mean "maximum number of color entries", + this showed up in several places, including uemf.c and uemf_print.c. + Added some labels to test drawings, slightly rearranged image section, added + PNG and JPG image tests and clrUsed=0 images. + Modified uemf_endian.c to suppress some compiler warnings. + Changed get_DIB_params to return the Compression enumeration. + Fixed a typo in uwmf_print.c. +0.1.3 2013-01-29 Add modes to EMF test programs that changes worldtransform, so + that the resulting test files will exercise rotation transforms. + Added flags indication for testbed programs. + Added test for ROUNDRECT records. Swapped argument orders for those _get/_set operations. +0.1.2 2013-01-25 Fixed bug revealed by newer gcc on Solaris, assignment of aligned 32 bit to unaligned + 16 bit segfaulted. +0.1.1 2013-01-24 Fixed a few compiler warnings under g++, mostly having to do + with signed unsigned comparisons. Eliminated + an unused variable from wmf_finish and two stray lines from U_WMRHEADER_set. + Cleaned up doxygen comments. +0.1.0 2013-01-09 Added WMF functions. + Simplified print functions. Changed output format of reademf slightly, + from U_EMRXXX to U_EMR_XXX - easier to read the new way. +0.0.11 2012-12-04 Moved UTF and related functions out of uemf.c uemf.h and into uemf_utf.c uemf_utf.h. +0.0.10 2012-11-28 Discovered that not enough space was being allocated for some UTF conversions. To be + safe need 4 bytes per glyph + 1 for UTF-8. +0.0.9 2012-09-26 Some "uninitialized variable warnings" for certain versions of + gcc. These were, as far as I could tell, all spurious, but to quiet them + the variables in question were all initialized to 0. + Fixed header related print/swap functions - depending on what type of header there + could be an access violation. + Fixed U_Utf16leToUtf8, could leak memory if the conversion failed. + Fixed sections which were not testing for all types of EMF headers. + Added RGBA_to_RGBA() so that extractions of subsets of bitmaps (offset, different size) + can be handled. + Added cutemf. Utility to remove records from an EMF file. + Added test_mapmodes. Program to generate test files in each MAPMODE. + Added test_mm_(mode)_ref.emf files. These are reference for: + test_mapmodes -vX 2000 -vY 1000 + +0.0.8 2012-09-10 Fixed bug in htable_insert, failed to celear newly added table + slots. Fixed test for EMR_GRADIENTFILL triangle mode (rectangle still produces toxic EMF files.) + Fixed bug in gradientfill_swap on Solaris. + +0.0.7 2012-08-30 Added/fixed tests for hatched, DIB, and mono strokes. + Corrected error in U_EMREXTCREATEPEN_set. + +0.0.6 2012-08-21 Added/fixed tests for hatched, DIB, and mono fills. + +0.0.5 2012-08-08 Minor changes to uemf.c to suppress compiler warnings. Fixed + one bug in SET_CB_FROM_PXBMI macro (which was not triggered in testbed + because all images were the same size). + +0.0.4 2012-07-25 More tests in testbed.c. Found and fixed bugs in + U_POLYPOLYLINE and U_POLYPOLYGON related code. + +0.0.3 2012-07-24 Warnings related to printing size_t on 64 bit Linux. Correct + fix is to use "zd", but gcc -std=c99 does not support that on Solaris 9, + the only available big endian system. So use cast or the size_t to (int) + and stick with %d format specifier. This should be OK as the sizes involved + should not be all that large. + + Bug in core9 affecting U_EMRARC_swap(), and related, on Big Endian. + +0.0.2 2012-07-12 first release + diff --git a/src/libuemf/uemf.c b/src/libuemf/uemf.c index 220c88545..55388cf53 100644 --- a/src/libuemf/uemf.c +++ b/src/libuemf/uemf.c @@ -1,7 +1,9 @@ /** - @file uemf.c Functions for manipulating EMF files and structures. + @file uemf.c + + @brief Functions for manipulating EMF files and structures. - [U_EMR*]_set all take data and return a pointer to memory holding the constructed record. + [U_EMR]_set all take data and return a pointer to memory holding the constructed record. The size of that record is also returned in recsize. It is also in the second int32 in the record, but may have been byte swapped and so not usable. If something goes wrong a NULL pointer is returned and recsize is set to 0. @@ -14,11 +16,11 @@ /* File: uemf.c -Version: 0.0.21 -Date: 20-FEB-2013 +Version: 0.0.25 +Date: 15-JAN-2014 Author: David Mathog, Biology Division, Caltech email: mathog@caltech.edu -Copyright: 2013 David Mathog and California Institute of Technology (Caltech) +Copyright: 2014 David Mathog and California Institute of Technology (Caltech) */ #ifdef __cplusplus @@ -41,9 +43,12 @@ extern "C" { #include <wingdi.h> //Not actually used, looking for collisions #endif #include "uemf.h" -/* one prototype from uemf_endian. Put it here because end user should never need to see it, sno + +//! \cond +/* one prototype from uemf_endian. Put it here because end user should never need to see it, so not in uemf.h or uemf_endian.h */ void U_swap2(void *ul, unsigned int count); +//! \endcond /** \brief Look up the name of the EMR record by type. Returns U_EMR_INVALID if out of range. @@ -54,7 +59,7 @@ void U_swap2(void *ul, unsigned int count); */ char *U_emr_names(unsigned int idx){ if(idx<U_EMR_MIN || idx > U_EMR_MAX){ idx = 0; } - static char *U_WMR_NAMES[U_EMR_MAX+1]={ + static char *U_EMR_NAMES[U_EMR_MAX+1]={ "U_EMR_INVALID", "U_EMR_HEADER", "U_EMR_POLYBEZIER", @@ -179,7 +184,7 @@ char *U_emr_names(unsigned int idx){ "U_EMR_COLORMATCHTOTARGETW", "U_EMR_CREATECOLORSPACEW" }; - return(U_WMR_NAMES[idx]); + return(U_EMR_NAMES[idx]); } @@ -463,7 +468,7 @@ uint32_t emr_properties(uint32_t type){ table[115] = 0xA0; // U_EMRSETLAYOUT 1 0 1 0 0 0 0 0 table[116] = 0x82; // U_EMRTRANSPARENTBLT 1 0 0 0 0 0 1 0 table[117] = 0xA0; // U_EMRUNDEF117 1 0 1 0 0 0 0 0 - table[118] = 0x82; // U_EMRGRADIENTFILL 1 0 0 0 0 0 1 0 + table[118] = 0x82; // U_EMRGRADIENTFILL 1 0 1 0 0 0 1 0 table[119] = 0xA0; // U_EMRSETLINKEDUFIS 1 0 1 0 0 0 0 0 table[120] = 0x20; // U_EMRSETTEXTJUSTIFICATION 0 0 1 0 0 0 0 0 table[121] = 0xA0; // U_EMRCOLORMATCHTOTARGETW 1 0 1 0 0 0 0 0 @@ -615,7 +620,7 @@ int emr_arc_points( \param h Height of pixel array \param stride Row stride of input pixel array in bytes \param colortype DIB BitCount Enumeration - \param use_ct If true use color table (only for 1-16 bit DIBs) + \param use_ct If true use color table (only for 1-16 bit DIBs). \param invert If DIB rows are in opposite order from RGBA rows */ int RGBA_to_DIB( @@ -695,7 +700,7 @@ int RGBA_to_DIB( b = *rptr++; a = *rptr++; if(use_ct){ - color = U_BGRA(r,g,b,a); // color has order in memory: b,g,r,a + color = U_BGRA(r,g,b,a); // color has order in memory: b,g,r,a, same as EMF+ ARGB index = -1; for(lct = *ct, k=0; k<found; k++,lct++){ // Is this color in the table (VERY inefficient if there are a lot of colors!!!) if(*(uint32_t *)lct != *(uint32_t *) &color)continue; @@ -793,14 +798,14 @@ int RGBA_to_DIB( /** \brief Get the actual number of colors in the color table from the BitMapInfoHeader. + \return Number of entries in the color table. + \param Bmih char * pointer to the U_BITMAPINFOHEADER + BitmapInfoHeader may list 0 for some types which implies the maximum value. If the image is big enough, that is set by the bit count, as in 256 for an 8 bit image. If the image is smaller it is set by width * height. Note, this may be called by WMF code, so it is not safe to assume the data is aligned. - - \return Number of entries in the color table. - \param Bmih char * pointer to the U_BITMAPINFOHEADER */ int get_real_color_count( const char *Bmih @@ -819,13 +824,11 @@ int get_real_color_count( /** \brief Get the actual number of colors in the color table from the ClrUsed, BitCount, Width, and Height. - BitmapInfoHeader may list 0 for some types which implies the maximum value. - If the image is big enough, that is set by the bit count, as in 256 for an 8 - bit image. - If the image is smaller it is set by width * height. - \return Number of entries in the color table. - \param PU_BITMAPINFOHEADER pointer to to the U_BITMAPINFOHEADER + \param Colors Number of colors in the table. + \param BitCount BitCount Enumeration + \param Width bitmap width + \param Height bitmap height */ int get_real_color_icount( int Colors, @@ -892,6 +895,11 @@ int get_DIB_params( if( numCt){ *ct = (PU_RGBQUAD) ((char *)Bmi + sizeof(U_BITMAPINFOHEADER)); } else { *ct = NULL; } } + else if(bic == U_BI_BITFIELDS){ /* to date only encountered once, for 32 bit, from PPT*/ + *numCt = 0; + *ct = NULL; + bic = U_BI_RGB; /* there seems to be no difference, at least for the 32 bit images */ + } else { *numCt = Bmih->biSizeImage; *ct = NULL; @@ -1536,14 +1544,13 @@ int drawing_size( } /** - \brief Set a U_COLORREF value from separeate R,G,B values. - Or use macro directly: cr = U_RGB(r,g,b). + \brief Set a U_COLORREF value from separate R,G,B values. \param red Red component \param green Green component \param blue Blue component */ -U_COLORREF colorref_set( +U_COLORREF colorref3_set( uint8_t red, uint8_t green, uint8_t blue @@ -1552,6 +1559,42 @@ U_COLORREF colorref_set( return(cr); } +/** + \brief Set a U_COLORREF value from separate R,G,B, and Reserved values. + \param red Red component + \param green Green component + \param blue Blue component + \param Reserved Reserved component + +*/ +U_COLORREF colorref4_set( + uint8_t red, + uint8_t green, + uint8_t blue, + uint8_t Reserved + ){ + U_COLORREF cr = (U_COLORREF){red , green, blue, Reserved}; + return(cr); +} + +/** + \brief Set a U_RGBQUAD value from separate R,G,B, Reserved values. + \param red Red component + \param green Green component + \param blue Blue component + \param reserved Reserved component + +*/ +U_RGBQUAD rgbquad_set( + uint8_t red, + uint8_t green, + uint8_t blue, + uint8_t reserved + ){ + U_RGBQUAD cr = (U_RGBQUAD){blue , green, red, reserved}; + return(cr); +} + /** \brief Set rect and rectl objects from Upper Left and Lower Right corner points. \param ul upper left corner of rectangle @@ -5434,6 +5477,12 @@ char *U_EMRTRANSPARENTBLT_set( \param ulMode Gradientfill Enumeration (determines Triangle/Rectangle) \param TriVert Array of TriVertex objects \param GradObj Array of gradient objects (each has 2 [rect] or 3 [triangle] indices into TriVert array) + +There is an MS documentation or library problem for this record, as the size of the GradObj must always be set +as if it was an array of U_GRADIENT3 objects for both rect and triangle. For horizontal and vertical gradients +this means that there will be unused bytes at the end of the record. This is not what the documentation says, +but it is how MS's libraries work. + */ char *U_EMRGRADIENTFILL_set( const U_RECTL rclBounds, @@ -5445,6 +5494,7 @@ char *U_EMRGRADIENTFILL_set( ){ char *record; unsigned int cbTriVert,cbGradObj,off; + unsigned int cbGradObjAlloc; /* larger than cbGradObj, because of problem described above */ int irecsize; cbTriVert = sizeof(U_TRIVERTEX) * nTriVert; // all of the cb's will be a multiple of 4 bytes @@ -5452,8 +5502,9 @@ char *U_EMRGRADIENTFILL_set( else if(ulMode == U_GRADIENT_FILL_RECT_H || ulMode == U_GRADIENT_FILL_RECT_V){ cbGradObj = sizeof(U_GRADIENT4) * nGradObj; } else { return(NULL); } + cbGradObjAlloc = sizeof(U_GRADIENT3) * nGradObj; - irecsize = sizeof(U_EMRGRADIENTFILL) + cbTriVert + cbGradObj; + irecsize = sizeof(U_EMRGRADIENTFILL) + cbTriVert + cbGradObjAlloc; record = malloc(irecsize); if(record){ ((PU_EMR) record)->iType = U_EMR_GRADIENTFILL; @@ -5466,6 +5517,10 @@ char *U_EMRGRADIENTFILL_set( memcpy(record + off, TriVert, cbTriVert); off += cbTriVert; memcpy(record + off, GradObj, cbGradObj); + off += cbGradObj; + if(cbGradObjAlloc > cbGradObj){ + memset(record+off,0,cbGradObjAlloc - cbGradObj); + } } return(record); } @@ -5517,7 +5572,6 @@ char *U_EMRCREATECOLORSPACEW_set( } - #ifdef __cplusplus } #endif diff --git a/src/libuemf/uemf.h b/src/libuemf/uemf.h index 1ff6ead60..a75ba801b 100644 --- a/src/libuemf/uemf.h +++ b/src/libuemf/uemf.h @@ -1,5 +1,7 @@ /** - @file uemf.h Structures and functions prototypes for EMF files. + @file uemf.h + + @brief Structures, definitions, and function prototypes for EMF files. EMF file Record structure information has been derived from Mingw, Wine, and libEMF header files, and from Microsoft's EMF Information pdf, release date March 28,2012, link from here: @@ -11,13 +13,93 @@ */ +/** \mainpage libUEMF overview +\section ov Overview +Microsoft's WMF, EMF, and EMF+ metafile types are supported. In each case functions are provided for reading, constructing, writing, and printing +metafile records. The methods used to do that differ somewhat between metafiles, and the simplest +way to get started is to have a look at the example programs provided. The WMF, EMF, and EMF+ structs and functions are +marked with U_WMF, U_EMF, U_PMF and U_WMR, U_EMR, and U_PMR prefixes. (PMF because "+" is a reserved character +in many contexts, so U_EMF+NAME would be a problem.) Please be aware that normally both EMF and EMF+ files have the ".emf" +file extension, and that it is very common for such files to contain both an EMF and an EMF+ representation of the +drawing. + +\section example_sec Example Programs +testbed_emf.c Creates an EMF file test_libuemf.emf.\n +testbed_wmf.c Creates a WMF file test_libuemf.wmf.\n +testbed_pmf.c Creates an EMF+ file test_libuemf_p.emf.\n +reademf.c Reads an EMF or EMF+ file and emits a text summary of its records.\n +readwmf.c Reads a WMF file and emits a text summary of its records.\n +emf-inout.cpp.example Example code from Inkscape to convert graphics from EMF to SVG.\n +emf-print.cpp.example Example code from Inkscape to print a drawing to EMF.\n +wmf-inout.cpp.example Example code from Inkscape to convert graphics from WMF to SVG.\n +wmf-print.cpp.example Example code from Inkscape to print a drawing to WMF. + +\section doxy_limits Documentation issues +There are currently some unresolved issues with Doxygen that result in some structs +not being "defined". This comes up when several different types of structs have the same +layout. When this occurs the first one listed on the "typedef struct" is defined but all the +others will only be shown under "typedef struct" referring to the first one. This is why +clicking on U_RECTL in a function parameter jumps to a typedef struct page, why U_RECTL is shown +as plain text here, but U_RECT is shown as a link here, and clicking on it jumps directly +to its structure definition. + +An additional issue is that the Enumeration names used in WMF are different from those +used in EMF, even when the values are either identical or differ only slightly, and no method +has been found yet to link one to the other in Doxygen. At present the only way to look up +these WMF enumerations is by referencing the following table: + + EMF WMF WMF Manual + EMF Binary Raster Operation Enumeration BinaryRasterOperation Enumeration 2.1.1.2 + EMF Bitcount Enumeration BitCount Enumeration 2.1.1.3 + EMF LB_Style Enumeration BrushStyle Enumeration 2.1.1.4 + EMF LF_CharSet Enumeration CharacterSet Enumeration 2.1.1.5 + EMF DIBColors Enumeration ColorUsage Enumeration [has 1 extra value] 2.1.1.6 + EMF BI_Compression Enumeration Compression Enumeration [has 3 extra values] 2.1.1.7 + - FamilyFont Enumeration 2.1.1.8 + EMF FloodFill Enumeration FloodFill Enumeration 2.1.1.9 + EMF LF_Quality Enumeration FontQuality Enumeration 2.1.1.10 + EMF LCS_Intent Enumeration GamutMappingIntent Enumeration 2.1.1.11 + EMF HatchStyle Enumeration HatchStyle Enumeration 2.1.1.12 + EMF Mirroring Enumeration LayoutEnumeration 2.1.1.13 + - LogicalColorSpace Enumeration 2.1.1.14 + EMF Profile Enumeration LogicalColorSpaceV5 Enumeration 2.1.1.15 + EMF MapMode Enumeration MapModeEnumeration 2.1.1.16 + - MetaFilesEscape Enumeration 2.1.1.17 + - MetafileType Enumeration 2.1.1.18 + - MetafileVersion Enumeration 2.1.1.19 + EMF BackgroundMode Enumeration MixModeEnumeration 2.1.1.20 + EMF LF_OutPrecision Enumeration OutPrecision Enumeration 2.1.1.21 + - PaletteEntryFlag Enumeration 2.1.1.22 + EMF PenStyle Enumeration PenStyle Enumeration [not values >0xFFFF] 2.1.1.23 + - PitchFont Enumeration 2.1.1.24 + EMF PolygonFillMode Enumeration PolyFillMode Enumeration [first 2 only] 2.1.1.25 + - PostScriptCap Enumeration 2.1.1.26 + - PostScriptClipping Enumeration 2.1.1.27 + - PostFeatureSetting Enumeration 2.1.1.28 + - PostScrioptJoin Enumeration 2.1.1.29 + EMF StretchMode Enumeration StretchMode Enumeration 2.1.1.30 + EMF Ternary Raster Operation Enumeration TernaryRasterOperation Enumeration 2.1.1.31 + EMF LF_ClipPrecision Enumeration ClipPrecision Flags 2.1.2.1 + EMF ExtTextOutOptions Enumeration ExtTextOutOptions Flags [subset] 2.1.2.2 + EMF TextAlignment Enumeration TextAlignment Enumeration 2.1.2.3 + EMF TextAlignment Enumeration VertialTextAlignment Enumeration 2.1.2.4 + EMF LF_PitchAndFamily Enumeration PitchAndFamily Enumerations 2.2.2.14 + +\section refs Reference documentation + + Manual Date Link + EMF 3/28/2012 http://msdn2.microsoft.com/en-us/library/cc230514.aspx + EMF+ 7/5/2012 http://msdn.microsoft.com/en-us/library/cc230724.aspx + WMF 7/5/2012 http://msdn2.microsoft.com/en-us/library/cc250370.aspx +*/ + /* File: uemf.h -Version: 0.0.19 -Date: 20-FEB-2013 +Version: 0.0.25 +Date: 15-JAN-2014 Author: David Mathog, Biology Division, Caltech email: mathog@caltech.edu -Copyright: 2013 David Mathog and California Institute of Technology (Caltech) +Copyright: 2014 David Mathog and California Institute of Technology (Caltech) */ #ifndef _UEMF_ @@ -27,13 +109,16 @@ Copyright: 2013 David Mathog and California Institute of Technology (Caltech) extern "C" { #endif +#include <stdlib.h> +#include <stdio.h> #include <stdint.h> +#include <string.h> #include <stdbool.h> #include "uemf_utf.h" #include "uemf_endian.h" - +/** \cond */ // *********************************************************************************** // defines not placed yet @@ -44,13 +129,477 @@ extern "C" { #define U_SYSPAL_NOSTATIC 2 #define U_ELF_VENDOR_SIZE 4 +/** \endcond */ + +// *************************************************************************** +/** \defgroup U_EMF_Miscellaneous_values EMF Miscellaneous Values + @{ +*/ +#define U_NONE 0 //!< Generic for nothing selected for all flag fields +#define U_PI 3.14159265358979323846 //!< pi +#define U_READ 1 //!< open file as "rb" +#define U_WRITE 0 //!< open file as "wb" +#define U_DV_SGNTR 0x08007664 //!< For U_DESIGNVECTOR Signature field +#define U_LP_VERSION 0x0300 //!< For U_LOGPALETTE palVersion field +#define U_RDH_RECTANGLES 1 //!< For U_RGNDATAHEADER iType field +#define U_RDH_OBJSIZE 0x20 //!< For U_RGNDATAHEADER dwSIze field +#define U_RGB_GAMMA_MIN (uint16_t)02500 //!< For U_COLORADJUSTMENT ca[Red|Green|Blue]Gamma fields +#define U_RGB_GAMMA_MAX (uint16_t)65000 //!< For U_COLORADJUSTMENT ca[Red|Green|Blue]Gamma fields +#define U_REFERENCE_WHITE_MIN (uint16_t)6000 //!< For U_COLORADJUSTMENT caReferenceWhite field +#define U_REFERENCE_WHITE_MAX (uint16_t)10000 //!< For U_COLORADJUSTMENT caReferenceWhite field +#define U_REFERENCE_BLACK_MIN (uint16_t)0 //!< For U_COLORADJUSTMENT caReferenceBlack field +#define U_REFERENCE_BLACK_MAX (uint16_t)4000 //!< For U_COLORADJUSTMENT caReferenceBlack field +#define U_COLOR_ADJ_MIN ((int16_t)-100) //!< For U_COLORADJUSTMENT ca[Contrast|Brightness|Colorfulness|RedGreenTint] fields +#define U_COLOR_ADJ_MAX (int16_t) 100 //!< For U_COLORADJUSTMENT ca[Contrast|Brightness|Colorfulness|RedGreenTint] fields +#define U_MAX_PATH 1024 //!< longest path name for a file +#define U_LCS_SIGNATURE 0x50534F43 //!< logColorSpace Signature +#define U_LCS_VERSION 0x400 //!< logColorSpace Version +#define U_REC_FREE 1 //!< use with emf_append +#define U_REC_KEEP 0 //!< use with emf_append +#define U_ROW_ORDER_INVERT 1 //!< For RGBA_to_DIB, invert row order in DIB relative to pixel array +#define U_ROW_ORDER_SAME 0 //!< For RGBA_to_DIB, same row order in DIB as in pixel array +#define U_CT_NO 0 //!< For RGBA_to_DIB, do not use color table +#define U_CT_BGRA 1 //!< For RGBA_to_DIB, use color table (16 bits or less only) BGRA colors, compatible with EMF+ ARGB +#define U_CT_ARGB 1 //!< For RGBA_to_DIB, use color table (16 bits or less only) BGRA colors, compatible with EMF+ ARGB +#define U_EMR_COMMENT_SPOOLFONTDEF 0x544F4E46 //!< For U_EMRCOMMENT record that is U_EMR_COMMENT_SPOOL, comment holds font definition informtion. +/** Solaris 8 has problems with round/roundf, just use this everywhere */ +#define U_ROUND(A) ( (A) > 0 ? floor((A)+0.5) : ( (A) < 0 ? -floor(-(A)+0.5) : (A) ) ) + +/** @} */ + + +typedef float U_FLOAT; //!< 32 bit float + +typedef uint32_t U_CBBITS; //!< Count of Bytes in object at corresponding U_OFF* +typedef uint32_t U_CBBITSMSK; //!< Count of Bytes in object at corresponding U_OFF* +typedef uint32_t U_CBBITSSRC; //!< Count of Bytes in object at corresponding U_OFF* +typedef uint32_t U_CBBMI; //!< Count of Bytes in object at corresponding U_OFF* +typedef uint32_t U_CBBMIMSK; //!< Count of Bytes in object at corresponding U_OFF* +typedef uint32_t U_CBBMISRC; //!< Count of Bytes in object at corresponding U_OFF* +typedef uint32_t U_CBDATA; //!< Count of Bytes in object at corresponding U_OFF* +typedef uint32_t U_CBNAME; //!< Count of Bytes in object at corresponding U_OFF* +typedef uint32_t U_CBPLENTRIES; //!< Count of Bytes in object at corresponding U_OFF* +typedef uint32_t U_CBPXLFMT; //!< Count of Bytes in object at corresponding U_OFF* +typedef uint32_t U_CBRGNDATA; //!< Count of Bytes in object at corresponding U_OFF* +typedef uint32_t U_CBSTR; //!< Count of Bytes in an 8 or 16 bit string + +typedef uint32_t U_OFFBITS; //!< Byte offset to TYPE, always measured from the start of the RECORD (not the struct) +typedef uint32_t U_OFFBITSMSK; //!< Byte offset to TYPE, always measured from the start of the RECORD (not the struct) +typedef uint32_t U_OFFBITSSRC; //!< Byte offset to TYPE, always measured from the start of the RECORD (not the struct) +typedef uint32_t U_OFFBMI; //!< Byte offset to TYPE, always measured from the start of the RECORD (not the struct) +typedef uint32_t U_OFFBMIMSK; //!< Byte offset to TYPE, always measured from the start of the RECORD (not the struct) +typedef uint32_t U_OFFBMISRC; //!< Byte offset to TYPE, always measured from the start of the RECORD (not the struct) +typedef uint32_t U_OFFDATA; //!< Byte offset to TYPE, always measured from the start of the RECORD (not the struct) +typedef uint32_t U_OFFDESC; //!< Byte offset to TYPE, always measured from the start of the RECORD (not the struct) +typedef uint32_t U_OFFDX; //!< Byte offset to TYPE, always measured from the start of the RECORD (not the struct) +typedef uint32_t U_OFFPLENTRIES; //!< Byte offset to TYPE, always measured from the start of the RECORD (not the struct) +typedef uint32_t U_OFFPXLFMT; //!< Byte offset to TYPE, always measured from the start of the RECORD (not the struct) +typedef uint32_t U_OFFSTR; //!< Byte offset to string of either 8 or 16 bit characters +typedef uint8_t U_DATA; //!< any binary sort of data, not otherwise classified. + +// "Types" For array components in structures, where not otherwise defined as a structure +typedef uint32_t U_FNTAXES; //!< Font Axes For U_DESIGNVECTOR +typedef uint32_t U_STYLEENTRY; //!< StyleEntry For U_EXTLOGPEN +typedef uint32_t U_POLYCOUNTS; //!< aPolyCounts For U_EMRPOLYPOLYLINE etc. + +// "Counts" for array components in structures +typedef uint32_t U_NUM_FNTAXES; //!< Number of U_FNTAXES +typedef uint32_t U_NUM_LOGPLTNTRY; //!< Number of U_LOGPLTENTRY +typedef uint32_t U_NUM_RECTL; //!< Number of U_RECTL +typedef uint32_t U_NUM_POINTL; //!< Number of U_POINTL +typedef uint32_t U_NUM_POINT16; //!< Number of U_POINT16 +typedef uint32_t U_NUM_STYLEENTRY; //!< Number of U_STYLEENTRY +typedef uint32_t U_NUM_POLYCOUNTS; //!< Number of U_POLYCOUNTS +typedef uint32_t U_NUM_EMRTEXT; //!< Number of U_EMRTEXT +typedef uint32_t U_NUM_STR; //!< Number of 8 or 16 bit characters in string +typedef uint32_t U_NUM_TRIVERTEX; //!< Number of U_TRIVERTEX +typedef uint32_t U_NUM_GRADOBJ; //!< Number of U_GRADIENT4 OR U_GRADIENT3 (determined at run time) +typedef uint32_t U_NUM_RGBQUAD; //!< Number of U_RGBQUAD (in bmciColors in U_BITMAPCOREINFO) + + + +/* ************************ WMF pieces used in EMF or EMF+ ****************************** */ + +/** \defgroup U_EMF_EMRSETROP2_iMode_Qualifiers EMF Binary Raster Operation Enumeration + + For U_EMRSETROP2 iMode field + Microsoft name: Binary Raster Operation Enumeration + WMF manual 2.1.1.2 + + These codes specify: + 1. an order of operands (composed of various orders and combinations of: Dest, Pen) + (There are 2, hence "Binary Raster Operation") + 2. an order of operators to apply to the operands (composed of Not, Xor, Or, And) + Only a few of the more common operations are provided here. + + The default is U_R2_COPYPEN. If this value is changed to something else all subsequenty + draw operations will use the altered logic. For instance, if it is set to U_R2_BLACK and + a red rectangle is drawn it will appear as a black rectangle. + + @{ +*/ +#define U_R2_BLACK 1 //!< BLACK +#define U_R2_NOTMERGEPEN 2 //!< NOTMERGEPEN +#define U_R2_MASKNOTPEN 3 //!< MASKNOTPEN +#define U_R2_NOTCOPYPEN 4 //!< NOTCOPYPEN +#define U_R2_MASKPENNOT 5 //!< MASKPENNOT +#define U_R2_NOT 6 //!< NOT +#define U_R2_XORPEN 7 //!< XORPEN +#define U_R2_NOTMASKPEN 8 //!< NOTMASKPEN +#define U_R2_MASKPEN 9 //!< MASKPEN +#define U_R2_NOTXORPEN 10 //!< NOTXORPEN +#define U_R2_NOP 11 //!< NOP +#define U_R2_MERGENOTPEN 12 //!< MERGENOTPEN +#define U_R2_COPYPEN 13 //!< COPYPEN +#define U_R2_MERGEPENNOT 14 //!< MERGEPENNOT +#define U_R2_MERGEPEN 15 //!< MERGEPEN +#define U_R2_WHITE 16 //!< WHITE +#define U_R2_LAST 16 //!< LAST +/** @} */ + +/** \defgroup U_EMF_BITMAPINFOHEADER_biBitCount_Qualifiers EMF BitCount Enumeration + For U_BITMAPINFOHEADER biBitCount field. + Microsoft name: Bitcount Enumeration + WMF manual 2.1.1.3 + @{ +*/ +#define U_BCBM_EXPLICIT 0 //!< Derived from JPG or PNG compressed image or ? +#define U_BCBM_MONOCHROME 1 //!< 2 colors. bmiColors array has two entries +#define U_BCBM_COLOR4 4 //!< 2^4 colors. bmiColors array has 16 entries +#define U_BCBM_COLOR8 8 //!< 2^8 colors. bmiColors array has 256 entries +#define U_BCBM_COLOR16 16 //!< 2^16 colors. bmiColors is not used. Pixels are 5 bits B,G,R with 1 unused bit +#define U_BCBM_COLOR24 24 //!< 2^24 colors. bmiColors is not used. Pixels are U_RGBTRIPLE. +#define U_BCBM_COLOR32 32 //!< 2^32 colors. bmiColors is not used. Pixels are U_RGBQUAD. Also use for EMF+ ARGB +/** @} */ + +/** \defgroup U_EMF_BITMAPINFOHEADER_biCompression_Qualifiers EMF BI_Compression Enumeration + For U_BITMAPINFOHEADER biCompression field + Microsoft name: Compression Enumeration + WMF manual 2.1.1.7 + @{ +*/ +#define U_BI_UNKNOWN -1 //!< not defined in EMF standard, not to be used in EMF files +#define U_BI_RGB 0 //!< Supported by libUEMF +#define U_BI_RLE8 1 //!< NOT supported by libUEMF +#define U_BI_RLE4 2 //!< NOT supported by libUEMF +#define U_BI_BITFIELDS 3 //!< Supported by libUEMF +#define U_BI_JPEG 4 //!< Supported by libUEMF +#define U_BI_PNG 5 //!< Supported by libUEMF +/** @} */ + +/** \defgroup U_EMF_LOGCOLORSPACE_lcsIntent_Qualifiers EMF LCS_Intent Enumeration + For U_LOGCOLORSPACEA/U_LOGCOLORSPACEW lcsIntent field + Microsoft name: LCS_Intent Enumeration + WMF manual 2.1.1.11 + @{ +*/ +#define U_LCS_GM_BUSINESS 0x00000001L //!< BUSINESS +#define U_LCS_GM_GRAPHICS 0x00000002L //!< GRAPHICS +#define U_LCS_GM_IMAGES 0x00000004L //!< IMAGES +#define U_LCS_GM_ABS_COLORIMETRIC 0x00000008L //!< ABS_COLORIMETRIC +/** @} */ + +/** \defgroup U_EMF_LOGCOLORSPACE_lcsCSType_Qualifiers EMF LCS_CSType Enumeration + For U_LOGCOLORSPACEA/U_LOGCOLORSPACEW lcsCSType field + Microsoft name: LCS_CSType Enumeration + WMF manual 2.1.1.14 + @{ +*/ +#define U_LCS_CALIBRATED_RGB 0x00000000L //!< CALIBRATED_RGB +#define U_LCS_DEVICE_RGB 0x00000001L //!< DEVICE_RGB +#define U_LCS_DEVICE_CMYK 0x00000002L //!< DEVICE_CMYK +/** @} */ + +/** \defgroup U_EMF_EMR_dwROP_Qualifiers EMF Ternary Raster Operation enumeration + + For U_EMR* dwROP fields. + Microsoft name: Ternary Raster Operation enumeration + WMF manual 2.1.1.31 + + These codes specify: + 1. an order of operands (composed of various orders and combinations of: Dest, Src, Pen) + (There are 3, hence "Ternary Raster Operation") + 2. an order of operators to apply to the operands (composed of Not, Xor, Or, And) + Only a few of the more common operations are provided here. + When the Operation does not use a Src operand the corresponding source bitmap may be + omitted from the record. + + For more details see: + http://wiki.winehq.org/TernaryRasterOps + + + @{ +*/ +#define U_SRCCOPY 0x00cc0020 //!< SRCCOPY +#define U_SRCPAINT 0x00ee0086 //!< SRCPAINT +#define U_SRCAND 0x008800c6 //!< SRCAND +#define U_SRCINVERT 0x00660046 //!< SRCINVERT +#define U_SRCERASE 0x00440328 //!< SRCERASE +#define U_NOTSRCCOPY 0x00330008 //!< NOTSRCCOPY +#define U_NOTSRCERASE 0x001100a6 //!< NOTSRCERASE +#define U_MERGECOPY 0x00c000ca //!< MERGECOPY +#define U_MERGEPAINT 0x00bb0226 //!< MERGEPAINT +#define U_PATCOPY 0x00f00021 //!< PATCOPY +#define U_PATPAINT 0x00fb0a09 //!< PATPAINT +#define U_PATINVERT 0x005a0049 //!< PATINVERT +#define U_DSTINVERT 0x00550009 //!< DSTINVERT +#define U_BLACKNESS 0x00000042 //!< BLACKNESS +#define U_WHITENESS 0x00ff0062 //!< WHITENESS +#define U_NOOP 0x00aa0029 //!< Many GDI programs end with a bitblt with this ROP == "D". Seems to work like flush() +#define U_NOMIRRORBITMAP 0x80000000 //!< If bit set, disable horizontal reflection of bitmap. +/** @} */ + +/** \defgroup U_EMF_EMRSETTEXTALIGN_iMode_Qualifiers EMF TextAlignment Enumeration + For U_EMRSETTEXTALIGN iMode field + Microsoft name: TextAlignment Enumeration + WMF Manual 2.1.2.3 + WMF Manual 2.1.2.4 + + Recall that EMF coordinates have UL closest to {0,0}, LR is below and to the right of UL and so has LARGER + {x,y} coordinates. In the following "TOP" is on the horizontal line defined by LR, as it has larger y coordinates, + which when viewing the EMF file, would actually be on the BOTTOM of the bounding rectangle. Similarly, left and right + are reversed. + + Microsoft documentation (WMF manual, section 2.1.2.3) says that the text starts on certain edges of the bounding rectangle. + That is apparently not true, whether the bounding rectangle is {0,0,-1,-1}, which is effectively no bounding rectangle, + or if a valid bounding rectangle is specified. In all cases the text (in Windows XP Preview) starts, has center at, or ends + at the center point. Vertical offsets seem to be defined analogously, but with respect to the height of the font. The bounding + rectangle defined for the U_EMRTEXT record appears to be ignored. + + Microsoft documentation (EMF manual,section 2.2.5) says that the same rectangle is used for "clipping or opaquing" by ExtTextOutA/W. + That does not seem to occur either. + + @{ +*/ +// Horizontal text flags +#define U_TA_DEFAULT 0x00 //!< default alignment +#define U_TA_NOUPDATECP 0x00 //!< Reference point does not move +#define U_TA_UPDATECP 0x01 //!< Reference point moves to end of next text drawn. +#define U_TA_LEFT 0x00 //!< Reference point is on left edge of bounding rectangle +#define U_TA_RIGHT 0x02 //!< Reference point is on right edge of bounding rectangle +#define U_TA_CENTER 0x06 //!< Reference point is on center vertical line of bounding rectangle +#define U_TA_TOP 0x00 //!< Reference point is on top edge of bounding rectangle +#define U_TA_BOTTOM 0x08 //!< Reference point is on bottom edge of bounding rectangle +#define U_TA_BASEBIT 0x10 //!< Reference point is on baseline of text if this bit is set, for 0x10 <-> 0x18 +#define U_TA_BASELINE 0x18 //!< Reference point is on baseline of text +#define U_TA_RTLREADING 0x100 //!< Set for Right to Left languages like Hebrew and Arabic +#define U_TA_MASK U_TA_BASELINE+U_TA_CENTER+U_TA_UPDATECP+U_TA_RTLREADING //!< Mask for these bits +// Vertical text flags +#define U_VTA_BASELINE U_TA_BASELINE //!< same meaning, but for vertical text +#define U_VTA_LEFT U_TA_BOTTOM //!< same meaning, but for vertical text +#define U_VTA_RIGHT U_TA_TOP //!< same meaning, but for vertical text +#define U_VTA_CENTER U_TA_CENTER //!< same meaning, but for vertical text +#define U_VTA_BOTTOM U_TA_RIGHT //!< same meaning, but for vertical text +#define U_VTA_TOP U_TA_LEFT //!< same meaning, but for vertical text +/** @} */ + +/** WMF manual 2.2.2.3 + \brief For U_BITMAPINFO bmiHeader field + + Microsoft name: BITMAPINFOHEADER Object +*/ +typedef struct { + uint32_t biSize; //!< Structure size in bytes + int32_t biWidth; //!< Bitmap width in pixels + int32_t biHeight; //!< Bitmap height in pixels, may be negative. + //!< abs(biHeight) is bitmap height + //!< bitmap may appear in two orientations: + //!< biHeight > 0 origin is LL corner, may be compressed, this is height after decompression. + //!< biHeight < 0 origin is UL corner, may not be compressed + uint16_t biPlanes; //!< Planes (must be 1) + uint16_t biBitCount; //!< BitCount Enumeration (determines number of RBG colors) + uint32_t biCompression; //!< BI_Compression Enumeration + uint32_t biSizeImage; //!< Image size in bytes or 0 = "default size (calculated from geometry?)" + int32_t biXPelsPerMeter; //!< X Resolution in pixels/meter + int32_t biYPelsPerMeter; //!< Y Resolution in pixels/meter + U_NUM_RGBQUAD biClrUsed; //!< Number of bmciColors in U_BITMAPINFO/U_BITMAPCOREINFO that are used by the bitmap + uint32_t biClrImportant; //!< Number of bmciColors needed (0 means all). +} U_BITMAPINFOHEADER, + *PU_BITMAPINFOHEADER; //!< WMF manual 2.2.2.3 + +/** WMF manual 2.2.2.6 + \brief For U_CIEXYZTRIPLE (all) fields + + Microsoft name: CIEXYZ Object +*/ +typedef struct { + int32_t ciexyzX; //!< CIE color space X component + int32_t ciexyzY; //!< CIE color space Y component + int32_t ciexyzZ; //!< CIE color space Z component +} U_CIEXYZ, + *PU_CIEXYZ; //!< WMF manual 2.2.2.6 + +/** WMF manual 2.2.2.7 + \brief For U_LOGCOLORSPACEA and U_LOGCOLORSPACEW lcsEndpints field + + defines a CIE colorspace. + Microsoft name: CIEXYZTRIPLE Object + +*/ +typedef struct { + U_CIEXYZ ciexyzRed; //!< CIE XYZ coord of red endpoint of colorspace + U_CIEXYZ ciexyzGreen; //!< CIE XYZ coord of green endpoint of colorspace + U_CIEXYZ ciexyzBlue; //!< CIE XYZ coord of blue endpoint of colorspace +} U_CIEXYZTRIPLE, + *PU_CIEXYZTRIPLE; //!< WMF manual 2.2.2.7 + +/** WMF manual 2.2.2.8 + \brief For U_BITMAPINFO crColor field + + NOTE that the color order is RGB reserved, flipped around from the preceding. + Microsoft name: COLORREF Object +*/ +typedef struct { + uint8_t Red; //!< Red color (0-255) + uint8_t Green; //!< Green color (0-255) + uint8_t Blue; //!< Blue color (0-255) + uint8_t Reserved; //!< Not used +} U_COLORREF, + *PU_COLORREF; //!< WMF manual 2.2.2.8 + +/** WMF manual 2.2.2.11 + \brief For U_LCS_GAMMARGB lcsGamma* fields + + Microsoft name:(unknown) +*/ +typedef struct { + unsigned ignoreHi :8; //!< not used + unsigned intPart :8; //!< integer part + unsigned fracPart :8; //!< fraction part + unsigned ignoreLo :8; //!< not used +} U_LCS_GAMMA, + *PU_LCS_GAMMA; //!< WMF manual 2.2.2.11 + +/** WMF manual 2.2.2.11 + \brief For U_LOGCOLORSPACEA and U_LOGCOLORSPACEW lcsGammaRGB field + + Microsoft name:(unknown) +*/ +typedef struct { + U_LCS_GAMMA lcsGammaRed; //!< Red Gamma + U_LCS_GAMMA lcsGammaGreen; //!< Green Gamma + U_LCS_GAMMA lcsGammaBlue; //!< Blue Gamma +} U_LCS_GAMMARGB, + *PU_LCS_GAMMARGB; //!< WMF manual 2.2.2.11 + +/** WMF manual 2.2.2.11 + \brief For U_EMRCREATECOLORSPACE lcs field + + Microsoft name: LOGCOLORSPACEA Object +*/ +typedef struct { + uint32_t lcsSignature; //!< must be U_LCS_SIGNATURE + uint32_t lcsVersion; //!< must be U_LCS_VERSION + uint32_t lcsSize; //!< Size in bytes of this structure + int32_t lcsCSType; //!< LCS_CSType Enumeration + int32_t lcsIntent; //!< LCS_Intent Enumeration + U_CIEXYZTRIPLE lcsEndpoints; //!< CIE XYZ color space endpoints + U_LCS_GAMMARGB lcsGammaRGB; //!< Gamma For RGB + char lcsFilename[U_MAX_PATH]; //!< Names an external color profile file, otherwise empty string +} U_LOGCOLORSPACEA, + *PU_LOGCOLORSPACEA; //!< WMF manual 2.2.2.11 + +/** WMF manual 2.2.2.12 + \brief For U_EMRCREATECOLORSPACEW lcs field + + Microsoft name: LOGCOLORSPACEW Object +*/ +typedef struct { + uint32_t lcsSignature; //!< must be U_LCS_SIGNATURE + uint32_t lcsVersion; //!< must be U_LCS_VERSION + uint32_t lcsSize; //!< Size in bytes of this structure + int32_t lcsCSType; //!< lcsCSType Enumeration + int32_t lcsIntent; //!< lcsIntent Enumeration + U_CIEXYZTRIPLE lcsEndpoints; //!< CIE XYZ color space endpoints + U_LCS_GAMMARGB lcsGammaRGB; //!< Gamma For RGB + uint16_t lcsFilename[U_MAX_PATH]; //!< Could name an external color profile file, otherwise empty string +} U_LOGCOLORSPACEW, + *PU_LOGCOLORSPACEW; //!< WMF manual 2.2.2.12 + +/** WMF manual 2.2.2.15 + \brief Used for any generic pair of uint32_t + + Microsoft name: POINTL Object +*/ +typedef struct { + int32_t x; //!< X value + int32_t y; //!< Y value +} U_PAIR, + U_POINT, //!< WMF manual 2.2.2.15 + U_POINTL, //!< WMF manual 2.2.2.15 + *PU_PAIR, //!< WMF manual 2.2.2.15 + *PU_POINT, //!< WMF manual 2.2.2.15 + *PU_POINTL; //!< WMF manual 2.2.2.15 + + +/** WMF manual 2.2.2.16 + \brief Point type for 16 bit EMR drawing functions. + + Microsoft name: POINTS Object. + Microsoft name: POINTS16 Object. +*/ +typedef struct { + int16_t x; //!< X size (16 bit) + int16_t y; //!< Y size (16 bit) +} U_POINT16, + *PU_POINT16; //!< WMF manual 2.2.2.16 + +/** WMF manual 2.2.2.19 + \brief Coordinates of the upper left, lower right corner. + + Note that the coordinate system is 0,0 in the upper left corner + of the screen an N,M in the lower right corner. + Microsoft name: RECTL Object +*/ +typedef struct { + int32_t left; //!< left coordinate + int32_t top; //!< top coordinate + int32_t right; //!< right coordinate + int32_t bottom; //!< bottom coordinate +} U_RECT, + U_RECTL, //!< WMF manual 2.2.2.19 + *PU_RECT, //!< WMF manual 2.2.2.19 + *PU_RECTL; //!< WMF manual 2.2.2.19 + +/** WMF manual 2.2.2.20 + \brief For U_BITMAPINFO bmiColors field + + NOTE that the color order is BGR, even though the name is RGB! + Microsoft name: RGBQUAD Object +*/ +typedef struct { + uint8_t Blue; //!< Blue color (0-255) + uint8_t Green; //!< Green color (0-255) + uint8_t Red; //!< Red color (0-255) + uint8_t Reserved; //!< Not used +} U_RGBQUAD, + *PU_RGBQUAD; //!< WMF manual 2.2.2.20 + +#define U_RCL_DEF (U_RECTL){0,0,-1,-1} //!< Use this when no bounds are needed. + +/** WMF manual 2.2.2.22 + \brief Pair of values indicating x and y sizes. + Microsoft name: SIZE Object + Microsoft name: SIZEL Object +*/ +typedef struct { + int32_t cx; //!< X size + int32_t cy; //!< Y size +} U_SIZE, + U_SIZEL, //!< WMF manual 2.2.2.22 + *PU_SIZE, //!< WMF manual 2.2.2.22 + *PU_SIZEL; //!< WMF manual 2.2.2.22 + + + +/* ************************ EMF or common to EMF and EMF+ ****************************** */ // *********************************************************************************** // Value enumerations and other predefined constants, alphabetical order by group -/** \defgroup Font_struct_widths Font name and style widths in characters +/** \defgroup U_EMF_FONT_STRUCT_WIDTHS EMF Font name and style widths in characters For U_LOGFONT and U_LOGFONT_PANOSE, @{ */ @@ -58,9 +607,10 @@ extern "C" { #define U_LF_FULLFACESIZE 64 //!< U_LOGFONT_PANOSE elfFullName field maximum width /** @} */ -/** \defgroup U_EMR_Qualifiers RecordType Enumeration - (RecordType Enumeration) +/** \defgroup U_EMF_EMR_Qualifiers EMF RecordType Enumeration + (RecordType Enumeration, EMF manual 2.1.1 ) For U_EMR iType field + EMF manual 2.1.1 @{ */ #define U_EMR_HEADER 1 //!< U_EMRHEADER record @@ -192,7 +742,8 @@ extern "C" { #define U_EMR_INVALID 0xFFFFFFFF //!< Not any valid U_EMF_ value /** @} */ -/** \defgroup U_DRAW_PROPERTIES draw properties + +/** \defgroup U_EMF_DRAW_PROPERTIES EMF draw properties Used in emr_properties() and wmr_properties. These are the bit definitions. @{ */ @@ -208,928 +759,827 @@ extern "C" { #define U_DRAW_NOFILL 0x200 //!< Object is not fillable (lines and arc, only used in WMF) /** @} */ -/** \defgroup U_EMRSETARCDIRECTION_Qualifiers ArcDirection Enumeration +/** \defgroup U_EMF_EMRSETARCDIRECTION_Qualifiers EMF ArcDirection Enumeration For U_EMRSETARCDIRECTION iArcDirection field + Microsoft name: ArcDirection Enumeration + EMF manual 2.1.2 @{ */ -#define U_AD_COUNTERCLOCKWISE 1 -#define U_AD_CLOCKWISE 2 +#define U_AD_COUNTERCLOCKWISE 1 //!< Draw arc counterclockwise. +#define U_AD_CLOCKWISE 2 //!< Draw arc clockwise. /** @} */ -/** \defgroup U_PANOSE_bArmStyle_Qualifiers ArmStyle Enumeration +/** \defgroup U_EMF_PANOSE_bArmStyle_Qualifiers EMF ArmStyle Enumeration For U_PANOSE bArmStyle field + Microsoft name: ArmStyle Enumeration + EMF manual 2.1.3 @{ */ -#define U_PAN_STRAIGHT_ARMS_HORZ 2 -#define U_PAN_STRAIGHT_ARMS_WEDGE 3 -#define U_PAN_STRAIGHT_ARMS_VERT 4 -#define U_PAN_STRAIGHT_ARMS_SINGLE_SERIF 5 -#define U_PAN_STRAIGHT_ARMS_DOUBLE_SERIF 6 -#define U_PAN_BENT_ARMS_HORZ 7 -#define U_PAN_BENT_ARMS_WEDGE 8 -#define U_PAN_BENT_ARMS_VERT 9 -#define U_PAN_BENT_ARMS_SINGLE_SERIF 10 -#define U_PAN_BENT_ARMS_DOUBLE_SERIF 11 +#define U_PAN_STRAIGHT_ARMS_HORZ 2 //!< straight arms horizontal +#define U_PAN_STRAIGHT_ARMS_WEDGE 3 //!< straight arms wedge +#define U_PAN_STRAIGHT_ARMS_VERT 4 //!< straight arms vertical +#define U_PAN_STRAIGHT_ARMS_SINGLE_SERIF 5 //!< straight arms singleserif +#define U_PAN_STRAIGHT_ARMS_DOUBLE_SERIF 6 //!< straight arms doubleserif +#define U_PAN_BENT_ARMS_HORZ 7 //!< bent arms horizontal +#define U_PAN_BENT_ARMS_WEDGE 8 //!< bent arms wedge +#define U_PAN_BENT_ARMS_VERT 9 //!< bent arms vertical +#define U_PAN_BENT_ARMS_SINGLE_SERIF 10 //!< bent arms singleserif +#define U_PAN_BENT_ARMS_DOUBLE_SERIF 11 //!< bent arms doubleserif /** @} */ -/** \defgroup U_EMRSETBKMODE_iMode_Qualifiers BackgroundMode enumeration +/** \defgroup U_EMF_EMRSETBKMODE_iMode_Qualifiers EMF BackgroundMode enumeration For U_EMRSETBKMODE iMode field + Microsoft name: BackgroundMode enumeration + EMF manual 2.1.4 @{ */ -#define U_TRANSPARENT 1 -#define U_OPAQUE 2 +#define U_TRANSPARENT 1 //!< Transparent background mode +#define U_OPAQUE 2 //!< Opaque background mode /** @} */ -/** \defgroup U_BITMAPINFOHEADER_biBitCount_Qualifiers BitCount Enumeration - For U_BITMAPINFOHEADER biBitCount field. - @{ -*/ -#define U_BCBM_EXPLICIT 0 //!< Derived from JPG or PNG compressed image or ? -#define U_BCBM_MONOCHROME 1 //!< 2 colors. bmiColors array has two entries -#define U_BCBM_COLOR4 4 //!< 2^4 colors. bmiColors array has 16 entries -#define U_BCBM_COLOR8 8 //!< 2^8 colors. bmiColors array has 256 entries -#define U_BCBM_COLOR16 16 //!< 2^16 colors. bmiColors is not used. Pixels are 5 bits B,G,R with 1 unused bit -#define U_BCBM_COLOR24 24 //!< 2^24 colors. bmiColors is not used. Pixels are U_RGBTRIPLE. -#define U_BCBM_COLOR32 32 //!< 2^32 colors. bmiColors is not used. Pixels are U_RGBQUAD. -/** @} */ - -/** \defgroup U_BITMAPINFOHEADER_biCompression_Qualifiers BI_Compression Enumeration - For U_BITMAPINFOHEADER biCompression field - @{ -*/ -#define U_BI_RGB 0 //!< This is the only one supported by UEMF at present -#define U_BI_RLE8 1 -#define U_BI_RLE4 2 -#define U_BI_BITFIELDS 3 -#define U_BI_JPEG 4 -#define U_BI_PNG 5 -/** @} */ - -/** \defgroup U_COLORADJUSTMENT_caFlags_Qualifiers ColorAdjustment Enumeration +/** \defgroup U_EMF_COLORADJUSTMENT_caFlags_Qualifiers EMF ColorAdjustment Enumeration For U_COLORADJUSTMENT caFlags field + Microsoft name: ColorAdjustment Enumeration + EMF manual 2.1.5 @{ */ -#define U_CA_NEGATIVE 0x0001 -#define U_CA_LOG_FILTER 0x0002 +#define U_CA_NEGATIVE 0x0001 //!< display Negative of image +#define U_CA_LOG_FILTER 0x0002 //!< display Logarithmi filter of image /** @} */ -/** \defgroup U_EMRCOLORMATCHTOTARGETW_dwFlags_Qualifiers ColorMatchToTarget Enumeration +/** \defgroup U_EMF_EMRCOLORMATCHTOTARGETW_dwFlags_Qualifiers EMF ColorMatchToTarget Enumeration For U_EMRCOLORMATCHTOTARGETW dwFlags field + Microsoft name: ColorMatchToTarget Enumeration + EMF manual 2.1.6 @{ */ -#define U_COLORMATCHTOTARGET_NOTEMBEDDED 0 -#define U_COLORMATCHTOTARGET_EMBEDDED 1 +#define U_COLORMATCHTOTARGET_NOTEMBEDDED 0 //!< Color match profile is not embedded in metafile +#define U_COLORMATCHTOTARGET_EMBEDDED 1 //!< Color match profile is embedded in metafile /** @} */ -/** \defgroup U_EMRCOLORMATCHTOTARGETW_dwAction_Qualifiers ColorSpace Enumeration +/** \defgroup U_EMF_EMRCOLORMATCHTOTARGETW_dwAction_Qualifiers EMF ColorSpace Enumeration For U_EMRCOLORMATCHTOTARGETW dwAction field + Microsoft name: ColorSpace Enumeration + EMF manual 2.1.7 @{ */ -#define U_CS_ENABLE 1 -#define U_CS_DISABLE 2 -#define U_CS_DELETE_TRANSFORM 3 +#define U_CS_ENABLE 1 //!< Enable color proofing. +#define U_CS_DISABLE 2 //!< Disable color proofing. +#define U_CS_DELETE_TRANSFORM 3 //!< Disable proofing and delete color transform. /** @} */ -/** \defgroup U_PANOSE_bContrast_Qualifiers Contrast Enumeration - For U_PANOSE bContrast field +/** \defgroup U_EMF_PANOSE_common_Qualifiers EMF PanoseCommon Enumeration + Used by all PAN_* enumerations, but only defined once here. + See also U_PAN_ALL1 after the U_PANOSE structure @{ */ -#define U_PAN_CONTRAST_NONE 2 -#define U_PAN_CONTRAST_VERY_LOW 3 -#define U_PAN_CONTRAST_LOW 4 -#define U_PAN_CONTRAST_MEDIUM_LOW 5 -#define U_PAN_CONTRAST_MEDIUM 6 -#define U_PAN_CONTRAST_MEDIUM_HIGH 7 -#define U_PAN_CONTRAST_HIGH 8 -#define U_PAN_CONTRAST_VERY_HIGH 9 +#define U_PAN_ANY 0 //!< Any (for any type of Panose enumeration) +#define U_PAN_NO_FIT 1 //!< No fit (for any type of Panose enumeration) /** @} */ -/** \defgroup U_DIBITS_iUsageSrc_Qualifiers DIBColors Enumeration - For U_EMRSETDIBITSTODEIVCE and U_EMRSTRETCHDIBITS iUsageSrc fields. +/** \defgroup U_EMF_PANOSE_bContrast_Qualifiers EMF Contrast Enumeration + For U_PANOSE bContrast field + Microsoft name: Contrast Enumeration + EMF manual 2.1.8 @{ */ -#define U_DIB_RGB_COLORS 0 -#define U_DIB_PAL_COLORS 1 +#define U_PAN_CONTRAST_NONE 2 //!< None +#define U_PAN_CONTRAST_VERY_LOW 3 //!< Very low +#define U_PAN_CONTRAST_LOW 4 //!< Low +#define U_PAN_CONTRAST_MEDIUM_LOW 5 //!< Medium low +#define U_PAN_CONTRAST_MEDIUM 6 //!< Medium +#define U_PAN_CONTRAST_MEDIUM_HIGH 7 //!< Medium high +#define U_PAN_CONTRAST_HIGH 8 //!< High +#define U_PAN_CONTRAST_VERY_HIGH 9 //!< Very high /** @} */ -/** \defgroup U_EMRCOMMENT_TYPES Comment record types - For U_EMRCOMMENT_* cIdent fields +/** \defgroup U_EMF_DIBITS_iUsageSrc_Qualifiers EMF DIBColors Enumeration + For U_EMRSETDIBITSTODEIVCE and U_EMRSTRETCHDIBITS iUsageSrc fields. + Microsoft name: DIBColors Enumeration + EMF manual 2.1.9 @{ */ -#define U_EMR_COMMENT_PUBLIC 0x43494447 -#define U_EMR_COMMENT_SPOOL 0x00000000 -#define U_EMR_COMMENT_SPOOLFONTDEF 0x544F4E46 -#define U_EMR_COMMENT_EMFPLUSRECORD 0x2B464D45 +#define U_DIB_RGB_COLORS 0 //!< color table contains colors +#define U_DIB_PAL_COLORS 1 //!< color table contains 16 bit indices into logical palette +#define U_DIB_PAL_INDICES 2 //!< no color table, pixel values are indices into logical palette /** @} */ -/** \defgroup U_EMR_COMMENT_PUBLIC EMRComment Enumeration +/** \defgroup U_EMF_EMR_COMMENT_PUBLIC EMF EMRComment Enumeration For U_EMRCOMMENT_PUBLIC pcIdent fields + Microsoft name: EMRComment Enumeration + EMF manual 2.1.10 @{ */ -#define U_EMR_COMMENT_WINDOWS_METAFILE 0x80000001 -#define U_EMR_COMMENT_BEGINGROUP 0x00000002 -#define U_EMR_COMMENT_ENDGROUP 0x00000003 -#define U_EMR_COMMENT_MULTIFORMATS 0x40000004 -#define U_EMR_COMMENT_UNICODE_STRING 0x00000040 -#define U_EMR_COMMENT_UNICODE_END 0x00000080 +#define U_EMR_COMMENT_WINDOWS_METAFILE 0x80000001 //!< Comment contains WMF +#define U_EMR_COMMENT_BEGINGROUP 0x00000002 //!< Comment begins group of EMF records +#define U_EMR_COMMENT_ENDGROUP 0x00000003 //!< Comment ends group of EMF records +#define U_EMR_COMMENT_MULTIFORMATS 0x40000004 //!< Comment contains some other representation of drawing +#define U_EMR_COMMENT_UNICODE_STRING 0x00000040 //!< Reserved +#define U_EMR_COMMENT_UNICODE_END 0x00000080 //!< Reserved /** @} */ -/** \defgroup U_EMRTEXT_foptions_Qualifiers ExtTextOutOptions Enumeration +/** \defgroup U_EMF_EMRTEXT_foptions_Qualifiers EMF ExtTextOutOptions Enumeration For U_EMRTEXT foptions field + Microsoft name: ExtTextOutOptions Enumeration + EMF manual 2.1.11 @{ */ -#define U_ETO_NONE 0x00000000 -#define U_ETO_GRAYED 0x00000001 -#define U_ETO_OPAQUE 0x00000002 -#define U_ETO_CLIPPED 0x00000004 -#define U_ETO_GLYPH_INDEX 0x00000010 -#define U_ETO_RTLREADING 0x00000080 -#define U_ETO_NO_RECT 0x00000100 -#define U_ETO_SMALL_CHARS 0x00000200 // For EMRSMALLTEXTOUT ONLY, does not affect EMRTEXTOUTA or EMRTEXTOUTW -#define U_ETO_NUMERICSLOCAL 0x00000400 -#define U_ETO_NUMERICSLATIN 0x00000800 -#define U_ETO_IGNORELANGUAGE 0x00001000 -#define U_ETO_PDY 0x00002000 -#define U_ETO_REVERSE_INDEX_MAP 0x00010000 -/** @} */ - -/** \defgroup U_PANOSE_bFamilyType_Qualifiers FamilyType Enumeration +#define U_ETO_NONE 0x00000000 //!< None +#define U_ETO_GRAYED 0x00000001 //!< Grayed +#define U_ETO_OPAQUE 0x00000002 //!< Fill rectangle with background color. +#define U_ETO_CLIPPED 0x00000004 //!< Clip text to rectangle. +#define U_ETO_GLYPH_INDEX 0x00000010 //!< Characters are glyph indices for the font. +#define U_ETO_RTLREADING 0x00000080 //!< Right to left text. +#define U_ETO_NO_RECT 0x00000100 //!< No bounding rectangle is specified. +#define U_ETO_SMALL_CHARS 0x00000200 //!< 8 bit characters instead of 16 bit. For EMRSMALLTEXTOUT ONLY, does not affect EMRTEXTOUTA or EMRTEXTOUTW +#define U_ETO_NUMERICSLOCAL 0x00000400 //!< Show numbers for the current locale. +#define U_ETO_NUMERICSLATIN 0x00000800 //!< Show numbers using European digits. +#define U_ETO_IGNORELANGUAGE 0x00001000 //!< Process Right to Left languages exactly as specified in the metafile. +#define U_ETO_PDY 0x00002000 //!< Both horizontal and vertical displacements are provided. +#define U_ETO_REVERSE_INDEX_MAP 0x00010000 //!< Reverse_index_map +/** @} */ + +/** \defgroup U_EMF_PANOSE_bFamilyType_Qualifiers EMF FamilyType Enumeration For U_PANOSE bFamilyType field + Microsoft name: FamilyType Enumeration + EMF manual 2.1.12 @{ */ -#define U_PAN_FAMILY_TEXT_DISPLAY 2 -#define U_PAN_FAMILY_SCRIPT 3 -#define U_PAN_FAMILY_DECORATIVE 4 -#define U_PAN_FAMILY_PICTORIAL 5 +#define U_PAN_FAMILY_TEXT_DISPLAY 2 //!< Text display +#define U_PAN_FAMILY_SCRIPT 3 //!< Script +#define U_PAN_FAMILY_DECORATIVE 4 //!< Decorative +#define U_PAN_FAMILY_PICTORIAL 5 //!< Pictorial /** @} */ -/** \defgroup U_EMREXTFLOODFILL_iMode_Qualifiers FloodFill Enumeration +/** \defgroup U_EMF_EMREXTFLOODFILL_iMode_Qualifiers EMF FloodFill Enumeration For U_EMREXTFLOODFILL iMode field + Microsoft name: FloodFill Enumeration + EMF manual 2.1.13 @{ */ -#define U_FLOODFILLBORDER 0x00000000 /* Color specified must be the same as the border - brush fill stops at this color */ -#define U_FLOODFILLSURFACE 0x00000001 /* Color specified must be different from the border - brush fills only this color */ +#define U_FLOODFILLBORDER 0x00000000 //!< Color specified must be the same as the border - brush fill stops at this color +#define U_FLOODFILLSURFACE 0x00000001 //!< Color specified must be different from the border - brush fills only this color /** @} */ -/** \defgroup U_DESIGNVECTOR_Signature_Qualifiers Signature Enumeration +/** \defgroup U_EMF_DESIGNVECTOR_Signature_Qualifiers EMF Signature Enumeration For U_DESIGNVECTOR Signature field + Microsoft name: Signature Enumeration + EMF manual 2.1.14 @{ */ -#define U_ENHMETA_SIGNATURE 0x464D4520 //!< also for U_EMRHEADER dSignature field -#define U_EPS_SIGNATURE 0x46535045 +#define U_ENHMETA_SIGNATURE 0x464D4520 //!< "EMF" signature also for U_EMRHEADER dSignature field. +#define U_EPS_SIGNATURE 0x46535045 //!< "FSPE" signature, indicates encapsulated postscript. /** @} */ -/** \defgroup U_EMRGRADIENTFILL_ulMode_Qualifiers GradientFill Enumeration +/** \defgroup U_EMF_EMRGRADIENTFILL_ulMode_Qualifiers EMF GradientFill Enumeration For U_EMRGRADIENTFILL ulMode field + Microsoft name: GradientFill Enumeration + EMF manual 2.1.15 @{ */ -#define U_GRADIENT_FILL_RECT_H 0x00000000 -#define U_GRADIENT_FILL_RECT_V 0x00000001 -#define U_GRADIENT_FILL_TRIANGLE 0x00000002 +#define U_GRADIENT_FILL_RECT_H 0x00000000 //!< Gradient is left to right. +#define U_GRADIENT_FILL_RECT_V 0x00000001 //!< Grident is top to bottom. +#define U_GRADIENT_FILL_TRIANGLE 0x00000002 //!< Gradient is between 3 vertices of a triangle. /** @} */ -/** \defgroup U_EMREXTTEXTOUT_iGraphicsMode_Qualifiers GraphicsMode Enumeration +/** \defgroup U_EMF_EMREXTTEXTOUT_iGraphicsMode_Qualifiers EMF GraphicsMode Enumeration For U_EMREXTTEXTOUTA/U_EMREXTTEXTOUTW and all other iGraphicsMode fields + Microsoft name: GraphicsMode Enumeration + EMF manual 2.1.16 @{ */ -#define U_GM_COMPATIBLE 1 -#define U_GM_ADVANCED 2 -#define U_GM_LAST 2 +#define U_GM_COMPATIBLE 1 //!< TrueType text ignores world to device transform except for Scale. Arcs ignore transform +#define U_GM_ADVANCED 2 //!< TrueType text and Arcs must conform to all of world to device transform. +#define U_GM_LAST 2 //!< Number of GraphicsMode Enumeration entries. /** @} */ -/** \defgroup U_LOGBRUSH_lbHatch_Qualifiers HatchStyle Enumeration +/** \defgroup U_EMF_LOGBRUSH_lbHatch_Qualifiers EMF HatchStyle Enumeration For U_LOGBRUSH lbHatch field + Microsoft name: HatchStyle Enumeration + EMF manual 2.1.17 @{ */ -#define U_HS_HORIZONTAL 0 -#define U_HS_VERTICAL 1 -#define U_HS_FDIAGONAL 2 -#define U_HS_BDIAGONAL 3 -#define U_HS_CROSS 4 -#define U_HS_DIAGCROSS 5 -#define U_HS_SOLIDCLR 6 -#define U_HS_DITHEREDCLR 7 -#define U_HS_SOLIDTEXTCLR 8 -#define U_HS_DITHEREDTEXTCLR 9 -#define U_HS_SOLIDBKCLR 10 -#define U_HS_DITHEREDBKCLR 11 -/** @} */ - -/** \defgroup U_EMRSETICMMODE_iMode_Qualifiers ICMMode Enumeration +#define U_HS_HORIZONTAL 0 //!< Horizontal. +#define U_HS_VERTICAL 1 //!< Vertical. +#define U_HS_FDIAGONAL 2 //!< Forward diagonal. +#define U_HS_BDIAGONAL 3 //!< Back diagonal. +#define U_HS_CROSS 4 //!< Cross. +#define U_HS_DIAGCROSS 5 //!< Diagonal cross. +#define U_HS_SOLIDCLR 6 //!< Solid color. +#define U_HS_DITHEREDCLR 7 //!< Dithered color. +#define U_HS_SOLIDTEXTCLR 8 //!< Solid text color. +#define U_HS_DITHEREDTEXTCLR 9 //!< Dithered text color. +#define U_HS_SOLIDBKCLR 10 //!< Solid background color. +#define U_HS_DITHEREDBKCLR 11 //!< Dithered background color. +/** @} */ + +/** \defgroup U_EMF_EMRSETICMMODE_iMode_Qualifiers EMF ICMMode Enumeration For EMF U_EMR_SETICMMODE iMode field + Microsoft name: ICMMode Enumeration + EMF manual 2.1.18 @{ */ -#define U_ICM_OFF 1 -#define U_ICM_ON 2 -#define U_ICM_QUERY 3 +#define U_ICM_OFF 1 //!< Off +#define U_ICM_ON 2 //!< On +#define U_ICM_QUERY 3 //!< Query /** @} */ -/** \defgroup U_COLORADJUSTMENT_caIlluminantIndex_Qualifiers Illuminant Enumeration +/** \defgroup U_EMF_COLORADJUSTMENT_caIlluminantIndex_Qualifiers EMF Illuminant Enumeration For U_COLORADJUSTMENT caIlluminantIndex field + Microsoft name: Illuminant Enumeration + EMF manual 2.1.19 @{ */ -#define U_ILLUMINANT_DEVICE_DEFAULT 0 -#define U_ILLUMINANT_A 1 -#define U_ILLUMINANT_B 2 -#define U_ILLUMINANT_C 3 -#define U_ILLUMINANT_D50 4 -#define U_ILLUMINANT_D55 5 -#define U_ILLUMINANT_D65 6 -#define U_ILLUMINANT_D75 7 -#define U_ILLUMINANT_F2 8 -#define U_ILLUMINANT_MAX_INDEX ILLUMINANT_F2 -#define U_ILLUMINANT_TUNGSTEN ILLUMINANT_A -#define U_ILLUMINANT_DAYLIGHT ILLUMINANT_C -#define U_ILLUMINANT_FLUORESCENT ILLUMINANT_F2 -#define U_ILLUMINANT_NTSC ILLUMINANT_C -/** @} */ - -/** \defgroup U_LOGBRUSH_lbStyle_Qualifiers LB_Style Enumeration - For U_LOGBRUSH lbStyle field - @{ -*/ -#define U_BS_SOLID 0 -#define U_BS_NULL 1 -#define U_BS_HOLLOW 1 -#define U_BS_HATCHED 2 -#define U_BS_PATTERN 3 -#define U_BS_INDEXED 4 -#define U_BS_DIBPATTERN 5 -#define U_BS_DIBPATTERNPT 6 -#define U_BS_PATTERN8X8 7 -#define U_BS_DIBPATTERN8X8 8 -#define U_BS_MONOPATTERN 9 -/** @} */ - -/** \defgroup _LOGCOLORSPACE_lcsCSType_Qualifiers LCS_CSType Enumeration - For U_LOGCOLORSPACEA/U_LOGCOLORSPACEW lcsCSType field - @{ -*/ -#define U_LCS_CALIBRATED_RGB 0x00000000L -#define U_LCS_DEVICE_RGB 0x00000001L -#define U_LCS_DEVICE_CMYK 0x00000002L -/** @} */ - -/** \defgroup U_LOGCOLORSPACE_lcsIntent_Qualifiers LCS_Intent Enumeration - For U_LOGCOLORSPACEA/U_LOGCOLORSPACEW lcsIntent field - @{ -*/ -#define U_LCS_GM_BUSINESS 0x00000001L -#define U_LCS_GM_GRAPHICS 0x00000002L -#define U_LCS_GM_IMAGES 0x00000004L -#define U_LCS_GM_ABS_COLORIMETRIC 0x00000008L -/** @} */ - -/** \defgroup U_PANOSE_bLetterForm_Qualifiers Letterform Enumeration +#define U_ILLUMINANT_DEVICE_DEFAULT 0 //!< Device default +#define U_ILLUMINANT_A 1 //!< A +#define U_ILLUMINANT_B 2 //!< B +#define U_ILLUMINANT_C 3 //!< C +#define U_ILLUMINANT_D50 4 //!< D50 +#define U_ILLUMINANT_D55 5 //!< D55 +#define U_ILLUMINANT_D65 6 //!< D65 +#define U_ILLUMINANT_D75 7 //!< D75 +#define U_ILLUMINANT_F2 8 //!< F2 +#define U_ILLUMINANT_MAX_INDEX ILLUMINANT_F2 //!< Max index +#define U_ILLUMINANT_TUNGSTEN ILLUMINANT_A //!< Tungsten +#define U_ILLUMINANT_DAYLIGHT ILLUMINANT_C //!< Daylight +#define U_ILLUMINANT_FLUORESCENT ILLUMINANT_F2 //!< Fluorescent +#define U_ILLUMINANT_NTSC ILLUMINANT_C //!< NTSC +/** @} */ + +/** \defgroup U_EMF_PANOSE_bLetterForm_Qualifiers EMF Letterform Enumeration For U_PANOSE bLetterForm field + Microsoft name: Letterform Enumeration + EMF manual 2.1.20 @{ */ -#define U_PAN_LETT_NORMAL_COMPACT 2 -#define U_PAN_LETT_NORMAL_WEIGHTED 3 -#define U_PAN_LETT_NORMAL_BOXED 4 -#define U_PAN_LETT_NORMAL_FLATTENED 5 -#define U_PAN_LETT_NORMAL_ROUNDED 6 -#define U_PAN_LETT_NORMAL_OFF_CENTER 7 -#define U_PAN_LETT_NORMAL_SQUARE 8 -#define U_PAN_LETT_OBLIQUE_COMPACT 9 -#define U_PAN_LETT_OBLIQUE_WEIGHTED 10 -#define U_PAN_LETT_OBLIQUE_BOXED 11 -#define U_PAN_LETT_OBLIQUE_FLATTENED 12 -#define U_PAN_LETT_OBLIQUE_ROUNDED 13 -#define U_PAN_LETT_OBLIQUE_OFF_CENTER 14 -#define U_PAN_LETT_OBLIQUE_SQUARE 15 -/** @} */ - -/** \defgroup U_LOGFONT_lfWeight_Qualifiers LF_Weight Enumeration - For U_LOGFONT lfWeight field +#define U_PAN_LETT_NORMAL_COMPACT 2 //!< Normal compact +#define U_PAN_LETT_NORMAL_WEIGHTED 3 //!< Normal weighted +#define U_PAN_LETT_NORMAL_BOXED 4 //!< Normal boxed +#define U_PAN_LETT_NORMAL_FLATTENED 5 //!< Normal flattened +#define U_PAN_LETT_NORMAL_ROUNDED 6 //!< Normal rounded +#define U_PAN_LETT_NORMAL_OFF_CENTER 7 //!< Normal off center +#define U_PAN_LETT_NORMAL_SQUARE 8 //!< Normal square +#define U_PAN_LETT_OBLIQUE_COMPACT 9 //!< Oblique compact +#define U_PAN_LETT_OBLIQUE_WEIGHTED 10 //!< Oblique weighted +#define U_PAN_LETT_OBLIQUE_BOXED 11 //!< Oblique boxed +#define U_PAN_LETT_OBLIQUE_FLATTENED 12 //!< Oblique flattened +#define U_PAN_LETT_OBLIQUE_ROUNDED 13 //!< Oblique rounded +#define U_PAN_LETT_OBLIQUE_OFF_CENTER 14 //!< Oblique off center +#define U_PAN_LETT_OBLIQUE_SQUARE 15 //!< Oblique square +/** @} */ + +/** \defgroup U_EMF_EMRSETMAPMODE_iMode_Qualifiers EMF MapMode Enumeration + For U_EMRSETMAPMODE iMode field + Microsoft name: MapMode Enumeration + EMF manual 2.1.21 @{ */ -#define U_FW_DONTCARE 0 -#define U_FW_THIN 100 -#define U_FW_EXTRALIGHT 200 -#define U_FW_ULTRALIGHT 200 -#define U_FW_LIGHT 300 -#define U_FW_NORMAL 400 -#define U_FW_REGULAR 400 -#define U_FW_MEDIUM 500 -#define U_FW_SEMIBOLD 600 -#define U_FW_DEMIBOLD 600 -#define U_FW_BOLD 700 -#define U_FW_EXTRABOLD 800 -#define U_FW_ULTRABOLD 800 -#define U_FW_HEAVY 900 -#define U_FW_BLACK 900 -/** @} */ - -/** \defgroup U_LOGFONT_lfItalic_Qualifiers LF_Italic Enumeration - For U_LOGFONT lfItalic field +#define U_MM_TEXT 1 //!< Text +#define U_MM_LOMETRIC 2 //!< Low metric +#define U_MM_HIMETRIC 3 //!< Hig hmetric +#define U_MM_LOENGLISH 4 //!< Low English +#define U_MM_HIENGLISH 5 //!< High English +#define U_MM_TWIPS 6 //!< Twips +#define U_MM_ISOTROPIC 7 //!< Isotropic +#define U_MM_ANISOTROPIC 8 //!< Anisotropic +#define U_MM_MIN U_MM_TEXT //!< smallest enumeration +#define U_MM_MAX U_MM_ANISOTROPIC //!< largest enumeration +#define U_MM_MAX_FIXEDSCALE U_MM_TWIPS //!< alternate definition +/** @} */ + +/** \defgroup U_EMF_MF_version EMF MetafileVersion Enumeration + For U_EMR_COMMENTS_METAFILE version field + Microsoft name: MetafileVersion Enumeration + EMF manual 2.1.22 @{ */ -#define U_FW_NOITALIC 0 -#define U_FW_ITALIC 1 +#define U_ENHMETA_VERSION 0x00010000 //!< U_EMRHEADER nVersion field /** @} */ -/** \defgroup U_LOGFONT_lfunderline_Qualifiers LF_Underline Enumeration - For U_LOGFONT lfunderline field +/** \defgroup U_EMF_PANOSE_bMidline_Qualifiers EMF MidLine Enumeration + For U_PANOSE bMidline field + Microsoft name: MidLine Enumeration + EMF manual 2.1.23 @{ */ -#define U_FW_NOUNDERLINE 0 -#define U_FW_UNDERLINE 1 -/** @} */ - -/** \defgroup U_LOGFONT_lfStrikeOut_Qualifiers LF_StrikeOut Enumeration - For U_LOGFONT lfStrikeOut field +#define U_PAN_MIDLINE_STANDARD_TRIMMED 2 //!< Midline standard trimmed +#define U_PAN_MIDLINE_STANDARD_POINTED 3 //!< Midline standard pointed +#define U_PAN_MIDLINE_STANDARD_SERIFED 4 //!< Midline standard serifed +#define U_PAN_MIDLINE_HIGH_TRIMMED 5 //!< Midline high trimmed +#define U_PAN_MIDLINE_HIGH_POINTED 6 //!< Midline high pointed +#define U_PAN_MIDLINE_HIGH_SERIFED 7 //!< Midline high serifed +#define U_PAN_MIDLINE_CONSTANT_TRIMMED 8 //!< Midline constant trimmed +#define U_PAN_MIDLINE_CONSTANT_POINTED 9 //!< Midline constant pointed +#define U_PAN_MIDLINE_CONSTANT_SERIFED 10 //!< Midline constant serifed +#define U_PAN_MIDLINE_LOW_TRIMMED 11 //!< Midline low trimmed +#define U_PAN_MIDLINE_LOW_POINTED 12 //!< Midline low pointed +#define U_PAN_MIDLINE_LOW_SERIFED 13 //!< Midline low serifed +/** @} */ + +/** \defgroup U_EMF_EMRMODIFYWORLDTRANSFORM_iMode_Qualifiers EMF ModifyWorldTransformMode Enumeration + For U_EMRMODIFYWORLDTRANSFORM iMode + Microsoft name: ModifyWorldTransformMode Enumeration + EMF manual 2.1.24 @{ */ -#define U_FW_NOSTRIKEOUT 0 -#define U_FW_STRIKEOUT 1 +#define U_MWT_IDENTITY 1 //!< Transform is identity. +#define U_MWT_LEFTMULTIPLY 2 //!< Left multiply transform. +#define U_MWT_RIGHTMULTIPLY 3 //!< Right multiply transform. +#define U_MWT_MIN U_MWT_IDENTITY //!< smallest enumeration. +#define U_MWT_MAX U_MWT_RIGHTMULTIPLY //!< largest enumeration. /** @} */ -/** \defgroup U_LOGFONT_lfCharSet_Qualifiers LF_CharSet Enumeration - For U_LOGFONT lfCharSet field - @{ -*/ -#define U_ANSI_CHARSET (uint8_t)0 /* CP1252, ansi-0, iso8859-{1,15} */ -#define U_DEFAULT_CHARSET (uint8_t)1 -#define U_SYMBOL_CHARSET (uint8_t)2 -#define U_SHIFTJIS_CHARSET (uint8_t)128 /* CP932 */ -#define U_HANGEUL_CHARSET (uint8_t)129 /* CP949, ksc5601.1987-0 */ -#define U_HANGUL_CHARSET U_HANGEUL_CHARSET -#define U_GB2312_CHARSET (uint8_t)134 /* CP936, gb2312.1980-0 */ -#define U_CHINESEBIG5_CHARSET (uint8_t)136 /* CP950, big5.et-0 */ -#define U_GREEK_CHARSET (uint8_t)161 /* CP1253 */ -#define U_TURKISH_CHARSET (uint8_t)162 /* CP1254, -iso8859-9 */ -#define U_HEBREW_CHARSET (uint8_t)177 /* CP1255, -iso8859-8 */ -#define U_ARABIC_CHARSET (uint8_t)178 /* CP1256, -iso8859-6 */ -#define U_BALTIC_CHARSET (uint8_t)186 /* CP1257, -iso8859-13 */ -#define U_RUSSIAN_CHARSET (uint8_t)204 /* CP1251, -iso8859-5 */ -#define U_EE_CHARSET (uint8_t)238 /* CP1250, -iso8859-2 */ -#define U_EASTEUROPE_CHARSET U_EE_CHARSET -#define U_THAI_CHARSET (uint8_t)222 /* CP874, iso8859-11, tis620 */ -#define U_JOHAB_CHARSET (uint8_t)130 /* korean (johab) CP1361 */ -#define U_MAC_CHARSET (uint8_t)77 -#define U_OEM_CHARSET (uint8_t)255 -/* I don't know if the values of *_CHARSET macros are defined in Windows - * or if we can choose them as we want. -- srtxg - */ -#define U_VISCII_CHARSET (uint8_t)240 /* viscii1.1-1 */ -#define U_TCVN_CHARSET (uint8_t)241 /* tcvn-0 */ -#define U_KOI8_CHARSET (uint8_t)242 /* koi8-{r,u,ru} */ -#define U_ISO3_CHARSET (uint8_t)243 /* iso8859-3 */ -#define U_ISO4_CHARSET (uint8_t)244 /* iso8859-4 */ -#define U_ISO10_CHARSET (uint8_t)245 /* iso8859-10 */ -#define U_CELTIC_CHARSET (uint8_t)246 /* iso8859-14 */ -/** @} */ - -/** \defgroup U_LOGFONT_lfOutPrecision_Qualifiers LF_OutPrecision Enumeration - For U_LOGFONT lfOutPrecision field +/** \defgroup U_EMF_LOGPEN_elpPenStyle_Qualifiers EMF PenStyle Enumeration + For U_LOGPEN lopnStyle and U_EXTLOGPEN elpPenStyle fields + Microsoft name: PenStyle Enumeration + EMF manual 2.1.25 @{ */ -#define U_OUT_DEFAULT_PRECIS 0 -#define U_OUT_STRING_PRECIS 1 -#define U_OUT_CHARACTER_PRECIS 2 -#define U_OUT_STROKE_PRECIS 3 -#define U_OUT_TT_PRECIS 4 -#define U_OUT_DEVICE_PRECIS 5 -#define U_OUT_RASTER_PRECIS 6 -#define U_OUT_TT_ONLY_PRECIS 7 -#define U_OUT_OUTLINE_PRECIS 8 -/** @} */ +#define U_PS_SOLID 0x00000000 //!< Solid line. +#define U_PS_DASH 0x00000001 //!< Dashed line. This only works when NO other U_PS is set. Line width is minimum no matter what pen is set to. +#define U_PS_DOT 0x00000002 //!< Dotted line. This only works when NO other U_PS is set. Line width is minimum no matter what pen is set to. +#define U_PS_DASHDOT 0x00000003 //!< Dash-Dot line. This only works when NO other U_PS is set. Line width is minimum no matter what pen is set to. +#define U_PS_DASHDOTDOT 0x00000004 //!< Dash-Dot-Dot line. This only works when NO other U_PS is set. Line width is minimum no matter what pen is set to. +#define U_PS_NULL 0x00000005 //!< Invisible line. +#define U_PS_INSIDEFRAME 0x00000006 //!< Draw line around drawing, then shrink drawing to fit within line taking its width into account. +#define U_PS_USERSTYLE 0x00000007 //!< User defined. +#define U_PS_ALTERNATE 0x00000008 //!< Every other pixel is drawn. +#define U_PS_STYLE_MASK 0x0000000f //!< Mask to select just the preceding line type fields. + +#define U_PS_ENDCAP_ROUND 0x00000000 //!< Round end cap. Only with U_PS_GEOMETRIC +#define U_PS_ENDCAP_SQUARE 0x00000100 //!< Square end cap. Only with U_PS_GEOMETRIC +#define U_PS_ENDCAP_FLAT 0x00000200 //!< Flat end cap. Only with U_PS_GEOMETRIC +#define U_PS_ENDCAP_MASK 0x00000f00 //!< Mask to select just the preceding ENDCAP fields. + +#define U_PS_JOIN_ROUND 0x00000000 //!< Rounded join. Only with U_PS_GEOMETRIC +#define U_PS_JOIN_BEVEL 0x00001000 //!< Beveled join. Only with U_PS_GEOMETRIC +#define U_PS_JOIN_MITER 0x00002000 //!< Mitered join. Only with U_PS_GEOMETRIC +#define U_PS_JOIN_MASK 0x0000f000 //!< Mask to select just the preceding JOIN fields. -/** \defgroup U_LOGFONT_lfClipPrecision_Qualifiers LF_ClipPrecision Enumeration - For U_LOGFONT lfClipPrecision field - @{ +#define U_PS_COSMETIC 0x00000000 //!< width may only be 1 pixel. (If set higher it is still drawn as 1). +#define U_PS_GEOMETRIC 0x00010000 //!< width may be >1 pixel, but style may only be U_PS_SOLID or U_PS_NULL. +#define U_PS_TYPE_MASK 0x000f0000 //!< Mask to select just the preceding TYPE fields. +/** @} */ +/** \defgroup U_EMF_EMRPOLY_iMode_Qualifiers EMF Point Enumeration + For U_EMRPOLYDRAW and U_EMRPOLAYDRAW16 abTypes fields. + Microsoft name: Point Enumeration + EMF manual 2.1.26 + @{ */ -#define U_CLIP_DEFAULT_PRECIS 0x00 -#define U_CLIP_CHARACTER_PRECIS 0x01 -#define U_CLIP_STROKE_PRECIS 0x02 -#define U_CLIP_MASK 0x0F -#define U_CLIP_LH_ANGLES 0x10 -#define U_CLIP_TT_ALWAYS 0x20 -#define U_CLIP_EMBEDDED 0x80 +#define U_PT_CLOSEFIGURE 0x0001 //!< Close figure +#define U_PT_LINETO 0x0002 //!< Line to +#define U_PT_BEZIERTO 0x0004 //!< Bezier to +#define U_PT_MOVETO 0x0006 //!< Move to /** @} */ -/** \defgroup U_LOGFONT_lfQuality_Qualifiers LF_Quality Enumeration - For For U_LOGFONT lfQuality field +/** \defgroup U_EMF_EMRSETPOLYFILLMODE_iMode_Qualifiers EMF PolygonFillMode Enumeration + For U_EMRSETPOLYFILLMODE iMode field + Microsoft name: PolygonFillMode Enumeration + EMF manual 2.1.27 @{ */ -#define U_DEFAULT_QUALITY 0 -#define U_DRAFT_QUALITY 1 -#define U_PROOF_QUALITY 2 -#define U_NONANTIALIASED_QUALITY 3 -#define U_ANTIALIASED_QUALITY 4 +#define U_ALTERNATE 1 //!< Alternate +#define U_WINDING 2 //!< Winding +#define U_POLYFILL_LAST 2 //!< Polyfill last /** @} */ -/** \defgroup U_LOGFONT_lfPitchAndFamily_Qualifiers LF_PitchAndFamily Enumeration - For U_LOGFONT lfPitchAndFamily field +/** \defgroup U_EMF_PANOSE_bProportion_Qualifiers EMF Proportion Enumeration + For U_PANOSE bProportion field + Microsoft name: Proportion Enumeration + EMF manual 2.1.28 @{ */ -#define U_DEFAULT_PITCH 0x00 -#define U_FIXED_PITCH 0x01 -#define U_VARIABLE_PITCH 0x02 -#define U_MONO_FONT 0x08 -#define U_FF_DONTCARE 0x00 -#define U_FF_ROMAN 0x10 -#define U_FF_SWISS 0x20 -#define U_FF_MODERN 0x30 -#define U_FF_SCRIPT 0x40 -#define U_FF_DECORATIVE 0x50 +#define U_PAN_PROP_OLD_STYLE 2 //!< Old style +#define U_PAN_PROP_MODERN 3 //!< Modern +#define U_PAN_PROP_EVEN_WIDTH 4 //!< Even width +#define U_PAN_PROP_EXPANDED 5 //!< Expanded +#define U_PAN_PROP_CONDENSED 6 //!< Condensed +#define U_PAN_PROP_VERY_EXPANDED 7 //!< Very expanded +#define U_PAN_PROP_VERY_CONDENSED 8 //!< Very condensed +#define U_PAN_PROP_MONOSPACED 9 //!< Monospaced /** @} */ -/** \defgroup U_EMRSETMAPMODE_iMode_Qualifiers MapMode Enumeration - For U_EMRSETMAPMODE iMode field +/** \defgroup U_EMF_EMRSELECTCLIP_iMode_Qualifiers EMF RegionMode Enumeration + For U_EMRSELECTCLIPPATH and U_EMREXTSELECTCLIPRGN iMode field + Microsoft name: RegionMode Enumeration + EMF manual 2.1.29 @{ */ -#define U_MM_TEXT 1 -#define U_MM_LOMETRIC 2 -#define U_MM_HIMETRIC 3 -#define U_MM_LOENGLISH 4 -#define U_MM_HIENGLISH 5 -#define U_MM_TWIPS 6 -#define U_MM_ISOTROPIC 7 -#define U_MM_ANISOTROPIC 8 -#define U_MM_MIN U_MM_TEXT -#define U_MM_MAX U_MM_ANISOTROPIC -#define U_MM_MAX_FIXEDSCALE U_MM_TWIPS +#define U_RGN_AND 1 //!< Region becomes intersection of existing region and new region. +#define U_RGN_OR 2 //!< Region becomes union of existing region and new region. +#define U_RGN_XOR 3 //!< Region becomes XOR of existing and new regions. +#define U_RGN_DIFF 4 //!< Region becomes part of existing region not in new region. +#define U_RGN_COPY 5 //!< Region becomes new region. +#define U_RGN_MIN U_RGN_AND //!< smallest enumeration. +#define U_RGN_MAX U_RGN_COPY //!< largest enumeration. /** @} */ - -/** \defgroup U_PANOSE_bMidline_Qualifiers MidLine Enumeration - For U_PANOSE bMidline field +/** \defgroup U_EMF_PANOSE_bSerifStyle_Qualifiers EMF SerifType Enumeration + For U_PANOSE bSerifStyle field + Microsoft name: SerifType Enumeration + EMF manual 2.1.30 @{ */ -#define U_PAN_MIDLINE_STANDARD_TRIMMED 2 -#define U_PAN_MIDLINE_STANDARD_POINTED 3 -#define U_PAN_MIDLINE_STANDARD_SERIFED 4 -#define U_PAN_MIDLINE_HIGH_TRIMMED 5 -#define U_PAN_MIDLINE_HIGH_POINTED 6 -#define U_PAN_MIDLINE_HIGH_SERIFED 7 -#define U_PAN_MIDLINE_CONSTANT_TRIMMED 8 -#define U_PAN_MIDLINE_CONSTANT_POINTED 9 -#define U_PAN_MIDLINE_CONSTANT_SERIFED 10 -#define U_PAN_MIDLINE_LOW_TRIMMED 11 -#define U_PAN_MIDLINE_LOW_POINTED 12 -#define U_PAN_MIDLINE_LOW_SERIFED 13 -/** @} */ - -/** \defgroup U_EMRSETLAYOUT_iMode_Qualifiers Mirroring Enumeration - For U_EMRSETLAYOUT iMode field +#define U_PAN_SERIF_COVE 2 //!< Serif cove +#define U_PAN_SERIF_OBTUSE_COVE 3 //!< Serif obtuse cove +#define U_PAN_SERIF_SQUARE_COVE 4 //!< Serif square cove +#define U_PAN_SERIF_OBTUSE_SQUARE_COVE 5 //!< Serif obtuse square cove +#define U_PAN_SERIF_SQUARE 6 //!< Serif square +#define U_PAN_SERIF_THIN 7 //!< Serif thin +#define U_PAN_SERIF_BONE 8 //!< Serif bone +#define U_PAN_SERIF_EXAGGERATED 9 //!< Serif exaggerated +#define U_PAN_SERIF_TRIANGLE 10 //!< Serif triangle +#define U_PAN_SERIF_NORMAL_SANS 11 //!< Serif normal sans +#define U_PAN_SERIF_OBTUSE_SANS 12 //!< Serif obtuse sans +#define U_PAN_SERIF_PERP_SANS 13 //!< Serif perp sans +#define U_PAN_SERIF_FLARED 14 //!< Serif flared +#define U_PAN_SERIF_ROUNDED 15 //!< Serif rounded +/** @} */ + +/** \defgroup U_EMF_EMRSELECTOBJECT_ihObject_Qualifiers EMF StockObject Enumeration + For U_EMRSELECTOBJECT ihObject field. + Microsoft name: StockObject Enumeration + EMF manual 2.1.31 @{ */ -#define U_LAYOUT_LTR 0x00000000 -#define U_LAYOUT_RTL 0x00000001 -#define U_LAYOUT_BITMAPORIENTATIONPRESERVED 0x00000008 -#define U_NOMIRRORBITMAP 0x80000000 -/** @} */ - -/** \defgroup U_EMRMODIFYWORLDTRANSFORM_iMode_Qualifiers ModifyWorldTransformMode Enumeration - For U_EMRMODIFYWORLDTRANSFORM iMode +#define U_STOCK_OBJECT 0x80000000 //!< Stock object +#define U_WHITE_BRUSH 0x80000000 //!< White brush +#define U_LTGRAY_BRUSH 0x80000001 //!< Ltgray brush +#define U_GRAY_BRUSH 0x80000002 //!< Gray brush +#define U_DKGRAY_BRUSH 0x80000003 //!< Dkgray brush +#define U_BLACK_BRUSH 0x80000004 //!< Black brush +#define U_NULL_BRUSH 0x80000005 //!< Null brush +#define U_HOLLOW_BRUSH 0x80000005 //!< Hollow brush +#define U_WHITE_PEN 0x80000006 //!< White pen +#define U_BLACK_PEN 0x80000007 //!< Black pen +#define U_NULL_PEN 0x80000008 //!< Null pen +#define U_OEM_FIXED_FONT 0x8000000A //!< Oem fixed font +#define U_ANSI_FIXED_FONT 0x8000000B //!< Ansi fixed font +#define U_ANSI_VAR_FONT 0x8000000C //!< Ansi var font +#define U_SYSTEM_FONT 0x8000000D //!< System font +#define U_DEVICE_DEFAULT_FONT 0x8000000E //!< Device default font +#define U_DEFAULT_PALETTE 0x8000000F //!< Default palette +#define U_SYSTEM_FIXED_FONT 0x80000010 //!< System fixed font +#define U_DEFAULT_GUI_FONT 0x80000011 //!< Default GUI font +#define U_STOCK_LAST 0x80000011 //!< Stock last +/** @} */ + +/** \defgroup U_EMF_EMRSETSTRETCHBLTMODE_iMode_Qualifiers EMF StretchMode Enumeration + For EMF U_EMRSETSTRETCHBLTMODE iMode field + Microsoft name: StretchMode Enumeration + EMF manual 2.1.32 and footnote 52 on page 297 @{ */ -#define U_MWT_IDENTITY 1 -#define U_MWT_LEFTMULTIPLY 2 -#define U_MWT_RIGHTMULTIPLY 3 -#define U_MWT_MIN U_MWT_IDENTITY -#define U_MWT_MAX U_MWT_RIGHTMULTIPLY +#define U_BLACKONWHITE 1 //!< AND the destination and source pixels. +#define U_WHITEONBLACK 2 //!< OR the destination and source pixels. +#define U_COLORONCOLOR 3 //!< Replace the destination pixels with the source pixels. +#define U_HALFTONE 4 //!< Replace a block of destination pixels with a half-tone representation of the source pixel. +#define U_MAXSTRETCHBLTMODE 4 //!< largest enumeration. +#define U_STRETCH_ANDSCANS 1 //!< AND the destination and source pixels. +#define U_STRETCH_ORSCANS 2 //!< OR the destination and source pixels. +#define U_STRETCH_DELETESCANS 3 //!< Replace the destination pixels with the source pixels. +#define U_STRETCH_HALFTONE 4 //!< Replace a block of destination pixels with a half-tone representation of the source pixel. /** @} */ -/** \defgroup U_PANOSE_common_Qualifiers PanoseCommon Enumeration - Used by all PAN_* enumerations, but only defined once here. - See also U_PAN_ALL1 after the U_PANOSE structure +/** \defgroup U_EMF_PANOSE_bStrokeVariation_Qualifiers EMF StrokeVariation Enumeration + For U_PANOSE bStrokeVariation field + Microsoft name: StrokeVariation Enumeration + EMF manual 2.1.33 @{ */ -#define U_PAN_ANY 0 -#define U_PAN_NO_FIT 1 +#define U_PAN_STROKE_GRADUAL_DIAG 2 //!< Gradual diagonal. +#define U_PAN_STROKE_GRADUAL_TRAN 3 //!< Gradual transitional. +#define U_PAN_STROKE_GRADUAL_VERT 4 //!< Gradual vertical. +#define U_PAN_STROKE_GRADUAL_HORZ 5 //!< Gradual horizontal. +#define U_PAN_STROKE_RAPID_VERT 6 //!< Rapid vertical. +#define U_PAN_STROKE_RAPID_HORZ 7 //!< Rapid horizontal. +#define U_PAN_STROKE_INSTANT_VERT 8 //!< Instant vertical. /** @} */ -/** \defgroup U_PANOSE_index PanoseIndex Enumeration - Fositions of each field in U_PANOSE structure. +/** \defgroup U_EMF_PANOSE_bWeight_Qualifiers EMF Weight Enumeration + For U_PANOSE bWeight field + EMF manual 2.1.34 @{ */ -#define U_PANOSE_COUNT 10 -#define U_PANOSE_FAMILYTYPE_INDEX 0 -#define U_PAN_SERIFSTYLE_INDEX 1 -#define U_PAN_WEIGHT_INDEX 2 -#define U_PAN_PROPORTION_INDEX 3 -#define U_PAN_CONTRAST_INDEX 4 -#define U_PAN_STROKEVARIATION_INDEX 5 -#define U_PAN_ARMSTYLE_INDEX 6 -#define U_PAN_LETTERFORM_INDEX 7 -#define U_PAN_MIDLINE_INDEX 8 -#define U_PAN_XHEIGHT_INDEX 9 +#define U_PAN_WEIGHT_VERY_LIGHT 2 //!< Very light +#define U_PAN_WEIGHT_LIGHT 3 //!< Light +#define U_PAN_WEIGHT_THIN 4 //!< Thin +#define U_PAN_WEIGHT_BOOK 5 //!< Book +#define U_PAN_WEIGHT_MEDIUM 6 //!< Medium +#define U_PAN_WEIGHT_DEMI 7 //!< Demi +#define U_PAN_WEIGHT_BOLD 8 //!< Bold +#define U_PAN_WEIGHT_HEAVY 9 //!< Heavy +#define U_PAN_WEIGHT_BLACK 10 //!< Black +#define U_PAN_WEIGHT_NORD 11 //!< Nord /** @} */ -/** \defgroup U_*LOGPEN_elpPenStyle_Qualifiers PenStyle Enumeration - For U_LOGPEN lopnStyle and U_EXTLOGPEN elpPenStyle fields +/** \defgroup U_EMF_PANOSE_bXHeight_Qualifiers EMF XHeight Enumeration + For U_PANOSE bXHeight field + EMF manual 2.1.35 @{ */ -#define U_PS_SOLID 0x00000000 -#define U_PS_DASH 0x00000001 //!< This only works when NO other U_PS is set. Line width is minimum no matter what pen is set to. -#define U_PS_DOT 0x00000002 //!< This only works when NO other U_PS is set. Line width is minimum no matter what pen is set to. -#define U_PS_DASHDOT 0x00000003 //!< This only works when NO other U_PS is set. Line width is minimum no matter what pen is set to. -#define U_PS_DASHDOTDOT 0x00000004 //!< This only works when NO other U_PS is set. Line width is minimum no matter what pen is set to. -#define U_PS_NULL 0x00000005 -#define U_PS_INSIDEFRAME 0x00000006 -#define U_PS_USERSTYLE 0x00000007 -#define U_PS_ALTERNATE 0x00000008 -#define U_PS_STYLE_MASK 0x0000000f - -#define U_PS_ENDCAP_ROUND 0x00000000 //!< These are only with U_PS_GEOMETRIC -#define U_PS_ENDCAP_SQUARE 0x00000100 -#define U_PS_ENDCAP_FLAT 0x00000200 -#define U_PS_ENDCAP_MASK 0x00000f00 - -#define U_PS_JOIN_ROUND 0x00000000 //!< These are only with U_PS_GEOMETRIC -#define U_PS_JOIN_BEVEL 0x00001000 -#define U_PS_JOIN_MITER 0x00002000 -#define U_PS_JOIN_MASK 0x0000f000 - -#define U_PS_COSMETIC 0x00000000 //!< width may only be 1 pixel. (If set higher it is still drawn as 1). -#define U_PS_GEOMETRIC 0x00010000 //!< width may be >1 pixel, but style may only be U_PS_SOLID or U_PS_NULL. -#define U_PS_TYPE_MASK 0x000f0000 +#define U_PAN_XHEIGHT_CONSTANT_SMALL 2 //!< Constant small +#define U_PAN_XHEIGHT_CONSTANT_STANDARD 3 //!< Constant standard +#define U_PAN_XHEIGHT_CONSTANT_LARGE 4 //!< Constant large +#define U_PAN_XHEIGHT_DUCKING_SMALL 5 //!< Ducking small +#define U_PAN_XHEIGHT_DUCKING_STANDARD 6 //!< Ducking standard +#define U_PAN_XHEIGHT_DUCKING_LARGE 7 //!< Ducking large /** @} */ -/** \defgroup U_PIXELFORMATDESCRIPTOR_dwFlags_Qualifiers PFD_dwFlags Enumeration - For U_PIXELFORMATDESCRIPTOR dwFlags field +/** \defgroup U_EMF_LOGFONT_lfWeight_Qualifiers EMF LF_Weight Enumeration + For U_LOGFONT lfWeight field + EMF manual 2.2.13, footnote 61 (on page 297) @{ */ -#define U_PFD_DOUBLEBUFFER 0x00000001 -#define U_PFD_STEREO 0x00000002 -#define U_PFD_DRAW_TO_WINDOW 0x00000004 -#define U_PFD_DRAW_TO_BITMAP 0x00000008 -#define U_PFD_SUPPORT_GDI 0x00000010 -#define U_PFD_SUPPORT_OPENGL 0x00000020 -#define U_PFD_GENERIC_FORMAT 0x00000040 -#define U_PFD_NEED_PALETTE 0x00000080 -#define U_PFD_NEED_SYSTEM_PALETTE 0x00000100 -#define U_PFD_SWAP_EXCHANGE 0x00000200 -#define U_PFD_SWAP_COPY 0x00000400 -#define U_PFD_SWAP_LAYER_BUFFERS 0x00000800 -#define U_PFD_GENERIC_ACCELERATED 0x00001000 -/** @} */ - -/** \defgroup U_PIXELFORMATDESCRIPTOR_iLayerType_Qualifiers PFD_iLayerType Enumeration - For U_PIXELFORMATDESCRIPTOR iLayerType field +#define U_FW_DONTCARE 0 //!< Don't care +#define U_FW_THIN 100 //!< Thin +#define U_FW_EXTRALIGHT 200 //!< Extra light +#define U_FW_ULTRALIGHT 200 //!< Ultra light +#define U_FW_LIGHT 300 //!< Light +#define U_FW_NORMAL 400 //!< Normal +#define U_FW_REGULAR 400 //!< Regular +#define U_FW_MEDIUM 500 //!< Medium +#define U_FW_SEMIBOLD 600 //!< Semibold +#define U_FW_DEMIBOLD 600 //!< Demibold +#define U_FW_BOLD 700 //!< Bold +#define U_FW_EXTRABOLD 800 //!< Extrabold +#define U_FW_ULTRABOLD 800 //!< Ultrabold +#define U_FW_HEAVY 900 //!< Heavy +#define U_FW_BLACK 900 //!< Black +/** @} */ + +/** \defgroup U_EMF_LOGFONT_lfItalic_Qualifiers EMF LF_Italic Enumeration + For U_LOGFONT lfItalic field + Microsoft name: LF_Italic Enumeration + EMF manual 2.2.13 @{ */ -#define U_PFD_MAIN_PLANE 0 -#define U_PFD_OVERLAY_PLANE 1 -#define U_PFD_UNDERLAY_PLANE (-1) +#define U_FW_NOITALIC 0 //!< Do not use italics. +#define U_FW_ITALIC 1 //!< Use italics. /** @} */ -/** \defgroup U_PIXELFORMATDESCRIPTOR_iPixelType_Qualifiers PFD_iPixelType Enumeration - For U_PIXELFORMATDESCRIPTOR iPixelType field +/** \defgroup U_EMF_LOGFONT_lfunderline_Qualifiers EMF LF_Underline Enumeration + For U_LOGFONT lfunderline field + Microsoft name: LF_Underline Enumeration + EMF manual 2.2.13 @{ */ -#define U_PFD_TYPE_RGBA 0 -#define U_PFD_TYPE_COLORINDEX 1 +#define U_FW_NOUNDERLINE 0 //!< Do not use underline. +#define U_FW_UNDERLINE 1 //!< Use underline. /** @} */ -/** \defgroup U_EMRPOLY_iMode_Qualifiers Point Enumeration - For U_EMRPOLYDRAW and U_EMRPOLAYDRAW16 abTypes fields. - @{ +/** \defgroup U_EMF_LOGFONT_lfStrikeOut_Qualifiers EMF LF_StrikeOut Enumeration + For U_LOGFONT lfStrikeOut field + EMF manual 2.2.13 + @{ */ -#define U_PT_CLOSEFIGURE 0x0001 -#define U_PT_LINETO 0x0002 -#define U_PT_BEZIERTO 0x0004 -#define U_PT_MOVETO 0x0006 +#define U_FW_NOSTRIKEOUT 0 //!< Do not use strikeout. +#define U_FW_STRIKEOUT 1 //!< Use strikeout. /** @} */ -/** \defgroup U_EMRSETPOLYFILLMODE_iMode_Qualifiers PolygonFillMode Enumeration - For U_EMRSETPOLYFILLMODE iMode field +/** \defgroup U_EMF_LOGFONT_lfCharSet_Qualifiers EMF LF_CharSet Enumeration + For U_LOGFONT lfCharSet field + EMF manual 2.2.13 & WMF manual 2.1.15 @{ */ -#define U_ALTERNATE 1 -#define U_WINDING 2 -#define U_POLYFILL_LAST 2 -/** @} */ - -/** \defgroup U_BITMAPV5HEADER_bV5CSType_Qualifiers Profile Enumeration - For U_BITMAPV5HEADER bV5CSType field +#define U_ANSI_CHARSET (uint8_t)0 //!< CP1252, ansi-0, iso8859-{1,15} +#define U_DEFAULT_CHARSET (uint8_t)1 //!< Default character set. +#define U_SYMBOL_CHARSET (uint8_t)2 //!< Symbol character set. +#define U_SHIFTJIS_CHARSET (uint8_t)128 //!< CP932 +#define U_HANGEUL_CHARSET (uint8_t)129 //!< CP949, ksc5601.1987-0 +#define U_HANGUL_CHARSET U_HANGEUL_CHARSET //!< CP949, ksc5601.1987-0 +#define U_GB2312_CHARSET (uint8_t)134 //!< CP936, gb2312.1980-0 +#define U_CHINESEBIG5_CHARSET (uint8_t)136 //!< CP950, big5.et-0 +#define U_GREEK_CHARSET (uint8_t)161 //!< CP1253 +#define U_TURKISH_CHARSET (uint8_t)162 //!< CP1254, -iso8859-9 +#define U_HEBREW_CHARSET (uint8_t)177 //!< CP1255, -iso8859-8 +#define U_ARABIC_CHARSET (uint8_t)178 //!< CP1256, -iso8859-6 +#define U_BALTIC_CHARSET (uint8_t)186 //!< CP1257, -iso8859-13 +#define U_RUSSIAN_CHARSET (uint8_t)204 //!< CP1251, -iso8859-5 +#define U_EE_CHARSET (uint8_t)238 //!< CP1250, -iso8859-2 +#define U_EASTEUROPE_CHARSET U_EE_CHARSET //!< CP1250, -iso8859-2 +#define U_THAI_CHARSET (uint8_t)222 //!< CP874, iso8859-11, tis620 +#define U_JOHAB_CHARSET (uint8_t)130 //!< korean (johab) CP1361 +#define U_MAC_CHARSET (uint8_t)77 //!< Macintosh character set. +#define U_OEM_CHARSET (uint8_t)255 //!< OEM character set. +#define U_VISCII_CHARSET (uint8_t)240 //!< viscii1.1-1 +#define U_TCVN_CHARSET (uint8_t)241 //!< tcvn-0 +#define U_KOI8_CHARSET (uint8_t)242 //!< koi8-{r,u,ru} +#define U_ISO3_CHARSET (uint8_t)243 //!< iso8859-3 +#define U_ISO4_CHARSET (uint8_t)244 //!< iso8859-4 +#define U_ISO10_CHARSET (uint8_t)245 //!< iso8859-10 +#define U_CELTIC_CHARSET (uint8_t)246 //!< iso8859-14 +/** @} */ + +/** \defgroup U_EMF_LOGFONT_lfOutPrecision_Qualifiers EMF LF_OutPrecision Enumeration + For U_LOGFONT lfOutPrecision field + EMF manual 2.2.13 & WMF manual 2.1.1.21 @{ */ -#define U_PROFILE_LINKED 'LINK' -#define U_PROFILE_EMBEDDED 'MBED' +#define U_OUT_DEFAULT_PRECIS 0 //!< Default precision +#define U_OUT_STRING_PRECIS 1 //!< String precision +#define U_OUT_CHARACTER_PRECIS 2 //!< Character precision +#define U_OUT_STROKE_PRECIS 3 //!< Stroke precision +#define U_OUT_TT_PRECIS 4 //!< Tt precision +#define U_OUT_DEVICE_PRECIS 5 //!< Device precision +#define U_OUT_RASTER_PRECIS 6 //!< Raster precision +#define U_OUT_TT_ONLY_PRECIS 7 //!< Tt_only precision +#define U_OUT_OUTLINE_PRECIS 8 //!< Outline precision /** @} */ -/** \defgroup U_PANOSE_bProportion_Qualifiers Proportion Enumeration - For U_PANOSE bProportion field +/** \defgroup U_EMF_LOGFONT_lfClipPrecision_Qualifiers EMF LF_ClipPrecision Enumeration + For U_LOGFONT lfClipPrecision field + EMF manual 2.2.13 & WMF manual 2.1.2.1 @{ */ -#define U_PAN_PROP_OLD_STYLE 2 -#define U_PAN_PROP_MODERN 3 -#define U_PAN_PROP_EVEN_WIDTH 4 -#define U_PAN_PROP_EXPANDED 5 -#define U_PAN_PROP_CONDENSED 6 -#define U_PAN_PROP_VERY_EXPANDED 7 -#define U_PAN_PROP_VERY_CONDENSED 8 -#define U_PAN_PROP_MONOSPACED 9 +#define U_CLIP_DEFAULT_PRECIS 0x00 //!< Use default clipping precision. +#define U_CLIP_CHARACTER_PRECIS 0x01 //!< Use character clipping precision +#define U_CLIP_STROKE_PRECIS 0x02 //!< (Source documentation is vague about what this means.) +#define U_CLIP_MASK 0x0F //!< MASK for bits in preceding. +#define U_CLIP_LH_ANGLES 0x10 //!< Set: font rotation by coordinate system, Clear: device fonts (only) rotate counterclockwise. +#define U_CLIP_TT_ALWAYS 0x20 //!< Reserved. +#define U_CLIP_EMBEDDED 0x80 //!< Font embedding is required. (Method for doing so is not documented in EMF or WMF.) /** @} */ -/** \defgroup U_EMR_dwROP_Qualifiers Ternary Raster Operation enumeration - For U_EMR* dwROP fields. - - These codes specify: - 1. an order of operands (composed of various orders and combinations of: Dest, Src, Pen) - (There are 3, hence "Ternary Raster Operation") - 2. an order of operators to apply to the operands (composed of Not, Xor, Or, And) - Only a few of the more common operations are provided here. - When the Operation does not use a Src operand the corresponding source bitmap may be - omitted from the record. - - For more details see: - http://wiki.winehq.org/TernaryRasterOps +/** \defgroup U_EMF_LOGFONT_lfQuality_Qualifiers EMF LF_Quality Enumeration + For For U_LOGFONT lfQuality field + EMF manual 2.2.13 & WMF manual 2.1.1.10 @{ */ -#define U_SRCCOPY 0xcc0020 -#define U_SRCPAINT 0xee0086 -#define U_SRCAND 0x8800c6 -#define U_SRCINVERT 0x660046 -#define U_SRCERASE 0x440328 -#define U_NOTSRCCOPY 0x330008 -#define U_NOTSRCERASE 0x1100a6 -#define U_MERGECOPY 0xc000ca -#define U_MERGEPAINT 0xbb0226 -#define U_PATCOPY 0xf00021 -#define U_PATPAINT 0xfb0a09 -#define U_PATINVERT 0x5a0049 -#define U_DSTINVERT 0x550009 -#define U_BLACKNESS 0x000042 -#define U_WHITENESS 0xff0062 -#define U_NOOP 0xaa0029 /* Many GDI programs end with a bitblt with this ROP == "D". Seems to work like flush() */ -/** @} */ - -/** \defgroup U_EMRSETROP2_iMode_Qualifiers Binary Raster Operation Enumeration - For U_EMRSETROP2 iMode field - - These codes specify: - 1. an order of operands (composed of various orders and combinations of: Dest, Pen) - (There are 2, hence "Binary Raster Operation") - 2. an order of operators to apply to the operands (composed of Not, Xor, Or, And) - Only a few of the more common operations are provided here. +#define U_DEFAULT_QUALITY 0 //!< Default quality +#define U_DRAFT_QUALITY 1 //!< Draft quality +#define U_PROOF_QUALITY 2 //!< Proof quality +#define U_NONANTIALIASED_QUALITY 3 //!< Nonantialiased quality +#define U_ANTIALIASED_QUALITY 4 //!< Antialiased quality +/** @} */ - The default is U_R2_COPYPEN. If this value is changed to something else all subsequenty - draw operations will use the altered logic. For instance, if it is set to U_R2_BLACK and - a red rectangle is drawn it will appear as a black rectangle. - - @{ -*/ -#define U_R2_BLACK 1 -#define U_R2_NOTMERGEPEN 2 -#define U_R2_MASKNOTPEN 3 -#define U_R2_NOTCOPYPEN 4 -#define U_R2_MASKPENNOT 5 -#define U_R2_NOT 6 -#define U_R2_XORPEN 7 -#define U_R2_NOTMASKPEN 8 -#define U_R2_MASKPEN 9 -#define U_R2_NOTXORPEN 10 -#define U_R2_NOP 11 -#define U_R2_MERGENOTPEN 12 -#define U_R2_COPYPEN 13 -#define U_R2_MERGEPENNOT 14 -#define U_R2_MERGEPEN 15 -#define U_R2_WHITE 16 -#define U_R2_LAST 16 -/** @} */ - -/** \defgroup U_EMRSELECTCLIP_iMode_Qualifiers RegionMode Enumeration - For U_EMRSELECTCLIPPATH and U_EMREXTSELECTCLIPRGN iMode field +/** \defgroup U_EMF_LOGFONT_lfPitchAndFamily_Qualifiers EMF LF_PitchAndFamily Enumeration + For U_LOGFONT lfPitchAndFamily field + EMF manual 2.2.13 & WMF manual 2.2.2.14 @{ */ -#define U_RGN_AND 1 -#define U_RGN_OR 2 -#define U_RGN_XOR 3 -#define U_RGN_DIFF 4 -#define U_RGN_COPY 5 -#define U_RGN_MIN U_RGN_AND -#define U_RGN_MAX U_RGN_COPY +#define U_DEFAULT_PITCH 0x00 //!< Default pitch +#define U_FIXED_PITCH 0x01 //!< Fixed pitch +#define U_VARIABLE_PITCH 0x02 //!< Variable pitch +#define U_MONO_FONT 0x08 //!< Mono font +#define U_FF_DONTCARE 0x00 //!< Font family don't care +#define U_FF_ROMAN 0x10 //!< Font family Roman +#define U_FF_SWISS 0x20 //!< Font family Swiss +#define U_FF_MODERN 0x30 //!< Font family Modern +#define U_FF_SCRIPT 0x40 //!< Font family Script +#define U_FF_DECORATIVE 0x50 //!< Font family Decorative /** @} */ -/** \defgroup U_PANOSE_bSerifStyle_Qualifiers SerifType Enumeration - For U_PANOSE bSerifStyle field - @{ -*/ -#define U_PAN_SERIF_COVE 2 -#define U_PAN_SERIF_OBTUSE_COVE 3 -#define U_PAN_SERIF_SQUARE_COVE 4 -#define U_PAN_SERIF_OBTUSE_SQUARE_COVE 5 -#define U_PAN_SERIF_SQUARE 6 -#define U_PAN_SERIF_THIN 7 -#define U_PAN_SERIF_BONE 8 -#define U_PAN_SERIF_EXAGGERATED 9 -#define U_PAN_SERIF_TRIANGLE 10 -#define U_PAN_SERIF_NORMAL_SANS 11 -#define U_PAN_SERIF_OBTUSE_SANS 12 -#define U_PAN_SERIF_PERP_SANS 13 -#define U_PAN_SERIF_FLARED 14 -#define U_PAN_SERIF_ROUNDED 15 -/** @} */ - -/** \defgroup U_EMRSELECTOBJECT_ihObject_Qualifiers StockObject Enumeration - For U_EMRSELECTOBJECT ihObject field. - @{ -*/ -#define U_STOCK_OBJECT 0x80000000 -#define U_WHITE_BRUSH 0x80000000 -#define U_LTGRAY_BRUSH 0x80000001 -#define U_GRAY_BRUSH 0x80000002 -#define U_DKGRAY_BRUSH 0x80000003 -#define U_BLACK_BRUSH 0x80000004 -#define U_NULL_BRUSH 0x80000005 -#define U_HOLLOW_BRUSH 0x80000005 -#define U_WHITE_PEN 0x80000006 -#define U_BLACK_PEN 0x80000007 -#define U_NULL_PEN 0x80000008 -#define U_OEM_FIXED_FONT 0x8000000A -#define U_ANSI_FIXED_FONT 0x8000000B -#define U_ANSI_VAR_FONT 0x8000000C -#define U_SYSTEM_FONT 0x8000000D -#define U_DEVICE_DEFAULT_FONT 0x8000000E -#define U_DEFAULT_PALETTE 0x8000000F -#define U_SYSTEM_FIXED_FONT 0x80000010 -#define U_DEFAULT_GUI_FONT 0x80000011 -#define U_STOCK_LAST 0x80000011 -/** @} */ - -/** \defgroup U_EMRSETSTRETCHBLTMODE_iMode_Qualifiers StretchMode Enumeration - For EMF U_EMRSETSTRETCHBLTMODE iMode field +/** \defgroup U_EMF_LOGBRUSH_lbStyle_Qualifiers EMF LB_Style Enumeration + For U_LOGBRUSH lbStyle field + EMF manual 2.2.20 @{ */ -#define U_BLACKONWHITE 1 -#define U_WHITEONBLACK 2 -#define U_COLORONCOLOR 3 -#define U_HALFTONE 4 -#define U_MAXSTRETCHBLTMODE 4 -#define U_STRETCH_ANDSCANS 1 -#define U_STRETCH_ORSCANS 2 -#define U_STRETCH_DELETESCANS 3 -#define U_STRETCH_HALFTONE 4 +#define U_BS_SOLID 0 //!< Solid brush. +#define U_BS_NULL 1 //!< Null brush. +#define U_BS_HOLLOW 1 //!< Hollow brush. +#define U_BS_HATCHED 2 //!< Hatched brush. +#define U_BS_PATTERN 3 //!< Pattern brush. +#define U_BS_INDEXED 4 //!< Indexed brush. +#define U_BS_DIBPATTERN 5 //!< Dibpattern brush. +#define U_BS_DIBPATTERNPT 6 //!< Dibpatternpt brush. +#define U_BS_PATTERN8X8 7 //!< Pattern 8x8 brush. +#define U_BS_DIBPATTERN8X8 8 //!< Dibpattern 8x8 brush. +#define U_BS_MONOPATTERN 9 //!< Monopattern brush. /** @} */ -/** \defgroup U_PANOSE_bStrokeVariation_Qualifiers StrokeVariation Enumeration - For U_PANOSE bStrokeVariation field +/** \defgroup U_EMF_PANOSE_index EMF PanoseIndex Enumeration + Fositions of each field in U_PANOSE structure. + Microsoft name: (none) + EMF manual 2.2.21 @{ */ -#define U_PAN_STROKE_GRADUAL_DIAG 2 -#define U_PAN_STROKE_GRADUAL_TRAN 3 -#define U_PAN_STROKE_GRADUAL_VERT 4 -#define U_PAN_STROKE_GRADUAL_HORZ 5 -#define U_PAN_STROKE_RAPID_VERT 6 -#define U_PAN_STROKE_RAPID_HORZ 7 -#define U_PAN_STROKE_INSTANT_VERT 8 +#define U_PAN_FAMILYTYPE_INDEX 0 //!< Familytype index +#define U_PAN_SERIFSTYLE_INDEX 1 //!< Serifstyle index +#define U_PAN_WEIGHT_INDEX 2 //!< Weight index +#define U_PAN_PROPORTION_INDEX 3 //!< Proportion index +#define U_PAN_CONTRAST_INDEX 4 //!< Contrast index +#define U_PAN_STROKEVARIATION_INDEX 5 //!< Strokevariation index +#define U_PAN_ARMSTYLE_INDEX 6 //!< Armstyle index +#define U_PAN_LETTERFORM_INDEX 7 //!< Letterform index +#define U_PAN_MIDLINE_INDEX 8 //!< Midline index +#define U_PAN_XHEIGHT_INDEX 9 //!< Xheight index +#define U_PAN_COUNT 10 //!< Count /** @} */ -/** \defgroup U_EMRSETTEXTALIGN_iMode_Qualifiers TextAlignment Enumeration - For U_EMRSETTEXTALIGN iMode field - - Recall that EMF coordinates have UL closest to {0,0}, LR is below and to the right of UL and so has LARGER - {x,y} coordinates. In the following "TOP" is on the horizontal line defined by LR, as it has larger y coordinates, - which when viewing the EMF file, would actually be on the BOTTOM of the bounding rectangle. Similarly, left and right - are reversed. - - Microsoft documentation (WMF manual, section 2.1.2.3) says that the text starts on certain edges of the bounding rectangle. - That is apparently not true, whether the bounding rectangle is {0,0,-1,-1}, which is effectively no bounding rectangle, - or if a valid bounding rectangle is specified. In all cases the text (in Windows XP Preview) starts, has center at, or ends - at the center point. Vertical offsets seem to be defined analogously, but with respect to the height of the font. The bounding - rectangle defined for the U_EMRTEXT record appears to be ignored. - - Microsoft documentation (EMF manual,section 2.2.5) says that the same rectangle is used for "clipping or opaquing" by ExtTextOutA/W. - That does not seem to occur either. +/** \defgroup U_EMF_PIXELFORMATDESCRIPTOR_iLayerType_Qualifiers EMF PFD_iLayerType Enumeration + For U_PIXELFORMATDESCRIPTOR iLayerType field + Microsoft name: (none) + EMF manual 2.2.22 @{ */ -// Horizontal text flags -#define U_TA_DEFAULT 0x00 // default alignment -#define U_TA_NOUPDATECP 0x00 // Reference point does not move -#define U_TA_UPDATECP 0x01 // Reference point moves to end of next text drawn. -#define U_TA_LEFT 0x00 // Reference point is on left edge of bounding rectangle -#define U_TA_RIGHT 0x02 // Reference point is on right edge of bounding rectangle -#define U_TA_CENTER 0x06 // Reference point is on center vertical line of bounding rectangle -#define U_TA_TOP 0x00 // Reference point is on top edge of bounding rectangle -#define U_TA_BOTTOM 0x08 // Reference point is on bottom edge of bounding rectangle -#define U_TA_BASEBIT 0x10 // Reference point is on baseline of text if this bit is set, for 0x10 <-> 0x18 -#define U_TA_BASELINE 0x18 // Reference point is on baseline of text -#define U_TA_RTLREADING 0x100 // Set for Right to Left languages like Hebrew and Arabic -#define U_TA_MASK U_TA_BASELINE+U_TA_CENTER+U_TA_UPDATECP+U_TA_RTLREADING -// Vertical text flags -#define U_VTA_BASELINE U_TA_BASELINE // for vertical text -#define U_VTA_LEFT U_TA_BOTTOM -#define U_VTA_RIGHT U_TA_TOP -#define U_VTA_CENTER U_TA_CENTER -#define U_VTA_BOTTOM U_TA_RIGHT -#define U_VTA_TOP U_TA_LEFT +#define U_PFD_MAIN_PLANE 0 //!< Main plane +#define U_PFD_OVERLAY_PLANE 1 //!< Overlay plane +#define U_PFD_UNDERLAY_PLANE (-1) //!< Underlay plane /** @} */ -/** \defgroup U_PANOSE_bWeight_Qualifiers Weight Enumeration - For U_PANOSE bWeight field +/** \defgroup U_EMF_PIXELFORMATDESCRIPTOR_iPixelType_Qualifiers EMF PFD_iPixelType Enumeration + For U_PIXELFORMATDESCRIPTOR iPixelType field + Microsoft name: (none) + EMF manual 2.2.22 @{ */ -#define U_PAN_WEIGHT_VERY_LIGHT 2 -#define U_PAN_WEIGHT_LIGHT 3 -#define U_PAN_WEIGHT_THIN 4 -#define U_PAN_WEIGHT_BOOK 5 -#define U_PAN_WEIGHT_MEDIUM 6 -#define U_PAN_WEIGHT_DEMI 7 -#define U_PAN_WEIGHT_BOLD 8 -#define U_PAN_WEIGHT_HEAVY 9 -#define U_PAN_WEIGHT_BLACK 10 -#define U_PAN_WEIGHT_NORD 11 +#define U_PFD_TYPE_RGBA 0 //!< Pixel contains an RGBA value. +#define U_PFD_TYPE_COLORINDEX 1 //!< Pixel contains an index into the color table. /** @} */ -/** \defgroup U_PANOSE_bXHeight_Qualifiers XHeight Enumeration - For U_PANOSE bXHeight field +/** \defgroup U_EMF_PIXELFORMATDESCRIPTOR_dwFlags_Qualifiers EMF PFD_dwFlags Enumeration + For U_PIXELFORMATDESCRIPTOR dwFlags field + EMF manual 2.2.22 + @{ +*/ +#define U_PFD_DOUBLEBUFFER 0x00000001 //!< Doublebuffer +#define U_PFD_STEREO 0x00000002 //!< Stereo +#define U_PFD_DRAW_TO_WINDOW 0x00000004 //!< Draw to window +#define U_PFD_DRAW_TO_BITMAP 0x00000008 //!< Draw to bitmap +#define U_PFD_SUPPORT_GDI 0x00000010 //!< Support gdi +#define U_PFD_SUPPORT_OPENGL 0x00000020 //!< Support opengl +#define U_PFD_GENERIC_FORMAT 0x00000040 //!< Generic format +#define U_PFD_NEED_PALETTE 0x00000080 //!< Need palette +#define U_PFD_NEED_SYSTEM_PALETTE 0x00000100 //!< Need system palette +#define U_PFD_SWAP_EXCHANGE 0x00000200 //!< Swap exchange +#define U_PFD_SWAP_COPY 0x00000400 //!< Swap copy +#define U_PFD_SWAP_LAYER_BUFFERS 0x00000800 //!< Swap layer buffers +#define U_PFD_GENERIC_ACCELERATED 0x00001000 //!< Generic accelerated +/** @} */ + +/** \defgroup U_EMF_EMRCOMMENT_TYPES EMF Comment record types + For U_EMRCOMMENT_* cIdent fields + EMF manual 2.3.3 @{ */ -#define U_PAN_XHEIGHT_CONSTANT_SMALL 2 -#define U_PAN_XHEIGHT_CONSTANT_STANDARD 3 -#define U_PAN_XHEIGHT_CONSTANT_LARGE 4 -#define U_PAN_XHEIGHT_DUCKING_SMALL 5 -#define U_PAN_XHEIGHT_DUCKING_STANDARD 6 -#define U_PAN_XHEIGHT_DUCKING_LARGE 7 +#define U_EMR_COMMENT_PUBLIC 0x43494447 //!< Public comment. +#define U_EMR_COMMENT_SPOOL 0x00000000 //!< Spool comment. +#define U_EMR_COMMENT_EMFPLUSRECORD 0x2B464D45 //!< EMF+ record comment. /** @} */ -/** \defgroup U_BLEND_Op_Qualifiers Blend Enumeration - For U_BLEND Op field +/** \defgroup U_EMF_EMRSETLAYOUT_iMode_Qualifiers EMF Mirroring Enumeration + For U_EMRSETLAYOUT iMode field + EMF manual 2.3.11.17 @{ */ -#define U_AC_SRC_GLOBAL 0 -#define U_AC_SRC_CONST 0 -#define U_AC_SRC_ALPHA 1 +#define U_LAYOUT_LTR 0x00000000 //!< Left to right lsyout. +#define U_LAYOUT_RTL 0x00000001 //!< Right to left layout. +#define U_LAYOUT_BITMAPORIENTATIONPRESERVED 0x00000008 //!< Do not flip bitmaps if layout is right to left. /** @} */ -// *************************************************************************** -/** \defgroup Miscellaneous_values Miscellaneous Values +/** \defgroup U_EMF_BLEND_Op_Qualifiers EMF Blend Enumeration + For U_BLEND Op field @{ */ -#define U_NONE 0 //!< Generic for nothing selected for all flag fields -#define U_PI 3.14159265358979323846 //!< pi -#define U_READ 1 -#define U_WRITE 0 -#define U_ENHMETA_VERSION 0x00010000 //!< U_EMRHEADER nVersion field -#define U_DV_SGNTR 0x08007664 //!< For U_DESIGNVECTOR Signature field -#define U_LP_VERSION 0x0300 //!< For U_LOGPALETTE palVersion field -#define U_RDH_RECTANGLES 1 //!< For U_RGNDATAHEADER iType field -#define U_RDH_OBJSIZE 0x20 //!< For U_RGNDATAHEADER dwSIze field -#define U_RGB_GAMMA_MIN (uint16_t)02500 //!< For U_COLORADJUSTMENT ca[Red|Green|Blue]Gamma fields -#define U_RGB_GAMMA_MAX (uint16_t)65000 //!< For U_COLORADJUSTMENT ca[Red|Green|Blue]Gamma fields -#define U_REFERENCE_WHITE_MIN (uint16_t)6000 //!< For U_COLORADJUSTMENT caReferenceWhite field -#define U_REFERENCE_WHITE_MAX (uint16_t)10000 //!< For U_COLORADJUSTMENT caReferenceWhite field -#define U_REFERENCE_BLACK_MIN (uint16_t)0 //!< For U_COLORADJUSTMENT caReferenceBlack field -#define U_REFERENCE_BLACK_MAX (uint16_t)4000 //!< For U_COLORADJUSTMENT caReferenceBlack field -#define U_COLOR_ADJ_MIN ((int16_t)-100) //!< For U_COLORADJUSTMENT ca[Contrast|Brightness|Colorfulness|RedGreenTint] fields -#define U_COLOR_ADJ_MAX (int16_t) 100 //!< For U_COLORADJUSTMENT ca[Contrast|Brightness|Colorfulness|RedGreenTint] fields -#define U_MAX_PATH 1024 //!< longest path name for a file -#define U_LCS_SIGNATURE 0x50534F43 //!< logColorSpace Signature -#define U_LCS_VERSION 0x400 //!< logColorSpace Version -#define U_REC_FREE 1 //!< used with emf_append -#define U_REC_KEEP 0 //!< used with emf_append -/** Solaris 8 has problems with round/roundf, just use this everywhere */ -#define U_ROUND(A) ( (A) > 0 ? floor((A)+0.5) : ( (A) < 0 ? -floor(-(A)+0.5) : (A) ) ) - +#define U_AC_SRC_GLOBAL 0 //!< Global +#define U_AC_SRC_CONST 0 //!< Const +#define U_AC_SRC_ALPHA 1 //!< Alpha /** @} */ + // *************************************************************************** // Macros -/** \defgroup Common_macros Common Macros +/** \defgroup U_EMF_Common_macros EMF Common Macros @{ */ -// Color U_BGR(A), byte order lo to hi: {B,G,R,A} corresponding to U_RGBQUAD. Set/Get Macros. +// Note, many of these were originally defined using C99 (type){val,val,val} format, but that turned out to +// have incompatibilities with C++, so use functions as the basis to avoid this. + +// Set/Get for U_RGBQUAD Colors, which are stored in byte order: {B,G,R,A}. // These are used in EMF structures and the byte order must be the same in memory or on disk. -#define U_BGR(r,g,b) (U_RGBQUAD){b,g,r,0} //!< Set any BGR color with an {r,g,b} triplet -#define U_BGRA(r,g,b,a) (U_RGBQUAD){b,g,r,a} //!< Set any BGRA color with an {r,g,b,a} quad -#define U_WHITE U_BGR(255,255,255) //!< Set BGR white. -#define U_BLACK U_BGR(0,0,0) //!< Set BGR black. -#define U_BGRAGetR(rgb) (rgb.Red ) //!< Color BGR Get Red Macro. -#define U_BGRAGetG(rgb) (rgb.Green ) //!< Color BGR Get Green Macro. -#define U_BGRAGetB(rgb) (rgb.Blue ) //!< Color BGR Get Blue Macro. -#define U_BGRAGetA(rgb) (rgb.Reserved) //!< Color BGR Get A/reserved Macro. - -#define U_PALETTERGB(r,g,b) U_RGB(r,g,b,0x02)) //!< Set any Palette RGB color. -#define U_PALETTEINDEX(i) ((U_COLORREF)(0x01000000 | (uint16_t)(i)))\ - //!< Get RGB from Palette by index. - -// Color U_RGB(A), byte order lo to hi: {R,G,B,A} corresponding to U_COLORREF. Set/Get Macros. +#define U_BGR(r,g,b) rgbquad_set(r, g, b, 0) //!< Set any BGR color with an {r,g,b} triplet +#define U_BGRA(r,g,b,a) rgbquad_set(r, g, b, a) //!< Set any BGRA color with an {r,g,b,a} quad +#define U_WHITE U_BGR(255,255,255) //!< Set BGR white. +#define U_BLACK U_BGR(0,0,0) //!< Set BGR black. +#define U_BGRAGetR(rgb) (rgb.Red ) //!< Color BGR Red. +#define U_BGRAGetG(rgb) (rgb.Green ) //!< Color BGR Green. +#define U_BGRAGetB(rgb) (rgb.Blue ) //!< Color BGR Blue. +#define U_BGRAGetA(rgb) (rgb.Reserved) //!< Color BGRA A/reserved + + +// Set/Get for U_COLORREF Color, which are stored in byte order:: {R,G,B,A}. // These are used in EMF structures and the byte order must be the same in memory or on disk. -// These MAY be used in PNG and other libraries if these enforce byte order in memory,otherwise +// These MAY be used in PNG and other libraries if these enforce byte order in memory, otherwise // U_swap4 may need to also be employed. +// -/// Set any RGB color with an {r,g,b} triplet -#define U_RGB(r,g,b) (U_COLORREF){(uint8_t)(r), (uint8_t)(g), (uint8_t)(b), 0} -/// Set any RGBA color with an {r,g,b,a} quad -#define U_RGBA(r,g,b,a) (U_COLORREF){(uint8_t)(r), (uint8_t)(g), (uint8_t)(b), (uint8_t)(a)} -#define U_RGBAGetR(rgb) ((U_COLORREF)rgb).Red //!< Color RGB Get Red Macro. -#define U_RGBAGetG(rgb) ((U_COLORREF)rgb).Green //!< Color RGB Get Green Macro. -#define U_RGBAGetB(rgb) ((U_COLORREF)rgb).Blue //!< Color RGB Get Blue Macro. -#define U_RGBAGetA(rgb) ((U_COLORREF)rgb).Reserved //!< Color RGBA Get A/reserved Macro. +#define colorref_set colorref3_set //!< Most frequent usage is 3 colors, so set the unqualified one to that +#define U_RGB(r,g,b) colorref3_set(r, g, b) //!< Set any RGB color with an {r,g,b} triplet +#define U_RGBA(r,g,b,a) colorref4_set(r, g, b, a) //!< Set any RGBA color with an {r,g,b,a} quad +#define U_RGBAGetR(rgb) (rgb.Red ) //!< Color RGB Red. +#define U_RGBAGetG(rgb) (rgb.Green ) //!< Color RGB Green +#define U_RGBAGetB(rgb) (rgb.Blue ) //!< Color RGB Blue +#define U_RGBAGetA(rgb) (rgb.Reserved) //!< Color RGBA A/reserved // color type conversions -#define U_RGB2BGR(rgb) (U_RGBQUAD){ U_RGBAGetB(rgb),U_RGBAGetG(rgb),U_RGBAGetR(rgb),0} //!< Set any BGR color from an RGB color -#define U_BGR2RGB(rgb) (U_COLORREF){U_BGRAGetR(rgb),U_BGRAGetG(rgb),U_BGRAGetB(rgb),0} //!< Set any RGB color from an BGR color -#define U_RGBA2BGRA(rgb) (U_RGBQUAD){ U_RGBAGetB(rgb),U_RGBAGetG(rgb),U_RGBAGetR(rgb),U_RGBAGetA(rgb)} //!< Set any BGRA color from an RGBA color -#define U_BGRA2RGBA(rgb) (U_COLORREF){U_BGRAGetR(rgb),U_BGRAGetG(rgb),U_BGRAGetB(rgb),U_BGRAGetA(rgb)} //!< Set any RGBA color from an BGRA color +#define U_RGB2BGR(rgb) U_BGR(U_RGBAGetR(rgb),U_RGBAGetG(rgb),U_RGBAGetB(rgb)) //!< Set any BGR color from an RGB color +#define U_BGR2RGB(rgb) U_RGB(U_BGRAGetR(rgb),U_BGRAGetG(rgb),U_BGRAGetB(rgb)) //!< Set any RGB color from an BGR color +#define U_RGBA2BGRA(rgb) U_BGRA(U_RGBAGetR(rgb),U_RGBAGetG(rgb),U_RGBAGetB(rgb),U_RGBAGetA(rgb)} //!< Set any BGRA color from an RGBA color +#define U_BGRA2RGBA(rgb) U_RGBA(U_BGRAGetR(rgb),U_BGRAGetG(rgb),U_BGRAGetB(rgb),U_BGRAGetA(rgb)} //!< Set any RGBA color from an BGRA color // Color CMYK Get/Set Macros #define U_CMYK(c,m,y,k)\ @@ -1157,171 +1607,38 @@ extern "C" { /** @} */ -typedef float U_FLOAT; - -typedef uint32_t U_CBBITS; // Describes byte count of TYPE -typedef uint32_t U_CBBITSMSK; -typedef uint32_t U_CBBITSSRC; -typedef uint32_t U_CBBMI; -typedef uint32_t U_CBBMIMSK; -typedef uint32_t U_CBBMISRC; -typedef uint32_t U_CBDATA; -typedef uint32_t U_CBNAME; -typedef uint32_t U_CBPLENTRIES; -typedef uint32_t U_CBPXLFMT; -typedef uint32_t U_CBRGNDATA; -typedef uint32_t U_CBSTR; // bytes in an 8 or 16 bit string - -typedef uint32_t U_OFFBITS; // Describes byte offset to TYPE, always measured from the start of the RECORD (not the struct) -typedef uint32_t U_OFFBITSMSK; -typedef uint32_t U_OFFBITSSRC; -typedef uint32_t U_OFFBMI; -typedef uint32_t U_OFFBMIMSK; -typedef uint32_t U_OFFBMISRC; -typedef uint32_t U_OFFDATA; -typedef uint32_t U_OFFDESC; -typedef uint32_t U_OFFDX; -typedef uint32_t U_OFFPLENTRIES; -typedef uint32_t U_OFFPXLFMT; -typedef uint32_t U_OFFSTR; // String of either 8 or 16 bit characters -typedef uint8_t U_DATA; // any binary sort of data, not otherwise classified. +/** Any generic pair of floats. -// "Types" For array components in structures, where not otherwise defined as a structure -typedef uint32_t U_FNTAXES; // Font Axes For U_DESIGNVECTOR -typedef uint32_t U_STYLEENTRY; // StyleEntry For U_EXTLOGPEN -typedef uint32_t U_POLYCOUNTS; // aPolyCounts For U_EMRPOLYPOLYLINE etc. - -// "Counts" for array components in structures -typedef uint32_t U_NUM_FNTAXES; // Number of U_FNTAXES -typedef uint32_t U_NUM_LOGPLTNTRY; // Number of U_LOGPLTENTRY -typedef uint32_t U_NUM_RECTL; // Number of U_RECTL -typedef uint32_t U_NUM_POINTL; // Number of U_POINTL -typedef uint32_t U_NUM_POINT16; // Number of U_POINT16 -typedef uint32_t U_NUM_STYLEENTRY; // Number of U_STYLEENTRY -typedef uint32_t U_NUM_POLYCOUNTS; // Number of U_POLYCOUNTS -typedef uint32_t U_NUM_EMRTEXT; // Number of U_EMRTEXT -typedef uint32_t U_NUM_STR; // Number of 8 or 16 bit characters in string -typedef uint32_t U_NUM_TRIVERTEX; // Number of U_TRIVERTEX -typedef uint32_t U_NUM_GRADOBJ; // Number of U_GRADIENT4 OR U_GRADIENT3 (determined at run time) -typedef uint32_t U_NUM_RGBQUAD; // Number of U_RGBQUAD (in bmciColors in U_BITMAPCOREINFO) - - -/** - \brief Pair of values indicating x and y sizes. - Microsoft name: SIZE Object - Microsoft name: SIZEL Object -*/ -typedef struct { - int32_t cx; //!< X size - int32_t cy; //!< Y size -} U_SIZE, U_SIZEL, *PU_SIZE, *PU_SIZEL; - -/** - \brief Used for any generic pair of floats Microsoft name: (none) */ typedef struct { - float x; //!< X value - float y; //!< Y value -} U_PAIRF, *PU_PAIRF; - -/** - \brief Used for any generic pair of uint32_t - Microsoft name: POINT Object -*/ -typedef struct { - int32_t x; //!< X value - int32_t y; //!< Y value -} U_PAIR, *PU_PAIR, U_POINT, *PU_POINT, U_POINTL, *PU_POINTL; - -/** - \brief Point type for 16 bit EMR drawing functions. - Microsoft name: POINTS Object - Microsoft name: POINTS16 Object -*/ -typedef struct { - int16_t x; //!< X size (16 bit) - int16_t y; //!< Y size (16 bit) -} U_POINT16, *PU_POINT16; - -/** - \brief Coordinates of the upper left, lower right corner. - Note that the coordinate system is 0,0 in the upper left corner - of the screen an N,M in the lower right corner. - Microsoft name: RECT Object -*/ -typedef struct { - int32_t left; //!< left coordinate - int32_t top; //!< top coordinate - int32_t right; //!< right coordinate - int32_t bottom; //!< bottom coordinate -} U_RECT, *PU_RECT, - U_RECTL, *PU_RECTL; + float x; //!< X value + float y; //!< Y value +} U_PAIRF, + *PU_PAIRF; //!< Any generic pair of floats. Microsoft name: (none) -#define U_RCL_DEF (U_RECTL){0,0,-1,-1} //!< Use this when no bounds are needed. /* ************************************************************ EMF structures OTHER than those corresponding to complete U_EMR_* records ************************************************************ */ -/** - \brief For U_BITMAPINFO bmiColors field - NOTE that the color order is BGR, even though the name is RGB! - Microsoft name: RGBQUAD Object -*/ -typedef struct { - uint8_t Blue; //!< Blue color (0-255) - uint8_t Green; //!< Green color (0-255) - uint8_t Red; //!< Red color (0-255) - uint8_t Reserved; //!< Not used -} U_RGBQUAD, *PU_RGBQUAD; +/** + \brief For U_POINT28_4 x and y fields. -/** - \brief For U_BITMAPINFO crColor field - NOTE that the color order is RGB reserved, flipped around from the preceding. - Microsoft name: COLORREF Object -*/ -typedef struct { - uint8_t Red; //!< Red color (0-255) - uint8_t Green; //!< Green color (0-255) - uint8_t Blue; //!< Blue color (0-255) - uint8_t Reserved; //!< Not used -} U_COLORREF, *PU_COLORREF; - -/** - \brief For U_POINT28_4 x and y fields. - Microsoft name: BitFIX28_4 Object. + EMF manual 2.2.1, Microsoft name: BitFIX28_4 Object. */ typedef struct { signed IntValue :28; //!< Signed integral bit field unsigned FracValue :4; //!< Unsigned integral bit field -} U_BITFIX28_4, *PU_BITFIX28_4; - -/** - \brief For U_LCS_GAMMARGB lcsGamma* fields - Microsoft name:(unknown) Object -*/ -typedef struct { - unsigned ignoreHi :8; //!< not used - unsigned intPart :8; //!< integer part - unsigned fracPart :8; //!< fraction part - unsigned ignoreLo :8; //!< not used -} U_LCS_GAMMA, *PU_LCS_GAMMA; - -/** - \brief For U_LOGCOLORSPACEA and U_LOGCOLORSPACEW lcsGammaRGB field - Microsoft name:(unknown) Object -*/ -typedef struct { - U_LCS_GAMMA lcsGammaRed; //!< Red Gamma - U_LCS_GAMMA lcsGammaGreen; //!< Green Gamma - U_LCS_GAMMA lcsGammaBlue; //!< Blue Gamma -} U_LCS_GAMMARGB, *PU_LCS_GAMMARGB; +} U_BITFIX28_4, + *PU_BITFIX28_4; //!< EMF manual 2.2.1 /** \brief For U_EMRSETOLORADJUSTMENT ColorAdjustment field + + EMF manual 2.2.2, Microsoft name: ColorAdjustment Object + Note, range constants are: RGB_GAMMA_[MIN|MAX],REFERENCE_[WHITE|BLACK]_[MIN|MAX],COLOR_ADJ_[MIN|MAX] - Microsoft name: ColorAdjustment Object */ typedef struct { uint16_t caSize; //!< Size of this structure in bytes @@ -1336,35 +1653,44 @@ typedef struct { int16_t caBrightness; //!< Brightness adjustment (range:-100:100, 0 is no correction) int16_t caColorfulness; //!< Colorfulness adjustment (range:-100:100, 0 is no correction) int16_t caRedGreenTint; //!< Tine adjustment (range:-100:100, 0 is no correction) -} U_COLORADJUSTMENT, *PU_COLORADJUSTMENT; +} U_COLORADJUSTMENT, + *PU_COLORADJUSTMENT; //!< EMF manual 2.2.2 -/** +/** EMF manual 2.2.3 \brief For ? (not implemented yet) + Microsoft name: DesignVector Object */ typedef struct { uint32_t Signature; //!< Must be 0x08007664 (AKA: DV_SGNTR) U_NUM_FNTAXES NumAxes; //!< Number of elements in Values, 0-16 U_FNTAXES Values[1]; //!< Optional. Array of font axes for opentype font -} U_DESIGNVECTOR,*PU_DESIGNVECTOR; +} U_DESIGNVECTOR, + *PU_DESIGNVECTOR; //!< EMF manual 2.2.3 -/** +/** \brief For U_EMR_COMMENT_MULTIFORMATS record, where an array of these is used - Microsoft name: EmrFormat Object + + EMF manual 2.2.4, Microsoft name: EmrFormat Object */ typedef struct { uint32_t signature; //!< FormatSignature Enumeration uint32_t nVersion; //!< Must be 1 if signature is EPS, else ignored U_CBDATA cbData; //!< Data size in bytes U_OFFDATA offData; //!< Offset in bytes to the Data from the start of the RECORD -} U_EMRFORMAT, *PU_EMRFORMAT; +} U_EMRFORMAT, + *PU_EMRFORMAT; //!< EMF manual 2.2.4 + +/** -/** \brief For U_EMR[POLY]EXTTEXTOUT[A|W] emrtext field + + EMF manual 2.2.5, Microsoft name: EmrText Object + Differs from implementation in Mingw and Wine in that the core struct has a fixed size. Optional and movable components must be handled with offsets. - Microsoft name: EmrText Object Following invariant core there may/must be: + U_RECTL rcl; (Optional, absent when fOptions & U_ETO_NO_RECT) grayed/clipping/opaque rectangle U_OFFDX offDx; (required) but position isn't static. Offset in bytes to the character spacing array measured @@ -1375,38 +1701,43 @@ typedef struct { char string (required) String buffer holding nChars (padded to a multiple of 4 bytes in length). uint32_t Dx[1] (required) character spacing, array with one entry per glyph. - */ typedef struct { U_POINTL ptlReference; //!< String start coordinates U_NUM_STR nChars; //!< Number of characters in the string U_OFFSTR offString; //!< Offset in bytes to the string from the start of the RECORD uint32_t fOptions; //!< ExtTextOutOptions Enumeration -} U_EMRTEXT, *PU_EMRTEXT; +} U_EMRTEXT, + *PU_EMRTEXT; //!< EMF manual 2.2.5 -/** +/** \brief For U_EPS_DATA Points field - Microsoft name: Point28_4 Object + + EMF manual 2.2.23, Microsoft name: Point28_4 Object, out of order, needed for 2.2.6 */ typedef struct { U_BITFIX28_4 x; //!< X coordinate U_BITFIX28_4 y; //!< Y coordinate -} U_POINT28_4, *PU_POINT28_4; +} U_POINT28_4, + *PU_POINT28_4; //!< EMF manual 2.2.23 -/** +/** \brief For embedding EPS in EMF via U_EMRFORMAT offData array in U_EMR_COMMENT_MULTIFORMATS - Microsoft name: EpsData Object + + EMF manual 2.2.6, Microsoft name: EpsData Object */ typedef struct { uint32_t sizeData; //!< Size in bytes of this object uint32_t version; //!< Must be 1 U_POINT28_4 Points[3]; //!< Defines parallelogram, UL, UR, LL corners, LR is derived. U_RECTL PostScriptData; //!< Record may include optional clipping/opaque rectangle -} U_EPS_DATA, *PU_EPS_DATA; +} U_EPS_DATA, + *PU_EPS_DATA; //!< EMF manual 2.2.6 -/** +/** \brief For GRADIENT_[TRIANGLE|U_RECT] - Microsoft name: TriVertex Object + + EMF manual 2.2.26, Microsoft name: TriVertex Object, out of order, needed for 2.2.7 */ typedef struct { int32_t x; //!< X coord @@ -1415,48 +1746,59 @@ typedef struct { uint16_t Green; //!< Green component uint16_t Blue; //!< Bule component uint16_t Alpha; //!< Alpha Transparency -} U_TRIVERTEX, *PU_TRIVERTEX; +} U_TRIVERTEX, + *PU_TRIVERTEX; //!< EMF manual 2.2.26 +/** + \brief For U_EMRGRADIENTFILL GradObj field + + EMF manual 2.2.7, Microsoft name: GradientRectangle Object +*/ +typedef struct { + uint32_t UpperLeft; //!< Index of UL corner in an array of U_TRIVERTEX objects + uint32_t LowerRight; //!< Index of LR corner in an array of U_TRIVERTEX objects +} U_GRADIENT4, + *PU_GRADIENT4; //!< EMF manual 2.2.7 /** \brief For U_EMRGRADIENTFILL GradObj field + EMF manual 2.2.8, Microsoft name: GradientTriangle Object + Gradient object notes. The next two structures are used to define the shape with reference to an existing array of points stored in an array of TriVertex objects in the U_EMRGRADIENTFILL record. The tricky part is that these two structures are different sizes. In some implementations (MingW) the array is cast to uint32_t and basically the cast is then ignored. For libUEMF we leave this out of the structure entirely and get to it with offsets. - - Microsoft name: GradientTriangle Object */ typedef struct { uint32_t Vertex1; //!< Index of Vertex1 in an array of U_TRIVERTEX objects uint32_t Vertex2; //!< Index of Vertex2 in an array of U_TRIVERTEX objects uint32_t Vertex3; //!< Index of Vertex3 in an array of U_TRIVERTEX objects -} U_GRADIENT3, *PU_GRADIENT3; +} U_GRADIENT3, + *PU_GRADIENT3; //!< EMF manual 2.2.8 -/** - \brief For U_EMRGRADIENTFILL GradObj field - Microsoft name: GradientRectangle Object -*/ -typedef struct { - uint32_t UpperLeft; //!< Index of UL corner in an array of U_TRIVERTEX objects - uint32_t LowerRight; //!< Index of LR corner in an array of U_TRIVERTEX objects -} U_GRADIENT4, *PU_GRADIENT4; +//Microsoft name: Header object, EMF manual 2.2.9 defined below with record structs +//Microsoft name: HeaderExtension1 object, EMF manual 2.2.10 defined below with record structs +//Microsoft name: HeaderExtension1 object, EMF manual 2.2.11 defined below with record structs /** \brief For U_EMRCREATEBRUSHINDIRECT lb field - Microsoft name: LogBrushEx Object + + EMF manual 2.2.12, Microsoft name: LogBrushEx Object */ typedef struct { //!< In MS documentation this is LogBrushEx Object uint32_t lbStyle; //!< LB_Style Enumeration U_COLORREF lbColor; //!< Brush color uint32_t lbHatch; //!< HatchStyle Enumeration -} U_LOGBRUSH, *PU_LOGBRUSH; -typedef U_LOGBRUSH U_PATTERN, *PU_PATTERN; +} U_LOGBRUSH, + U_PATTERN, //!< EMF manual 2.2.12 + *PU_LOGBRUSH, //!< EMF manual 2.2.12 + *PU_PATTERN; //!< EMF manual 2.2.12 /** \brief For U_LOGFONT_PANOSE elfLogFont field - Microsoft name: LogFont Object + + EMF manual 2.2.13, Microsoft name: LogFont Object */ typedef struct { int32_t lfHeight; //!< Height in Logical units @@ -1473,12 +1815,18 @@ typedef struct { uint8_t lfQuality; //!< LF_Quality Enumeration uint8_t lfPitchAndFamily; //!< LF_PitchAndFamily Enumeration uint16_t lfFaceName[U_LF_FACESIZE]; //!< Name of font. If <U_LF_FACESIZE chars must be null terminated -} U_LOGFONT, *PU_LOGFONT; +} U_LOGFONT, + *PU_LOGFONT; //!< EMF manual 2.2.13 + +// Microsoft name: LogFontEx Object (not implemented) EMF manual 2.2.14 +// Microsoft name: LogFontExDv Object (not implemented) EMF manual 2.2.15 /** \brief For U_LOGFONT_PANOSE elfPanose field - Microsoft name: Panose Object + + EMF manual 2.2.21, Microsoft name: Panose Object */ +// out of order, needed for 2.2.16 typedef struct { uint8_t bFamilyType; //!< FamilyType Enumeration uint8_t bSerifStyle; //!< SerifType Enumeration @@ -1490,17 +1838,16 @@ typedef struct { uint8_t bLetterform; //!< Letterform Enumeration uint8_t bMidline; //!< Midline Enumeration uint8_t bXHeight; //!< XHeight Enumeration -} U_PANOSE, *PU_PANOSE; +} U_PANOSE, + *PU_PANOSE; //!< EMF manual 2.2.21 -#define U_PAN_ALL0 (U_PANOSE){0,0,0,0,0,0,0,0,0,0} // all U_PAN_ANY, have not seen this in an EMF file -#define U_PAN_ALL1 (U_PANOSE){1,1,1,1,1,1,1,1,1,1} // all U_PAN_NO_FIT, this is what createfont() would have made - -// Microsoft name: LogFontEx Object (not implemented) -// Microsoft name: LogFontExDv Object (not implemented) +#define U_PAN_ALL0 (U_PANOSE){0,0,0,0,0,0,0,0,0,0} //!< all U_PAN_ANY, have not seen this in an EMF file +#define U_PAN_ALL1 (U_PANOSE){1,1,1,1,1,1,1,1,1,1} //!< all U_PAN_NO_FIT, this is what createfont() would have made /** \brief For U_EMREXTCREATEFONTINDIRECTW elfw field - Microsoft name: LogFont_Panose Object + + EMF manual 2.2.16, Microsoft name: LogFontPanose Object */ typedef struct { U_LOGFONT elfLogFont; //!< Basic font attributes @@ -1514,44 +1861,57 @@ typedef struct { uint32_t elfCulture; //!< Must be 0, Ignore U_PANOSE elfPanose; //!< Panose Object. If all zero, it is ignored. uint16_t elfPadding; //!< Ignore -} U_LOGFONT_PANOSE, *PU_LOGFONT_PANOSE; +} U_LOGFONT_PANOSE, + *PU_LOGFONT_PANOSE; //!< EMF manual 2.2.16 /** \brief For U_LOGPALETTE palPalEntry field(s) - Microsoft name: LogPaletteEntry Object + + EMF manual 2.2.18, Microsoft name: LogPaletteEntry Object */ +// out of order, needed for 2.2.17 typedef struct { uint8_t peReserved; //!< Ignore uint8_t peRed; //!< Palette entry Red Intensity uint8_t peGreen; //!< Palette entry Green Intensity uint8_t peBlue; //!< Palette entry Blue Intensity -} U_LOGPLTNTRY, *PU_LOGPLTNTRY; +} U_LOGPLTNTRY, + *PU_LOGPLTNTRY; //!< EMF manual 2.2.18 /** \brief For U_EMRCREATEPALETTE lgpl field - Microsoft name: LogPalette Object + + EMF manual 2.2.17, Microsoft name: LogPalette Object + */ typedef struct { uint16_t palVersion; //!< Must be 0x0300 (AKA: U_LP_VERSION) uint16_t palNumEntries; //!< Number of U_LOGPLTNTRY objects U_LOGPLTNTRY palPalEntry[1]; //!< PC_Entry Enumeration -} U_LOGPALETTE, *PU_LOGPALETTE; +} U_LOGPALETTE, + *PU_LOGPALETTE; //!< EMF manual 2.2.17 + +// Microsoft name: LogPaletteEntry Object, EMF manual 2.2.18, defined above, before 2.2.17 /** \brief For U_EMRCREATEPEN lopn field - Microsoft name: LogPen Object + + EMF manual 2.2.19, Microsoft name: LogPen Object */ typedef struct { uint32_t lopnStyle; //!< PenStyle Enumeration U_POINT lopnWidth; //!< Width of pen set by X, Y is ignored U_COLORREF lopnColor; //!< Pen color value -} U_LOGPEN, *PU_LOGPEN; +} U_LOGPEN, + *PU_LOGPEN; //!< EMF manual 2.2.19 -// Microsoft name: LogPenEx Object (not implemented) +// Microsoft name: LogPenEx Object (not implemented) EMF manual 2.2.20 +// Microsoft name: Panose Object, EMF manual 2.2.21, defined above, before 2.2.16 /** \brief For U_EMRPIXELFORMAT pfd field - Microsoft name: PixelFormatDescriptor Object + + EMF manual 2.2.22, Microsoft name: PixelFormatDescriptor Object */ typedef struct { uint16_t nSize; //!< Structure size in bytes @@ -1580,34 +1940,46 @@ typedef struct { uint32_t dwLayerMask; //!< may be ignored uint32_t dwVisibleMask; //!< color or index of underlay plane uint32_t dwDamageMask; //!< may be ignored -} U_PIXELFORMATDESCRIPTOR, *PU_PIXELFORMATDESCRIPTOR; +} U_PIXELFORMATDESCRIPTOR, + *PU_PIXELFORMATDESCRIPTOR; //!< EMF manual 2.2.22 + +// Microsoft name: Point28_4 Object. EMF manual 2.2.23, defined above, before 2.2.6 /** \brief For U_RGNDATA rdb field - Microsoft name: RegionDataHeader Object (RGNDATAHEADER) + + EMF manual 2.2.25, Microsoft name: RegionDataHeader Object (RGNDATAHEADER) */ +// out of order, needed for 2.2.24 typedef struct { uint32_t dwSize; //!< Size in bytes, must be 0x20 (AKA: U_RDH_OBJSIZE) uint32_t iType; //!< Must be 1 (AKA: U_RDH_RECTANGLES) U_NUM_RECTL nCount; //!< Number of rectangles in region uint32_t nRgnSize; //!< Size in bytes of rectangle buffer U_RECTL rclBounds; //!< Region bounds -} U_RGNDATAHEADER,*PU_RGNDATAHEADER; +} U_RGNDATAHEADER, + *PU_RGNDATAHEADER; //!< EMF manual 2.2.25 /** \brief For U_EMRFILLRGN RgnData field(s) - Microsoft name: RegionData Object + + EMF manual 2.2.24, Microsoft name: RegionData Object + */ typedef struct { U_RGNDATAHEADER rdh; //!< Data description U_RECTL Buffer[1]; //!< Array of U_RECTL elements -} U_RGNDATA,*PU_RGNDATA; +} U_RGNDATA, + *PU_RGNDATA; //!< EMF manual 2.2.24 -// Microsoft name: UniversalFontId Object (not implemented) +// Microsoft name: RegionDataHeader Object. EMF manual 2.2.25, defined above, before 2.2.24 +// Microsoft name: TriVertex Object. EMF manual 2.2.26, defined above, before 2.2.7 +// Microsoft name: UniversalFontId Object. EMF manual 2.2.27 (not implemented) /** \brief For U_EMR[FILLRGN|STRETCHBLT|MASKBLT|PLGBLT] xformSrc field - Microsoft name: Xform Object + + EMF manual 2.2.28, Microsoft name: Xform Object */ typedef struct { U_FLOAT eM11; //!< Matrix element M11 @@ -1616,62 +1988,13 @@ typedef struct { U_FLOAT eM22; //!< Matrix element M22 U_FLOAT eDx; //!< X offset in logical units U_FLOAT eDy; //!< Y offset in logical units -} U_XFORM , *PU_XFORM; - -/** - \brief For U_CIEXYZTRIPLE (all) fields - Microsoft name: CIEXYZ Object -*/ -typedef struct { - int32_t ciexyzX; //!< CIE color space X component - int32_t ciexyzY; //!< CIE color space Y component - int32_t ciexyzZ; //!< CIE color space Z component -} U_CIEXYZ, *PU_CIEXYZ; - -/** - \brief For U_LOGCOLORSPACEA and U_LOGCOLORSPACEW lcsEndpints field - defines a CIE colorspace - Microsoft name: CIEXYZTRIPLE Object -*/ -typedef struct { - U_CIEXYZ ciexyzRed; //!< CIE XYZ coord of red endpoint of colorspace - U_CIEXYZ ciexyzGreen; //!< CIE XYZ coord of green endpoint of colorspace - U_CIEXYZ ciexyzBlue; //!< CIE XYZ coord of blue endpoint of colorspace -} U_CIEXYZTRIPLE, *PU_CIEXYZTRIPLE; - -/** - \brief For U_EMRCREATECOLORSPACE lcs field - Microsoft name: LOGCOLORSPACEA Object -*/ -typedef struct { - uint32_t lcsSignature; //!< must be U_LCS_SIGNATURE - uint32_t lcsVersion; //!< must be U_LCS_VERSION - uint32_t lcsSize; //!< Size in bytes of this structure - int32_t lcsCSType; //!< LCS_CSType Enumeration - int32_t lcsIntent; //!< LCS_Intent Enumeration - U_CIEXYZTRIPLE lcsEndpoints; //!< CIE XYZ color space endpoints - U_LCS_GAMMARGB lcsGammaRGB; //!< Gamma For RGB - char lcsFilename[U_MAX_PATH]; //!< Names an external color profile file, otherwise empty string -} U_LOGCOLORSPACEA, *PU_LOGCOLORSPACEA; - -/** - \brief For U_EMRCREATECOLORSPACEW lcs field - Microsoft name: LOGCOLORSPACEW Object -*/ -typedef struct { - uint32_t lcsSignature; //!< must be U_LCS_SIGNATURE - uint32_t lcsVersion; //!< must be U_LCS_VERSION - uint32_t lcsSize; //!< Size in bytes of this structure - int32_t lcsCSType; //!< lcsCSType Enumeration - int32_t lcsIntent; //!< lcsIntent Enumeration - U_CIEXYZTRIPLE lcsEndpoints; //!< CIE XYZ color space endpoints - U_LCS_GAMMARGB lcsGammaRGB; //!< Gamma For RGB - uint16_t lcsFilename[U_MAX_PATH]; //!< Could name an external color profile file, otherwise empty string -} U_LOGCOLORSPACEW, *PU_LOGCOLORSPACEW; - +} U_XFORM , + *PU_XFORM; //!< EMF manual 2.2.28 + /** \brief For U_EMREXTCREATEPEN lopn field - Microsoft name: EXTLOGPEN Object + + EMF manual 2.2.20, Microsoft name: LogPenEx Object */ typedef struct { uint32_t elpPenStyle; //!< PenStyle Enumeration @@ -1681,49 +2004,34 @@ typedef struct { uint32_t elpHatch; //!< HatchStyle Enumeration U_NUM_STYLEENTRY elpNumEntries; //!< Count of StyleEntry array U_STYLEENTRY elpStyleEntry[1]; //!< Array of StyleEntry (For user specified dot/dash patterns) -} U_EXTLOGPEN, *PU_EXTLOGPEN; - -/** - \brief For U_BITMAPINFO bmiHeader field - Microsoft name: BITMAPINFOHEADER Object -*/ -typedef struct { - uint32_t biSize; //!< Structure size in bytes - int32_t biWidth; //!< Bitmap width in pixels - int32_t biHeight; //!< Bitmap height in pixels, may be negative. - //!< abs(biHeight) is bitmap height - //!< bitmap may appear in two orientations: - //!< biHeight > 0 origin is LL corner, may be compressed, this is height after decompression. - //!< biHeight < 0 origin is UL corner, may not be compressed - uint16_t biPlanes; //!< Planes (must be 1) - uint16_t biBitCount; //!< BitCount Enumeration (determines number of RBG colors) - uint32_t biCompression; //!< BI_Compression Enumeration - uint32_t biSizeImage; //!< Image size in bytes or 0 = "default size (calculated from geometry?)" - int32_t biXPelsPerMeter; //!< X Resolution in pixels/meter - int32_t biYPelsPerMeter; //!< Y Resolution in pixels/meter - U_NUM_RGBQUAD biClrUsed; //!< Number of bmciColors in U_BITMAPINFO/U_BITMAPCOREINFO that are used by the bitmap - uint32_t biClrImportant; //!< Number of bmciColors needed (0 means all). -} U_BITMAPINFOHEADER, *PU_BITMAPINFOHEADER; +} U_EXTLOGPEN, + *PU_EXTLOGPEN; //!< EMF manual 2.2.20 /** \brief For U_EMR_* OffBmi* fields + + WMF Manual 2.2.2.9, Microsoft name: (none). + Description of a Bitmap which in some cases is a Device Independent Bitmap (DIB) - Microsoft name: BITMAPINFO Object */ typedef struct { U_BITMAPINFOHEADER bmiHeader; //!< Geometry and pixel properties U_RGBQUAD bmiColors[1]; //!< Color table. 24 bit images do not use color table values. -} U_BITMAPINFO, *PU_BITMAPINFO; +} U_BITMAPINFO, + *PU_BITMAPINFO; //!< WMF Manual 2.2.2.9 /** \brief U_EMRALPHABLEND Blend field + + EMF Manual 2.3.1.1, Microsoft name: BLENDFUNCTION field of EMR_ALPHABLEND record. */ typedef struct { uint8_t Operation; //!< Must be 0 uint8_t Flags; //!< Must be 0 uint8_t Global; //!< Alpha for whole thing if Op is U_AC_SRC_GLOBAL (AKA U_AC_SRC_GLOBAL) uint8_t Op; //!< Blend Enumeration -} U_BLEND, *PU_BLEND; +} U_BLEND, + *PU_BLEND; //!< EMF Manual 2.3.1.1 # /** @@ -1735,43 +2043,53 @@ typedef struct { uint32_t iType; //!< Type of EMR record uint32_t nSize; //!< Size of entire record in bytes (multiple of 4). uint32_t dParm[1]; //!< Data in record -} U_ENHMETARECORD, *PU_ENHMETARECORD; +} U_ENHMETARECORD, + *PU_ENHMETARECORD; //!< General form of an EMF record. -/** First two fields of all EMF records +/** First two fields of all EMF records, + First two fields of all EMF+ records (1 or more within an EMF comment) For accessing iType and nSize files in all U_EMR* records Microsoft name: EMR Object */ typedef struct { uint32_t iType; //!< Type of EMR record uint32_t nSize; //!< Size of entire record in bytes (multiple of 4). -} U_EMR, *PU_EMR; +} U_EMR, + *PU_EMR; //!< First two fields of all EMF records, +/** Generic EMR record with two 32 bit values. + Microsoft name: (none) +*/ typedef struct { U_EMR emr; //!< U_EMR U_PAIR pair; //!< pair of 32 bit values -} U_EMRGENERICPAIR, *PU_EMRGENERICPAIR; +} U_EMRGENERICPAIR, + *PU_EMRGENERICPAIR; //!< Generic EMR record with two 32 bit values. Microsoft name: (none) // *********************************************************************************** -// The following have U_EMR_# records +// The following have U_EMR_# records. They are ordered by their record index, not by EMF manual position. /* Index 1 */ /** - \brief The firstU_ENHMETARECORD record in the metafile. - - Microsoft names instead: Header, HeaderExtension1, and HeaderExtension2 objects. These are - used nowhere else, so they are combined here, along with the first two fields which were not listed in the Header. - - Note also that three fields in this file (nBytes, nRecords, nHandles) must be (re)set after the entire EMF - is constructed, since typically they are not known until then. bOpenGL may or may not be knowable when this - header is written. - - Note also that rclBounds and rclFrame are supposed to be the region bounding the drawn content within the - EMF. This is generally smaller than the size from szlDevice. However, since libUEMF does not actually draw - anything it has no way of knowing what these values are. Instead when it creates a header it sets these to - match the szl* fields. + \brief The first U_ENHMETARECORD record in the metafile. + + EMF manual 2.2.9, Microsoft name: Header object, HeaderExtension1 object, HeaderExtension2 object + + Microsoft names instead: Header, HeaderExtension1, and HeaderExtension2 objects. These are + used nowhere else, so they are combined here, along with the first two fields which were not listed in the Header. + + Note also that three fields in this file (nBytes, nRecords, nHandles) must be (re)set after the entire EMF + is constructed, since typically they are not known until then. bOpenGL may or may not be knowable when this + header is written. + + Note also that rclBounds and rclFrame are supposed to be the region bounding the drawn content within the + EMF. This is generally smaller than the size from szlDevice. However, since libUEMF does not actually draw + anything it has no way of knowing what these values are. Instead when it creates a header it sets these to + match the szl* fields. + */ typedef struct { U_EMR emr; //!< U_EMR @@ -1784,360 +2102,519 @@ typedef struct { uint16_t nHandles; //!< Number of graphics objects used in the Metafile uint16_t sReserved; //!< Must be 0 uint32_t nDescription; //!< Characters in the Description field, 0 if no description - uint32_t offDescription; //!< Offset in bytes to Description field + uint32_t offDescription; //!< Offset in bytes to optional UTF-16BE string Description field uint32_t nPalEntries; //!< Number of Palette entries (in U_EMR_EOF record). U_SIZEL szlDevice; //!< Reference device size in pixels U_SIZEL szlMillimeters; //!< Reference device size in 0.01 mm /** Fields for winver >= win95 */ U_CBPXLFMT cbPixelFormat; //!< Size in bytes of PixelFormatDescriptor, 0 if no PFD - U_OFFPXLFMT offPixelFormat; //!< Offset in bytes to PixelFormatDescriptor from the start of the RECORD, 0 if no PFD + U_OFFPXLFMT offPixelFormat; //!< Offset in bytes to optional PixelFormatDescriptor from the start of the RECORD, 0 if no PFD uint32_t bOpenGL; //!< nonZero if OpenGL commands are included /** Fields for winver >= win98 */ U_SIZEL szlMicrometers; //!< Size of the display device in micrometer - //!< Record may include optional Description, UTF-16BE string - //!< Record may include optional PxlFmtDescriptor, U_PIXELFORMATDESCRIPTOR -} U_EMRHEADER, *PU_EMRHEADER; +} U_EMRHEADER, + *PU_EMRHEADER; //!< EMF manual 2.2.9 -/* Index 2,3,4,5,6*/ +/* Index 2,3,4,5,6 */ +/** EMF manual 2.3.5.16 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< bounding rectangle in device units U_NUM_POINTL cptl; //!< Number of points to draw U_POINTL aptl[1]; //!< array of points -} U_EMRPOLYBEZIER, *PU_EMRPOLYBEZIER, - U_EMRPOLYGON, *PU_EMRPOLYGON, - U_EMRPOLYLINE, *PU_EMRPOLYLINE, - U_EMRPOLYBEZIERTO, *PU_EMRPOLYBEZIERTO, - U_EMRPOLYLINETO, *PU_EMRPOLYLINETO; +} U_EMRPOLYBEZIER, + U_EMRPOLYGON, //!< EMF manual 2.3.5.22 + U_EMRPOLYLINE, //!< EMF manual 2.3.5.24 + U_EMRPOLYBEZIERTO, //!< EMF manual 2.3.5.18 + U_EMRPOLYLINETO, //!< EMF manual 2.3.5.26 + *PU_EMRPOLYBEZIER, //!< EMF manual 2.3.5.16 + *PU_EMRPOLYGON, //!< EMF manual 2.3.5.22 + *PU_EMRPOLYLINE, //!< EMF manual 2.3.5.24 + *PU_EMRPOLYBEZIERTO, //!< EMF manual 2.3.5.18 + *PU_EMRPOLYLINETO; //!< EMF manual 2.3.5.26 /* Index 7,8 */ +/** EMF manual 2.3.5.30 + + After this struct the record also contains an array of points:\n + U_POINTL aptl[1]; +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< bounding rectangle in device units U_NUM_POLYCOUNTS nPolys; //!< Number of elements in aPolyCounts U_NUM_POINTL cptl; //!< Total number of points (over all poly) U_POLYCOUNTS aPolyCounts[1]; //!< Number of points in each poly (sequential) -// This will appear somewhere but is not really part of the core structure. -// U_POINTL aptl[1]; //!< array of points -} U_EMRPOLYPOLYLINE, *PU_EMRPOLYPOLYLINE, - U_EMRPOLYPOLYGON, *PU_EMRPOLYPOLYGON; +} U_EMRPOLYPOLYLINE, + U_EMRPOLYPOLYGON, //!< EMF manual 2.3.5.28 + *PU_EMRPOLYPOLYLINE, //!< EMF manual 2.3.5.30 + *PU_EMRPOLYPOLYGON; //!< EMF manual 2.3.5.28 /* Index 9,11 (numbers interleave with next one) */ +/** EMF manual 2.3.11.30 +*/ typedef struct { U_EMR emr; //!< U_EMR U_SIZEL szlExtent; //!< H & V extent in logical units -} U_EMRSETWINDOWEXTEX, *PU_EMRSETWINDOWEXTEX, - U_EMRSETVIEWPORTEXTEX, *PU_EMRSETVIEWPORTEXTEX; +} U_EMRSETWINDOWEXTEX, + U_EMRSETVIEWPORTEXTEX, //!< EMF manual manual 2.3.11.28 + *PU_EMRSETWINDOWEXTEX, //!< EMF manual manual 2.3.11.30 + *PU_EMRSETVIEWPORTEXTEX; //!< EMF manual manual 2.3.11.28 /* Index 10,12,13 */ +/** EMF manual 2.3.11.31 +*/ typedef struct { U_EMR emr; //!< U_EMR U_POINTL ptlOrigin; //!< H & V origin in logical units -} U_EMRSETWINDOWORGEX, *PU_EMRSETWINDOWORGEX, - U_EMRSETVIEWPORTORGEX, *PU_EMRSETVIEWPORTORGEX, - U_EMRSETBRUSHORGEX, *PU_EMRSETBRUSHORGEX; +} U_EMRSETWINDOWORGEX, + U_EMRSETVIEWPORTORGEX, //!< EMF manual 2.3.11.29 + U_EMRSETBRUSHORGEX, //!< EMF manual 2.3.11.12 + *PU_EMRSETWINDOWORGEX, //!< EMF manual 2.3.11.31 + *PU_EMRSETVIEWPORTORGEX, //!< EMF manual 2.3.11.29 + *PU_EMRSETBRUSHORGEX; //!< EMF manual 2.3.11.12 + + +/* Index 14 */ +/** EMF manual 3.2.4.1 -/* Index 14 -*/ -/** This is a very odd structure because the nSizeLast follows an optional variable size field. Consequently -even though nSizeLast has a name it cannot actually be accessed by it! Following the core appear these fields: +even though nSizeLast has a name it cannot actually be accessed by it! Following the core structure +appear these fields:\n U_LOGPLTNTRY PalEntries[1]; Record may include optional array of PalEntries uint32_t nSizeLast; Mandatory, but position isn't fixed. Must have same value as emr.nSize in header record + */ typedef struct { U_EMR emr; //!< U_EMR U_CBPLENTRIES cbPalEntries; //!< Number of palette entries U_OFFPLENTRIES offPalEntries; //!< Offset in bytes to array of palette entries -} U_EMREOF, *PU_EMREOF; +} U_EMREOF, + *PU_EMREOF; //!< EMF manual 3.2.4.1 /* Index 15 */ +/** EMF manual 2.3.5.36 +*/ typedef struct { U_EMR emr; //!< U_EMR U_POINTL ptlPixel; //!< Pixel coordinates (logical) U_COLORREF crColor; //!< Pixel color -} U_EMRSETPIXELV, *PU_EMRSETPIXELV; +} U_EMRSETPIXELV, + *PU_EMRSETPIXELV; //!< EMF manual 2.3.5.36 /* Index 16 */ +/** EMF manual 2.3.11.20 +*/ typedef struct { U_EMR emr; //!< U_EMR uint32_t dwFlags; //!< must be 1 -} U_EMRSETMAPPERFLAGS, *PU_EMRSETMAPPERFLAGS; +} U_EMRSETMAPPERFLAGS, + *PU_EMRSETMAPPERFLAGS; //!< EMF manual 2.3.11.20 -/* Index 17,18,19,20,21,22,67,98,115 */ +/* Index 17,18,19,20,21,22,67,98,115 +*/ +/** EMF manual 2.3.11.19 MapMode enumeration +*/ typedef struct { U_EMR emr; //!< U_EMR uint32_t iMode; //!< enumeration varies with type -} U_EMRSETMAPMODE, *PU_EMRSETMAPMODE, //!< MapMode enumeration - U_EMRSETBKMODE, *PU_EMRSETBKMODE, //!< BackgroundMode Enumeration - U_EMRSETPOLYFILLMODE, *PU_EMRSETPOLYFILLMODE, //!< PolygonFillMode Enumeration - U_EMRSETROP2, *PU_EMRSETROP2, //!< Binary Raster Operation Enumeration - U_EMRSETSTRETCHBLTMODE, *PU_EMRSETSTRETCHBLTMODE, //!< StretchMode Enumeration - U_EMRSETTEXTALIGN, *PU_EMRSETTEXTALIGN, //!< TextAlignment enumeration - U_EMRSELECTCLIPPATH, *PU_EMRSELECTCLIPPATH, //!< RegionMode Enumeration - U_EMRSETICMMODE, *PU_EMRSETICMMODE, //!< ICMMode Enumeration - U_EMRSETLAYOUT, *PU_EMRSETLAYOUT; //!< Mirroring Enumeration +} U_EMRSETMAPMODE, + U_EMRSETBKMODE, //!< EMF manual 2.3.11.11 BackgroundMode Enumeration + U_EMRSETPOLYFILLMODE, //!< EMF manual 2.3.11.22 PolygonFillMode Enumeration + U_EMRSETROP2, //!< EMF manual 2.3.11.23 Binary Raster Operation Enumeration + U_EMRSETSTRETCHBLTMODE, //!< EMF manual 2.3.11.24 StretchMode Enumeration + U_EMRSETTEXTALIGN, //!< EMF manual 2.3.11.25 TextAlignment enumeration + U_EMRSELECTCLIPPATH, //!< EMF manual 2.3.2.5 RegionMode Enumeration + U_EMRSETICMMODE, //!< EMF manual 2.3.11.14 ICMMode Enumeration + U_EMRSETLAYOUT, //!< EMF manual 2.3.11.17 Mirroring Enumeration + *PU_EMRSETMAPMODE, //!< EMF manual 2.3.11.19 MapMode enumeration + *PU_EMRSETBKMODE, //!< EMF manual 2.3.11.11 BackgroundMode Enumeration + *PU_EMRSETPOLYFILLMODE, //!< EMF manual 2.3.11.22 PolygonFillMode Enumeration + *PU_EMRSETROP2, //!< EMF manual 2.3.11.23 Binary Raster Operation Enumeration + *PU_EMRSETSTRETCHBLTMODE, //!< EMF manual 2.3.11.24 StretchMode Enumeration + *PU_EMRSETTEXTALIGN, //!< EMF manual 2.3.11.25 TextAlignment enumeration + *PU_EMRSELECTCLIPPATH, //!< EMF manual 2.3.2.5 RegionMode Enumeration + *PU_EMRSETICMMODE, //!< EMF manual 2.3.11.14 ICMMode Enumeration + *PU_EMRSETLAYOUT; //!< EMF manual 2.3.11.17 Mirroring Enumeration /* Index 23 */ +/** EMF manual 2.3.11.13 +*/ typedef struct { U_EMR emr; //!< U_EMR U_COLORADJUSTMENT ColorAdjustment; //!< Color Adjustment -} U_EMRSETCOLORADJUSTMENT, *PU_EMRSETCOLORADJUSTMENT; +} U_EMRSETCOLORADJUSTMENT, + *PU_EMRSETCOLORADJUSTMENT; //!< EMF manual 2.3.11.13 /* Index 24, 25 */ +/** EMF manual 2.3.11.26 +*/ typedef struct { U_EMR emr; //!< U_EMR U_COLORREF crColor; //!< Color -} U_EMRSETTEXTCOLOR, *PU_EMRSETTEXTCOLOR, - U_EMRSETBKCOLOR, *PU_EMRSETBKCOLOR; +} U_EMRSETTEXTCOLOR, + U_EMRSETBKCOLOR, //!< EMF manual 2.3.11.10 + *PU_EMRSETTEXTCOLOR, //!< EMF manual 2.3.11.26 + *PU_EMRSETBKCOLOR; //!< EMF manual 2.3.11.10 /* Index 26 */ +/** EMF manual 2.3.2.4 +*/ typedef struct { U_EMR emr; //!< U_EMR U_POINTL ptlOffset; //!< Clipping region -} U_EMROFFSETCLIPRGN, *PU_EMROFFSETCLIPRGN; +} U_EMROFFSETCLIPRGN, + *PU_EMROFFSETCLIPRGN; //!< EMF manual 2.3.2.4 /* Index 27, 54 */ +/** +EMF manual 2.3.11.4 +EMF manual 2.3.5.13 +*/ typedef struct { U_EMR emr; //!< U_EMR U_POINTL ptl; //!< Point coordinates -} U_EMRMOVETOEX, *PU_EMRMOVETOEX, - U_EMRLINETO, *PU_EMRLINETO; +} U_EMRMOVETOEX, + U_EMRLINETO, //!< EMF manual 2.3.5.13 + *PU_EMRMOVETOEX, //!< EMF manual 2.3.11.4 + *PU_EMRLINETO; //!< EMF manual 2.3.5.13 /* Index 28,33,52,59,60,61,65,66,68 */ +/** EMF manual 2.3.2 +*/ typedef struct { U_EMR emr; //!< U_EMR } - U_EMRSETMETARGN, *PU_EMRSETMETARGN, - U_EMRSAVEDC, *PU_EMRSAVEDC, - U_EMRREALIZEPALETTE, *PU_EMRREALIZEPALETTE, - U_EMRBEGINPATH, *PU_EMRBEGINPATH, - U_EMRENDPATH, *PU_EMRENDPATH, - U_EMRCLOSEFIGURE, *PU_EMRCLOSEFIGURE, - U_EMRFLATTENPATH, *PU_EMRFLATTENPATH, - U_EMRWIDENPATH, *PU_EMRWIDENPATH, - U_EMRABORTPATH, *PU_EMRABORTPATH; - -/* Index 29,30 */ + U_EMRSETMETARGN, + U_EMRSAVEDC, //!< EMF manual 2.3.11 + U_EMRREALIZEPALETTE, //!< EMF manual 2.3.10 + U_EMRBEGINPATH, //!< EMF manual 2.3.10 + U_EMRENDPATH, //!< EMF manual 2.3.10 + U_EMRCLOSEFIGURE, //!< EMF manual 2.3.10 + U_EMRFLATTENPATH, //!< EMF manual 2.3.10 + U_EMRWIDENPATH, //!< EMF manual 2.3.10 + U_EMRABORTPATH, //!< EMF manual 2.3.10 + *PU_EMRSETMETARGN, //!< EMF manual 2.3.2 + *PU_EMRSAVEDC, //!< EMF manual 2.3.11 + *PU_EMRREALIZEPALETTE, //!< EMF manual 2.3.10 + *PU_EMRBEGINPATH, //!< EMF manual 2.3.10 + *PU_EMRENDPATH, //!< EMF manual 2.3.10 + *PU_EMRCLOSEFIGURE, //!< EMF manual 2.3.10 + *PU_EMRFLATTENPATH, //!< EMF manual 2.3.10 + *PU_EMRWIDENPATH, //!< EMF manual 2.3.10 + *PU_EMRABORTPATH; //!< EMF manual 2.3.10 + +/* Index 29,30 */ +/** EMF manual 2.3.2.1 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclClip; //!< Clipping Region -} U_EMREXCLUDECLIPRECT, *PU_EMREXCLUDECLIPRECT, - U_EMRINTERSECTCLIPRECT, *PU_EMRINTERSECTCLIPRECT; +} U_EMREXCLUDECLIPRECT, + U_EMRINTERSECTCLIPRECT, //!< EMF manual 2.3.2.3 + *PU_EMREXCLUDECLIPRECT, //!< EMF manual 2.3.2.1 + *PU_EMRINTERSECTCLIPRECT; //!< EMF manual 2.3.2.3 /* Index 31,32 */ +/** EMF manual 2.3.11.7 +*/ typedef struct { U_EMR emr; //!< U_EMR int32_t xNum; //!< Horizontal multiplier (!=0) int32_t xDenom; //!< Horizontal divisor (!=0) int32_t yNum; //!< Vertical multiplier (!=0) int32_t yDenom; //!< Vertical divisor (!=0) -} U_EMRSCALEVIEWPORTEXTEX, *PU_EMRSCALEVIEWPORTEXTEX, - U_EMRSCALEWINDOWEXTEX, *PU_EMRSCALEWINDOWEXTEX; +} U_EMRSCALEVIEWPORTEXTEX, + U_EMRSCALEWINDOWEXTEX, //!< EMF manual 2.3.11.8 + *PU_EMRSCALEVIEWPORTEXTEX, //!< EMF manual 2.3.11.7 + *PU_EMRSCALEWINDOWEXTEX; //!< EMF manual 2.3.11.8 /* Index 33 (see 28) */ -/* Index 34 */ +/* Index 34 */ +/** EMF manual 2.3.11.6 +*/ typedef struct { U_EMR emr; //!< U_EMR int32_t iRelative; //!< DC to restore. -1 is preceding -} U_EMRRESTOREDC, *PU_EMRRESTOREDC; +} U_EMRRESTOREDC, + *PU_EMRRESTOREDC; //!< EMF manual 2.3.11.6 /* Index 35 */ +/** EMF manual 2.3.12.2 +*/ typedef struct { U_EMR emr; //!< U_EMR U_XFORM xform; //!< Transform -} U_EMRSETWORLDTRANSFORM, *PU_EMRSETWORLDTRANSFORM; +} U_EMRSETWORLDTRANSFORM, + *PU_EMRSETWORLDTRANSFORM; //!< EMF manual 2.3.12.2 /* Index 36 */ +/** EMF manual 2.3.12.1 +*/ typedef struct { U_EMR emr; //!< U_EMR U_XFORM xform; //!< Transform uint32_t iMode; //!< ModifyWorldTransformMode Enumeration -} U_EMRMODIFYWORLDTRANSFORM, *PU_EMRMODIFYWORLDTRANSFORM; +} U_EMRMODIFYWORLDTRANSFORM, + *PU_EMRMODIFYWORLDTRANSFORM; //!< EMF manual 2.3.12.1 /* Index 37,40 */ +/** EMF manual 2.3.8.3 +*/ typedef struct { U_EMR emr; //!< U_EMR uint32_t ihObject; //!< Number of a stock or created object -} U_EMRDELETEOBJECT, *PU_EMRDELETEOBJECT, - U_EMRSELECTOBJECT, *PU_EMRSELECTOBJECT; +} U_EMRDELETEOBJECT, + U_EMRSELECTOBJECT, //!< EMF manual 2.3.8.5 + *PU_EMRDELETEOBJECT, //!< EMF manual 2.3.8.3 + *PU_EMRSELECTOBJECT; //!< EMF manual 2.3.8.5 /* Index 38 */ +/** EMF manual 2.3.7.7 +*/ typedef struct { U_EMR emr; //!< U_EMR uint32_t ihPen; //!< Index to place object in EMF object table (this entry must not yet exist) U_LOGPEN lopn; //!< Pen properties -} U_EMRCREATEPEN, *PU_EMRCREATEPEN; +} U_EMRCREATEPEN, + *PU_EMRCREATEPEN; //!< EMF manual 2.3.7.7 -/* Index 39 */ +/* Index 39 */ +/** EMF manual 2.3.7.1 +*/ typedef struct { U_EMR emr; //!< U_EMR uint32_t ihBrush; //!< Index to place object in EMF object table (this entry must not yet exist) U_LOGBRUSH lb; //!< Brush properties -} U_EMRCREATEBRUSHINDIRECT, *PU_EMRCREATEBRUSHINDIRECT; +} U_EMRCREATEBRUSHINDIRECT, + *PU_EMRCREATEBRUSHINDIRECT; //!< EMF manual 2.3.7.1 /* Index 40 see 37 */ -/* Index 41 */ +/* Index 41 */ +/** EMF manual 2.3.5.1 +*/ typedef struct { U_EMR emr; //!< U_EMR U_POINTL ptlCenter; //!< Center in logical units uint32_t nRadius; //!< Radius in logical units U_FLOAT eStartAngle; //!< Starting angle in degrees (counter clockwise from x axis) U_FLOAT eSweepAngle; //!< Sweep angle in degrees -} U_EMRANGLEARC, *PU_EMRANGLEARC; +} U_EMRANGLEARC, + *PU_EMRANGLEARC; //!< EMF manual 2.3.5.1 -/* Index 42,43 */ +/* Index 42,43 */ +/** EMF manual 2.3.5.5 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBox; //!< bounding rectangle in logical units -} U_EMRELLIPSE, *PU_EMRELLIPSE, - U_EMRRECTANGLE, *PU_EMRRECTANGLE; +} U_EMRELLIPSE, + U_EMRRECTANGLE, //!< EMF manual 2.3.5.5 + *PU_EMRELLIPSE, //!< EMF manual 2.3.5.5 + *PU_EMRRECTANGLE; //!< EMF manual 2.3.5.34 -/* Index 44 */ +/* Index 44 */ +/** EMF manual 2.3.5.35 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBox; //!< bounding rectangle in logical units U_SIZEL szlCorner; //!< W & H in logical units of ellipse used to round corner -} U_EMRROUNDRECT, *PU_EMRROUNDRECT; +} U_EMRROUNDRECT, + *PU_EMRROUNDRECT; //!< EMF manual 2.3.5.35 -/* Index 45, 46 ,47, 55 */ +/* Index 45, 46 ,47, 55 */ +/** EMF manual 2.3.5.2 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBox; //!< bounding rectangle in logical units U_POINTL ptlStart; //!< Start point in logical units U_POINTL ptlEnd; //!< End point in logical units -} U_EMRARC, *PU_EMRARC, - U_EMRCHORD, *PU_EMRCHORD, - U_EMRPIE, *PU_EMRPIE, - U_EMRARCTO, *PU_EMRARCTO; +} U_EMRARC, + U_EMRCHORD, //!< EMF manual 2.3.5.4 + U_EMRPIE, //!< EMF manual 2.3.5.15 + U_EMRARCTO, //!< EMF manual 2.3.5.3 + *PU_EMRARC, //!< EMF manual 2.3.5.2 + *PU_EMRCHORD, //!< EMF manual 2.3.5.4 + *PU_EMRPIE, //!< EMF manual 2.3.5.15 + *PU_EMRARCTO; //!< EMF manual 2.3.5.3 -/* Index 48 */ +/* Index 48 */ +/** EMF manual 2.3.8.6 +*/ typedef struct { U_EMR emr; //!< U_EMR uint32_t ihPal; //!< Index of a Palette object in the EMF object table -} U_EMRSELECTPALETTE, *PU_EMRSELECTPALETTE; +} U_EMRSELECTPALETTE, + *PU_EMRSELECTPALETTE; //!< EMF manual 2.3.8.6 -/* Index 49 */ +/* Index 49 */ +/** EMF manual 2.3.7.6 +*/ typedef struct { U_EMR emr; //!< U_EMR uint32_t ihPal; //!< Index to place object in EMF object table (this entry must not yet exist) U_LOGPALETTE lgpl; //!< Palette properties -} U_EMRCREATEPALETTE, *PU_EMRCREATEPALETTE; +} U_EMRCREATEPALETTE, + *PU_EMRCREATEPALETTE; //!< EMF manual 2.3.7.6 /* Index 50 */ +/** EMF manual 2.3.8.8 +*/ typedef struct { U_EMR emr; //!< U_EMR uint32_t ihPal; //!< Index of a Palette object in the EMF object table uint32_t iStart; //!< First Palette entry in selected object to set U_NUM_LOGPLTNTRY cEntries; //!< Number of Palette entries in selected object to set U_LOGPLTNTRY aPalEntries[1]; //!< Values to set with -} U_EMRSETPALETTEENTRIES, *PU_EMRSETPALETTEENTRIES; +} U_EMRSETPALETTEENTRIES, + *PU_EMRSETPALETTEENTRIES; //!< EMF manual 2.3.8.8 /* Index 51 */ +/** EMF manual 2.3.8.4 +*/ typedef struct { U_EMR emr; //!< U_EMR uint32_t ihPal; //!< Index of a Palette object in the EMF object table uint32_t cEntries; //!< Number to expand or truncate the Palette entry list to. -} U_EMRRESIZEPALETTE, *PU_EMRRESIZEPALETTE; +} U_EMRRESIZEPALETTE, + *PU_EMRRESIZEPALETTE; //!< EMF manual 2.3.8.4 /* Index 52 (see 28) */ /* Index 53 */ +/** EMF manual 2.3.5.6 +*/ typedef struct { U_EMR emr; //!< U_EMR U_POINTL ptlStart; //!< Start point in logical units U_COLORREF crColor; //!< Color to fill with uint32_t iMode; //!< FloodFill Enumeration -} U_EMREXTFLOODFILL, *PU_EMREXTFLOODFILL; +} U_EMREXTFLOODFILL, + *PU_EMREXTFLOODFILL; //!< EMF manual 2.3.5.6 /* Index 54 (see 27) */ /* Index 55 (see 45) */ -/* Index 56 */ +/* Index 56 */ +/** EMF manual 2.3.5.20 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< Bounding rectangle in device units U_NUM_POINTL cptl; //!< Number of U_POINTL objects U_POINTL aptl[1]; //!< Array of U_POINTL objects uint8_t abTypes[1]; //!< Array of Point Enumeration -} U_EMRPOLYDRAW, *PU_EMRPOLYDRAW; +} U_EMRPOLYDRAW, + *PU_EMRPOLYDRAW; //!< EMF manual 2.3.5.20 -/* Index 57 */ +/* Index 57 */ +/** EMF manual 2.3.11.9 +*/ typedef struct { U_EMR emr; //!< U_EMR uint32_t iArcDirection; //!< ArcDirection Enumeration -} U_EMRSETARCDIRECTION, *PU_EMRSETARCDIRECTION; +} U_EMRSETARCDIRECTION, + *PU_EMRSETARCDIRECTION; //!< EMF manual 2.3.11.9 + +/* Index 58 */ +/** EMF manual 2.3.11.21 -/* Index 58 IMPORTANT!!!! The Microsoft structure uses a float for the miterlimit but the EMF file record uses an unsigned int. The latter form is used in this structure. */ typedef struct { U_EMR emr; //!< U_EMR uint32_t eMiterLimit; //!< Miter limit (max value of mitered length / line width) -} U_EMRSETMITERLIMIT, *PU_EMRSETMITERLIMIT; +} U_EMRSETMITERLIMIT, + *PU_EMRSETMITERLIMIT; //!< EMF manual 2.3.11.21 /* Index 59,60,61 (see 28) */ -/* Index 62,63,64 */ +/* Index 62,63,64 */ +/** EMF manual 2.3.5.9 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< Bounding rectangle in device units -} U_EMRFILLPATH, *PU_EMRFILLPATH, - U_EMRSTROKEANDFILLPATH, *PU_EMRSTROKEANDFILLPATH, - U_EMRSTROKEPATH, *PU_EMRSTROKEPATH; +} U_EMRFILLPATH, + U_EMRSTROKEANDFILLPATH, //!< EMF manual 2.3.5.38 + U_EMRSTROKEPATH, //!< EMF manual 2.3.5.39 + *PU_EMRFILLPATH, //!< EMF manual 2.3.5.9 + *PU_EMRSTROKEANDFILLPATH, //!< EMF manual 2.3.5.38 + *PU_EMRSTROKEPATH; //!< EMF manual 2.3.5.39 /* Index 65,66 (see 28) */ /* Index 67 (see 17) */ /* Index 68 (see 28) */ /* Index 69 (not a defined U_EMR record type ) */ -/* Index 70 */ + +/* Index 70 */ +/** EMF manual 2.3.3.1 +*/ typedef struct { U_EMR emr; //!< U_EMR U_CBDATA cbData; //!< Number of bytes in comment uint8_t Data[1]; //!< Comment (any binary data, interpretation is program specific) -} U_EMRCOMMENT, *PU_EMRCOMMENT; //!< AKA GDICOMMENT +} U_EMRCOMMENT, + *PU_EMRCOMMENT; //!< EMF manual 2.3.3.1, AKA GDICOMMENT /* variant comment types */ +/** EMF manual 2.3.3.2 +*/ typedef struct { U_EMR emr; //!< U_EMR U_CBDATA cbData; //!< Number of bytes in comment uint32_t cIdent; //!< Comment identifier, must be U_EMR_COMMENT_EMFPLUSRECORD uint8_t Data[1]; //!< EMF Plus record -} U_EMRCOMMENT_EMFPLUS, *PU_EMRCOMMENT_EMFPLUS; //!< EMF Plus comment +} U_EMRCOMMENT_EMFPLUS, + *PU_EMRCOMMENT_EMFPLUS; //!< EMF manual 2.3.3.2, EMF Plus comment +/** EMF manual 2.3.3.3 +*/ typedef struct { U_EMR emr; //!< U_EMR U_CBDATA cbData; //!< Number of bytes in comment uint32_t cIdent; //!< Comment identifier, must be U_EMR_COMMENT_SPOOL uint32_t esrIdent; //!< EMFSpoolRecordIdentifier, may be U_EMR_COMMENT_SPOOLFONTDEF uint8_t Data[1]; //!< EMF Spool records -} U_EMRCOMMENT_SPOOL, *PU_EMRCOMMENT_SPOOL; //!< EMF Spool comment +} U_EMRCOMMENT_SPOOL, + *PU_EMRCOMMENT_SPOOL; //!< EMF manual 2.3.3.3, EMF Spool comment +/** EMF manual 2.3.3.4 +*/ typedef struct { U_EMR emr; //!< U_EMR U_CBDATA cbData; //!< Number of bytes in comment uint32_t cIdent; //!< Comment identifier, must be U_EMR_COMMENT_PUBLIC uint32_t pcIdent; //!< Public Comment Identifier, from EMRComment Enumeration uint8_t Data[1]; //!< Public comment data -} U_EMRCOMMENT_PUBLIC, *PU_EMRCOMMENT_PUBLIC; //!< EMF Public comment +} U_EMRCOMMENT_PUBLIC, + *PU_EMRCOMMENT_PUBLIC; //!< EMF manual 2.3.3.4, EMF Public comment -/* Index 71 */ +/* Index 71 */ +/** EMF manual 2.3.5.10 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< Bounding rectangle in device units U_CBRGNDATA cbRgnData; //!< Size in bytes of Region data uint32_t ihBrush; //!< Index of a Brush object in the EMF object table U_RGNDATA RgnData[1]; //!< Variable size U_RGNDATA structure -} U_EMRFILLRGN, *PU_EMRFILLRGN; +} U_EMRFILLRGN, + *PU_EMRFILLRGN; //!< EMF manual 2.3.5.10 /* Index 72 */ +/** EMF manual 2.3.5.11 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< Bounding rectangle in device units @@ -2145,26 +2622,36 @@ typedef struct { uint32_t ihBrush; //!< Index of a Brush object in the EMF object table U_SIZEL szlStroke; //!< W & H of Brush stroke U_RGNDATA RgnData[1]; //!< Variable size U_RGNDATA structure -} U_EMRFRAMERGN, *PU_EMRFRAMERGN; +} U_EMRFRAMERGN, + *PU_EMRFRAMERGN; //!< EMF manual 2.3.5.11 /* Index 73,74 */ +/** EMF manual 2.3.11.3 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< Bounding rectangle in device units U_CBRGNDATA cbRgnData; //!< Size in bytes of Region data U_RGNDATA RgnData[1]; //!< Variable size U_RGNDATA structure -} U_EMRINVERTRGN, *PU_EMRINVERTRGN, - U_EMRPAINTRGN, *PU_EMRPAINTRGN; +} U_EMRINVERTRGN, + U_EMRPAINTRGN, //!< EMF manual 2.3.5.14 + *PU_EMRINVERTRGN, //!< EMF manual 2.3.11.3 + *PU_EMRPAINTRGN; //!< EMF manual 2.3.5.14 /* Index 75 */ +/** EMF manual 2.3.2.2 +*/ typedef struct { U_EMR emr; //!< U_EMR U_CBRGNDATA cbRgnData; //!< Size in bytes of Region data uint32_t iMode; //!< RegionMode Enumeration U_RGNDATA RgnData[1]; //!< Variable size U_RGNDATA structure -} U_EMREXTSELECTCLIPRGN, *PU_EMREXTSELECTCLIPRGN; +} U_EMREXTSELECTCLIPRGN, + *PU_EMREXTSELECTCLIPRGN; //!< EMF manual 2.3.2.2 /* Index 76 */ +/** EMF manual 2.3.1.2 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< Bounding rectangle in device units @@ -2180,9 +2667,12 @@ typedef struct { U_OFFBITSSRC offBitsSrc; //!< Offset in bytes to the bitmap (within bitmapbuffer) U_CBBITS cbBitsSrc; //!< Size in bytes of bitmap //!< Record may include optional bitmapbuffer -} U_EMRBITBLT, *PU_EMRBITBLT; +} U_EMRBITBLT, + *PU_EMRBITBLT; //!< EMF manual 2.3.1.2 /* Index 77 */ +/** EMF manual 2.3.1.6 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< Bounding rectangle in device units @@ -2199,9 +2689,12 @@ typedef struct { U_CBBITS cbBitsSrc; //!< Size in bytes of bitmap U_POINTL cSrc; //!< Src W & H in logical units //!< Record may include optional bitmapbuffer -} U_EMRSTRETCHBLT, *PU_EMRSTRETCHBLT; +} U_EMRSTRETCHBLT, + *PU_EMRSTRETCHBLT; //!< EMF manual 2.3.1.6 -/* Index 78 */ +/* Index 78 */ +/** EMF manual 2.3.1.3 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< Bounding rectangle in device units @@ -2223,9 +2716,12 @@ typedef struct { U_OFFBITSMSK offBitsMask; //!< Offset in bytes to the mask bitmap (within maskbitmapbuffer) U_CBBITSMSK cbBitsMask; //!< Size in bytes of bitmap //!< Record may include optional Source and mask bitmapbuffers -} U_EMRMASKBLT, *PU_EMRMASKBLT; +} U_EMRMASKBLT, + *PU_EMRMASKBLT; //!< EMF manual 2.3.1.3 /* Index 79 */ +/** EMF manual 2.3.1.4 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< Bounding rectangle in device units @@ -2246,9 +2742,12 @@ typedef struct { U_OFFBITSMSK offBitsMask; //!< Offset in bytes to the mask bitmap (within maskbitmapbuffer) U_CBBITSMSK cbBitsMask; //!< Size in bytes of bitmap //!< Record may include optional Source and mask bitmapbuffers -} U_EMRPLGBLT, *PU_EMRPLGBLT; +} U_EMRPLGBLT, + *PU_EMRPLGBLT; //!< EMF manual 2.3.1.4 /* Index 80 */ +/** EMF manual 2.3.1.5 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< Bounding rectangle in device units @@ -2263,9 +2762,12 @@ typedef struct { uint32_t iStartScan; //!< First scan line uint32_t cScans; //!< Number of scan lines //!< Record may includes optional bitmapbuffer -} U_EMRSETDIBITSTODEVICE, *PU_EMRSETDIBITSTODEVICE; +} U_EMRSETDIBITSTODEVICE, + *PU_EMRSETDIBITSTODEVICE; //!< EMF manual 2.3.1.5 /* Index 81 */ +/** EMF manual 2.3.1.7 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< Bounding rectangle in device units @@ -2280,18 +2782,23 @@ typedef struct { uint32_t dwRop; //!< Ternary Raster Operation enumeration U_POINTL cDest; //!< Destination W & H in logical units //!< Record may includes optional bitmapbuffer -} U_EMRSTRETCHDIBITS, *PU_EMRSTRETCHDIBITS; +} U_EMRSTRETCHDIBITS, + *PU_EMRSTRETCHDIBITS; //!< EMF manual 2.3.1.7 /* Index 82 */ +/** EMF manual 2.3.7.8 +*/ typedef struct { U_EMR emr; //!< U_EMR uint32_t ihFont; //!< Index of the font in the EMF object table U_LOGFONT_PANOSE elfw; //!< Font parameters, either U_LOGFONT or U_LOGFONT_PANOSE, the latter is bigger so use that type here -} U_EMREXTCREATEFONTINDIRECTW, *PU_EMREXTCREATEFONTINDIRECTW; +} U_EMREXTCREATEFONTINDIRECTW, + *PU_EMREXTCREATEFONTINDIRECTW; //!< EMF manual 2.3.7.8 -/* Index 83,84 */ -/** -Variable and optional fields may follow core structure in record: +/* Index 83,84 */ +/** EMF manual 2.3.5.7 + +Variable and optional fields may follow core structure in record:\n U_RECTL rcl; absent when fOptions & U_ETO_NO_RECT) grayed/clipping/opaque rectangle @@ -2306,25 +2813,33 @@ typedef struct { U_FLOAT exScale; //!< scale to 0.01 mm units ( only if iGraphicsMode & U_GM_COMPATIBLE) U_FLOAT eyScale; //!< scale to 0.01 mm units ( only if iGraphicsMode & U_GM_COMPATIBLE) U_EMRTEXT emrtext; //!< Text parameters -// U_RECTL rcl; absent when fOptions & U_ETO_NO_RECT) grayed/clipping/opaque rectangle -// U_OFFDX offDx; (required) but position isn't static. Offset in bytes to the character spacing array from the start of the RECORD -// Record may include optional Dx, character spacing, array of uint32_t -} U_EMREXTTEXTOUTA, *PU_EMREXTTEXTOUTA, - U_EMREXTTEXTOUTW, *PU_EMREXTTEXTOUTW; +} U_EMREXTTEXTOUTA, + U_EMREXTTEXTOUTW, //!< EMF manual 2.3.5.8 + *PU_EMREXTTEXTOUTA, //!< EMF manual 2.3.5.7 + *PU_EMREXTTEXTOUTW; //!< EMF manual 2.3.5.8 /* Index 85,86,87,88,89 */ +/** EMF manual 2.3.5.17 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< Bounding rectangle in device units U_NUM_POINT16 cpts; //!< Number of POINT16 in array U_POINT16 apts[1]; //!< Array of POINT16 -} U_EMRPOLYBEZIER16,*PU_EMRPOLYBEZIER16, - U_EMRPOLYGON16,*PU_EMRPOLYGON16, - U_EMRPOLYLINE16,*PU_EMRPOLYLINE16, - U_EMRPOLYBEZIERTO16,*PU_EMRPOLYBEZIERTO16, - U_EMRPOLYLINETO16,*PU_EMRPOLYLINETO16; - +} U_EMRPOLYBEZIER16, + U_EMRPOLYGON16, //!< EMF manual 2.3.5.23 + U_EMRPOLYLINE16, //!< EMF manual 2.3.5.25 + U_EMRPOLYBEZIERTO16, //!< EMF manual 2.3.5.19 + U_EMRPOLYLINETO16, //!< EMF manual 2.3.5.27 + *PU_EMRPOLYBEZIER16, //!< EMF manual 2.3.5.17 + *PU_EMRPOLYGON16, //!< EMF manual 2.3.5.23 + *PU_EMRPOLYLINE16, //!< EMF manual 2.3.5.25 + *PU_EMRPOLYBEZIERTO16, //!< EMF manual 2.3.5.19 + *PU_EMRPOLYLINETO16; //!< EMF manual 2.3.5.27 + /* Index 90,91 */ +/** EMF manual 2.3.5.31 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< Bounding rectangle in device units @@ -2332,20 +2847,27 @@ typedef struct { U_NUM_POINT16 cpts; //!< Total number of points (over all poly) U_POLYCOUNTS aPolyCounts[1]; //!< Number of points in each poly (sequential) // This will appear somewhere but is not really part of the core structure. -// U_POINT16 apts[1]; //!< array of point16 -} U_EMRPOLYPOLYLINE16,*PU_EMRPOLYPOLYLINE16, - U_EMRPOLYPOLYGON16,*PU_EMRPOLYPOLYGON16; +// U_POINT16 apts[1]; //!< array of point16 +} U_EMRPOLYPOLYLINE16, + U_EMRPOLYPOLYGON16, //!< EMF manual 2.3.5.29 + *PU_EMRPOLYPOLYLINE16, //!< EMF manual 2.3.5.31 + *PU_EMRPOLYPOLYGON16; //!< EMF manual 2.3.5.29 /* Index 92 */ +/** EMF manual 2.3.5.21 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< Bounding rectangle in device units U_NUM_POINT16 cpts; //!< Total number of points (over all poly) U_POINT16 apts[1]; //!< array of points uint8_t abTypes[1]; //!< Array of Point Enumeration -} U_EMRPOLYDRAW16,*PU_EMRPOLYDRAW16; +} U_EMRPOLYDRAW16, + *PU_EMRPOLYDRAW16; //!< EMF manual 2.3.5.21 -/* Index 93 */ +/* Index 93 */ +/** EMF manual 2.3.7.5 +*/ typedef struct { U_EMR emr; //!< U_EMR uint32_t ihBrush; //!< Index to place object in EMF object table (this entry must not yet exist) @@ -2355,9 +2877,12 @@ typedef struct { U_OFFBITS offBits; //!< Offset in bytes to the DIB bitmap data (within DIBbitmapbuffer U_CBBITS cbBits; //!< Size in bytes of DIB bitmap //!< Record may include optional DIB bitmapbuffer -} U_EMRCREATEMONOBRUSH, *PU_EMRCREATEMONOBRUSH; +} U_EMRCREATEMONOBRUSH, + *PU_EMRCREATEMONOBRUSH; //!< EMF manual 2.3.7.5 -/* Index 94 */ +/* Index 94 */ +/** EMF manual 2.3.7.4 +*/ typedef struct { U_EMR emr; //!< U_EMR uint32_t ihBrush; //!< Index to place object in EMF object table (this entry must not yet exist) @@ -2367,9 +2892,12 @@ typedef struct { U_OFFBITS offBits; //!< Offset in bytes to the DIB bitmap data (within DIB bitmapbuffer U_CBBITS cbBits; //!< Size in bytes of DIB bitmap //!< Record may include optional DIB bitmapbuffer -} U_EMRCREATEDIBPATTERNBRUSHPT, *PU_EMRCREATEDIBPATTERNBRUSHPT; +} U_EMRCREATEDIBPATTERNBRUSHPT, + *PU_EMRCREATEDIBPATTERNBRUSHPT; //!< EMF manual 2.3.7.4 /* Index 95 */ +/** EMF manual 2.3.7.9 +*/ typedef struct { U_EMR emr; //!< U_EMR uint32_t ihPen; //!< Index to place object in EMF object table (this entry must not yet exist) @@ -2379,9 +2907,12 @@ typedef struct { U_CBBITS cbBits; //!< Size in bytes of DIB bitmap U_EXTLOGPEN elp; //!< Pen parameters (Size is Variable!!!!) //!< Record may include optional DIB bitmap -} U_EMREXTCREATEPEN, *PU_EMREXTCREATEPEN; +} U_EMREXTCREATEPEN, + *PU_EMREXTCREATEPEN; //!< EMF manual 2.3.7.9 -/* Index 96.97 */ +/* Index 96.97 */ +/** EMF manual 2.3.5.32 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< Bounding rectangle in device units @@ -2390,63 +2921,89 @@ typedef struct { U_FLOAT eyScale; //!< scale to 0.01 mm units ( only if iGraphicsMode & U_GM_COMPATIBLE) U_NUM_EMRTEXT cStrings; //!< Number of U_EMRTEXT in array U_EMRTEXT emrtext[1]; //!< Text parameters -} U_EMRPOLYTEXTOUTA, *PU_EMRPOLYTEXTOUTA, - U_EMRPOLYTEXTOUTW, *PU_EMRPOLYTEXTOUTW; +} U_EMRPOLYTEXTOUTA, + U_EMRPOLYTEXTOUTW, //!< EMF manual 2.3.5.33 + *PU_EMRPOLYTEXTOUTA, //!< EMF manual 2.3.5.32 + *PU_EMRPOLYTEXTOUTW; //!< EMF manual 2.3.5.33 /* Index 98 (see 17) */ /* Index 99 */ +/** EMF manual 2.3.7.2 +*/ typedef struct { U_EMR emr; //!< U_EMR uint32_t ihCS; //!< Index to place object in EMF object table (this entry must not yet exist) U_LOGCOLORSPACEA lcs; //!< ColorSpace parameters -} U_EMRCREATECOLORSPACE, *PU_EMRCREATECOLORSPACE; +} U_EMRCREATECOLORSPACE, + *PU_EMRCREATECOLORSPACE; //!< EMF manual 2.3.7.2 /* Index 100,101 */ +/** EMF manual 2.3.8.2 +*/ typedef struct { U_EMR emr; //!< U_EMR uint32_t ihCS; //!< Index of object in EMF object table -} U_EMRDELETECOLORSPACE, *PU_EMRDELETECOLORSPACE, - U_EMRSETCOLORSPACE, *PU_EMRSETCOLORSPACE; +} U_EMRDELETECOLORSPACE, + U_EMRSETCOLORSPACE, //!< EMF manual 2.3.8.7 + *PU_EMRDELETECOLORSPACE, //!< EMF manual 2.3.8.2 + *PU_EMRSETCOLORSPACE; //!< EMF manual 2.3.8.7 /* Index 102 */ +/** EMF manual 2.3.9.2 +*/ typedef struct { U_EMR emr; //!< U_EMR U_CBDATA cbData; //!< Size of OpenGL data in bytes U_DATA Data[1]; //!< OpenGL data -} U_EMRGLSRECORD, *PU_EMRGLSRECORD; +} U_EMRGLSRECORD, + *PU_EMRGLSRECORD; //!< EMF manual 2.3.9.2 /* Index 103 */ +/** EMF manual 2.3.9.1 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< Bounding rectangle in device units U_CBDATA cbData; //!< Size of OpenGL data in bytes U_DATA Data[1]; //!< OpenGL data -} U_EMRGLSBOUNDEDRECORD, *PU_EMRGLSBOUNDEDRECORD; +} U_EMRGLSBOUNDEDRECORD, + *PU_EMRGLSBOUNDEDRECORD; //!< EMF manual 2.3.9.1 /* Index 104 */ +/** EMF manual 2.3.11.5 +*/ typedef struct { U_EMR emr; //!< U_EMR U_PIXELFORMATDESCRIPTOR pfd; //!< PixelFormatDescriptor -} U_EMRPIXELFORMAT, *PU_EMRPIXELFORMAT; +} U_EMRPIXELFORMAT, + *PU_EMRPIXELFORMAT; //!< EMF manual 2.3.11.5 /* Index 105 */ +/** EMF manual 2.3.6.1 +*/ typedef struct { U_EMR emr; //!< U_EMR U_CBDATA cjIn; //!< Number of bytes to send to printer driver U_DATA Data[1]; //!< Data to send -} U_EMRDRAWESCAPE, *PU_EMRDRAWESCAPE; +} U_EMRDRAWESCAPE, + *PU_EMRDRAWESCAPE; //!< EMF manual 2.3.6.1 /* Index 106 */ +/** EMF manual 2.3.6.2 +*/ typedef struct { U_EMR emr; //!< U_EMR U_CBDATA cjIn; //!< Number of bytes to send to printer driver U_DATA Data[1]; //!< Data to send -} U_EMREXTESCAPE, *PU_EMREXTESCAPE; +} U_EMREXTESCAPE, + *PU_EMREXTESCAPE; //!< EMF manual 2.3.6.2 /* Index 107 (not implemented ) */ /* Index 108 */ +/** EMF manual 2.3.5.37 +*/ typedef struct { U_EMR emr; //!< U_EMR U_POINTL Dest; //!< Where to draw the text @@ -2458,22 +3015,34 @@ typedef struct { //!< the tail end of this record is variable. //!< U_RECTL rclBounds; Record may include optional Bounding rectangle (absent when: fuOPtions & ETO_NO_U_RECT) //!< uint32_t TextString; text to output (fuOptions & ETO_SMALL_CHARS ? 8 bit : 16 bit) -} U_EMRSMALLTEXTOUT, *PU_EMRSMALLTEXTOUT; +} U_EMRSMALLTEXTOUT, + *PU_EMRSMALLTEXTOUT; //!< EMF manual 2.3.5.37 -/* Index 109 (not implemented ) */ +/* Index 109 (not implemented ) +EMF manual 2.3.11.2 +*/ /* Index 110 */ +/** EMF manual 2.3.6.3 +*/ typedef struct { U_EMR emr; //!< U_EMR U_CBDATA cbDriver; //!< Number of bytes in driver name (note, BYTES, not CHARACTERS) U_CBDATA cbData; //!< Number of bytes in data uint16_t Driver[1]; //!< Driver name in uint16_t characters, null terminated uint8_t Data[1]; //!< Data for printer driver -} U_EMRNAMEDESCAPE, *PU_EMRNAMEDESCAPE; +} U_EMRNAMEDESCAPE, + *PU_EMRNAMEDESCAPE; //!< EMF manual 2.3.6.3 -/* Index 111-113 (not implemented ) */ +/* Index 111-113 (not implemented ) + EMF manual 2.3.8.1 + EMF manual 2.3.11.15 + EMF manual 2.3.11.16 +*/ /* Index 114 */ +/** EMF manual 2.3.1.1 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< Bounding rectangle in device units @@ -2490,11 +3059,14 @@ typedef struct { U_CBBITS cbBitsSrc; //!< Size in bytes of bitmap U_POINTL cSrc; //!< Source W & H in logical units //!< Record may include optional DIB bitmap -} U_EMRALPHABLEND, *PU_EMRALPHABLEND; +} U_EMRALPHABLEND, + *PU_EMRALPHABLEND; //!< EMF manual 2.3.1.1 /* Index 115 (see 17) */ -/* Index 116 */ +/* Index 116 */ +/** EMF manual 2.3.1.8 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< Bounding rectangle in device units @@ -2511,11 +3083,14 @@ typedef struct { U_CBBITS cbBitsSrc; //!< Size in bytes of bitmap U_POINTL cSrc; //!< Source W & H in logical units //!< Record may includes optional bitmapbuffer -} U_EMRTRANSPARENTBLT, *PU_EMRTRANSPARENTBLT; +} U_EMRTRANSPARENTBLT, + *PU_EMRTRANSPARENTBLT; //!< EMF manual 2.3.1.8 /* Index 117 (not a defined U_EMR record type ) */ /* Index 118 */ +/** EMF manual 2.3.5.12 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< Bounding rectangle in device units @@ -2525,21 +3100,30 @@ typedef struct { //parts that are required but which are not included in the core structure // U_TRIVERTEX TriVert[1]; Array of TriVertex objects // uint32_t GradObj[1]; Array of gradient objects (each has 2 or 3 indices into TriVert array) -} U_EMRGRADIENTFILL, *PU_EMRGRADIENTFILL; +} U_EMRGRADIENTFILL, + *PU_EMRGRADIENTFILL; //!< EMF manual 2.3.5.12 -/* Index 119,120 (not implemented ) */ +/* Index 119,120 (not implemented ) +EMF manual 2.3.11.18 +EMF manual 2.3.11.27 +*/ /* Index 121 */ +/** EMF manual 2.3.11.1 +*/ typedef struct { U_EMR emr; //!< U_EMR uint32_t dwAction; //!< ColorSpace Enumeration uint32_t dwFlags; //!< ColorMatchToTarget Enumeration - U_CBNAME cbName; //!< Number of bytes in in UTF16 name of the color profile + U_CBNAME cbName; //!< Number of bytes in UTF16 name of the color profile U_CBDATA cbData; //!< Number of bytes of the target profile uint8_t Data[1]; //!< Data of size cbName+cbData: Name in UTF16 then color profile data -} U_EMRCOLORMATCHTOTARGETW, *PU_EMRCOLORMATCHTOTARGETW; +} U_EMRCOLORMATCHTOTARGETW, + *PU_EMRCOLORMATCHTOTARGETW; //!< EMF manual 2.3.11.1 /* Index 122 */ +/** EMF manual 2.3.7.3 +*/ typedef struct { U_EMR emr; //!< U_EMR uint32_t ihCS; //!< Index of the logical color space object in the EMF object table @@ -2547,11 +3131,15 @@ typedef struct { uint32_t dwFlags; //!< If low bit set Data is present U_CBDATA cbData; //!< Number of bytes of theData field. uint8_t Data[1]; //!< (Optional, dwFlags & 1) color profile data -} U_EMRCREATECOLORSPACEW, *PU_EMRCREATECOLORSPACEW; +} U_EMRCREATECOLORSPACEW, + *PU_EMRCREATECOLORSPACEW; //!< EMF manual 2.3.7.3 // ************************************************************************************************ // Utility function structures +/** + Storage for keeping track of properties of the growing EMF file as records are added. +*/ typedef struct { FILE *fp; //!< Open file size_t allocated; //!< Size of the buffer @@ -2591,11 +3179,13 @@ typedef struct { double M12; //!< Matrix element 1,2 double M21; //!< Matrix element 2,1 double M22; //!< Matrix element 2,2 -} U_MAT2X2, *PU_MAT2X2; +} U_MAT2X2, + *PU_MAT2X2; //!< 2 x 2 matrix, used by xform_alt_set() function. // ************************************************************************************************ // Prototypes +//! \cond int memprobe(const void *buf, size_t size); void wchar8show(const char *src); void wchar16show(const uint16_t *src); @@ -2652,7 +3242,9 @@ U_POINT16 point16_set(int16_t x, int16_t y); U_PANOSE panose_set(uint8_t bFamilyType, uint8_t bSerifStyle, uint8_t bWeight, uint8_t bProportion, uint8_t bContrast, uint8_t bStrokeVariation, uint8_t bArmStyle, uint8_t bLetterform, uint8_t bMidline, uint8_t bXHeight ); -U_COLORREF colorref_set(uint8_t red, uint8_t green, uint8_t blue); +U_COLORREF colorref3_set(uint8_t red, uint8_t green, uint8_t blue); +U_COLORREF colorref4_set(uint8_t red, uint8_t green, uint8_t blue, uint8_t reserved); +U_RGBQUAD rgbquad_set(uint8_t red,uint8_t green, uint8_t blue, uint8_t reserved); U_LOGBRUSH logbrush_set(uint32_t lbStyle, U_COLORREF lbColor, int32_t lbHatch); U_XFORM xform_set(U_FLOAT eM11, U_FLOAT eM12, U_FLOAT eM21, U_FLOAT eM22, U_FLOAT eDx, U_FLOAT eDy); U_XFORM xform_alt_set(U_FLOAT scale, U_FLOAT ratio, U_FLOAT rot, U_FLOAT axisrot, U_FLOAT eDx, U_FLOAT eDy); @@ -2865,8 +3457,9 @@ char *U_EMRSMALLTEXTOUT_set(const U_POINTL Dest, const U_NUM_STR cChars, const u // U_EMRFORCEUFIMAPPING_set 109 Not implemented // U_EMRNAMEDESCAPE_set 110 Not implemented // U_EMRCOLORCORRECTPALETTE_set 111 Not implemented -// U_EMRSETICMPROFILEA_set 112 Not implemented -// U_EMRSETICMPROFILEW_set 113 Not implemented +// U_EMRSETICMPROFILEA_set 112 Not implemented +// U_EMRSETICMPROFILEW_set 113 Not implemented + char *U_EMRALPHABLEND_set(const U_RECTL rclBounds, const U_POINTL Dest, const U_POINTL cDest, const U_POINTL Src, const U_POINTL cSrc, const U_XFORM xformSrc, const U_COLORREF crBkColorSrc, const uint32_t iUsageSrc, @@ -2886,6 +3479,8 @@ char *U_EMRGRADIENTFILL_set(const U_RECTL rclBounds, const U_NUM_TRIVERTEX nTriV char *U_EMRCREATECOLORSPACEW_set(const uint32_t ihCS, const U_LOGCOLORSPACEW lcs, const uint32_t dwFlags, const U_CBDATA cbData, const uint8_t *Data); +//! \endcond + #ifdef __cplusplus } #endif diff --git a/src/libuemf/uemf_endian.c b/src/libuemf/uemf_endian.c index cdae07a3d..f025416c3 100644 --- a/src/libuemf/uemf_endian.c +++ b/src/libuemf/uemf_endian.c @@ -1,5 +1,7 @@ /** - @file uemf_endian.c Functions for converting EMF records between Big Endian and Little Endian + @file uemf_endian.c + + @brief Functions for converting EMF records between Big Endian and Little Endian byte orders. EMF files use Little Endian order. On a Big Endian machine the data must be converted to/from Little Endian when it is writen to/read from a file. @@ -16,12 +18,12 @@ */ /* -File: uemf_endian.h -Version: 0.0.12 -Date: 14-FEB-2013 +File: uemf_endian.c +Version: 0.0.14 +Date: 15-JAN-2014 Author: David Mathog, Biology Division, Caltech email: mathog@caltech.edu -Copyright: 2013 David Mathog and California Institute of Technology (Caltech) +Copyright: 2014 David Mathog and California Institute of Technology (Caltech) */ #ifdef __cplusplus @@ -35,7 +37,7 @@ extern "C" { #include "uemf_endian.h" // hide almost everuything in here from Doxygen -//! @cond +//! \cond /* ********************************************************************************************** These functions convert standard objects used in the EMR records. @@ -1095,7 +1097,7 @@ void U_EMRABORTPATH_swap(char *record, int torev){ } // U_EMRUNDEF69 69 -#define U_EMRUNDEF69_swap U_EMRNOTIMPLEMENTED_swap +#define U_EMRUNDEF69_swap(A,B) U_EMRNOTIMPLEMENTED_swap(A,B) //!< Not implemented. // U_EMRCOMMENT 70 Comment (any binary data, interpretation is program specific) void U_EMRCOMMENT_swap(char *record, int torev){ @@ -1458,9 +1460,9 @@ void U_EMREXTCREATEPEN_swap(char *record, int torev){ } // U_EMRPOLYTEXTOUTA 96 NOT IMPLEMENTED, denigrated after Windows NT -#define U_EMRPOLYTEXTOUTA_swap U_EMRNOTIMPLEMENTED_swap +#define U_EMRPOLYTEXTOUTA_swap(A,B) U_EMRNOTIMPLEMENTED_swap(A,B) //!< Not implemented. // U_EMRPOLYTEXTOUTW 97 NOT IMPLEMENTED, denigrated after Windows NT -#define U_EMRPOLYTEXTOUTW_swap U_EMRNOTIMPLEMENTED_swap +#define U_EMRPOLYTEXTOUTW_swap(A,B) U_EMRNOTIMPLEMENTED_swap(A,B) //!< Not implemented. // U_EMRSETICMMODE 98 void U_EMRSETICMMODE_swap(char *record, int torev){ @@ -1486,9 +1488,9 @@ void U_EMRDELETECOLORSPACE_swap(char *record, int torev){ } // U_EMRGLSRECORD 102 Not implemented -#define U_EMRGLSRECORD_swap U_EMRNOTIMPLEMENTED_swap +#define U_EMRGLSRECORD_swap(A,B) U_EMRNOTIMPLEMENTED_swap(A,B) //!< Not implemented. // U_EMRGLSBOUNDEDRECORD 103 Not implemented -#define U_EMRGLSBOUNDEDRECORD_swap U_EMRNOTIMPLEMENTED_swap +#define U_EMRGLSBOUNDEDRECORD_swap(A,B) U_EMRNOTIMPLEMENTED_swap(A,B) //!< Not implemented. // U_EMRPIXELFORMAT 104 void U_EMRPIXELFORMAT_swap(char *record, int torev){ @@ -1498,11 +1500,11 @@ void U_EMRPIXELFORMAT_swap(char *record, int torev){ } // U_EMRDRAWESCAPE 105 Not implemented -#define U_EMRDRAWESCAPE_swap U_EMRNOTIMPLEMENTED_swap +#define U_EMRDRAWESCAPE_swap(A,B) U_EMRNOTIMPLEMENTED_swap(A,B) //!< Not implemented. // U_EMREXTESCAPE 106 Not implemented -#define U_EMREXTESCAPE_swap U_EMRNOTIMPLEMENTED_swap +#define U_EMREXTESCAPE_swap(A,B) U_EMRNOTIMPLEMENTED_swap(A,B) //!< Not implemented. // U_EMRUNDEF107 107 Not implemented -#define U_EMRUNDEF107_swap U_EMRNOTIMPLEMENTED_swap +#define U_EMRUNDEF107_swap(A,B) U_EMRNOTIMPLEMENTED_swap(A,B) //!< Not implemented. // U_EMRSMALLTEXTOUT 108 void U_EMRSMALLTEXTOUT_swap(char *record, int torev){ @@ -1526,15 +1528,15 @@ void U_EMRSMALLTEXTOUT_swap(char *record, int torev){ } // U_EMRFORCEUFIMAPPING 109 Not implemented -#define U_EMRFORCEUFIMAPPING_swap U_EMRNOTIMPLEMENTED_swap +#define U_EMRFORCEUFIMAPPING_swap(A,B) U_EMRNOTIMPLEMENTED_swap(A,B) //!< Not implemented. // U_EMRNAMEDESCAPE 110 Not implemented -#define U_EMRNAMEDESCAPE_swap U_EMRNOTIMPLEMENTED_swap +#define U_EMRNAMEDESCAPE_swap(A,B) U_EMRNOTIMPLEMENTED_swap(A,B) //!< Not implemented. // U_EMRCOLORCORRECTPALETTE 111 Not implemented -#define U_EMRCOLORCORRECTPALETTE_swap U_EMRNOTIMPLEMENTED_swap +#define U_EMRCOLORCORRECTPALETTE_swap(A,B) U_EMRNOTIMPLEMENTED_swap(A,B) //!< Not implemented. // U_EMRSETICMPROFILEA 112 Not implemented -#define U_EMRSETICMPROFILEA_swap U_EMRNOTIMPLEMENTED_swap +#define U_EMRSETICMPROFILEA_swap(A,B) U_EMRNOTIMPLEMENTED_swap(A,B) //!< Not implemented. // U_EMRSETICMPROFILEW 113 Not implemented -#define U_EMRSETICMPROFILEW_swap U_EMRNOTIMPLEMENTED_swap +#define U_EMRSETICMPROFILEW_swap(A,B) U_EMRNOTIMPLEMENTED_swap(A,B) //!< Not implemented. // U_EMRALPHABLEND 114 void U_EMRALPHABLEND_swap(char *record, int torev){ @@ -1553,7 +1555,7 @@ void U_EMRTRANSPARENTBLT_swap(char *record, int torev){ // U_EMRUNDEF117 117 Not implemented -#define U_EMRUNDEF117_swap U_EMRNOTIMPLEMENTED_swap +#define U_EMRUNDEF117_swap(A,B) U_EMRNOTIMPLEMENTED_swap(A,B) //!< Not implemented. // U_EMRGRADIENTFILL 118 void U_EMRGRADIENTFILL_swap(char *record, int torev){ int nTriVert=0; @@ -1589,11 +1591,11 @@ void U_EMRGRADIENTFILL_swap(char *record, int torev){ } // U_EMRSETLINKEDUFIS 119 Not implemented -#define U_EMRSETLINKEDUFIS_swap U_EMRNOTIMPLEMENTED_swap +#define U_EMRSETLINKEDUFIS_swap(A,B) U_EMRNOTIMPLEMENTED_swap(A,B) //!< Not implemented. // U_EMRSETTEXTJUSTIFICATION120 Not implemented (denigrated) -#define U_EMRSETTEXTJUSTIFICATION_swap U_EMRNOTIMPLEMENTED_swap +#define U_EMRSETTEXTJUSTIFICATION_swap(A,B) U_EMRNOTIMPLEMENTED_swap(A,B) //!< Not implemented. // U_EMRCOLORMATCHTOTARGETW 121 Not implemented -#define U_EMRCOLORMATCHTOTARGETW_swap U_EMRNOTIMPLEMENTED_swap +#define U_EMRCOLORMATCHTOTARGETW_swap(A,B) U_EMRNOTIMPLEMENTED_swap(A,B) //!< Not implemented. // U_EMRCREATECOLORSPACEW 122 void U_EMRCREATECOLORSPACEW_swap(char *record, int torev){ @@ -1605,7 +1607,7 @@ void U_EMRCREATECOLORSPACEW_swap(char *record, int torev){ // ordered bytes: Data } -//! @endcond +//! \endcond /** @@ -1619,7 +1621,7 @@ void U_EMRCREATECOLORSPACEW_swap(char *record, int torev){ or immediately after reading the data from a file. */ int U_emf_endian(char *contents, size_t length, int torev){ - size_t off; + uint32_t off; uint32_t OK, recnum, iType; char *record; PU_ENHMETARECORD pEmr; diff --git a/src/libuemf/uemf_endian.h b/src/libuemf/uemf_endian.h index 9866aacaf..317968c34 100644 --- a/src/libuemf/uemf_endian.h +++ b/src/libuemf/uemf_endian.h @@ -1,5 +1,7 @@ /** - @file uemf_endian.h Prototype for function for converting EMF records between Big Endian and Little Endian + @file uemf_endian.h + + @brief Defintions and prototype for function for converting EMF records between Big Endian and Little Endian byte orders. */ /* @@ -18,17 +20,36 @@ Copyright: 2012 David Mathog and California Institute of Technology (Caltech) extern "C" { #endif -/* There is no way for the preprocessor, in general, to figure out endianness. So the command line must define +/** \defgroup U_Endian Byte order identification + + There is no way for the preprocessor, in general, to figure out endianness. So the command line must define WORDS_BIGENDIAN for a big endian machine. Otherwise we assume is is little endian. If it is something - else this code won't work in any case. */ + else this code won't work in any case. + + @{ +*/ + #ifdef WORDS_BIGENDIAN -#define U_BYTE_SWAP 1 +#define U_BYTE_SWAP 1 //!< byte swapping into metafile is required +#define U_IS_BE 1 //!< this machine is big endian +#define U_IS_LE 0 //!< this machine is not little endian #else -#define U_BYTE_SWAP 0 +#define U_BYTE_SWAP 0 //!< byte swapping into metafile is not required +#define U_IS_BE 0 //!< this machine is not big endian +#define U_IS_LE 1 //!< this machine is little endian #endif +#define U_XE 0 //!< do not rearrange endian for target +#define U_LE 1 //!< target is Little Endian +#define U_BE 2 //!< target is Big Endian +#define U_RP 4 //!< replicate first instance +#define U_XX 0xFF //!< may be used to terminate a list of these target entries +/** @} */ + +//! \cond // prototypes int U_emf_endian(char *contents, size_t length, int torev); +//! \endcond #ifdef __cplusplus } diff --git a/src/libuemf/uemf_print.c b/src/libuemf/uemf_print.c index b7cbf9a14..aa574bd73 100644 --- a/src/libuemf/uemf_print.c +++ b/src/libuemf/uemf_print.c @@ -1,11 +1,13 @@ /** - @file uemf_print.c Functions for printing EMF records + @file uemf_print.c + + @brief Functions for printing EMF records */ /* File: uemf_print.c -Version: 0.0.12 -Date: 04-FEB-2013 +Version: 0.0.15 +Date: 17-OCT-2013 Author: David Mathog, Biology Division, Caltech email: mathog@caltech.edu Copyright: 2013 David Mathog and California Institute of Technology (Caltech) @@ -20,6 +22,14 @@ extern "C" { #include <stddef.h> /* for offsetof() macro */ #include <string.h> #include "uemf.h" +#include "upmf_print.h" + +//! \cond +#define UNUSED(x) (void)(x) + +/* one needed prototype */ +void U_swap4(void *ul, unsigned int count); +//! \endcond /** \brief Print some number of hex bytes @@ -395,7 +405,7 @@ void blend_print( void extlogpen_print( PU_EXTLOGPEN elp ){ - unsigned i; + unsigned int i; U_STYLEENTRY *elpStyleEntry; printf("elpPenStyle:0x%8.8X " ,elp->elpPenStyle ); printf("elpWidth:%u " ,elp->elpWidth ); @@ -407,7 +417,7 @@ void extlogpen_print( printf("elpStyleEntry:"); elpStyleEntry = (uint32_t *) elp->elpStyleEntry; for(i=0;i<elp->elpNumEntries;i++){ - printf("%u:%u ",i,elpStyleEntry[i]); + printf("%d:%u ",i,elpStyleEntry[i]); } } } @@ -420,7 +430,7 @@ void extlogpen_print( void logpen_print( U_LOGPEN lp ){ - printf("lopnStyle:%u " ,lp.lopnStyle ); + printf("lopnStyle:0x%8.8X " ,lp.lopnStyle ); printf("lopnWidth:"); pointl_print( lp.lopnWidth ); printf("lopnColor:"); colorref_print(lp.lopnColor ); } @@ -478,13 +488,13 @@ void rgndataheader_print( void rgndata_print( PU_RGNDATA rd ){ - unsigned i; + unsigned int i; PU_RECTL rects; printf("rdh:"); rgndataheader_print(rd->rdh ); if(rd->rdh.nCount){ rects = (PU_RECTL) &(rd->Buffer); for(i=0;i<rd->rdh.nCount;i++){ - printf("%u:",i); rectl_print(rects[i]); + printf("%d:",i); rectl_print(rects[i]); } } } @@ -497,7 +507,7 @@ void coloradjustment_print( U_COLORADJUSTMENT ca ){ printf("caSize:%u " ,ca.caSize ); - printf("caFlags:%u " ,ca.caFlags ); + printf("caFlags:0x%4.4X " ,ca.caFlags ); printf("caIlluminantIndex:%u " ,ca.caIlluminantIndex); printf("caRedGamma:%u " ,ca.caRedGamma ); printf("caGreenGamma:%u " ,ca.caGreenGamma ); @@ -519,7 +529,7 @@ void pixelformatdescriptor_print( ){ printf("nSize:%u " ,pfd.nSize ); printf("nVersion:%u " ,pfd.nVersion ); - printf("dwFlags:%u " ,pfd.dwFlags ); + printf("dwFlags:0x%8.8X " ,pfd.dwFlags ); printf("iPixelType:%u " ,pfd.iPixelType ); printf("cColorBits:%u " ,pfd.cColorBits ); printf("cRedBits:%u " ,pfd.cRedBits ); @@ -556,7 +566,7 @@ void emrtext_print( const char *record, int type ){ - unsigned i, off; + unsigned int i,off; char *string; PU_EMRTEXT pemt = (PU_EMRTEXT) emt; // constant part @@ -573,7 +583,7 @@ void emrtext_print( free(string); } } - printf("fOptions:%u " ,pemt->fOptions ); + printf("fOptions:0x%8.8X " ,pemt->fOptions ); off = sizeof(U_EMRTEXT); if(!(pemt->fOptions & U_ETO_NO_RECT)){ printf("rcl"); rectl_print( *((U_RECTL *)(emt+off)) ); @@ -609,35 +619,35 @@ by end user code and to further that end prototypes are NOT provided and they ar // Functions with the same form starting with U_EMRPOLYBEZIER_print void core1_print(const char *name, const char *contents){ - unsigned i; - (void) name; + unsigned int i; + UNUSED(name); PU_EMRPOLYLINETO pEmr = (PU_EMRPOLYLINETO) (contents); printf(" rclBounds: "); rectl_print(pEmr->rclBounds); printf("\n"); printf(" cptl: %d\n",pEmr->cptl ); printf(" Points: "); for(i=0;i<pEmr->cptl; i++){ - printf("[%u]:",i); pointl_print(pEmr->aptl[i]); + printf("[%d]:",i); pointl_print(pEmr->aptl[i]); } printf("\n"); } // Functions with the same form starting with U_EMRPOLYPOLYLINE_print void core2_print(const char *name, const char *contents){ - unsigned i; - (void) name; + unsigned int i; + UNUSED(name); PU_EMRPOLYPOLYGON pEmr = (PU_EMRPOLYPOLYGON) (contents); printf(" rclBounds: "); rectl_print(pEmr->rclBounds); printf("\n"); printf(" nPolys: %d\n",pEmr->nPolys ); printf(" cptl: %d\n",pEmr->cptl ); printf(" Counts: "); for(i=0;i<pEmr->nPolys; i++){ - printf(" [%u]:%d ",i,pEmr->aPolyCounts[i] ); + printf(" [%d]:%d ",i,pEmr->aPolyCounts[i] ); } printf("\n"); PU_POINTL paptl = (PU_POINTL)((char *)pEmr->aPolyCounts + sizeof(uint32_t)* pEmr->nPolys); printf(" Points: "); for(i=0;i<pEmr->cptl; i++){ - printf(" [%u]:",i); pointl_print(paptl[i]); + printf(" [%d]:",i); pointl_print(paptl[i]); } printf("\n"); } @@ -645,8 +655,8 @@ void core2_print(const char *name, const char *contents){ // Functions with the same form starting with U_EMRSETMAPMODE_print void core3_print(const char *name, const char *label, const char *contents){ + UNUSED(name); PU_EMRSETMAPMODE pEmr = (PU_EMRSETMAPMODE)(contents); - (void) name; if(!strcmp(label,"crColor:")){ printf(" %-15s ",label); colorref_print(*(U_COLORREF *)&(pEmr->iMode)); printf("\n"); } @@ -660,22 +670,22 @@ void core3_print(const char *name, const char *label, const char *contents){ // Functions taking a single U_RECT or U_RECTL, starting with U_EMRELLIPSE_print, also U_EMRFILLPATH_print, void core4_print(const char *name, const char *contents){ + UNUSED(name); PU_EMRELLIPSE pEmr = (PU_EMRELLIPSE)( contents); - (void) name; printf(" rclBox: "); rectl_print(pEmr->rclBox); printf("\n"); } // Functions with the same form starting with U_EMRPOLYBEZIER16_print void core6_print(const char *name, const char *contents){ - unsigned i; - (void) name; + UNUSED(name); + unsigned int i; PU_EMRPOLYBEZIER16 pEmr = (PU_EMRPOLYBEZIER16) (contents); printf(" rclBounds: "); rectl_print(pEmr->rclBounds); printf("\n"); printf(" cpts: %d\n",pEmr->cpts ); printf(" Points: "); PU_POINT16 papts = (PU_POINT16)(&(pEmr->apts)); for(i=0; i<pEmr->cpts; i++){ - printf(" [%u]:",i); point16_print(papts[i]); + printf(" [%d]:",i); point16_print(papts[i]); } printf("\n"); } @@ -686,8 +696,8 @@ void core6_print(const char *name, const char *contents){ // print routines must supply the names of the two arguments. These cannot be null. If the second one is // empty the values are printed as a pair {x,y}, otherwise each is printed with its own label on a separate line. void core7_print(const char *name, const char *field1, const char *field2, const char *contents){ + UNUSED(name); PU_EMRGENERICPAIR pEmr = (PU_EMRGENERICPAIR) (contents); - (void) name; if(*field2){ printf(" %-15s %d\n",field1,pEmr->pair.x); printf(" %-15s %d\n",field2,pEmr->pair.y); @@ -699,8 +709,8 @@ void core7_print(const char *name, const char *field1, const char *field2, const // For U_EMREXTTEXTOUTA and U_EMREXTTEXTOUTW, type=0 for the first one void core8_print(const char *name, const char *contents, int type){ + UNUSED(name); PU_EMREXTTEXTOUTA pEmr = (PU_EMREXTTEXTOUTA) (contents); - (void) name; printf(" iGraphicsMode: %u\n",pEmr->iGraphicsMode ); printf(" rclBounds: "); rectl_print(pEmr->rclBounds); printf("\n"); printf(" exScale: %f\n",pEmr->exScale ); @@ -712,8 +722,8 @@ void core8_print(const char *name, const char *contents, int type){ // Functions that take a rect and a pair of points, starting with U_EMRARC_print void core9_print(const char *name, const char *contents){ + UNUSED(name); PU_EMRARC pEmr = (PU_EMRARC) (contents); - (void) name; printf(" rclBox: "); rectl_print(pEmr->rclBox); printf("\n"); printf(" ptlStart: "); pointl_print(pEmr->ptlStart); printf("\n"); printf(" ptlEnd: "); pointl_print(pEmr->ptlEnd); printf("\n"); @@ -721,21 +731,21 @@ void core9_print(const char *name, const char *contents){ // Functions with the same form starting with U_EMRPOLYPOLYLINE16_print void core10_print(const char *name, const char *contents){ - unsigned i; + UNUSED(name); + unsigned int i; PU_EMRPOLYPOLYLINE16 pEmr = (PU_EMRPOLYPOLYLINE16) (contents); - (void) name; printf(" rclBounds: "); rectl_print(pEmr->rclBounds); printf("\n"); printf(" nPolys: %d\n",pEmr->nPolys ); printf(" cpts: %d\n",pEmr->cpts ); printf(" Counts: "); for(i=0;i<pEmr->nPolys; i++){ - printf(" [%u]:%d ",i,pEmr->aPolyCounts[i] ); + printf(" [%d]:%d ",i,pEmr->aPolyCounts[i] ); } printf("\n"); printf(" Points: "); PU_POINT16 papts = (PU_POINT16)((char *)pEmr->aPolyCounts + sizeof(uint32_t)* pEmr->nPolys); for(i=0; i<pEmr->cpts; i++){ - printf(" [%u]:",i); point16_print(papts[i]); + printf(" [%d]:",i); point16_print(papts[i]); } printf("\n"); @@ -743,17 +753,17 @@ void core10_print(const char *name, const char *contents){ // Functions with the same form starting with U_EMRINVERTRGN_print and U_EMRPAINTRGN_print, void core11_print(const char *name, const char *contents){ - unsigned i,roff; + UNUSED(name); + unsigned int i,roff; PU_EMRINVERTRGN pEmr = (PU_EMRINVERTRGN) (contents); - (void) name; printf(" rclBounds: "); rectl_print(pEmr->rclBounds); printf("\n"); printf(" cbRgnData: %d\n",pEmr->cbRgnData); // This one is a pain since each RGNDATA may be a different size, so it isn't possible to index through them. roff=0; i=1; char *prd = (char *) &(pEmr->RgnData); - while(roff + 28 < pEmr->emr.nSize){ // up to the end of the record - printf(" RegionData:%u",i); + while(roff + sizeof(U_RGNDATAHEADER) < pEmr->cbRgnData){ // stop at end of the record 4*4 = header + 4*4=rect + printf(" RegionData:%d",i); rgndata_print((PU_RGNDATA) (prd + roff)); roff += (((PU_RGNDATA)prd)->rdh.dwSize + ((PU_RGNDATA)prd)->rdh.nRgnSize - 16); printf("\n"); @@ -763,8 +773,8 @@ void core11_print(const char *name, const char *contents){ // common code for U_EMRCREATEMONOBRUSH_print and U_EMRCREATEDIBPATTERNBRUSHPT_print, void core12_print(const char *name, const char *contents){ + UNUSED(name); PU_EMRCREATEMONOBRUSH pEmr = (PU_EMRCREATEMONOBRUSH) (contents); - (void) name; printf(" ihBrush: %u\n",pEmr->ihBrush ); printf(" iUsage : %u\n",pEmr->iUsage ); printf(" offBmi : %u\n",pEmr->offBmi ); @@ -780,8 +790,8 @@ void core12_print(const char *name, const char *contents){ // common code for U_EMRALPHABLEND_print and U_EMRTRANSPARENTBLT_print, void core13_print(const char *name, const char *contents){ + UNUSED(name); PU_EMRALPHABLEND pEmr = (PU_EMRALPHABLEND) (contents); - (void) name; printf(" rclBounds: "); rectl_print( pEmr->rclBounds); printf("\n"); printf(" Dest: "); pointl_print(pEmr->Dest); printf("\n"); printf(" cDest: "); pointl_print(pEmr->cDest); printf("\n"); @@ -814,8 +824,8 @@ They are listed in order by the corresponding U_EMR_* index number. \param contents pointer to a buffer holding all EMR records */ void U_EMRNOTIMPLEMENTED_print(const char *name, const char *contents){ - (void) name; - (void) contents; + UNUSED(name); + UNUSED(contents); printf(" Not Implemented!\n"); } @@ -1016,7 +1026,7 @@ void U_EMRSETPIXELV_print(const char *contents){ */ void U_EMRSETMAPPERFLAGS_print(const char *contents){ PU_EMRSETMAPPERFLAGS pEmr = (PU_EMRSETMAPPERFLAGS)(contents); - printf(" dwFlags: %u\n",pEmr->dwFlags); + printf(" dwFlags: 0x%8.8X\n",pEmr->dwFlags); } @@ -1128,7 +1138,7 @@ void U_EMRMOVETOEX_print(const char *contents){ \param contents pointer to a buffer holding all EMR records */ void U_EMRSETMETARGN_print(const char *contents){ - (void) contents; + UNUSED(contents); } // U_EMREXCLUDECLIPRECT 29 @@ -1174,7 +1184,7 @@ void U_EMRSCALEWINDOWEXTEX_print(const char *contents){ \param contents pointer to a buffer holding all EMR records */ void U_EMRSAVEDC_print(const char *contents){ - (void) contents; + UNUSED(contents); } // U_EMRRESTOREDC 34 @@ -1353,7 +1363,7 @@ void U_EMRCREATEPALETTE_print(const char *contents){ \param contents pointer to a buffer holding all EMR records */ void U_EMRSETPALETTEENTRIES_print(const char *contents){ - unsigned i; + unsigned int i; PU_EMRSETPALETTEENTRIES pEmr = (PU_EMRSETPALETTEENTRIES)(contents); printf(" ihPal: %u\n",pEmr->ihPal); printf(" iStart: %u\n",pEmr->iStart); @@ -1362,7 +1372,7 @@ void U_EMRSETPALETTEENTRIES_print(const char *contents){ printf(" PLTEntries:"); PU_LOGPLTNTRY aPalEntries = (PU_LOGPLTNTRY) &(pEmr->aPalEntries); for(i=0; i<pEmr->cEntries; i++){ - printf("%u:",i); logpltntry_print(aPalEntries[i]); + printf("%d:",i); logpltntry_print(aPalEntries[i]); } printf("\n"); } @@ -1383,7 +1393,7 @@ void U_EMRRESIZEPALETTE_print(const char *contents){ \param contents pointer to a buffer holding all EMR records */ void U_EMRREALIZEPALETTE_print(const char *contents){ - (void) contents; + UNUSED(contents); } // U_EMREXTFLOODFILL 53 @@ -1422,19 +1432,19 @@ void U_EMRARCTO_print(const char *contents){ \param contents pointer to a buffer holding all EMR records */ void U_EMRPOLYDRAW_print(const char *contents){ - unsigned i; + unsigned int i; PU_EMRPOLYDRAW pEmr = (PU_EMRPOLYDRAW)(contents); printf(" rclBounds: "); rectl_print( pEmr->rclBounds); printf("\n"); printf(" cptl: %d\n",pEmr->cptl ); printf(" Points: "); for(i=0;i<pEmr->cptl; i++){ - printf(" [%u]:",i); + printf(" [%d]:",i); pointl_print(pEmr->aptl[i]); } printf("\n"); printf(" Types: "); for(i=0;i<pEmr->cptl; i++){ - printf(" [%u]:%u ",i,pEmr->abTypes[i]); + printf(" [%d]:%u ",i,pEmr->abTypes[i]); } printf("\n"); } @@ -1464,7 +1474,7 @@ void U_EMRSETMITERLIMIT_print(const char *contents){ \param contents pointer to a buffer holding all EMR records */ void U_EMRBEGINPATH_print(const char *contents){ - (void) contents; + UNUSED(contents); } // U_EMRENDPATH 60 @@ -1473,7 +1483,7 @@ void U_EMRBEGINPATH_print(const char *contents){ \param contents pointer to a buffer holding all EMR records */ void U_EMRENDPATH_print(const char *contents){ - (void) contents; + UNUSED(contents); } // U_EMRCLOSEFIGURE 61 @@ -1482,7 +1492,7 @@ void U_EMRENDPATH_print(const char *contents){ \param contents pointer to a buffer holding all EMR records */ void U_EMRCLOSEFIGURE_print(const char *contents){ - (void) contents; + UNUSED(contents); } // U_EMRFILLPATH 62 @@ -1518,7 +1528,7 @@ void U_EMRSTROKEPATH_print(const char *contents){ \param contents pointer to a buffer holding all EMR records */ void U_EMRFLATTENPATH_print(const char *contents){ - (void) contents; + UNUSED(contents); } // U_EMRWIDENPATH 66 @@ -1527,7 +1537,7 @@ void U_EMRFLATTENPATH_print(const char *contents){ \param contents pointer to a buffer holding all EMR records */ void U_EMRWIDENPATH_print(const char *contents){ - (void) contents; + UNUSED(contents); } // U_EMRSELECTCLIPPATH 67 @@ -1545,41 +1555,57 @@ void U_EMRSELECTCLIPPATH_print(const char *contents){ \param contents pointer to a buffer holding all EMR records */ void U_EMRABORTPATH_print(const char *contents){ - (void) contents; + UNUSED(contents); } // U_EMRUNDEF69 69 -#define U_EMRUNDEF69_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRUNDEF69",A) +#define U_EMRUNDEF69_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRUNDEF69",A) //!< Not implemented. // U_EMRCOMMENT 70 Comment (any binary data, interpretation is program specific) /** \brief Print a pointer to a U_EMR_COMMENT record. - \param contents pointer to a buffer holding all EMR records + \param contents pointer to a location in memory holding the comment record + \param blimit size in bytes of the comment record + \param off offset in bytes to the first byte in this record + + EMF+ records, if any, are stored in EMF comment records. */ -void U_EMRCOMMENT_print(const char *contents){ +void U_EMRCOMMENT_print(const char *contents, const char *blimit, size_t off){ char *string; char *src; - uint32_t cIdent,cbData; - PU_EMRCOMMENT pEmr = (PU_EMRCOMMENT)(contents); + uint32_t cIdent,cIdent2,cbData; + size_t loff; + int recsize; + static int recnum=0; + + PU_EMRCOMMENT pEmr = (PU_EMRCOMMENT)(contents); /* There are several different types of comments */ cbData = pEmr->cbData; printf(" cbData: %d\n",cbData ); - src = (char *)(&pEmr->Data); // default + src = (char *)&(pEmr->Data); // default if(cbData >= 4){ + /* Since the comment is just a big bag of bytes the emf endian code cannot safely touch + any of its payload. This is the only record type with that limitation. Try to determine + what the contents are even if more byte swapping is required. */ cIdent = *(uint32_t *)(src); + if(U_BYTE_SWAP){ U_swap4(&(cIdent),1); } if( cIdent == U_EMR_COMMENT_PUBLIC ){ printf(" cIdent: Public\n"); PU_EMRCOMMENT_PUBLIC pEmrp = (PU_EMRCOMMENT_PUBLIC) pEmr; - printf(" pcIdent: %8.8x\n",pEmrp->pcIdent); + cIdent2 = pEmrp->pcIdent; + if(U_BYTE_SWAP){ U_swap4(&(cIdent2),1); } + printf(" pcIdent: 0x%8.8x\n",cIdent2); src = (char *)&(pEmrp->Data); cbData -= 8; } else if(cIdent == U_EMR_COMMENT_SPOOL ){ printf(" cIdent: Spool\n"); PU_EMRCOMMENT_SPOOL pEmrs = (PU_EMRCOMMENT_SPOOL) pEmr; - printf(" esrIdent: %8.8x\n",pEmrs->esrIdent); + cIdent2 = pEmrs->esrIdent; + if(U_BYTE_SWAP){ U_swap4(&(cIdent2),1); } + printf(" esrIdent: 0x%8.8x\n",cIdent2); src = (char *)&(pEmrs->Data); cbData -= 8; } @@ -1587,7 +1613,15 @@ void U_EMRCOMMENT_print(const char *contents){ printf(" cIdent: EMF+\n"); PU_EMRCOMMENT_EMFPLUS pEmrpl = (PU_EMRCOMMENT_EMFPLUS) pEmr; src = (char *)&(pEmrpl->Data); - cbData -= 4; + loff = 16; /* Header size of the header part of an EMF+ comment record */ + while(loff < cbData + 12){ // EMF+ records may not fill the entire comment, cbData value includes cIdent, but not U_EMR or cbData + recsize = U_pmf_onerec_print(src, blimit, recnum, loff + off); + if(recsize<=0)break; + loff += recsize; + src += recsize; + recnum++; + } + return; } else { printf(" cIdent: not (Public or Spool or EMF+)\n"); @@ -1600,7 +1634,6 @@ void U_EMRCOMMENT_print(const char *contents){ printf(" Data: <%s>\n",string); free(string); } - } // U_EMRFILLRGN 71 @@ -1609,7 +1642,7 @@ void U_EMRCOMMENT_print(const char *contents){ \param contents pointer to a buffer holding all EMR records */ void U_EMRFILLRGN_print(const char *contents){ - unsigned i,roff; + int i,roff; PU_EMRFILLRGN pEmr = (PU_EMRFILLRGN)(contents); printf(" rclBounds: "); rectl_print(pEmr->rclBounds); printf("\n"); printf(" cbRgnData: %u\n",pEmr->cbRgnData); @@ -1618,8 +1651,8 @@ void U_EMRFILLRGN_print(const char *contents){ roff=0; i=1; char *prd = (char *) &(pEmr->RgnData); - while(roff + 28 < pEmr->emr.nSize){ // up to the end of the record - printf(" RegionData[%u]: ",i); rgndata_print((PU_RGNDATA) (prd + roff)); printf("\n"); + while(roff + sizeof(U_RGNDATAHEADER) < pEmr->emr.nSize){ // up to the end of the record + printf(" RegionData[%d]: ",i); rgndata_print((PU_RGNDATA) (prd + roff)); printf("\n"); roff += (((PU_RGNDATA)prd)->rdh.dwSize + ((PU_RGNDATA)prd)->rdh.nRgnSize - 16); } } @@ -1630,7 +1663,7 @@ void U_EMRFILLRGN_print(const char *contents){ \param contents pointer to a buffer holding all EMR records */ void U_EMRFRAMERGN_print(const char *contents){ - unsigned i,roff; + int i,roff; PU_EMRFRAMERGN pEmr = (PU_EMRFRAMERGN)(contents); printf(" rclBounds: "); rectl_print(pEmr->rclBounds); printf("\n"); printf(" cbRgnData: %u\n",pEmr->cbRgnData); @@ -1640,8 +1673,8 @@ void U_EMRFRAMERGN_print(const char *contents){ roff=0; i=1; char *prd = (char *) &(pEmr->RgnData); - while(roff + 28 < pEmr->emr.nSize){ // up to the end of the record - printf(" RegionData[%u]: ",i); rgndata_print((PU_RGNDATA) (prd + roff)); printf("\n"); + while(roff + sizeof(U_RGNDATAHEADER) < pEmr->emr.nSize){ // up to the end of the record + printf(" RegionData[%d]: ",i); rgndata_print((PU_RGNDATA) (prd + roff)); printf("\n"); roff += (((PU_RGNDATA)prd)->rdh.dwSize + ((PU_RGNDATA)prd)->rdh.nRgnSize - 16); } } @@ -1670,14 +1703,14 @@ void U_EMRPAINTRGN_print(const char *contents){ \param contents pointer to a buffer holding all EMR records */ void U_EMREXTSELECTCLIPRGN_print(const char *contents){ - unsigned i,roff; + int i,roff; PU_EMREXTSELECTCLIPRGN pEmr = (PU_EMREXTSELECTCLIPRGN) (contents); printf(" cbRgnData: %u\n",pEmr->cbRgnData); printf(" iMode: %u\n",pEmr->iMode); // This one is a pain since each RGNDATA may be a different size, so it isn't possible to index through them. char *prd = (char *) &(pEmr->RgnData); i=roff=0; - while(roff + 16 < pEmr->emr.nSize){ // stop at end of the record + while(roff + sizeof(U_RGNDATAHEADER) < pEmr->cbRgnData){ // stop at end of the record 4*4 = header + 4*4=rect printf(" RegionData[%d]: ",i++); rgndata_print((PU_RGNDATA) (prd + roff)); printf("\n"); roff += (((PU_RGNDATA)prd)->rdh.dwSize + ((PU_RGNDATA)prd)->rdh.nRgnSize - 16); } @@ -1693,7 +1726,7 @@ void U_EMRBITBLT_print(const char *contents){ printf(" rclBounds: "); rectl_print( pEmr->rclBounds); printf("\n"); printf(" Dest: "); pointl_print(pEmr->Dest); printf("\n"); printf(" cDest: "); pointl_print(pEmr->cDest); printf("\n"); - printf(" dwRop : %u\n", pEmr->dwRop ); + printf(" dwRop : 0x%8.8X\n", pEmr->dwRop ); printf(" Src: "); pointl_print(pEmr->Src); printf("\n"); printf(" xformSrc: "); xform_print( pEmr->xformSrc); printf("\n"); printf(" crBkColorSrc: "); colorref_print( pEmr->crBkColorSrc); printf("\n"); @@ -1719,7 +1752,7 @@ void U_EMRSTRETCHBLT_print(const char *contents){ printf(" rclBounds: "); rectl_print( pEmr->rclBounds); printf("\n"); printf(" Dest: "); pointl_print(pEmr->Dest); printf("\n"); printf(" cDest: "); pointl_print(pEmr->cDest); printf("\n"); - printf(" dwRop : %u\n", pEmr->dwRop ); + printf(" dwRop : 0x%8.8X\n", pEmr->dwRop ); printf(" Src: "); pointl_print(pEmr->Src); printf("\n"); printf(" xformSrc: "); xform_print( pEmr->xformSrc); printf("\n"); printf(" crBkColorSrc: "); colorref_print( pEmr->crBkColorSrc); printf("\n"); @@ -1746,7 +1779,7 @@ void U_EMRMASKBLT_print(const char *contents){ printf(" rclBounds: "); rectl_print( pEmr->rclBounds); printf("\n"); printf(" Dest: "); pointl_print(pEmr->Dest); printf("\n"); printf(" cDest: "); pointl_print(pEmr->cDest); printf("\n"); - printf(" dwRop : %u\n", pEmr->dwRop ); + printf(" dwRop : 0x%8.8X\n", pEmr->dwRop ); printf(" Src: "); pointl_print(pEmr->Src); printf("\n"); printf(" xformSrc: "); xform_print( pEmr->xformSrc); printf("\n"); printf(" crBkColorSrc: "); colorref_print( pEmr->crBkColorSrc); printf("\n"); @@ -1857,7 +1890,7 @@ void U_EMRSTRETCHDIBITS_print(const char *contents){ printf(" offBitsSrc: %u\n", pEmr->offBitsSrc ); printf(" cbBitsSrc: %u\n", pEmr->cbBitsSrc ); printf(" iUsageSrc: %u\n", pEmr->iUsageSrc ); - printf(" dwRop : %u\n", pEmr->dwRop ); + printf(" dwRop : 0x%8.8X\n", pEmr->dwRop ); printf(" cDest: "); pointl_print(pEmr->cDest); printf("\n"); } @@ -1967,19 +2000,19 @@ void U_EMRPOLYPOLYGON16_print(const char *contents){ \param contents pointer to a buffer holding all EMR records */ void U_EMRPOLYDRAW16_print(const char *contents){ - unsigned i; + unsigned int i; PU_EMRPOLYDRAW16 pEmr = (PU_EMRPOLYDRAW16)(contents); printf(" rclBounds: "); rectl_print( pEmr->rclBounds); printf("\n"); printf(" cpts: %d\n",pEmr->cpts ); printf(" Points: "); for(i=0;i<pEmr->cpts; i++){ - printf(" [%u]:",i); + printf(" [%d]:",i); point16_print(pEmr->apts[i]); } printf("\n"); printf(" Types: "); for(i=0;i<pEmr->cpts; i++){ - printf(" [%u]:%u ",i,pEmr->abTypes[i]); + printf(" [%d]:%u ",i,pEmr->abTypes[i]); } printf("\n"); } @@ -2024,9 +2057,9 @@ void U_EMREXTCREATEPEN_print(const char *contents){ } // U_EMRPOLYTEXTOUTA 96 NOT IMPLEMENTED, denigrated after Windows NT -#define U_EMRPOLYTEXTOUTA_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRPOLYTEXTOUTA",A) +#define U_EMRPOLYTEXTOUTA_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRPOLYTEXTOUTA",A) //!< Not implemented. // U_EMRPOLYTEXTOUTW 97 NOT IMPLEMENTED, denigrated after Windows NT -#define U_EMRPOLYTEXTOUTW_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRPOLYTEXTOUTW",A) +#define U_EMRPOLYTEXTOUTW_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRPOLYTEXTOUTW",A) //!< Not implemented. // U_EMRSETICMMODE 98 /** @@ -2067,9 +2100,9 @@ void U_EMRDELETECOLORSPACE_print(const char *contents){ } // U_EMRGLSRECORD 102 Not implemented -#define U_EMRGLSRECORD_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRGLSRECORD",A) +#define U_EMRGLSRECORD_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRGLSRECORD",A) //!< Not implemented. // U_EMRGLSBOUNDEDRECORD 103 Not implemented -#define U_EMRGLSBOUNDEDRECORD_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRGLSBOUNDEDRECORD",A) +#define U_EMRGLSBOUNDEDRECORD_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRGLSBOUNDEDRECORD",A) //!< Not implemented. // U_EMRPIXELFORMAT 104 /** @@ -2082,11 +2115,11 @@ void U_EMRPIXELFORMAT_print(const char *contents){ } // U_EMRDRAWESCAPE 105 Not implemented -#define U_EMRDRAWESCAPE_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRDRAWESCAPE",A) +#define U_EMRDRAWESCAPE_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRDRAWESCAPE",A) //!< Not implemented. // U_EMREXTESCAPE 106 Not implemented -#define U_EMREXTESCAPE_print(A) U_EMRNOTIMPLEMENTED_print("U_EMREXTESCAPE",A) +#define U_EMREXTESCAPE_print(A) U_EMRNOTIMPLEMENTED_print("U_EMREXTESCAPE",A) //!< Not implemented. // U_EMRUNDEF107 107 Not implemented -#define U_EMRUNDEF107_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRUNDEF107",A) +#define U_EMRUNDEF107_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRUNDEF107",A) //!< Not implemented. // U_EMRSMALLTEXTOUT 108 /** @@ -2119,15 +2152,15 @@ void U_EMRSMALLTEXTOUT_print(const char *contents){ } // U_EMRFORCEUFIMAPPING 109 Not implemented -#define U_EMRFORCEUFIMAPPING_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRFORCEUFIMAPPING",A) +#define U_EMRFORCEUFIMAPPING_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRFORCEUFIMAPPING",A) //!< Not implemented. // U_EMRNAMEDESCAPE 110 Not implemented -#define U_EMRNAMEDESCAPE_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRNAMEDESCAPE",A) +#define U_EMRNAMEDESCAPE_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRNAMEDESCAPE",A) //!< Not implemented. // U_EMRCOLORCORRECTPALETTE 111 Not implemented -#define U_EMRCOLORCORRECTPALETTE_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRCOLORCORRECTPALETTE",A) +#define U_EMRCOLORCORRECTPALETTE_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRCOLORCORRECTPALETTE",A) //!< Not implemented. // U_EMRSETICMPROFILEA 112 Not implemented -#define U_EMRSETICMPROFILEA_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRSETICMPROFILEA",A) +#define U_EMRSETICMPROFILEA_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRSETICMPROFILEA",A) //!< Not implemented. // U_EMRSETICMPROFILEW 113 Not implemented -#define U_EMRSETICMPROFILEW_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRSETICMPROFILEW",A) +#define U_EMRSETICMPROFILEW_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRSETICMPROFILEW",A) //!< Not implemented. // U_EMRALPHABLEND 114 /** @@ -2157,14 +2190,14 @@ void U_EMRTRANSPARENTBLT_print(const char *contents){ } // U_EMRUNDEF117 117 Not implemented -#define U_EMRUNDEF117_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRUNDEF117",A) +#define U_EMRUNDEF117_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRUNDEF117",A) //!< Not implemented. // U_EMRGRADIENTFILL 118 /** \brief Print a pointer to a U_EMR_GRADIENTFILL record. \param contents pointer to a buffer holding all EMR records */ void U_EMRGRADIENTFILL_print(const char *contents){ - unsigned i; + unsigned int i; PU_EMRGRADIENTFILL pEmr = (PU_EMRGRADIENTFILL)(contents); printf(" rclBounds: "); rectl_print( pEmr->rclBounds); printf("\n"); printf(" nTriVert: %u\n", pEmr->nTriVert ); @@ -2197,11 +2230,11 @@ void U_EMRGRADIENTFILL_print(const char *contents){ } // U_EMRSETLINKEDUFIS 119 Not implemented -#define U_EMRSETLINKEDUFIS_print(A) U_EMRNOTIMPLEMENTED_print("U_EMR_SETLINKEDUFIS",A) +#define U_EMRSETLINKEDUFIS_print(A) U_EMRNOTIMPLEMENTED_print("U_EMR_SETLINKEDUFIS",A) //!< Not implemented. // U_EMRSETTEXTJUSTIFICATION120 Not implemented (denigrated) -#define U_EMRSETTEXTJUSTIFICATION_print(A) U_EMRNOTIMPLEMENTED_print("U_EMR_SETTEXTJUSTIFICATION",A) +#define U_EMRSETTEXTJUSTIFICATION_print(A) U_EMRNOTIMPLEMENTED_print("U_EMR_SETTEXTJUSTIFICATION",A) //!< Not implemented. // U_EMRCOLORMATCHTOTARGETW 121 Not implemented -#define U_EMRCOLORMATCHTOTARGETW_print(A) U_EMRNOTIMPLEMENTED_print("U_EMR_COLORMATCHTOTARGETW",A) +#define U_EMRCOLORMATCHTOTARGETW_print(A) U_EMRNOTIMPLEMENTED_print("U_EMR_COLORMATCHTOTARGETW",A) //!< Not implemented. // U_EMRCREATECOLORSPACEW 122 /** @@ -2209,16 +2242,16 @@ void U_EMRGRADIENTFILL_print(const char *contents){ \param contents pointer to a buffer holding all EMR records */ void U_EMRCREATECOLORSPACEW_print(const char *contents){ - unsigned i; + unsigned int i; PU_EMRCREATECOLORSPACEW pEmr = (PU_EMRCREATECOLORSPACEW)(contents); printf(" ihCS: %u\n", pEmr->ihCS ); printf(" ColorSpace: "); logcolorspacew_print(pEmr->lcs); printf("\n"); - printf(" dwFlags: %u\n", pEmr->dwFlags ); + printf(" dwFlags: 0x%8.8X\n", pEmr->dwFlags ); printf(" cbData: %u\n", pEmr->cbData ); - printf(" Data: "); + printf(" Data(hexvalues):"); if(pEmr->dwFlags & 1){ for(i=0; i<pEmr->cbData; i++){ - printf("[%u]:%2.2X ",i,pEmr->Data[i]); + printf("[%d]:%2.2X ",i,pEmr->Data[i]); } } printf("\n"); @@ -2234,9 +2267,9 @@ void U_EMRCREATECOLORSPACEW_print(const char *contents){ */ int U_emf_onerec_print(const char *contents, const char *blimit, int recnum, size_t off){ PU_ENHMETARECORD lpEMFR = (PU_ENHMETARECORD)(contents + off); - unsigned size; + unsigned int size; - printf("%-30srecord:%5d type:%3d offset:%8d size:%8d\n",U_emr_names(lpEMFR->iType),recnum,lpEMFR->iType,(int) off,lpEMFR->nSize); + printf("%-30srecord:%5d type:%-4d offset:%8d rsize:%8d\n",U_emr_names(lpEMFR->iType),recnum,lpEMFR->iType,(int) off,lpEMFR->nSize); size = lpEMFR->nSize; contents += off; @@ -2317,7 +2350,7 @@ int U_emf_onerec_print(const char *contents, const char *blimit, int recnum, siz case U_EMR_SELECTCLIPPATH: U_EMRSELECTCLIPPATH_print(contents); break; case U_EMR_ABORTPATH: U_EMRABORTPATH_print(contents); break; case U_EMR_UNDEF69: U_EMRUNDEF69_print(contents); break; - case U_EMR_COMMENT: U_EMRCOMMENT_print(contents); break; + case U_EMR_COMMENT: U_EMRCOMMENT_print(contents, blimit, off); break; case U_EMR_FILLRGN: U_EMRFILLRGN_print(contents); break; case U_EMR_FRAMERGN: U_EMRFRAMERGN_print(contents); break; case U_EMR_INVERTRGN: U_EMRINVERTRGN_print(contents); break; diff --git a/src/libuemf/uemf_print.h b/src/libuemf/uemf_print.h index 238e0e659..896de659e 100644 --- a/src/libuemf/uemf_print.h +++ b/src/libuemf/uemf_print.h @@ -1,5 +1,7 @@ /** - @file uemf_print.h Functions for printing records from EMF files. + @file uemf_print.h + + @brief Prototypes for functions for printing records from EMF files. */ /* @@ -18,6 +20,7 @@ Copyright: 2013 David Mathog and California Institute of Technology (Caltech) extern "C" { #endif +//! \cond /* prototypes for objects used in EMR records */ void hexbytes_print(uint8_t *buf,unsigned int num); void colorref_print(U_COLORREF color); @@ -55,112 +58,114 @@ void emrtext_print(const char *emt, const char *record, int type); /* prototypes for EMR records */ void U_EMRNOTIMPLEMENTED_print(const char *name, const char *contents, int recnum, int off); -void U_EMRHEADER_print(const char *contents, int recnum, int off); -void U_EMRPOLYBEZIER_print(const char *contents, int recnum, int off); -void U_EMRPOLYGON_print(const char *contents, int recnum, int off); -void U_EMRPOLYLINE_print(const char *contents, int recnum, int off); -void U_EMRPOLYBEZIERTO_print(const char *contents, int recnum, int off); -void U_EMRPOLYLINETO_print(const char *contents, int recnum, int off); -void U_EMRPOLYPOLYLINE_print(const char *contents, int recnum, int off); -void U_EMRPOLYPOLYGON_print(const char *contents, int recnum, int off); -void U_EMRSETWINDOWEXTEX_print(const char *contents, int recnum, int off); -void U_EMRSETWINDOWORGEX_print(const char *contents, int recnum, int off); -void U_EMRSETVIEWPORTEXTEX_print(const char *contents, int recnum, int off); -void U_EMRSETVIEWPORTORGEX_print(const char *contents, int recnum, int off); -void U_EMRSETBRUSHORGEX_print(const char *contents, int recnum, int off); -void U_EMREOF_print(const char *contents, int recnum, int off); -void U_EMRSETPIXELV_print(const char *contents, int recnum, int off); -void U_EMRSETMAPPERFLAGS_print(const char *contents, int recnum, int off); -void U_EMRSETMAPMODE_print(const char *contents, int recnum, int off); -void U_EMRSETBKMODE_print(const char *contents, int recnum, int off); -void U_EMRSETPOLYFILLMODE_print(const char *contents, int recnum, int off); -void U_EMRSETROP2_print(const char *contents, int recnum, int off); -void U_EMRSETSTRETCHBLTMODE_print(const char *contents, int recnum, int off); -void U_EMRSETTEXTALIGN_print(const char *contents, int recnum, int off); -void U_EMRSETCOLORADJUSTMENT_print(const char *contents, int recnum, int off); -void U_EMRSETTEXTCOLOR_print(const char *contents, int recnum, int off); -void U_EMRSETBKCOLOR_print(const char *contents, int recnum, int off); -void U_EMROFFSETCLIPRGN_print(const char *contents, int recnum, int off); -void U_EMRMOVETOEX_print(const char *contents, int recnum, int off); -void U_EMRSETMETARGN_print(const char *contents, int recnum, int off); -void U_EMREXCLUDECLIPRECT_print(const char *contents, int recnum, int off); -void U_EMRINTERSECTCLIPRECT_print(const char *contents, int recnum, int off); -void U_EMRSCALEVIEWPORTEXTEX_print(const char *contents, int recnum, int off); -void U_EMRSCALEWINDOWEXTEX_print(const char *contents, int recnum, int off); -void U_EMRSAVEDC_print(const char *contents, int recnum, int off); -void U_EMRRESTOREDC_print(const char *contents, int recnum, int off); -void U_EMRSETWORLDTRANSFORM_print(const char *contents, int recnum, int off); -void U_EMRMODIFYWORLDTRANSFORM_print(const char *contents, int recnum, int off); -void U_EMRSELECTOBJECT_print(const char *contents, int recnum, int off); -void U_EMRCREATEPEN_print(const char *contents, int recnum, int off); -void U_EMRCREATEBRUSHINDIRECT_print(const char *contents, int recnum, int off); -void U_EMRDELETEOBJECT_print(const char *contents, int recnum, int off); -void U_EMRANGLEARC_print(const char *contents, int recnum, int off); -void U_EMRELLIPSE_print(const char *contents, int recnum, int off); -void U_EMRRECTANGLE_print(const char *contents, int recnum, int off); -void U_EMRROUNDRECT_print(const char *contents, int recnum, int off); -void U_EMRARC_print(const char *contents, int recnum, int off); -void U_EMRCHORD_print(const char *contents, int recnum, int off); -void U_EMRPIE_print(const char *contents, int recnum, int off); -void U_EMRSELECTPALETTE_print(const char *contents, int recnum, int off); -void U_EMRCREATEPALETTE_print(const char *contents, int recnum, int off); -void U_EMRSETPALETTEENTRIES_print(const char *contents, int recnum, int off); -void U_EMRRESIZEPALETTE_print(const char *contents, int recnum, int off); -void U_EMRREALIZEPALETTE_print(const char *contents, int recnum, int off); -void U_EMREXTFLOODFILL_print(const char *contents, int recnum, int off); -void U_EMRLINETO_print(const char *contents, int recnum, int off); -void U_EMRARCTO_print(const char *contents, int recnum, int off); -void U_EMRPOLYDRAW_print(const char *contents, int recnum, int off); -void U_EMRSETARCDIRECTION_print(const char *contents, int recnum, int off); -void U_EMRSETMITERLIMIT_print(const char *contents, int recnum, int off); -void U_EMRBEGINPATH_print(const char *contents, int recnum, int off); -void U_EMRENDPATH_print(const char *contents, int recnum, int off); -void U_EMRCLOSEFIGURE_print(const char *contents, int recnum, int off); -void U_EMRFILLPATH_print(const char *contents, int recnum, int off); -void U_EMRSTROKEANDFILLPATH_print(const char *contents, int recnum, int off); -void U_EMRSTROKEPATH_print(const char *contents, int recnum, int off); -void U_EMRFLATTENPATH_print(const char *contents, int recnum, int off); -void U_EMRWIDENPATH_print(const char *contents, int recnum, int off); -void U_EMRSELECTCLIPPATH_print(const char *contents, int recnum, int off); -void U_EMRABORTPATH_print(const char *contents, int recnum, int off); -void U_EMRCOMMENT_print(const char *contents, int recnum, int off); -void U_EMRFILLRGN_print(const char *contents, int recnum, int off); -void U_EMRFRAMERGN_print(const char *contents, int recnum, int off); -void U_EMRINVERTRGN_print(const char *contents, int recnum, int off); -void U_EMRPAINTRGN_print(const char *contents, int recnum, int off); -void U_EMREXTSELECTCLIPRGN_print(const char *contents, int recnum, int off); -void U_EMRBITBLT_print(const char *contents, int recnum, int off); -void U_EMRSTRETCHBLT_print(const char *contents, int recnum, int off); -void U_EMRMASKBLT_print(const char *contents, int recnum, int off); -void U_EMRPLGBLT_print(const char *contents, int recnum, int off); -void U_EMRSETDIBITSTODEVICE_print(const char *contents, int recnum, int off); -void U_EMRSTRETCHDIBITS_print(const char *contents, int recnum, int off); -void U_EMREXTCREATEFONTINDIRECTW_print(const char *contents, int recnum, int off); -void U_EMREXTTEXTOUTA_print(const char *contents, int recnum, int off); -void U_EMREXTTEXTOUTW_print(const char *contents, int recnum, int off); -void U_EMRPOLYBEZIER16_print(const char *contents, int recnum, int off); -void U_EMRPOLYGON16_print(const char *contents, int recnum, int off); -void U_EMRPOLYLINE16_print(const char *contents, int recnum, int off); -void U_EMRPOLYBEZIERTO16_print(const char *contents, int recnum, int off); -void U_EMRPOLYLINETO16_print(const char *contents, int recnum, int off); -void U_EMRPOLYPOLYLINE16_print(const char *contents, int recnum, int off); -void U_EMRPOLYPOLYGON16_print(const char *contents, int recnum, int off); -void U_EMRPOLYDRAW16_print(const char *contents, int recnum, int off); -void U_EMRCREATEMONOBRUSH_print(const char *contents, int recnum, int off); -void U_EMRCREATEDIBPATTERNBRUSHPT_print(const char *contents, int recnum, int off); -void U_EMREXTCREATEPEN_print(const char *contents, int recnum, int off); -void U_EMRSETICMMODE_print(const char *contents, int recnum, int off); -void U_EMRCREATECOLORSPACE_print(const char *contents, int recnum, int off); -void U_EMRSETCOLORSPACE_print(const char *contents, int recnum, int off); -void U_EMRDELETECOLORSPACE_print(const char *contents, int recnum, int off); -void U_EMRPIXELFORMAT_print(const char *contents, int recnum, int off); -void U_EMRSMALLTEXTOUT_print(const char *contents, int recnum, int off); -void U_EMRALPHABLEND_print(const char *contents, int recnum, int off); -void U_EMRSETLAYOUT_print(const char *contents, int recnum, int off); -void U_EMRTRANSPARENTBLT_print(const char *contents, int recnum, int off); -void U_EMRGRADIENTFILL_print(const char *contents, int recnum, int off); -void U_EMRCREATECOLORSPACEW_print(const char *contents, int recnum, int off); +void U_EMRHEADER_print(const char *contents); +void U_EMRPOLYBEZIER_print(const char *contents); +void U_EMRPOLYGON_print(const char *contents); +void U_EMRPOLYLINE_print(const char *contents); +void U_EMRPOLYBEZIERTO_print(const char *contents); +void U_EMRPOLYLINETO_print(const char *contents); +void U_EMRPOLYPOLYLINE_print(const char *contents); +void U_EMRPOLYPOLYGON_print(const char *contents); +void U_EMRSETWINDOWEXTEX_print(const char *contents); +void U_EMRSETWINDOWORGEX_print(const char *contents); +void U_EMRSETVIEWPORTEXTEX_print(const char *contents); +void U_EMRSETVIEWPORTORGEX_print(const char *contents); +void U_EMRSETBRUSHORGEX_print(const char *contents); +void U_EMREOF_print(const char *contents); +void U_EMRSETPIXELV_print(const char *contents); +void U_EMRSETMAPPERFLAGS_print(const char *contents); +void U_EMRSETMAPMODE_print(const char *contents); +void U_EMRSETBKMODE_print(const char *contents); +void U_EMRSETPOLYFILLMODE_print(const char *contents); +void U_EMRSETROP2_print(const char *contents); +void U_EMRSETSTRETCHBLTMODE_print(const char *contents); +void U_EMRSETTEXTALIGN_print(const char *contents); +void U_EMRSETCOLORADJUSTMENT_print(const char *contents); +void U_EMRSETTEXTCOLOR_print(const char *contents); +void U_EMRSETBKCOLOR_print(const char *contents); +void U_EMROFFSETCLIPRGN_print(const char *contents); +void U_EMRMOVETOEX_print(const char *contents); +void U_EMRSETMETARGN_print(const char *contents); +void U_EMREXCLUDECLIPRECT_print(const char *contents); +void U_EMRINTERSECTCLIPRECT_print(const char *contents); +void U_EMRSCALEVIEWPORTEXTEX_print(const char *contents); +void U_EMRSCALEWINDOWEXTEX_print(const char *contents); +void U_EMRSAVEDC_print(const char *contents); +void U_EMRRESTOREDC_print(const char *contents); +void U_EMRSETWORLDTRANSFORM_print(const char *contents); +void U_EMRMODIFYWORLDTRANSFORM_print(const char *contents); +void U_EMRSELECTOBJECT_print(const char *contents); +void U_EMRCREATEPEN_print(const char *contents); +void U_EMRCREATEBRUSHINDIRECT_print(const char *contents); +void U_EMRDELETEOBJECT_print(const char *contents); +void U_EMRANGLEARC_print(const char *contents); +void U_EMRELLIPSE_print(const char *contents); +void U_EMRRECTANGLE_print(const char *contents); +void U_EMRROUNDRECT_print(const char *contents); +void U_EMRARC_print(const char *contents); +void U_EMRCHORD_print(const char *contents); +void U_EMRPIE_print(const char *contents); +void U_EMRSELECTPALETTE_print(const char *contents); +void U_EMRCREATEPALETTE_print(const char *contents); +void U_EMRSETPALETTEENTRIES_print(const char *contents); +void U_EMRRESIZEPALETTE_print(const char *contents); +void U_EMRREALIZEPALETTE_print(const char *contents); +void U_EMREXTFLOODFILL_print(const char *contents); +void U_EMRLINETO_print(const char *contents); +void U_EMRARCTO_print(const char *contents); +void U_EMRPOLYDRAW_print(const char *contents); +void U_EMRSETARCDIRECTION_print(const char *contents); +void U_EMRSETMITERLIMIT_print(const char *contents); +void U_EMRBEGINPATH_print(const char *contents); +void U_EMRENDPATH_print(const char *contents); +void U_EMRCLOSEFIGURE_print(const char *contents); +void U_EMRFILLPATH_print(const char *contents); +void U_EMRSTROKEANDFILLPATH_print(const char *contents); +void U_EMRSTROKEPATH_print(const char *contents); +void U_EMRFLATTENPATH_print(const char *contents); +void U_EMRWIDENPATH_print(const char *contents); +void U_EMRSELECTCLIPPATH_print(const char *contents); +void U_EMRABORTPATH_print(const char *contents); +void U_EMRCOMMENT_print(const char *contents, const char *blimit, size_t off); +void U_EMRFILLRGN_print(const char *contents); +void U_EMRFRAMERGN_print(const char *contents); +void U_EMRINVERTRGN_print(const char *contents); +void U_EMRPAINTRGN_print(const char *contents); +void U_EMREXTSELECTCLIPRGN_print(const char *contents); +void U_EMRBITBLT_print(const char *contents); +void U_EMRSTRETCHBLT_print(const char *contents); +void U_EMRMASKBLT_print(const char *contents); +void U_EMRPLGBLT_print(const char *contents); +void U_EMRSETDIBITSTODEVICE_print(const char *contents); +void U_EMRSTRETCHDIBITS_print(const char *contents); +void U_EMREXTCREATEFONTINDIRECTW_print(const char *contents); +void U_EMREXTTEXTOUTA_print(const char *contents); +void U_EMREXTTEXTOUTW_print(const char *contents); +void U_EMRPOLYBEZIER16_print(const char *contents); +void U_EMRPOLYGON16_print(const char *contents); +void U_EMRPOLYLINE16_print(const char *contents); +void U_EMRPOLYBEZIERTO16_print(const char *contents); +void U_EMRPOLYLINETO16_print(const char *contents); +void U_EMRPOLYPOLYLINE16_print(const char *contents); +void U_EMRPOLYPOLYGON16_print(const char *contents); +void U_EMRPOLYDRAW16_print(const char *contents); +void U_EMRCREATEMONOBRUSH_print(const char *contents); +void U_EMRCREATEDIBPATTERNBRUSHPT_print(const char *contents); +void U_EMREXTCREATEPEN_print(const char *contents); +void U_EMRSETICMMODE_print(const char *contents); +void U_EMRCREATECOLORSPACE_print(const char *contents); +void U_EMRSETCOLORSPACE_print(const char *contents); +void U_EMRDELETECOLORSPACE_print(const char *contents); +void U_EMRPIXELFORMAT_print(const char *contents); +void U_EMRSMALLTEXTOUT_print(const char *contents); +void U_EMRALPHABLEND_print(const char *contents); +void U_EMRSETLAYOUT_print(const char *contents); +void U_EMRTRANSPARENTBLT_print(const char *contents); +void U_EMRGRADIENTFILL_print(const char *contents); +void U_EMRCREATECOLORSPACEW_print(const char *contents); int U_emf_onerec_print(const char *contents, char *blimit, int recnum, int off); +//! \endcond + #ifdef __cplusplus } diff --git a/src/libuemf/uemf_utf.c b/src/libuemf/uemf_utf.c index 48d2510f0..f329e74d9 100644 --- a/src/libuemf/uemf_utf.c +++ b/src/libuemf/uemf_utf.c @@ -1,5 +1,7 @@ /** - @file uemf_utf.c Functions for manipulating UTF and various types of text. + @file uemf_utf.c + + @brief Functions for manipulating UTF and various types of text. Compile with "U_VALGRIND" defined defined to enable code which lets valgrind check each record for @@ -32,10 +34,12 @@ extern "C" { #include <math.h> // for U_ROUND() #include "uemf_utf.h" +//! \cond /* Prototypes for functions used here and defined in uemf_endian.c, but which are not supposed to be used in end user code. */ void U_swap2(void *ul, unsigned int count); +//! \endcond /* ******************************************************************************************** */ diff --git a/src/libuemf/uemf_utf.h b/src/libuemf/uemf_utf.h index e42de23e6..68452b687 100644 --- a/src/libuemf/uemf_utf.h +++ b/src/libuemf/uemf_utf.h @@ -1,5 +1,7 @@ /** - @file uemf_utf.h for manipulating UTF and various types of text. + @file uemf_utf.h + + @brief Prototypes for functions that manipulate UTF and various types of text. */ diff --git a/src/libuemf/upmf.c b/src/libuemf/upmf.c new file mode 100644 index 000000000..742b8b0f7 --- /dev/null +++ b/src/libuemf/upmf.c @@ -0,0 +1,8057 @@ +/** + @file upmf.c + + @brief Functions for manipulating EMF+ files and structures. + + EMF+ is much more object based than is EMF or WMF, so the U_PMR_*_set and most U_PMF_*_set functions + return a pointer to a PseudoObject. PseudoObjects are structs that contain a data field to hold the + object in EMF+ file byte order, size information, and some type information. This is sufficient to allow + complex records to be built up from the various sorts of nested objects which they normally contain. + If something goes wrong a NULL pointer is returned and recsize is set to 0. + + EMF+ does not use a separate set of endian functions, _get and _set routines convert from/to + the EMF+ file byte order on the fly. + + WARNING: Microsoft's EMF+ documentation is little-endian for everything EXCEPT + bitfields, which are big-endian. See EMF+ manual section 1.3.2 + That documentation also uses 0 as the MOST significant bit, N-1 as the least. + This code is little-endian throughout, and 0 is the LEAST significant bit + +*/ + +/* +File: upmf.c +Version: 0.0.4 +Date: 27-NOV-2013 +Author: David Mathog, Biology Division, Caltech +email: mathog@caltech.edu +Copyright: 2013 David Mathog and California Institute of Technology (Caltech) +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <iconv.h> +#include <wchar.h> +#include <errno.h> +#include <string.h> +#include <limits.h> // for INT_MAX, INT_MIN +#include <math.h> // for sin, cos, tan2, use U_ROUND() instead of roundf() +#include <stddef.h> /* for offsetof() macro */ +#if 0 +#include <windef.h> //Not actually used, looking for collisions +#include <winnt.h> //Not actually used, looking for collisions +#include <wingdi.h> //Not actually used, looking for collisions +#endif +#include "upmf.h" // includes uemf.h +#include "uemf_endian.h" // for U_swap* functions + +//! \cond + +/// things Doxygen should not process +/* remove this after debugging is completed */ +void dumphex(uint8_t *buf,unsigned int num){ + for(; num; num--,buf++){ + printf("%2.2X",*buf); + } +} + + +/* Prototypes for functions used here and defined in uemf_endian.c, but which are not supposed +to be used in end user code. */ + +void U_swap2(void *ul, unsigned int count); +void U_swap4(void *ul, unsigned int count); +//! \endcond + +/** + \brief Utility function for writing one or more EMF+ records in a PseudoObject to the EMF output file + \param po U_PSEUDO_OBJ to write + \param sum U_PSEUDO_OBJ to use for scratch space + \param et EMFTRACK used to write records to EMF file +*/ +void U_PMR_write(U_PSEUDO_OBJ *po, U_PSEUDO_OBJ *sum, EMFTRACK *et){ + char *rec; + sum->Used = 0; /* clean it out, retaining allocated memory */ + sum = U_PO_append(sum, "EMF+", 4); /* indicates that this comment holds an EMF+ record */ + sum = U_PO_append(sum, po->Data, po->Used); /* the EMF+ record itself */ + rec = U_EMRCOMMENT_set(sum->Used, sum->Data); /* stuff it into the EMF comment */ + (void) emf_append((PU_ENHMETARECORD)rec, et, 1); /* write it to the EMF file */ + U_PO_free(&po); /* delete the PseudoObjects */ +} + +/** + \brief Utility function to draw a line. + \return 1 on success, 0 on error. + \param PenID Index of U_PMF_PEN object to use in the EMF+ object table (0-63, inclusive) + \param PathID Index of U_PMF_PATH object to use in the EMF+ object table (0-63, inclusive) + \param Start U_PMF_POINTF coordinates of start of line. + \param End U_PMF_POINTF coordinates of end of line. + \param Dashed Set if the line is dashed, clear if it is not. + \param sum PseudoObject used for scratch space + \param et EMFTRACK used to write records to EMF file + +*/ +int U_PMR_drawline(uint32_t PenID, uint32_t PathID, U_PMF_POINTF Start, U_PMF_POINTF End, int Dashed, U_PSEUDO_OBJ *sum, EMFTRACK *et){ + U_DPSEUDO_OBJ *dpath; + U_PSEUDO_OBJ *poPath; + U_PSEUDO_OBJ *po; + int status=0; + int PTP_value = ( Dashed ? U_PTP_DashMode : U_PTP_None); + dpath = U_PATH_create(0, NULL, 0, 0); /* create an empty path*/ + if(dpath){ + if(U_PATH_moveto(dpath, Start, PTP_value) && U_PATH_lineto(dpath, End, PTP_value)){ + poPath = U_PMF_PATH_set2(U_PMF_GRAPHICSVERSIONOBJ_set(2), dpath); + if(poPath){ + po = U_PMR_OBJECT_PO_set(PathID, poPath); + U_PO_free(&poPath); + if(po){ + U_PMR_write(po, sum, et); + po = U_PMR_DRAWPATH_set(PathID, PenID); + if(po){ + U_PMR_write(po, sum, et); + status = 1; + } + } + } + } + U_DPO_free(&dpath); + } + return(status); +} + +/** + \brief Utility function for drawing strings onto the baseline in one call. + \return 1 on success, 0 on error. + \param string Text to draw in UTF-8 format + \param Vpos StringAlignment Enumeration. Always drawn on baseline, but using one of these three modes. + \param FontID Index of U_PMF_FONT object to use in the EMF+ object table (0-63, inclusive) + \param BrushID U_PSEUDO_OBJ containing a U_PMF_ARGB or a U_PMF_4NUM. Color or U_PMF_BRUSH object in the EMF+ object table (0-63, inclusive) + \param FormatID index of U_PMF_STRINGFORMAT object to use in the EMF+ Object Table. + \param Sfs StringFormat structure. Ignored values: StringAlignment, LineAlign, Flags + \param FontName Name of font to draw with + \param Height Height of font in pixels (positive) + \param fip U_FontInfoParams (ascent, descent, and so forth) + \param FontFlags FontStyle Flags + \param x X position in pixels of left side of EM box of first character + \param y Y position in pixels of baseline of first character + \param sum PseudoObject used for scratch space + \param et EMFTRACK used to write records to EMF file + + EMF+ manual 2.3.4.14, Microsoft name: EmfPlusDrawString Record, Index 0x1C + + For most fonts Ascent and Descent are used to adjust the bounding box to properly position the + baseline. Some fonts, like Verdana, are strange and they position the baseline on the bottom of + the bounding box if that box has the same height as the font. For those fonts specify 0.0 for + both Ascent and Descent. +*/ +int U_PMR_drawstring( const char *string, int Vpos, uint32_t FontID, const U_PSEUDO_OBJ *BrushID, uint32_t FormatID, + U_PMF_STRINGFORMAT Sfs, const char *FontName, U_FLOAT Height, U_FontInfoParams *fip, uint32_t FontFlags, + U_FLOAT x, U_FLOAT y, U_PSEUDO_OBJ *sum, EMFTRACK *et){ + U_PSEUDO_OBJ *po; + U_PSEUDO_OBJ *poSF; + U_PSEUDO_OBJ *poFont; + U_PSEUDO_OBJ *poRect; + U_FLOAT rx,ry,rw,rh,rd; + uint16_t *UFontName; + uint16_t *Text16; + int slen; + int status = 0; + double aval, dval; + + Sfs.Flags = U_SF_NoFitBlackBox + U_SF_NoClip; + + if(Vpos < U_SA_Near || Vpos > U_SA_Far)return(0); + Sfs.StringAlignment = U_SA_Near; // Horizontal + Sfs.LineAlign = Vpos; // Vertical + + UFontName = U_Utf8ToUtf16le(FontName, 0, NULL); + slen = strlen(FontName); + poFont = U_PMF_FONT_set(U_PMF_GRAPHICSVERSIONOBJ_set(2), Height, U_UT_World, FontFlags, slen, UFontName); + if(poFont){ + po = U_PMR_OBJECT_PO_set(FontID, poFont); /* font to use */ + if(po){ + U_PMR_write(po, sum, et); + + poSF = U_PMF_STRINGFORMAT_set(&Sfs, NULL); + if(poSF){ + po = U_PMR_OBJECT_PO_set(FormatID, poSF); + U_PO_free(&poSF); + if(po){ + U_PMR_write(po, sum, et); + + rw = 4*Height*slen; /* This could probably be any value */ + rh = Height; + rx = x; + if(fip->LineGap > -fip->Descent){ aval = fip->yMax; } // sylfaen, palatino + else { aval = fip->Ascent; } // others + if(fip->LineGap && (fip->LineGap < -fip->Descent)){ dval = ((double) (fip->Descent - fip->LineGap)) / ((double) fip->EmSize); } //shruti and some others + else { dval = ((double) fip->Descent ) / ((double) fip->EmSize); } + switch(Vpos){ + case U_SA_Near: + rd = Height * aval / ((double) fip->EmSize); + break; + case U_SA_Center: + rd = 0.5 * ( Height * aval / ((double) fip->EmSize) + Height * ( 1.0 + dval)); + break; + case U_SA_Far: + rd = Height * ( 1.0 + dval); + break; + } + ry = y - rd; /* draw from upper left corner, which is shifted to put baseline on y */ + poRect = U_PMF_RECTF4_set(rx, ry, rw, rh); +#if 0 +(void) U_PMR_drawline(OBJ_PEN_BLACK_1,OBJ_PATH_1, (U_PMF_POINTF){x-100, ry}, (U_PMF_POINTF){x+100, ry}, 0, sum, et); +(void) U_PMR_drawline(OBJ_PEN_BLACK_1,OBJ_PATH_1, (U_PMF_POINTF){x-100, ry+rh}, (U_PMF_POINTF){x+100, ry+rh}, 0, sum, et); +(void) U_PMR_drawline(OBJ_PEN_BLACK_1,OBJ_PATH_1, (U_PMF_POINTF){x-100, ry}, (U_PMF_POINTF){x-100, ry + Height * (double) fip->Ascent / ((double) fip->EmSize)}, 0, sum, et); +(void) U_PMR_drawline(OBJ_PEN_BLACK_1,OBJ_PATH_1, (U_PMF_POINTF){x- 90, ry}, (U_PMF_POINTF){x- 90, ry - Height * (double) fip->Descent / ((double) fip->EmSize)}, 0, sum, et); +(void) U_PMR_drawline(OBJ_PEN_BLACK_1,OBJ_PATH_1, (U_PMF_POINTF){x- 80, ry}, (U_PMF_POINTF){x- 80, ry + Height * (double) fip->yMax / ((double) fip->EmSize)}, 0, sum, et); +(void) U_PMR_drawline(OBJ_PEN_BLACK_1,OBJ_PATH_1, (U_PMF_POINTF){x- 70, ry}, (U_PMF_POINTF){x- 70, ry - Height * (double) fip->yMin / ((double) fip->EmSize)}, 0, sum, et); +(void) U_PMR_drawline(OBJ_PEN_BLACK_1,OBJ_PATH_1, (U_PMF_POINTF){x- 60, ry}, (U_PMF_POINTF){x- 60, ry + Height * (double) fip->LineGap / ((double) fip->EmSize)}, 0, sum, et); +(void) U_PMR_drawline(OBJ_PEN_BLACK_1,OBJ_PATH_1, (U_PMF_POINTF){x- 50, ry}, (U_PMF_POINTF){x- 50, ry + Height * ( 1.0 - (((double) (fip->LineGap - fip->Descent)) / ((double) fip->EmSize)) )}, 0, sum, et); +#endif + + Text16 = U_Utf8ToUtf16le(string, 0, NULL); + slen = strlen(string); + po = U_PMR_DRAWSTRING_set(FontID, BrushID, FormatID, slen, poRect, Text16); + if(po){ + U_PMR_write(po, sum, et); + status = 1; /* Success!!! */ + } + U_PO_free(&poRect); + free(Text16); + } + } + } + U_PO_free(&poFont); + } + free(UFontName); + return(status); +} + +/** + \brief Allocate and construct an array of U_POINT16 objects from a set of U_PMF_POINTF objects, endianness in and out is LE + \returns pointer to an array of U_POINT16 structures. + \param points pointer to the source U_POINT structures + \param count number of members in points + + If a coordinate is out of range it saturates at boundary. +*/ +U_PMF_POINT *POINTF_To_POINT16_LE(U_PMF_POINTF *points, int count){ + U_PMF_POINT *newpts; + U_PMF_POINTF ptfl; + int i; + newpts = (U_PMF_POINT *) malloc(count * sizeof(U_PMF_POINT)); + + for(i=0; i<count; i++){ + memcpy(&ptfl, &(points[i]), 8); + if(U_BYTE_SWAP){ U_swap4(&ptfl,2); } /* on BE platforms swap going in and coming out */ + newpts[i].X = U_MNMX(ptfl.X, INT16_MIN, INT16_MAX); + newpts[i].Y = U_MNMX(ptfl.Y, INT16_MIN, INT16_MAX); + if(U_BYTE_SWAP){ U_swap2(&(newpts[i]),2); } + } + return(newpts); +} + +/** + \brief Look up the name of the EMR+ record by type. Returns U_EMR_INVALID if out of range. + + \return name of the PMR record, "U_EMR_INVALID" if out of range. + \param idx PMR record type WITHOUT the U_PMR_RECFLAG bit. + +*/ +char *U_pmr_names(unsigned int idx){ + if(idx<U_PMR_MIN || idx > U_PMR_MAX){ idx = 0; } + static char *U_PMR_NAMES[U_PMR_MAX+1]={ + "U_PMR_INVALID", + "U_PMR_Header", + "U_PMR_EndOfFile", + "U_PMR_Comment", + "U_PMR_GetDC", + "U_PMR_MultiFormatStart", + "U_PMR_MultiFormatSection", + "U_PMR_MultiFormatEnd", + "U_PMR_Object", + "U_PMR_Clear", + "U_PMR_FillRects", + "U_PMR_DrawRects", + "U_PMR_FillPolygon", + "U_PMR_DrawLines", + "U_PMR_FillEllipse", + "U_PMR_DrawEllipse", + "U_PMR_FillPie", + "U_PMR_DrawPie", + "U_PMR_DrawArc", + "U_PMR_FillRegion", + "U_PMR_FillPath", + "U_PMR_DrawPath", + "U_PMR_FillClosedCurve", + "U_PMR_DrawClosedCurve", + "U_PMR_DrawCurve", + "U_PMR_DrawBeziers", + "U_PMR_DrawImage", + "U_PMR_DrawImagePoints", + "U_PMR_DrawString", + "U_PMR_SetRenderingOrigin", + "U_PMR_SetAntiAliasMode", + "U_PMR_SetTextRenderingHint", + "U_PMR_SetTextContrast", + "U_PMR_SetInterpolationMode", + "U_PMR_SetPixelOffsetMode", + "U_PMR_SetCompositingMode", + "U_PMR_SetCompositingQuality", + "U_PMR_Save", + "U_PMR_Restore", + "U_PMR_BeginContainer", + "U_PMR_BeginContainerNoParams", + "U_PMR_EndContainer", + "U_PMR_SetWorldTransform", + "U_PMR_ResetWorldTransform", + "U_PMR_MultiplyWorldTransform", + "U_PMR_TranslateWorldTransform", + "U_PMR_ScaleWorldTransform", + "U_PMR_RotateWorldTransform", + "U_PMR_SetPageTransform", + "U_PMR_ResetClip", + "U_PMR_SetClipRect", + "U_PMR_SetClipPath", + "U_PMR_SetClipRegion", + "U_PMR_OffsetClip", + "U_PMR_DrawDriverstring", + "U_PMR_StrokeFillPath", + "U_PMR_SerializableObject", + "U_PMR_SetTSGraphics", + "U_PMR_SetTSClip" + }; + return(U_PMR_NAMES[idx]); +} + +/** + \brief Convert from PseudoObject OID to ObjectType enumeration. + \returns OT value on success, 0 if no match + \param OID PseudoObject OID (based on EMF+ manual chapter number. ) + + Only OTs that may be stored in the EMF+ object table are supported. +*/ + +int U_OID_To_OT(uint32_t OID){ + int otype; + if( OID==U_PMF_BRUSH_OID ){ otype = U_OT_Brush; } + else if(OID==U_PMF_PEN_OID ){ otype = U_OT_Pen; } + else if(OID==U_PMF_PATH_OID ){ otype = U_OT_Path; } + else if(OID==U_PMF_REGION_OID ){ otype = U_OT_Region; } + else if(OID==U_PMF_IMAGE_OID ){ otype = U_OT_Image; } + else if(OID==U_PMF_FONT_OID ){ otype = U_OT_Font; } + else if(OID==U_PMF_STRINGFORMAT_OID ){ otype = U_OT_StringFormat; } + else if(OID==U_PMF_IMAGEATTRIBUTES_OID){ otype = U_OT_ImageAttributes; } + else if(OID==U_PMF_CUSTOMLINECAP_OID ){ otype = U_OT_CustomLineCap; } + else { otype = U_OT_Invalid; } + return(otype); +} + +/** + \brief Convert from PseudoObject OID to BrushType enumeration. + \returns BT value on success, -1 if no match + \param OID PseudoObject OID (based on EMF+ manual chapter number. ) + + Only OIDs that map to BT's are supported. +*/ + +int U_OID_To_BT(uint32_t OID){ + int otype; + if( OID==U_PMF_HATCHBRUSHDATA_OID ){ otype = U_BT_HatchFill; } + else if(OID==U_PMF_LINEARGRADIENTBRUSHDATA_OID ){ otype = U_BT_LinearGradient; } + else if(OID==U_PMF_PATHGRADIENTBRUSHDATA_OID ){ otype = U_BT_PathGradient; } + else if(OID==U_PMF_SOLIDBRUSHDATA_OID ){ otype = U_BT_SolidColor; } + else if(OID==U_PMF_TEXTUREBRUSHDATA_OID ){ otype = U_BT_TextureFill; } + else { otype = -1; } + return(otype); +} + +/** + \brief Convert from PseudoObject OID to CustomLineCapDataType Enumeration. + \returns BT value on success, -1 if no match + \param OID PseudoObject OID (based on EMF+ manual chapter number. ) + + Only OIDs that map to CLCDT's are supported. +*/ + +int U_OID_To_CLCDT(uint32_t OID){ + int otype; + if( OID==U_PMF_CUSTOMLINECAPDATA_OID ){ otype = U_CLCDT_Default; } + else if(OID==U_PMF_CUSTOMLINECAPARROWDATA_OID ){ otype = U_CLCDT_AdjustableArrow; } + else { otype = -1; } + return(otype); +} + +/** + \brief Convert from PseudoObject OID to ImageDataType Enumeration. + \returns BT value on success, -1 if no match + \param OID PseudoObject OID (based on EMF+ manual chapter number. ) + + Only OIDs that map to IDT's are supported. +*/ + +int U_OID_To_IDT(uint32_t OID){ + int otype; + if( OID==U_PMF_BITMAP_OID ){ otype = U_IDT_Bitmap; } + else if(OID==U_PMF_METAFILE_OID ){ otype = U_IDT_Metafile; } + else { otype = -1; } + return(otype); +} + +/** + \brief Convert from PseudoObject OID to RegionNodeDataType Enumeration. + \returns BT value on success, -1 if no match + \param OID PseudoObject OID (based on EMF+ manual chapter number. ) + + Only OIDs that map to RNDT's are supported. +*/ + +int U_OID_To_RNDT(uint32_t OID){ + int otype; + if( OID==U_PMF_REGIONNODECHILDNODES_OID ){ otype = U_RNDT_Kids; } /* there are 5 types, which must be specified separately */ + else if(OID==U_PMF_RECTF_OID ){ otype = U_RNDT_Rect; } + else if(OID==U_PMF_REGIONNODEPATH_OID ){ otype = U_RNDT_Path; } + else { otype = -1; } + return(otype); +} + +/** + \brief Append data to an U_OBJ_ACCUM structure. + \param oa pointer to the U_OBJ_ACCUM structure + \param data data to add + \param size bytes in data + \param Type object type + \param Id Object ID + \returns 0 on success, !0 on error. -1 on Type change, -2 on Id change + + Safe to test for Id, Type changes by calling with size=0. +*/ +int U_OA_append(U_OBJ_ACCUM *oa, const char *data, int size, int Type, int Id){ + int tail; + if(!oa)return(2); + if(oa->used){ + if(oa->Type != Type)return(-1); + if(oa->Id != Id)return(-2); + } + tail = oa->used; + if(oa->used + size >= oa->space){ + oa->space += size; + oa->accum = (char *) realloc(oa->accum, oa->space); + if(!oa->accum)return(1); + } + memcpy(oa->accum + tail,data,size); + oa->used += size; + oa->Type = Type; + oa->Id = Id; + return(0); +} + + +/** + \brief Clear an U_OBJ_ACCUM structure. Accumulated storage is retained. + \param oa pointer to the U_OBJ_ACCUM structure + \returns 0 on success, !0 on error. +*/ +int U_OA_clear(U_OBJ_ACCUM *oa){ + if(!oa)return(2); + oa->used=0; + /* Type and Id may be ignored as they are reset on the first append */ + return(0); +} + +/** + \brief Release an U_OBJ_ACCUM structure. Accumulated storage is free'd. + \param oa pointer to the U_OBJ_ACCUM structure + \returns 0 on success, !0 on error. +*/ +int U_OA_release(U_OBJ_ACCUM *oa){ + if(!oa)return(2); + oa->used=0; + oa->space = 0; + if(oa->accum)free(oa->accum); + oa->accum=NULL; + return(0); +} + +/** + \brief Create and set an U_PSEUDO_OBJ + \returns pointer to the U_PSEUDO_OBJ, NULL on error + \param Data Data to copy into the PseudoObject's data. If NULL, space is allocated, but is cleared instead of filled. + \param Size Number of bytes to allocate for Data (may be >Use if padding is present) + \param Use Number of data bytes in Data (whether or not Data is actually copied) + \param Type Type numbers are from manual section: 1.2.3.47 -> 0x01020347 + + If Data is NULL and Size is 0 an empty PseudoObject is created. One byte of storage + is allocated for Data, Size is set to 1, and Used to 0. + + If Data is NULL and Size is !0 a zero filled PseudoObject is created. + + If Data is !Null and Size is !0 a data filled PseudoObject is created. +*/ +U_PSEUDO_OBJ *U_PO_create(char *Data, size_t Size, size_t Use, uint32_t Type){ + if(Use>Size)return(NULL); + size_t tSize = (Size ? Size : 1); + U_PSEUDO_OBJ *po = (U_PSEUDO_OBJ *)malloc(sizeof(U_PSEUDO_OBJ)); + if(po){ + po->Data = malloc(tSize); + if(po->Data){ + po->Size = tSize; + po->Used = Use; + po->Type = Type; + if(Data){ memcpy(po->Data, Data, Use); } /* if Use < Size uninitialized bytes will be present! */ + else { memset(po->Data, 0, tSize); } + } + else { + free(po); + po=NULL; + } + } + return(po); +} + +/** + \brief Append data to a U_PSEUDO_OBJ object and return it + \returns pointer to the U_PSEUDO_OBJ object, NULL on error + \param po PseudoObject to append to. Cannot be NULL. + \param Data Data to copy into the PseudoObject's data. If NULL, space is allocated (if necessary) and cleared instead of filled. + \param Size Number of data bytes in Data +*/ +U_PSEUDO_OBJ *U_PO_append(U_PSEUDO_OBJ *po, const char *Data, size_t Size){ + /* po cannot be NULL,as in U_PO_po_append(), because there would be no way to determine the TYPE of the resulting PO */ + if(po){ + if(po->Used + Size > po->Size){ + po->Size = po->Used + Size; + po->Data = realloc(po->Data, po->Size); + } + if(po->Data){ + if(Data){ memcpy(po->Data + po->Used, Data, Size); } + else { memset(po->Data + po->Used, 0, Size); } + po->Used += Size; + } + if(!po->Data){ + free(po); + po=NULL; + } + } + return(po); +} + +/** + \brief Append data to a U_PSEUDO_OBJ object and return it + \returns pointer to the U_PSEUDO_OBJ object, NULL on error + \param po PseudoObject to append to. May be NULL. + \param Src PseudoObject to append. + \param StripE Set: leading Elements in Src->Data is not copied, Clear: it is copied. +*/ +U_PSEUDO_OBJ *U_PO_po_append(U_PSEUDO_OBJ *po, U_PSEUDO_OBJ *Src, int StripE){ + if(!Src){ return(NULL); } + char *Data = Src->Data; + size_t Size = Src->Size; + if(StripE){ Size -= 4; } + if(!po){ + po = U_PO_create(NULL, 0, 0, Src->Type); /* create an empty pseudoobject */ + } + if(po){ + if(po->Data){ + if(po->Used + Size > po->Size){ + po->Size = po->Used + Size; + po->Data = realloc(po->Data, po->Size); + } + if(po->Data){ + if(Data){ + if(StripE){ memcpy(po->Data + po->Used, Data + 4, Size); } /* Size is already 4 less, skip the leading Elements value */ + else { memcpy(po->Data + po->Used, Data, Size); } /* copy everything */ + } + else { memset(po->Data + po->Used, 0, Size); } /* set everything */ + po->Used += Size; + } + } + if(!po->Data){ + free(po); + po=NULL; + } + } + return(po); +} + +/** + \brief Free an U_PSEUDO_OBJ structure. All associated memory is released. + \param po Address of a pointer to the U_PSEUDO_OBJ structure, Pointer is set to NULL. + \returns 1 on success, 0 on error. +*/ +int U_PO_free(U_PSEUDO_OBJ **po){ + if(!po)return(0); + if(!*po)return(1); + if((*po)->Data)free((*po)->Data); + free(*po); + *po=NULL; + return(1); +} + +/** \brief create a PseudoObject with data in the correct byte order for an EMF+ file. + \returns The PseudoObject on success, NULL on error. + + \param Type the type of the PseudoObject that is created. Allowed values are in U_PID_Values. + \param List an array of U_SERIAL_DESC structures containing the data to store. + + The U_PMF_SERIAL_set() function should not ever be called directly by end user code. + + Each U_SERIAL_DESC element in List consists of Data fields and a description of that data. List is terminated + by the first U_SERIAL_DESC element having a TE value of U_XX. + + Data fields: an array of a basic type of Units bytes repeated Reps times with the target byte order + described in TE. + + Ptrs: Address of the first byte of the data fields. + + Units: Number of bytes of in each data field unit + + Reps: Number of repeats of the unit in data fields. + If a Ptr is NULL, and Units*Reps is not zero, then Units*Reps 0x00 bytes are stored. + If a Ptr is NULL, and Units*Reps is zero, this U_SERIAL_DESC is ignored. + if a Ptr is NOT NULL, and Units * Reps is not zero, then the data is stored in the indicated byte order. + If a Ptr is NOT NULL, and Units or Reps is zero an error is signaled. + + TE: (Target Endian) the byte order in which to store each unit of a data field as defined in U_Endian. + Byte swapping is only enabled when Units is 2 or 4. In addition to the byte order values U_XE, U_LE, + and U_BE, and the array terminator U_XX, the value may also be U_RP. U_RP means there is only a + single unit in the data fields, but it is to be copied to the target Reps times. That is, the data + was passed in with a form of run length encoding. + + Creates an empty PseudoObject if all pointers are NULL and all sizes are zero. + */ +U_PSEUDO_OBJ *U_PMF_SERIAL_set(uint32_t Type, const U_SERIAL_DESC *List){ + U_PSEUDO_OBJ *po=NULL; + size_t Total=0; + size_t FSize; + char *cptr; + char *hptr; + const U_SERIAL_DESC *lptr; + if(!List)return(NULL); + for(lptr=List; lptr->TE != U_XX; lptr++){ + if(!(lptr->Units * lptr->Reps) && lptr->Ptr)return(po); + Total += lptr->Units * lptr->Reps; + } + po = U_PO_create(NULL, Total, Total, Type); + if(po){ + cptr = po->Data; + for(lptr=List; lptr->TE != U_XX; lptr++){ + FSize = lptr->Units * lptr->Reps; + if(FSize){ /* Ptr is not NULL, that would have been detected already */ + hptr = cptr; + if(lptr->TE & U_RP){ U_PMF_REPCPY_DSTSHIFT(&cptr, lptr->Ptr, lptr->Units, lptr->Reps); } + else { U_PMF_MEMCPY_DSTSHIFT(&cptr, lptr->Ptr, FSize); } + if(((lptr->TE & U_LE) && U_IS_BE) || ((lptr->TE & U_BE) && U_IS_LE)){ + if(lptr->Units==2){ U_swap2(hptr,lptr->Reps); } + else if(lptr->Units==4){ U_swap4(hptr,lptr->Reps); } + } + } + } + } + return(po); +} + +/** + \brief Create U_DPSEUDO_OBJ's for the Points and Types of a path + \param Elements Number of elements in Points. May be zero, which creates an empty path. + \param Points Array of U_PMF_POINTF values. + \param First Apply to first point, unsigned byte, lower 4 bits hold the PathPointType flag upper 4 bits hold the PathPointType enumeration. Must have U_PPT_Start set. + \param Others Apply to all other points, unsigned byte, lower 4 bits hold the PathPointType flag upper 4 bits hold the PathPointType enumeration. Must have U_PPT_Line or U_PPT_Bezier set. + \returns pointer to the DU_PSEUDO_OBJ object, NULL on error +*/ +U_DPSEUDO_OBJ *U_PATH_create(int Elements, const U_PMF_POINTF *Points, uint8_t First, uint8_t Others){ + if(Elements){ + if(!Points){ return(NULL); } + if( (First & U_PPT_MASK) != U_PPT_Start ){ return(NULL); } + if(!(Others & U_PPT_Bezier)){ return(NULL); } /* will pass if either line or bezier is set */ + } + + U_DPSEUDO_OBJ *Path = (U_DPSEUDO_OBJ *)malloc(sizeof(U_DPSEUDO_OBJ)); + const U_SERIAL_DESC List[] = { {NULL,0,0,U_XX} }; + if(Path){ + Path->Elements = Elements; + Path->poPoints = U_PMF_SERIAL_set(U_PMF_RAW_OID, List); /* Empty PO to hold points as raw data */ + if(!Elements){ + Path->poTypes = U_PMF_SERIAL_set(U_PMF_RAW_OID, List); /* Empty PO to hold types as raw data */ + } + else { + Path->poPoints = U_PO_append(Path->poPoints, (char *)Points, Elements*sizeof(U_PMF_POINTF)); + if(Path->poPoints){ + U_PSEUDO_OBJ *tpo = U_PMF_PATHPOINTTYPE_set2(Elements, First | U_PPT_Start, Others); /* PO holding types, has leading Elements value */ + Path->poTypes = U_PO_po_append(NULL, tpo, U_PMF_DROP_ELEMENTS); /* remove the leading Elements value*/ + U_PO_free(&tpo); + if(!Path->poTypes){ U_PO_free(&Path->poPoints); } + } + if(!Path->poPoints){ U_DPO_free(&Path); } + } + } + return(Path); +} + +/** + \brief Free U_DPSEUDO_OBJ's + \returns 1 on success, 0 on error. +*/ +int U_DPO_free(U_DPSEUDO_OBJ **dpo){ + if(!dpo){ return(0); } + if(!*dpo){ return(1); } + U_DPSEUDO_OBJ *kpo = *dpo; + if(kpo->poPoints){ U_PO_free(&kpo->poPoints); } + if(kpo->poTypes){ U_PO_free(&kpo->poTypes); } + free(*dpo); + *dpo=NULL; + return(1); +} + +/** + \brief Clear U_DPSEUDO_OBJ's. Memory is retained, Elements and Used values are set to 0. + \returns 1 on success, 0 on error. + + It is much more efficient to clear a DPO and reuse it than to free that DPO and create another. +*/ +int U_DPO_clear(U_DPSEUDO_OBJ *dpo){ + if(!dpo){ return(0); } + if(dpo->poPoints){ dpo->poPoints->Used = 0; } + if(dpo->poTypes){ dpo->poTypes->Used = 0; } + dpo->Elements = 0; + return(1); +} + +/** + \brief Append a "moveto" point to a path + \param Path Address of a DoublePseudoObject holding the path to append to. + \param Point Point to move to. + \param Flags Flags may be (U_PTP_None, U_PTP_DashMode, U_PTP_PathMarker, U_PTP_NoBit, U_PTP_CloseSubpath) + \returns 1 on success, 0 on error. +*/ +int U_PATH_moveto(U_DPSEUDO_OBJ *Path, U_PMF_POINTF Point, uint8_t Flags){ + if(!Path){ return(0); } + U_PSEUDO_OBJ *tpo; + uint8_t Type = (Flags & U_PTP_NotClose) | U_PPT_Start; + + tpo = U_PMF_POINTF_set(1, &Point); + if(!tpo){ return(0); } + Path->poPoints = U_PO_po_append(Path->poPoints, tpo, U_PMF_DROP_ELEMENTS); + U_PO_free(&tpo); + + tpo = U_PMF_PATHPOINTTYPE_set(1, &Type); + if(!tpo){ return(0); } + Path->poTypes = U_PO_po_append(Path->poTypes, tpo, U_PMF_DROP_ELEMENTS); + U_PO_free(&tpo); + + Path->Elements++; + return(1); +} + +/** + \brief Append a "lineto" point to a path + \param Path Address of a DoublePseudoObject holding the path to append to. + \param Point U_PMF_POINTF point to draw to. + \param Flags Flags may be (U_PTP_None, U_PTP_DashMode, U_PTP_PathMarker, U_PTP_NoBit, U_PTP_CloseSubpath) + \returns 1 on success, 0 on error. +*/ +int U_PATH_lineto(U_DPSEUDO_OBJ *Path, U_PMF_POINTF Point, uint8_t Flags){ + if(!Path || !Path->Elements){ return(0); } /* must be at least one point to extend from */ + if(Path->poTypes->Data[Path->Elements - 1] & U_PTP_CloseSubpath){ return(0); } /* cannot extend a closed subpath */ + U_PSEUDO_OBJ *tpo; + uint8_t Type = (Flags & U_PTP_NotClose) | U_PPT_Line; + tpo = U_PMF_POINTF_set(1, &Point); + if(!tpo){ return(0); } + Path->poPoints = U_PO_po_append(Path->poPoints, tpo, U_PMF_DROP_ELEMENTS); + U_PO_free(&tpo); + + tpo = U_PMF_PATHPOINTTYPE_set(1, &Type); + if(!tpo){ return(0); } + Path->poTypes = U_PO_po_append(Path->poTypes, tpo, U_PMF_DROP_ELEMENTS); + U_PO_free(&tpo); + + Path->Elements++; + return(1); +} + +/** + \brief Set the closepath bit in the last point + \param Path Address of a DoublePseudoObject holding the path to act upon. + \returns 1 on success, 0 on error. +*/ +int U_PATH_closepath(U_DPSEUDO_OBJ *Path){ + if(!Path || !Path->poTypes){ return(0); } + uint32_t Elements = Path->Elements; + uint8_t *Type = (uint8_t *)(Path->poTypes->Data) + Elements - 1; + if(*Type & U_PPT_Start){ return(0); } /* single point closed path makes no sense */ + *Type = *Type | U_PTP_CloseSubpath; + return(1); +} + +/** + \brief Append a "polylineto" set of point to a path + \param Path Address of a DoublePseudoObject holding the path to append to. + \param Elements number of Points and Flags + \param Points Line points. + \param Flags Flags (U_PTP_None, U_PTP_DashMode, U_PTP_PathMarker, U_PTP_NoBit, but NOT U_PTP_CloseSubpath) + \param StartSeg If set, use U_PPT_Start PathPointType enumeration for first point, otherwise use U_PPT_Line. + \returns 1 on success, 0 on error. +*/ +int U_PATH_polylineto(U_DPSEUDO_OBJ *Path, uint32_t Elements, const U_PMF_POINTF *Points, uint8_t Flags, uint8_t StartSeg){ + if(!Path || !Points){ return(0); } + if(!Elements){ return(1); } /* harmless - do nothing */ + U_PSEUDO_OBJ *tpo; + uint8_t First, Others; + + tpo = U_PMF_POINTF_set(Elements, Points); + Path->poPoints = U_PO_po_append(Path->poPoints, tpo, U_PMF_DROP_ELEMENTS); + U_PO_free(&tpo); + if(StartSeg){ First = (Flags & U_PTP_NotClose) | U_PPT_Start; } + else { First = (Flags & U_PTP_NotClose) | U_PPT_Line; } + Others = (Flags & U_PTP_NotClose) | U_PPT_Line; + tpo = U_PMF_PATHPOINTTYPE_set2(Elements, First, Others); + if(!tpo){ return(0); } + Path->poTypes = U_PO_po_append(Path->poTypes, tpo, U_PMF_DROP_ELEMENTS); + U_PO_free(&tpo); + + Path->Elements += Elements; + return(1); +} + + +/** + \brief Append a "polybezierto" set of point to a path + \param Path Address of a DoublePseudoObject holding the path to append to. + \param Elements number of Points + \param Points Bezier points. Optional starting point, then N sets of 3, example: [P1] (Q12A Q12B P2) (Q23A Q23B P3). + \param Flags Flags (U_PTP_None, U_PTP_DashMode, U_PTP_PathMarker, U_PTP_NoBit, but NOT U_PTP_CloseSubpath) + \param StartSeg If set, use U_PPT_Start PathPointType enumeration for first point, otherwise use U_PPT_Bezier. + \returns 1 on success, 0 on error. + + If Start is set Elements must be 1 + multiple of 3. Ie, P1 Q12A Q12B P2 Q23A Q23B P3 + + If Start is clear Elements must be a multiple of 3. Ie, (P1, already in path) Q12A Q12B P2 Q23A Q23B P3 +*/ +int U_PATH_polybezierto(U_DPSEUDO_OBJ *Path, uint32_t Elements, const U_PMF_POINTF *Points, uint8_t Flags, uint8_t StartSeg){ + if(!Path || !Points){ return(0); } + if(!Elements){ + if(StartSeg){ return(0); } /* cannot have both a NEW segment and ZERO points */ + else{ return(1); } /* harmless - do nothing */ + } + if(StartSeg && ((Elements - 1) % 3)){ return(0); } /* new segment must be 1 + N*3 points */ + if(!StartSeg && (Elements % 3)){ return(0); } /* extend segment must be N*3 points */ + U_PSEUDO_OBJ *tpo; + uint8_t First, Others; + + tpo = U_PMF_POINTF_set(Elements, Points); + Path->poPoints = U_PO_po_append(Path->poPoints, tpo, U_PMF_DROP_ELEMENTS); + U_PO_free(&tpo); + + if(StartSeg){ First = (Flags & U_PTP_NotClose) | U_PPT_Start; } + else { First = (Flags & U_PTP_NotClose) | U_PPT_Bezier; } + Others = (Flags & U_PTP_NotClose) | U_PPT_Bezier; + tpo = U_PMF_PATHPOINTTYPE_set2(Elements, First, Others); + if(!tpo){ return(0); } + Path->poTypes = U_PO_po_append(Path->poTypes, tpo, U_PMF_DROP_ELEMENTS); + U_PO_free(&tpo); + + Path->Elements += Elements; + return(1); +} + +/** + \brief Append a "polygon" set of points to a path. + \param Path Address of a DoublePseudoObject holding the path to append to. + \param Elements number of Points and Flags + \param Points Line points. + \param Flags Flags (U_PTP_None, U_PTP_DashMode, U_PTP_PathMarker, U_PTP_NoBit, but NOT U_PTP_CloseSubpath) + \returns 1 on success, 0 on error. +*/ +int U_PATH_polygon(U_DPSEUDO_OBJ *Path, uint32_t Elements, const U_PMF_POINTF *Points, uint8_t Flags){ + int status = U_PATH_polylineto(Path, Elements, Points, Flags, U_SEG_NEW); + if(status){ + status = U_PATH_closepath(Path); + } + return(status); +} + +//! \cond +// These are not exposed in the API +/* Parameterized Ellipse coordinates */ +U_PMF_POINTF U_eparam(U_FLOAT a, U_FLOAT b, U_PMF_POINTF *center, double Ang, double Theta){ + U_PMF_POINTF point; + point.X = center->X + a*cos(Theta)*cos(Ang) - b*sin(Theta)*sin(Ang); + point.Y = center->Y + a*sin(Theta)*cos(Ang) + b*cos(Theta)*sin(Ang); + return(point); +} + +/* Parameterized Ellipse derivative */ +U_PMF_POINTF U_eparam2(U_FLOAT a, U_FLOAT b, double Ang, double Theta){ + U_PMF_POINTF point; + point.X = -a*cos(Theta)*sin(Ang) - b*sin(Theta)*cos(Ang); + point.Y = -a*sin(Theta)*sin(Ang) + b*cos(Theta)*cos(Ang); + return(point); +} + +double U_aparam(double Ang1, double Ang2){ + double Alpha; + double t2; + t2 = tan((Ang2 - Ang1)/2.0); + t2 *= t2; + Alpha = sin(Ang2 - Ang1) * (sqrt(4 + 3*t2) -1.0)/3.0; + return(Alpha); +} + +/* Parameterized Bezier point Q1 or Q2 derivative */ +U_PMF_POINTF U_qparam(double Alpha, double a, double b, U_PMF_POINTF *Point, double Ang, double Theta, int mode){ + U_PMF_POINTF Q, Prime; + Prime = U_eparam2(a,b,Ang,Theta); + if(mode==1){ /* Q1, anything else is Q2*/ + Q.X = Point->X + Alpha * Prime.X; + Q.Y = Point->Y + Alpha * Prime.Y; + } + else { + Q.X = Point->X - Alpha * Prime.X; + Q.Y = Point->Y - Alpha * Prime.Y; + } + return(Q); +} +//! \endcond + +/** + \brief Append an "arcto" set of points to a path (Bezier points are calculated, and these are appended + \param Path Address of a pointer to the U_PSEUDO_OBJ that holds points + \param Start Start angle, >=0.0, degrees clockwise from 3:00 + \param Sweep Sweep angle, -360<= angle <=360, degrees clockwise from Start + \param Rot Rotation angle to apply to coordinate system (Start and Rect), positive is degrees clockwise + \param Rect U_PMF_RECTF that defines the bounding rectangle. + \param Flags Flags (U_PTP_None, U_PTP_DashMode, U_PTP_PathMarker, U_PTP_NoBit, but NOT U_PTP_CloseSubpath) + \param StartSeg If set, the arc starts a new segment, if clear, continue the existing segment. Starting a new segment does not automatically apply U_PATH_closepath to the existing path. + \returns 1 on success, 0 on error. + + Based on Luc Maisonobe's work, http://www.spaceroots.org/documents/ellipse/ +*/ +int U_PATH_arcto(U_DPSEUDO_OBJ *Path, U_FLOAT Start, U_FLOAT Sweep, U_FLOAT Rot, U_PMF_RECTF *Rect, uint8_t Flags, int StartSeg){ + U_PMF_POINTF Bz[3]; + U_PMF_POINTF Center; + U_PMF_POINTF P1,P2; + double a, b; + int done = 0; + int fpoint = 0; + double L1, L2; /* These are degrees CounterClockwise from 3:00 */ + double Ang1, Ang2; /* These are parametric angles, derived from L1, L2*/ + double Alpha; /* Dimensionless number used for Q1, Q2 */ + double Theta; /* Rot in radians */ + double Slop; /* do not let rounding errors cause spurious end points */ + if(!Path){ return(0); } + if((Sweep > 360.0) || (Sweep < -360.0)){ return(0); } + /* Start should be between 0 and 360 degrees, but it does not really matter because sin, and cos will accept anything */ + /* the sign on Sweep and Start is correct bacause LM's derivation has y positive up, but GDI+ has y positive down. */ + a = Rect->Width/2.0; + b = Rect->Height/2.0; + if(!a || !b){ return(0); } + Center.X = Rect->X + a; + Center.Y = Rect->Y + b; + /* convert to radians */ + Start = (2.0 * U_PI * Start)/360.0; + Sweep = (2.0 * U_PI * Sweep)/360.0; + Theta = (2.0 * U_PI * Rot )/360.0; + Slop = Sweep/100000.0; + L1 = Start; + + while(!done){ + if(Sweep < 0){ + L2 = L1 - U_PI/2.0; + if(L2 <= Sweep + Start - Slop){ L2 = Sweep + Start; done = 1; } + else {done = 0; } + } + else { + L2 = L1 + U_PI/2.0; + if(L2 >= Sweep + Start + Slop){ L2 = Sweep + Start; done = 1; } + else {done = 0; } + } + Ang1 = atan2(sin(L1)/b, cos(L1)/a); + Ang2 = atan2(sin(L2)/b, cos(L2)/a); + Alpha = U_aparam(Ang1, Ang2); + P1 = U_eparam(a, b, &Center, Ang1, Theta); /* P1 */ + P2 = U_eparam(a, b, &Center, Ang2, Theta); /* P2 */ + Bz[0] = U_qparam(Alpha, a, b, &P1, Ang1, Theta, 1); /* Q1 */ + Bz[1] = U_qparam(Alpha, a, b, &P2, Ang2, Theta, 2); /* Q2 */ + Bz[2] = P2; + if(!fpoint){ + if(StartSeg){ U_PATH_moveto(Path, P1, Flags); } + else { U_PATH_lineto(Path, P1, Flags); } + fpoint = 1; + } + U_PATH_polybezierto(Path, 3, Bz, Flags, U_SEG_OLD ); + L1 = L2; + } + return(1); +} + +/** + \brief Allocate and construct an array of U_PMF_POINTF objects which have been subjected to a U_XFORM + \returns pointer to an array of U_PMF_POINTF structures. + \param points pointer to the source U_PMF_POINTF structures + \param count number of members in points + \param xform U_XFORM to apply + +*/ +U_PMF_POINTF *pointfs_transform(U_PMF_POINTF *points, int count, U_XFORM xform){ + U_PMF_POINTF *newpts=NULL;; + int i; + float X,Y; + newpts = (U_PMF_POINTF *) malloc(count * sizeof(U_PMF_POINTF)); + if(newpts){ + for(i=0; i<count; i++){ + X = points[i].X; + Y = points[i].Y; + newpts[i].X = U_ROUND(X * xform.eM11 + Y * xform.eM21 + xform.eDx); + newpts[i].Y = U_ROUND(X * xform.eM12 + Y * xform.eM22 + xform.eDy); + } + } + return(newpts); +} + +/** + \brief Allocate and construct an array of U_PMF_RECTF objects which have been subjected to a U_XFORM + \returns pointer to an array of U_PMF_RECTF structures. + \param Rects pointer to the source U_PMF_RECTF structures + \param Count number of members in Rects + \param Xform U_XFORM to apply. Rotation is ignored, only translation is applied. + +*/ +U_PMF_RECTF *rectfs_transform(U_PMF_RECTF *Rects, int Count, U_XFORM Xform){ + U_PMF_RECTF *newRects; + int i; + newRects = (U_PMF_RECTF *) malloc(Count * sizeof(U_PMF_RECTF)); + if(newRects){ + for(i=0; i<Count; i++){ + newRects[i].X = U_ROUND(Rects[i].X + Xform.eDx); + newRects[i].Y = U_ROUND(Rects[i].Y + Xform.eDy); + newRects[i].Width = U_ROUND(Rects[i].Width); + newRects[i].Height = U_ROUND(Rects[i].Height); + } + } + return(newRects); +} + +/** + \brief Utility function calculate the transformation matrix needed to make a gradient run precisely corner to corner of a rectangle + \param Angle Rotation in degrees clockwise of the gradient. 0 is horizontal gradient. + \param w Width of the rectangle + \param h Height of the rectangle + \param x X coordinate of upper left corner of rectangle + \param y Y coordinate of upper left corner of rectangle + \param Periods Periods of gradient corner to corner. 1.0 is one, corner to corner. + \return Transformation matrix. All values are zero if Periods, w, or h are less than or equal to zero. +*/ +U_PMF_TRANSFORMMATRIX tm_for_gradrect(U_FLOAT Angle, U_FLOAT w, U_FLOAT h, U_FLOAT x, U_FLOAT y, U_FLOAT Periods){ +//! \cond +#define CLOSE_TO_IS_REALLY_ZERO(A) ((A) > 1.0e-10 || (A) < -1.0e-10 ? (A) : 0.0) //! \hideinitializer +//! \endcond + U_PMF_TRANSFORMMATRIX tm; + double dang = Angle * 2*U_PI /360.0; + double scale; + double cd,sd; + if((Periods <=0.0) || (w <= 0.0) || (h <= 0.0)){ + tm.m11 = tm.m12 = tm.m21 = tm.m22 = tm.dX = tm.dY = 0.0; + } + else { + /* + scale is gradient period divided by w + The scale value sets the gradient period to match exactly with the inscribed (w,h) rectangle + in the direction specified by the angle. + The numberator of scale is the max of the four dot product values of the rotated X basis unit vector with (w,h), + with each of the vectors {w,h}, {-w,h}, {-w,-h}, {w,h}. Those vectors run from each corner in turn + to the opposite corner. The one most parallel to the rotated unit vector will have both terms positive. + + Trig results like cos(pi/2) are not stable between platforms due to minor differences in the + implementation. Detect these and make them zero, which then allows binary comparison of output files. + Otherwise the binary comparisons between platforms would fail because of a bunch of insignificant digits. + */ + cd = CLOSE_TO_IS_REALLY_ZERO(cos(dang)); + sd = CLOSE_TO_IS_REALLY_ZERO(sin(dang)); + scale = (w*fabs(cd) + h*fabs(sd))/(w*Periods); + tm.m11 = scale * cd; + tm.m12 = -scale * sd; + tm.m21 = scale * sd; + tm.m22 = scale * cd; + /* offset is to one corner of the square, depending on which quadrant the rotation selects. */ + if(cos(dang)>=0){ + tm.dX = x; + if(sin(dang)>=0){tm.dY = y + h; } // LL corner + else { tm.dY = y; } // UL corner + } + else { + tm.dX = x + w; + if(sin(dang)>=0){ tm.dY = y + h; } // LR corner + else { tm.dY = y; } // UR corner + } + } + return tm; +#undef CLOSE_TO_IS_REALLY_ZERO +} +/** + \brief Create a U_PSEUDO_OBJ containing a U_PMR_FILLPATH and U_PMR_DRAWPATH records. + \returns pointer to U_PSEUDO_OBJ or NULL on error. + \param PathID U_PMF_PATH object in the EMF+ object table (0-63, inclusive) + \param PenID U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + \param BrushID U_PSEUDO_OBJ containing a U_PMF_ARGB or a U_PMF_4NUM. Color or U_PMF_BRUSH object in the EMF+ object table (0-63, inclusive) +*/ +U_PSEUDO_OBJ *U_PMR_drawfill(uint32_t PathID, uint32_t PenID, const U_PSEUDO_OBJ *BrushID){ + U_PSEUDO_OBJ *po = U_PMR_FILLPATH_set(PathID, BrushID); + if(po){ + U_PSEUDO_OBJ *tpo = U_PMR_DRAWPATH_set(PathID, PenID); + po = U_PO_po_append(po, tpo, U_PMF_KEEP_ELEMENTS); + U_PO_free(&tpo); + } + return(po); +} + + + +/** + \brief Extract a single data field from a source. + \returns 1 on success, 0 on error. + \param Src where the data is coming from. It is incremented by the number of bytes retrieved. + \param Dst where the data will be stored. This must either be NULL (in which case the Src + is advanced and nothing is stored, or it must be allocated to Reps * Units bytes!!!! + \param Units number of bytes in each unit of the data field + \param Reps number of repeats of units in the data field. + If a Ptr is NULL, then Units*Reps 0 bytes are stored. + If a Ptr is NOT NULL, and Units or Reps, is zero an error is signaled. + If a Ptr is NULL and Units*Reps is 0, nothing happens. + \param SE logical (Source Endian). Only relevant for Sizes of 2 or 4 + Indicates when Bytes may need to be rearranged when they are retrieved. + U_XE no change (this is used when the data has already been set to the proper orientation or it is not known) + U_LE source is Little Endian + U_BE source is Big Endian. + U_XX error + +*/ +int U_PMF_SERIAL_get(const char **Src, void *Dst, size_t Units, size_t Reps, int SE){ + if(!Src || !*Src || SE == U_XX){ return(0); } + U_PMF_MEMCPY_SRCSHIFT(Dst, Src, Units * Reps); + if(!Dst){ return(1); } /* "fake" get, no data was retrieved, so we are done */ + if(SE == U_XE){ return(1); } + if(SE == U_LE && U_IS_LE){ return(1); } + if(SE == U_BE && U_IS_BE){ return(1); } + /* need to swap */ + if( Units==2){ U_swap2(Dst,Reps); } + else if(Units==4){ U_swap4(Dst,Reps); } + return(1); +} + +/** + \brief Conditionally extract an array of data from a source, allocating space to hold it. + \returns 1 on success, 0 on error. + \param Src where the data is coming from. It is incremented by the number of bytes retrieved. + \param Dst Caller must free. Where the pointer to the data will be stored. Reps * Units bytes will be allocated, + \param Units number of bytes in each unit of the data field + \param Reps number of repeats of units in the data field. + If a Ptr is NULL, then Units*Reps 0 bytes are stored. + If a Ptr is NOT NULL, and Units or Reps, is zero an error is signaled. + If a Ptr is NULL and Units*Reps is 0, nothing happens. + \param SE logical (Source Endian). Only relevant for Sizes of 2 or 4 + Indicates when Bytes may need to be rearranged when they are retrieved. + U_XE no change (this is used when the data has already been set to the proper orientation or it is not known) + U_LE source is Little Endian + U_BE source is Big Endian. + U_XX error + \param Cond Store the data into *Dst if true, set *Dst to NULL otherwise. + +*/ +int U_PMF_SERIAL_array_copy_get(const char **Src, void **Dst, size_t Units, size_t Reps, int SE, int Cond){ + if(!Src || !*Src || !Dst || SE == U_XX){ return(0); } + if(!Cond){ + *Src += Units * Reps; + *Dst = NULL; + return(1); + } + *Dst = malloc(Units * Reps); + if(!*Dst){ return(1); } /* "fake" get, no data was retrieved, so we are done */ + U_PMF_MEMCPY_SRCSHIFT(*Dst, Src, Units * Reps); + if(SE == U_XE){ return(1); } + if(SE == U_LE && U_IS_LE){ return(1); } + if(SE == U_BE && U_IS_BE){ return(1); } + /* need to swap */ + if( Units==2){ U_swap2(*Dst,Reps); } + else if(Units==4){ U_swap4(*Dst,Reps); } + return(1); +} + + + +/** + \brief Calculate the length in bytes of a relative path object composed of U_PMF_INTEGER7 and U_PMF_INTER15 values + \return >=0 length == success, <0 error + \param contents Start of a relative path consisting of int7 and int15 X,Y pairs. + \param Elements number of relative X,Y pairs in the object +*/ +int U_PMF_LEN_REL715(const char *contents, int Elements){ + int length=0; + Elements *= 2; /* N pairs = 2N values */ + for( ; Elements; Elements--){ + /* X or Y value */ + if(*contents & U_TEST_INT7){ contents +=2; length +=2; } //int15 + else { contents +=1; length +=1; } //int7 + } + return(length); +} + +/** + \brief Calculate the length in bytes of objects which are a 4 byte Count followed by Count * float bytes + \return >=0 length == success, <0 error + Object types whose size may be derived with this function are: + U_PMF_COMPOUNDLINEDATA + U_PMF_DASHEDLINEDATA +*/ +int U_PMF_LEN_FLOATDATA(const char *contents){ + int Size; + U_PMF_SERIAL_get(&contents, &Size, 4, 1, U_LE); + Size = 4*Size + 4; + return(Size); +} + +/** + \brief Calculate the length in bytes of objects which are a 4 byte count followed by count bytes + \return >=0 length == success, <0 error + Object types whose size may be derived with this function are: + U_PMF_BOUNDARYPATHDATA + U_PMF_BOUNDARYPOINTDATA + U_PMF_CUSTOMSTARTCAPDATA + U_PMF_PATH + U_PMF_LINEPATH + U_PMF_REGIONNODEPATH +*/ +int U_PMF_LEN_BYTEDATA(const char *contents){ + int Size; + U_PMF_SERIAL_get(&contents, &Size, 4, 1, U_LE); + Size += 4; + return(Size); +} + +/** + \brief Create a string containing the curly bracket form of the 16 byte GUID value + \return number of bytes in record, 0 on error + \param GUID pointer to the 16 unsigned bytes + \return string in curly bracket form. + http://msdn.microsoft.com/en-us/library/cc230316.aspx + + Text form is Data1-Data2-Data3-Data4, the first 3 are stored as little endian integers, the last as a string (big endian). +*/ +char *U_PMF_CURLYGUID_set(uint8_t *GUID){ + char *string=malloc(64); + if(string){ + sprintf(string,"{%2.2X%2.2X%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X}", + GUID[3],GUID[2],GUID[1],GUID[0], + GUID[5],GUID[4], + GUID[7],GUID[6], + GUID[8],GUID[9], + GUID[10],GUID[11],GUID[12],GUID[13],GUID[14],GUID[15] + ); + } + return(string); +} + +/** + \brief Identify a known curly GUID + \param string Curly GUID form. + \return EmageEffects Enumerator + + EMF+ manual 2.1.3.1, Microsoft name: ImageEffects Identifier +*/ +int U_PMF_KNOWNCURLYGUID_set(const char *string){ + int status; + if( !strcmp(string,"{633C80A4-1843-482B-9EF2-BE2834C5FDD4}")){ status = U_IEE_BlurEffectGuid; } + else if(!strcmp(string,"{D3A1DBE1-8EC4-4C17-9F4C-EA97AD1C343D}")){ status = U_IEE_BrightnessContrastEffectGuid; } + else if(!strcmp(string,"{537E597D-251E-48DA-9664-29CA496B70F8}")){ status = U_IEE_ColorBalanceEffectGuid; } + else if(!strcmp(string,"{DD6A0022-58E4-4A67-9D9B-D48EB881A53D}")){ status = U_IEE_ColorCurveEffectGuid; } + else if(!strcmp(string,"{A7CE72A9-0F7F-40D7-B3CC-D0C02D5C3212}")){ status = U_IEE_ColorLookupTableEffectGuid; } + else if(!strcmp(string,"{718F2615-7933-40E3-A511-5F68FE14DD74}")){ status = U_IEE_ColorMatrixEffectGuid; } + else if(!strcmp(string,"{8B2DD6C3-EB07-4D87-A5F0-7108E26A9C5F}")){ status = U_IEE_HueSaturationLightnessEffectGuid;} + else if(!strcmp(string,"{99C354EC-2A31-4F3A-8C34-17A803B33A25}")){ status = U_IEE_LevelsEffectGuid; } + else if(!strcmp(string,"{74D29D05-69A4-4266-9549-3CC52836B632}")){ status = U_IEE_RedEyeCorrectionEffectGuid; } + else if(!strcmp(string,"{63CBF3EE-C526-402C-8F71-62C540BF5142}")){ status = U_IEE_SharpenEffectGuid; } + else if(!strcmp(string,"{1077AF00-2848-4441-9489-44AD4C2D7A2C}")){ status = U_IEE_TintEffectGuid; } + else { status = U_IEE_Unknown; } + return(status); +} + +/** \brief Load a GUID from text format into EMF+ file binary format. + \param string Curly GUID as text, minus the barckets and dashes. + \return GUID in EMF+ file binary format. + + +This accepts a string that is 16 bytes long = 32 characters hex (no dash spaces or brackets) as text. +Text form is; Data1|Data2|Data3|Data4, first three are stored as little endian integers of 4,2,2 bytes, respectively, +last is stored like a string (big endian), after conversion from text hex to binary. + +This function is not normally called by end user code. +*/ +uint8_t *U_LOAD_GUID(char *string){ + uint32_t Data1,tData2,tData3,tByte; + uint16_t Data2,Data3; + char *Data4 = string + 16; + uint8_t *hold = malloc(16); + char *lf = (char *) hold; + int i; + if(hold){ + Data1=tData2=tData3=0; + if(3 != sscanf(string + 0,"%8X",&Data1) + + sscanf(string + 8,"%4X",&tData2) + + sscanf(string + 12,"%4X",&tData3)){ + free(lf); + return(NULL); + } + Data2=tData2; + Data3=tData3; + U_PMF_MEMCPY_DSTSHIFT(&lf, &Data1, 4); + U_PMF_MEMCPY_DSTSHIFT(&lf, &Data2, 2); + U_PMF_MEMCPY_DSTSHIFT(&lf, &Data3, 2); + if(U_IS_BE){ /* these fields are stored little endian */ + U_swap4(hold,1); + U_swap2(hold+4,2); + } + /* remainder is converted byte by byte and stored in that order */ + for(i=0;i<8;i++,Data4+=2,lf++){ + if(1 != sscanf(Data4,"%2X",&tByte)){ + free(lf); + return(NULL); + } + *lf=tByte; + } + } + return(hold); +} + +/** + \brief Generate the 16 byte form from OID of the ImageEffects Identifier + \param OID OID of the ImageEffects Identifier + \return pointer to 16 byte buffer holding the long GUID binary form, or NULL on error. + + EMF+ manual 2.1.3.1, Microsoft name: ImageEffects Identifier +*/ +uint8_t *U_OID_To_GUID(uint32_t OID){ + uint8_t *lf = NULL; + if( OID == U_PMF_IE_BLUR_OID ){ lf = U_LOAD_GUID("633C80A41843482B9EF2BE2834C5FDD4"); } + else if(OID == U_PMF_IE_BRIGHTNESSCONTRAST_OID ){ lf = U_LOAD_GUID("D3A1DBE18EC44C179F4CEA97AD1C343D"); } + else if(OID == U_PMF_IE_COLORBALANCE_OID ){ lf = U_LOAD_GUID("537E597D251E48DA966429CA496B70F8"); } + else if(OID == U_PMF_IE_COLORCURVE_OID ){ lf = U_LOAD_GUID("DD6A002258E44A679D9BD48EB881A53D"); } + else if(OID == U_PMF_IE_COLORLOOKUPTABLE_OID ){ lf = U_LOAD_GUID("A7CE72A90F7F40D7B3CCD0C02D5C3212"); } + else if(OID == U_PMF_IE_COLORMATRIX_OID ){ lf = U_LOAD_GUID("718F2615793340E3A5115F68FE14DD74"); } + else if(OID == U_PMF_IE_HUESATURATIONLIGHTNESS_OID){ lf = U_LOAD_GUID("8B2DD6C3EB074D87A5F07108E26A9C5F"); } + else if(OID == U_PMF_IE_LEVELS_OID ){ lf = U_LOAD_GUID("99C354EC2A314F3A8C3417A803B33A25"); } + else if(OID == U_PMF_IE_REDEYECORRECTION_OID ){ lf = U_LOAD_GUID("74D29D0569A4426695493CC52836B632"); } + else if(OID == U_PMF_IE_SHARPEN_OID ){ lf = U_LOAD_GUID("63CBF3EEC526402C8F7162C540BF5142"); } + else if(OID == U_PMF_IE_TINT_OID ){ lf = U_LOAD_GUID("1077AF0028484441948944AD4C2D7A2C"); } + return(lf); +} + +/** + \brief copy data and shift source pointer by the amount of data moved + \param Dst Destination in memory + \param Src Source in memory + \param Size Number of bytes to move +*/ +void U_PMF_MEMCPY_SRCSHIFT(void *Dst, const char **Src, size_t Size){ + if(Dst)memcpy(Dst, *Src, Size); + *Src += Size; +} + +/** + \brief copy data and shift destination pointer by the amount of data moved + \param Dst Destination in memory (this must not be NULL) + \param Src Source in memory (if this is NULL, fill with that many zero bytes instead) + \param Size Number of bytes to move +*/ +void U_PMF_MEMCPY_DSTSHIFT(char **Dst, const void *Src, size_t Size){ + if(Src){ memcpy(*Dst, Src, Size); } + else { memset(*Dst, 0, Size); } + *Dst += Size; +} + +/** + \brief Copy the single instance at Src repeatedly to Dst. + \param Dst Destination in memory + \param Src Source in memory (if this is NULL, fill with that many zero bytes instead) + \param Size number of bytes in single instance that is template. + \param Reps Number of instances of the template to opy +*/ +void U_PMF_REPCPY_DSTSHIFT(char **Dst, const void *Src, size_t Size, size_t Reps){ + for(;Reps;Reps--){ + if(Src){ memcpy(*Dst, Src, Size); } + else { memset(*Dst, 0, Size); } + *Dst += Size; + } +} + +/** + \brief save pointer to data and shift source pointer by the amount of data moved + \param Dst Destination in memory + \param Src Source in memory or NULL. If NULL Dst is set to NULL. + \param Size Number of bytes to move +*/ +void U_PMF_PTRSAV_SHIFT(const char **Dst, const char **Src, size_t Size){ + if(*Src){ + if(Dst)*Dst = *Src; + *Src += Size; + } + else { + if(Dst)*Dst = NULL; + } +} + +/** + \brief save pointer to data and shift source pointer by the amount of data moved + \return 1 on sucess, 0 on error + \param Dst Destination in memory + \param Src Source in memory or NULL. If NULL Dst is set to NULL. + \param Doit Assign if true, otherwise, set to NULL +*/ +int U_PMF_PTRSAV_COND(const char **Dst, const char *Src, int Doit){ + if(!Dst){ return(0); } + if(Src && Doit){ *Dst = Src; } + else { *Dst = NULL; } + return(1); +} + +/** + \brief Get the 16 bit unsigned Flags field from a header. + \param contents Record from which to extract data, will be incremented by header size. + \return Flags field + In many records the only value needed from the header is Flags. Rather than mapping + the entire Header and returning it, in these instances this function may be called to + just get this one value. +*/ +uint16_t U_PMF_HEADERFLAGS_get(const char *contents){ + uint16_t Flags; + const char *cptr = contents + offsetof(U_PMF_CMN_HDR,Flags); + U_PMF_SERIAL_get(&cptr, &Flags, 2, 1, U_LE); /* EMF+ manual documents it as BE, but this code implements it as LE*/ + return(Flags); +} + +/** + \brief Retrieve whichever header fields are requested. NULL pointers do not retrieve. + \param contents Record from which to extract data, will be incremented by header size. + \param Type Record type + \param Flags Record flags + \param Size Records size + \param Datasize Data size + \return 1 on success, 0 on failure. +*/ +int U_PMF_HEADERFIELDS_get(const char *contents, + uint16_t *Type, uint16_t *Flags, uint32_t *Size, uint32_t *Datasize){ + if(!contents){ return(0); } + U_PMF_SERIAL_get(&contents, Type, 2, 1, U_LE); + U_PMF_SERIAL_get(&contents, Flags, 2, 1, U_LE); /* EMF+ manual documents it as BE, but this code implements it as LE*/ + U_PMF_SERIAL_get(&contents, Size, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Datasize, 4, 1, U_LE); + return(1); +} + +/** + \brief Get the entire EMF+ record header. + \param contents Record from which to extract data, will be offset by header size. + \param Header Location to store data (may be NULL) + \returns 1 + If Header is Null, nothing is stored but contents is still offset. +*/ +int U_PMF_CMN_HDR_get(const char **contents, U_PMF_CMN_HDR *Header){ + if(!contents || !*contents){ return(0); } + if(Header){ + U_PMF_SERIAL_get(contents, &(Header->Type), 2, 1, U_LE); + U_PMF_SERIAL_get(contents, &(Header->Flags), 2, 1, U_LE); /* EMF+ manual documents it as BE, but this code implements it as LE*/ + U_PMF_SERIAL_get(contents, &(Header->Size), 4, 1, U_LE); + U_PMF_SERIAL_get(contents, &(Header->DataSize), 4, 1, U_LE); + } + else { + *contents += sizeof(U_PMF_CMN_HDR); + } + return(1); +} + +/** + \brief Return the size of a PenData object from an EMF+ record. + \param PenData Address in memory where the PenData object starts. + \returns size of the object in bytes +*/ +int U_PMF_LEN_PENDATA(const char *PenData){ + uint32_t Flags; + int length=12; /* Flags, Unit, Width */ + U_PMF_SERIAL_get(&PenData, &Flags, 4, 1, U_LE); + PenData += 8; /* skip Unit and Width */ + length += U_PMF_LEN_OPTPENDATA(PenData, Flags); + return(length); +} + +/** + \brief Return the size of an OptPenData object from an EMF+ record. + \param PenData Address in memory where the PenData object starts. + \param Flags PenData Flags that indicate which fields are present. + \returns size of the object in bytes +*/ +int U_PMF_LEN_OPTPENDATA(const char *PenData, uint32_t Flags){ + int length=0; + if(Flags & U_PD_Transform){ length += sizeof(U_PMF_TRANSFORMMATRIX); } + if(Flags & U_PD_StartCap){ length += sizeof(int32_t); } + if(Flags & U_PD_EndCap){ length += sizeof(int32_t); } + if(Flags & U_PD_Join){ length += sizeof(uint32_t); } + if(Flags & U_PD_MiterLimit){ length += sizeof(U_FLOAT); } + if(Flags & U_PD_LineStyle){ length += sizeof(int32_t); } + if(Flags & U_PD_DLCap){ length += sizeof(int32_t); } + if(Flags & U_PD_DLOffset){ length += sizeof(int32_t); } + if(Flags & U_PD_DLData){ length += U_PMF_LEN_FLOATDATA(PenData + length); } + if(Flags & U_PD_NonCenter){ length += sizeof(int32_t); } + if(Flags & U_PD_CLData){ length += U_PMF_LEN_FLOATDATA(PenData + length); } + if(Flags & U_PD_CustomStartCap){ length += U_PMF_LEN_BYTEDATA(PenData + length); } + if(Flags & U_PD_CustomEndCap){ length += U_PMF_LEN_BYTEDATA(PenData + length); } + return(length); +} + +/** + \brief Create and set a U_PMF_BRUSH PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Version EmfPlusGraphicsVersion object + \param Bd U_PSEUDO_OBJ containing one of the 5 types of Brush data + + EMF+ manual 2.2.1.1, Microsoft name: EmfPlusBrush Object +*/ +U_PSEUDO_OBJ *U_PMF_BRUSH_set(uint32_t Version, const U_PSEUDO_OBJ *Bd){ + if(!Bd){ return(NULL); } + int32_t Type = U_OID_To_BT(Bd->Type); + if(Type < 0){ return(NULL); } + const U_SERIAL_DESC List[] = { + {&Version, 4, 1, U_LE}, + {&Type, 4, 1, U_LE}, + {Bd->Data, Bd->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_BRUSH_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_CUSTOMLINECAP PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Version EmfPlusGraphicsVersion object + \param Ld U_PSEUDO_OBJ containing one of the 2 types of Linecap data + + EMF+ manual 2.2.1.2, Microsoft name: EmfPlusCustomLineCap Object +*/ +U_PSEUDO_OBJ *U_PMF_CUSTOMLINECAP_set(uint32_t Version, const U_PSEUDO_OBJ *Ld){ + if(!Ld){ return(NULL); } + int32_t Type = U_OID_To_CLCDT(Ld->Type); + if(Type<0){ return(NULL); } + const U_SERIAL_DESC List[] = { + {&Version, 4, 1, U_LE}, + {&Type, 4, 1, U_LE}, + {Ld->Data, Ld->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_CUSTOMLINECAP_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_FONT PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Version EmfPlusGraphicsVersion object + \param EmSize em size in units of SizeUnit + \param SizeUnit UnitType enumeration + \param FSFlags FontStyle flags + \param Length Number of Unicode Characters in FamilyName + \param Font Unicode (UTF-16LE) fontname + + EMF+ manual 2.2.1.3, Microsoft name: EmfPlusFont Object +*/ +U_PSEUDO_OBJ *U_PMF_FONT_set(uint32_t Version, U_FLOAT EmSize, uint32_t SizeUnit, + int32_t FSFlags, uint32_t Length, const uint16_t *Font){ + uint32_t cbFont = 2 * wchar16len(Font); /* this need not be 2*Length parameter */ + uint32_t pad = (0x3 & cbFont ? 2 : 0); + const U_SERIAL_DESC List[] = { + {&Version, 4, 1, U_LE}, + {&EmSize, 4, 1, U_LE}, + {&SizeUnit,4, 1, U_LE}, + {&FSFlags, 4, 1, U_LE}, + {NULL, 4, 1, U_LE}, /* NULL is for Reserved field */ + {&Length, 4, 1, U_LE}, + {Font, cbFont, 1, U_LE}, + {NULL, pad, (pad ? 1 : 0), (pad ? U_XE : U_XX)}, /* Entire record must be a multiple of 4 */ + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_FONT_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_IMAGE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Version EmfPlusGraphicsVersion object + \param Id U_PSEUDO_OBJ containing one of the 2 types of image data + + EMF+ manual 2.2.1.4, Microsoft name: EmfPlusImage Object +*/ +U_PSEUDO_OBJ *U_PMF_IMAGE_set(uint32_t Version, const U_PSEUDO_OBJ *Id){ + if(!Id){ return(NULL); } + int32_t Type = U_OID_To_IDT(Id->Type); + if(Type<0){ return(NULL);} + const U_SERIAL_DESC List[] = { + {&Version, 4, 1, U_LE}, + {&Type, 4, 1, U_LE}, + {Id->Data, Id->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_IMAGE_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_IMAGEATTRIBUTES PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Version EmfPlusGraphicsVersion object + \param WrapMode WrapMode object + \param ClampColor EmfPlusARGB object + \param ObjectClamp ObjectClamp Identifiers + + EMF+ manual 2.2.1.5, Microsoft name: EmfPlusImageAttributes Object +*/ +U_PSEUDO_OBJ *U_PMF_IMAGEATTRIBUTES_set(uint32_t Version, uint32_t WrapMode, uint32_t ClampColor, uint32_t ObjectClamp){ + uint32_t Reserved=0; + const U_SERIAL_DESC List[] = { + {&Version, 4, 1, U_LE}, + {&Reserved, 4, 1, U_LE}, + {&WrapMode, 4, 1, U_LE}, + {&ClampColor, 4, 1, U_LE}, + {&ObjectClamp, 4, 1, U_LE}, + {&Reserved, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_IMAGEATTRIBUTES_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_PATH PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Version EmfPlusGraphicsVersion object + \param Points U_PSEUDO_OBJ containing array of points (of type PMFPointR, PMFPoint, or PMFPointF, determined by U_PPF_P and U_PPF_C bits in Flags) + \param Types U_PSEUDO_OBJ containing array of types (U_PMF_PATHPOINTTYPE or U_PMF_PATHPOINTTYPERLE, determined by U_PPF_R big in Flags) + + EMF+ manual 2.2.1.6, Microsoft name: EmfPlusPath Object +*/ +U_PSEUDO_OBJ *U_PMF_PATH_set(uint32_t Version, const U_PSEUDO_OBJ *Points, const U_PSEUDO_OBJ *Types){ + int ctype, RelAbs, rtype; + int pad; + if(Points){ + if( Points->Type == U_PMF_POINTR_OID){ RelAbs = 1; ctype = 0; } + else if(Points->Type == (U_PMF_POINT_OID | U_PMF_ARRAY_OID)){ RelAbs = 0; ctype = 1; } + else if(Points->Type == (U_PMF_POINTF_OID | U_PMF_ARRAY_OID)){ RelAbs = 0; ctype = 0; } + else { return(NULL); } + } + else { return(NULL); } + if(Types){ + if( Types->Type == (U_PMF_PATHPOINTTYPERLE_OID | U_PMF_ARRAY_OID)){ rtype = 1; } + else if(Types->Type == (U_PMF_PATHPOINTTYPE_OID | U_PMF_ARRAY_OID)){ rtype = 0; } + else { return(NULL); } + } + else { return(NULL); } + uint16_t Flags = (rtype ? U_PPF_R : 0) | (ctype ? U_PPF_C : 0)| (RelAbs ? U_PPF_P : 0); + pad = (0x3 & (Points->Used + Types->Used)); + if(pad){ pad = 4 - pad; } + const U_SERIAL_DESC List[] = { + {&Version, 4, 1, U_LE }, + {Points->Data, 4, 1, U_XE }, /* Elements from Points */ + {&Flags, 2, 1, U_LE }, + {NULL, 2, 1, U_LE }, /* Reserved field */ + {Points->Data + 4, Points->Used - 4, 1, U_XE }, /* omit Points Elements */ + {Types->Data +4, Types->Used - 4, 1, U_XE }, /* omit Types Elements */ + {NULL, pad, (pad ? 1 : 0), (pad ? U_XE : U_XX)}, /* if no padding is needed the Units will be zero and nothing will happen */ + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_PATH_OID, List); + return(po); +} + + +/** + \brief Create and set a U_PMF_PATH PseudoObject that uses U_PMF_POINTF coordinates + \return Pointer to PseudoObject, NULL on error + \param Version EmfPlusGraphicsVersion object + \param Path U_DPSEUDO_OBJ containing a path. + + EMF+ manual 2.2.1.6, Microsoft name: EmfPlusPath Object +*/ +U_PSEUDO_OBJ *U_PMF_PATH_set2(uint32_t Version, const U_DPSEUDO_OBJ *Path){ + if(!Path || !Path->Elements){ return(NULL); } + uint16_t Flags = 0; + int pad = (0x3 & Path->Elements); + if(pad){ pad = 4 - pad; } + const U_SERIAL_DESC List[] = { + {&Version, 4, 1, U_LE }, + {&Path->Elements, 4, 1, U_LE }, + {&Flags, 2, 1, U_LE }, + {NULL, 2, 1, U_LE }, /* Reserved field */ + {Path->poPoints->Data, 4, 2*Path->Elements,U_XE }, /* raw OID, so no leading Elements to omit */ + {Path->poTypes->Data, 1, Path->Elements, U_XE }, /* raw OID, so no leading Elements to omit */ + {NULL, pad, (pad ? 1 : 0), (pad ? U_XE : U_XX)}, /* if no padding is needed the Units will be zero and nothing will happen */ + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_PATH_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_PATH PseudoObject that uses U_PMF_POINT (int 16) coordinates + \return Pointer to PseudoObject, NULL on error + \param Version EmfPlusGraphicsVersion object + \param Path U_DPSEUDO_OBJ containing a path. + + EMF+ manual 2.2.1.6, Microsoft name: EmfPlusPath Object +*/ +U_PSEUDO_OBJ *U_PMF_PATH_set3(uint32_t Version, const U_DPSEUDO_OBJ *Path){ + if(!Path || !Path->Elements){return(NULL); } + uint16_t Flags = U_PPF_C; + int pad = (0x3 & Path->Elements); + if(pad){ pad = 4 - pad; } + U_PMF_POINT *Points16 = POINTF_To_POINT16_LE((U_PMF_POINTF *)Path->poPoints->Data, Path->Elements); + if(!Points16){ return(NULL); } + const U_SERIAL_DESC List[] = { + {&Version, 4, 1, U_LE }, + {&Path->Elements, 4, 1, U_LE }, + {&Flags, 2, 1, U_LE }, + {NULL, 2, 1, U_LE }, /* Reserved field */ + {Points16, 2, 2*Path->Elements,U_XE }, /* raw data, so no leading Elements to omit */ + {Path->poTypes->Data, 1, Path->Elements, U_XE }, /* raw data, so no leading Elements to omit */ + {NULL, pad, (pad ? 1 : 0), (pad ? U_XE : U_XX)}, /* if no padding is needed the Units will be zero and nothing will happen */ + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_PATH_OID, List); + free(Points16); + return(po); +} + +/** + \brief Create and set a U_PMF_PEN PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Version EmfPlusGraphicsVersion object + \param PenData U_PSEUDO_OBJ containing U_PMF_PENDATA object + \param Brush U_PSEUDO_OBJ containing U_PMF_BRUSH object + + EMF+ manual 2.2.1.7, Microsoft name: EmfPlusPen Object +*/ +U_PSEUDO_OBJ *U_PMF_PEN_set(uint32_t Version, const U_PSEUDO_OBJ *PenData, const U_PSEUDO_OBJ *Brush){ + if(!PenData || (PenData->Type != U_PMF_PENDATA_OID)){ return(NULL); } + if(!Brush || (Brush->Type != U_PMF_BRUSH_OID) ){ return(NULL); } + const U_SERIAL_DESC List[] = { + {&Version, 4, 1, U_LE}, + {NULL, 4, 1, U_LE}, + {PenData->Data, PenData->Used, 1, U_XE}, + {Brush->Data, Brush->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_PEN_OID, List); + return(po); +} + + +/** + \brief Create and set a U_PMF_REGION PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Version EmfPlusGraphicsVersion object + \param Count Number of CHILD nodes. This is one less than the total number of U_PMF_REGIONNODE objects in Nodes. + \param Nodes U_PSEUDO_OBJ containing U_PMF_REGIONNODE object (Nodes defining region, may be a single element or a binary tree) + + EMF+ manual 2.2.1.8, Microsoft name: EmfPlusRegion Object +*/ +U_PSEUDO_OBJ *U_PMF_REGION_set(uint32_t Version, uint32_t Count, const U_PSEUDO_OBJ *Nodes){ + if(Nodes->Type != U_PMF_REGIONNODE_OID)return(NULL); + const U_SERIAL_DESC List[] = { + {&Version, 4, 1, U_LE}, + {&Count, 4, 1, U_LE}, + {Nodes->Data, Nodes->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_REGION_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_STRINGFORMAT PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Sfs pointer to U_PMF_STRINGFORMAT structure, with no variable part + \param Sfd (optional) U_PSEUDO_OBJ containing U_PMF_STRINGFORMATDATA object + + EMF+ manual 2.2.1.9, Microsoft name: EmfPlusStringFormat Object +*/ +U_PSEUDO_OBJ *U_PMF_STRINGFORMAT_set(U_PMF_STRINGFORMAT *Sfs, const U_PSEUDO_OBJ *Sfd){ + if(Sfd){ + if((!Sfs->TabStopCount && !Sfs->RangeCount) || (Sfd->Type != U_PMF_STRINGFORMATDATA_OID))return(NULL); + } + else { + if(Sfs->TabStopCount || Sfs->RangeCount)return(NULL); + } + const U_SERIAL_DESC List[] = { + {&Sfs->Version, 4, 1, U_LE}, + {&Sfs->Flags, 4, 1, U_LE}, + {&Sfs->Language, 4, 1, U_LE}, + {&Sfs->StringAlignment, 4, 1, U_LE}, + {&Sfs->LineAlign, 4, 1, U_LE}, + {&Sfs->DigitSubstitution, 4, 1, U_LE}, + {&Sfs->DigitLanguage, 4, 1, U_LE}, + {&Sfs->FirstTabOffset, 4, 1, U_LE}, + {&Sfs->HotkeyPrefix, 4, 1, U_LE}, + {&Sfs->LeadingMargin, 4, 1, U_LE}, + {&Sfs->TrailingMargin, 4, 1, U_LE}, + {&Sfs->Tracking, 4, 1, U_LE}, + {&Sfs->Trimming, 4, 1, U_LE}, + {&Sfs->TabStopCount, 4, 1, U_LE}, + {&Sfs->RangeCount, 4, 1, U_LE}, + {(Sfd ? Sfd->Data : NULL), (Sfd ? Sfd->Used : 0), 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_STRINGFORMAT_OID, List); + return(po); +} + +/** + \brief Create and set a PMF_4NUM PseudoObject (used for BrushID's) + \return Pointer to PseudoObject, NULL on error + \param BrushID U_PMF_BRUSH object in the EMF+ object table (0-63, inclusive) + +*/ +U_PSEUDO_OBJ *U_PMF_4NUM_set(uint32_t BrushID){ + if(BrushID>63){ return(NULL); } + const U_SERIAL_DESC List[] = { + {&BrushID, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_4NUM_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_ARGB PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Alpha Alpha (0-255) + \param Red Red color (0-255) + \param Green Green color (0-255) + \param Blue Blue color (0-255) + + EMF+ manual 2.2.2.1, Microsoft name: EmfPlusARGB Object +*/ +U_PSEUDO_OBJ *U_PMF_ARGB_set(uint8_t Alpha, uint8_t Red, uint8_t Green, uint8_t Blue){ + const U_SERIAL_DESC List[] = { + {&Blue, 1, 1, U_XE}, + {&Green, 1, 1, U_XE}, + {&Red, 1, 1, U_XE}, + {&Alpha, 1, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_ARGB_OID, List); + return(po); +} + +/** + \brief Create and set an Array of U_PMF_ARGB valus in a PseudoObject + \return Pointer to PseudoObject containing the count, followed by the array of colors, NULL on error + \param Count Number of entries in Colors + \param Colors Array of ARGB values + + EMF+ manual 2.2.2.1, Microsoft name: EmfPlusARGB Object +*/ +U_PSEUDO_OBJ *U_PMF_ARGBN_set(uint32_t Count, U_PMF_ARGB *Colors){ + const U_SERIAL_DESC List[] = { + {&Count, 4, 1, U_LE}, + {Colors, 4, Count, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_ARGB_OID | U_PMF_ARRAY_OID, List); + return(po); +} + +/** + \brief Set a U_PMF_ARGB object + \return Object + \param Alpha Alpha (0-255) + \param Red Red color (0-255) + \param Green Green color (0-255) + \param Blue Blue color (0-255) + + EMF+ manual 2.2.2.1, Microsoft name: EmfPlusARGB Object +*/ +U_PMF_ARGB U_PMF_ARGBOBJ_set(uint8_t Alpha, uint8_t Red, uint8_t Green, uint8_t Blue){ + U_PMF_ARGB argb; + char *ptr = (char *) &argb; + U_PMF_MEMCPY_DSTSHIFT(&ptr, &Blue, 1); + U_PMF_MEMCPY_DSTSHIFT(&ptr, &Green, 1); + U_PMF_MEMCPY_DSTSHIFT(&ptr, &Red, 1); + U_PMF_MEMCPY_DSTSHIFT(&ptr, &Alpha, 1); + return(argb); +} + +/** + \brief Create and set a U_PMF_BITMAP PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Bs pointer to U_PMF_BITMAP structure, with no variable part + \param Bm U_PSEUDO_OBJ containing an U_PMF_BITMAPDATA or U_PMF_COMPRESSEDIMAGE object + + EMF+ manual 2.2.2.2, Microsoft name: EmfPlusBitmap Object +*/ +U_PSEUDO_OBJ *U_PMF_BITMAP_set(const U_PMF_BITMAP *Bs, const U_PSEUDO_OBJ *Bm){ + if(Bm->Type != U_PMF_BITMAPDATA_OID && + Bm->Type != U_PMF_COMPRESSEDIMAGE_OID )return(NULL); + uint32_t Pad = UP4(Bm->Used) - Bm->Used; /* undocumented padding, must be present for at least PNG */ + const U_SERIAL_DESC List[] = { + {Bs, 4, 5, U_LE}, + {Bm->Data, Bm->Used, 1, U_XE}, + {NULL, (Pad ? Pad : 0), (Pad ? 1 : 0), U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_BITMAP_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_BITMAPDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Ps (optional) U_PSEUDO_OBJ containing a U_PMF_PALETTE structure + \param cbBm Bytes in Bm + \param Bm An array of bytes, meaning depends on fields in U_PMF_BITMAP object and the PixelFormat enumeration. + + EMF+ manual 2.2.2.3, Microsoft name: EmfPlusBitmapData Object +*/ +U_PSEUDO_OBJ *U_PMF_BITMAPDATA_set( const U_PSEUDO_OBJ *Ps, int cbBm, const char *Bm){ + if(Ps && (Ps->Type != U_PMF_PALETTE_OID))return(NULL); + const U_SERIAL_DESC List[] = { + {(Ps ? Ps->Data : NULL), (Ps ? Ps->Used : 0), (Ps ? 1 : 0), U_LE}, + {Bm, cbBm, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_BITMAPDATA_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_BLENDCOLORS PseudoObject + \return Pointer to PseudoObject, NULL on Positions and Colors + \param Elements number of elements in Positions, must agree with the number of Colors. + \param Positions positions along gradient line. The first position MUST be 0.0 and the last MUST be 1.0. + \param Colors U_PSEUDO_OBJ containing an array of U_PMF_ARGB objects: object colors at positions on gradient line + + EMF+ manual 2.2.2.4, Microsoft name: EmfPlusBlendColors Object +*/ +U_PSEUDO_OBJ *U_PMF_BLENDCOLORS_set(uint32_t Elements, const U_FLOAT *Positions, const U_PSEUDO_OBJ *Colors){ + if(!Colors || !Positions || Colors->Type != (U_PMF_ARGB_OID | U_PMF_ARRAY_OID)){ return(NULL); } + uint32_t CElements = (Colors->Used - 4)/4; + if(CElements != Elements){ return(NULL); } + const U_SERIAL_DESC List[] = { + {&CElements, 4, 1, U_LE}, + {Positions, 4, CElements, U_LE}, + {Colors->Data + 4, Colors->Used - 4, 1, U_XE}, /* omit Elements part of this PseudoObject */ + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_BLENDCOLORS_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_BLENDCOLORS PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Elements members in osition, inluding Start and End (0.0 - 1.0) + \param StartColor Start Color (U_PMF_ARGB) + \param EndColor End Color (U_PMF_ARGB) + + EMF+ manual 2.2.2.5, Microsoft name: EmfPlusBlendFactors Object + + + Positions always start at 0.0 and always end at 1.0. It is not well documented but other + start and end values generally do not work. +*/ +U_PSEUDO_OBJ *U_PMF_BLENDCOLORS_linear_set(uint32_t Elements, U_PMF_ARGB StartColor, U_PMF_ARGB EndColor){ + double dP,dR,dG,dB,dA,P,R,G,B,A; + U_FLOAT StartPos = 0.0; + U_FLOAT EndPos = 1.0; + U_FLOAT *Positions; + U_FLOAT *pP; + U_PMF_ARGB *Colors; + U_PMF_ARGB *pC; + unsigned int i; + if(Elements <= 2 ){ return(NULL); } + pP = Positions = (U_FLOAT *)malloc(Elements *sizeof(U_FLOAT)); + if(!Positions){ return(NULL); } + pC = Colors = (U_PMF_ARGB *)malloc(Elements *sizeof(U_PMF_ARGB)); + if(!Colors){ + free(Positions); + return(NULL); + } + dP = (EndPos - StartPos )/(float)(Elements - 1); + dB = ((double)EndColor.Blue - (double)StartColor.Blue )/(double)(Elements - 1); + dG = ((double)EndColor.Green - (double)StartColor.Green)/(double)(Elements - 1); + dR = ((double)EndColor.Red - (double)StartColor.Red )/(double)(Elements - 1); + dA = ((double)EndColor.Alpha - (double)StartColor.Alpha)/(double)(Elements - 1); + P = StartPos; + B = StartColor.Blue; + G = StartColor.Green; + R = StartColor.Red; + A = StartColor.Alpha; + for(i=0;i<Elements;i++,pC++,pP++){ /* hopefully the rounding errors are not a problem, used doubles to minimize that */ + *pP = P; + P += dP; + *pC = (U_PMF_ARGB){B,G,R,A}; + B += dB; + G += dG; + R += dR; + A += dA; + } + U_PSEUDO_OBJ *poColors = U_PMF_ARGBN_set(Elements, Colors); + U_PSEUDO_OBJ *po = U_PMF_BLENDCOLORS_set(Elements, Positions, poColors); + U_PO_free(&poColors); + free(Positions); + free(Colors); + return(po); +} + + +/** + \brief Create and set a U_PMF_BLENDFACTORS PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Elements members in each array + \param Positions positions along gradient line. The first position MUST be 0.0 and the last MUST be 1.0. + \param Factors blending factors, 0.0->1.0 values, inclusiv + + EMF+ manual 2.2.2.5, Microsoft name: EmfPlusBlendFactors Object +*/ +U_PSEUDO_OBJ *U_PMF_BLENDFACTORS_set(uint32_t Elements, const U_FLOAT *Positions, const U_FLOAT *Factors){ + if(!Positions || !Factors)return(NULL); + const U_SERIAL_DESC List[] = { + {&Elements, 4, 1, U_LE}, + {Positions, 4, Elements, U_LE}, + {Factors, 4, Elements, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_BLENDFACTORS_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_BLENDFACTORS PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Elements members in osition, inluding Start and End (0.0 - 1.0) + \param StartFactor Start Factor (0.0 - 1.0) + \param EndFactor End Factor (0.0 - 1.0) + + EMF+ manual 2.2.2.5, Microsoft name: EmfPlusBlendFactors Object + + + Positions always start at 0.0 and always end at 1.0. It is not well documented but other + start and end values generally do not work. +*/ +U_PSEUDO_OBJ *U_PMF_BLENDFACTORS_linear_set(uint32_t Elements, U_FLOAT StartFactor, U_FLOAT EndFactor){ + double dP,dF,P,F; + U_FLOAT StartPos = 0.0; + U_FLOAT EndPos = 1.0; + U_FLOAT *Positions; + U_FLOAT *Factors; + U_FLOAT *pP; + U_FLOAT *pF; + unsigned int i; + if(Elements <= 2 ){ return(NULL); } + pP = Positions = (U_FLOAT *)malloc(Elements *sizeof(U_FLOAT)); + if(!Positions){ return(NULL); } + pF = Factors = (U_FLOAT *)malloc(Elements *sizeof(U_FLOAT)); + if(!Factors){ + free(Positions); + return(NULL); + } + dP = (EndPos - StartPos )/(float)(Elements - 1); + dF = (EndFactor - StartFactor)/(float)(Elements - 1); + P = StartPos; + F = StartFactor; + for(i=0;i<Elements;i++){ /* hopefully the rounding errors are not a problem, used doubles to minimize that */ + *pP++ = P; P += dP; + *pF++ = F; F += dF; + } + U_PSEUDO_OBJ *po = U_PMF_BLENDFACTORS_set(Elements, Positions, Factors); + free(Positions); + free(Factors); + return(po); +} + +/** + \brief Create and set a U_PMF_BOUNDARYPATHDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Path U_PSEUDO_OBJ containing U_PMF_PATH object + + EMF+ manual 2.2.2.6, Microsoft name: EmfPlusBoundaryPathData Object +*/ +U_PSEUDO_OBJ *U_PMF_BOUNDARYPATHDATA_set(const U_PSEUDO_OBJ *Path){ + if(Path->Type != U_PMF_PATH_OID)return(NULL); + /* PO Used is size_t, might be 8 bytes, value in record must be 4 bytes */ + uint32_t Used = Path->Used; + const U_SERIAL_DESC List[] = { + {&Used, 4, 1, U_LE}, + {Path->Data, Path->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_BOUNDARYPATHDATA_OID, List); + return(po); +} + + +/** + \brief Create and set a U_PMF_BOUNDARYPOINTDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Elements members in each array + \param Points array of U_PMF_POINTF + + EMF+ manual 2.2.2.7, Microsoft name: EmfPlusBoundaryPointData Object +*/ +U_PSEUDO_OBJ *U_PMF_BOUNDARYPOINTDATA_set(uint32_t Elements, const U_PMF_POINTF *Points){ + if(!Points)return(NULL); + const U_SERIAL_DESC List[] = { + {&Elements, 4, 1, U_LE}, + {Points, 4, 2*Elements,U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_BOUNDARYPOINTDATA_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_CHARACTERRANGE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param First First position in range + \param Length Range length + + EMF+ manual 2.2.2.8, Microsoft name: EmfPlusCharacterRange Object +*/ +U_PSEUDO_OBJ *U_PMF_CHARACTERRANGE_set(int32_t First, int32_t Length){ + const U_SERIAL_DESC List[] = { + {&First, 4, 1, U_LE}, + {&Length, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_CHARACTERRANGE_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_COMPOUNDLINEDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Elements Members in Widths + \param Widths Array of U_FLOAT Line or gap widths (0.0 <-> 1.0, fraction of total line width ) + + EMF+ manual 2.2.2.9, Microsoft name: EmfPlusCompoundLineData Object +*/ +U_PSEUDO_OBJ *U_PMF_COMPOUNDLINEDATA_set(int32_t Elements, const char *Widths){ + if(!Widths)return(NULL); + const U_SERIAL_DESC List[] = { + {&Elements ,4, 1, U_LE}, + {Widths, 4, Elements,U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_COMPOUNDLINEDATA_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_COMPRESSEDIMAGE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param cbImage Bytes in Image + \param Image Stored image in one of the supported formats (GIF, PNG, etc.). + + EMF+ manual 2.2.2.10, Microsoft name: EmfPlusCompressedImage Object +*/ +U_PSEUDO_OBJ *U_PMF_COMPRESSEDIMAGE_set(int32_t cbImage, const char *Image){ + if(!cbImage || !Image)return(NULL); + const U_SERIAL_DESC List[] = { + {Image, cbImage, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_COMPRESSEDIMAGE_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_CUSTOMENDCAPDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Clc U_PSEUDO_OBJ containing a U_PMF_CUSTOMLINECAP object + + EMF+ manual 2.2.2.11, Microsoft name: EmfPlusCustomEndCapData Object +*/ +U_PSEUDO_OBJ *U_PMF_CUSTOMENDCAPDATA_set(const U_PSEUDO_OBJ *Clc){ + if(Clc->Type != U_PMF_CUSTOMLINECAP_OID)return(NULL); + /* PO Used is size_t, might be 8 bytes, value in record must be 4 bytes */ + uint32_t Used = Clc->Used; + const U_SERIAL_DESC List[] = { + {&Used, 4, 1, U_LE}, + {Clc->Data, Clc->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_CUSTOMENDCAPDATA_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_CUSTOMLINECAPARROWDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Width Arrow cap width (is multiplied by line width before draw) + \param Height Arrow cap length (is multiplied by line width before draw) + \param MiddleInset Pixels between outer edge and filled region + \param FillState If set, fill, otherwise, only border + \param StartCap LineCap enumeration (type of cap) + \param EndCap LineCap enumeration + \param Join LineJoin enumeration + \param MiterLimit Maximum (miter length / line width) + \param WidthScale Scale for U_PMF_CUSTOMLINECAP object + + EMF+ manual 2.2.2.12, Microsoft name: EmfPlusCustomLineCapArrowData Object +*/ +U_PSEUDO_OBJ *U_PMF_CUSTOMLINECAPARROWDATA_set(U_FLOAT Width, U_FLOAT Height, + U_FLOAT MiddleInset, uint32_t FillState, uint32_t StartCap, uint32_t EndCap, uint32_t Join, + U_FLOAT MiterLimit, U_FLOAT WidthScale + ){ + const U_SERIAL_DESC List[] = { + {&Width, 4, 1, U_LE}, + {&Height ,4, 1, U_LE}, + {&MiddleInset, 4, 1, U_LE}, + {&FillState, 4, 1, U_LE}, + {&StartCap, 4, 1, U_LE}, + {&EndCap, 4, 1, U_LE}, + {&Join, 4, 1, U_LE}, + {&MiterLimit, 4, 1, U_LE}, + {&WidthScale, 4, 1, U_LE}, + {NULL, 8, 2, U_LE}, /* FillHotSpots and LineHotSpots */ + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_CUSTOMLINECAPARROWDATA_OID, List); + return(po); +} + + +/** + \brief Create and set a U_PMF_CUSTOMLINECAPDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Flags CustomLineCapData flags + \param Cap LineCap enumeration (type of cap) + \param Inset Distance line cap start -> line end + \param StartCap LineCap enumeration + \param EndCap LineCap enumeration + \param Join LineJoin enumeration + \param MiterLimit Maximum (miter length / line width) + \param WidthScale Scale for U_PMF_CUSTOMLINECAP object + \param Clcod U_PSEUDO_OBJ containing a U_PMF_CUSTOMLINECAPOPTIONALDATA object + + EMF+ manual 2.2.2.13, Microsoft name: EmfPlusCustomLineCapData Object +*/ +U_PSEUDO_OBJ *U_PMF_CUSTOMLINECAPDATA_set(uint32_t Flags, uint32_t Cap, + U_FLOAT Inset, uint32_t StartCap, uint32_t EndCap, + uint32_t Join, U_FLOAT MiterLimit, U_FLOAT WidthScale, + const U_PSEUDO_OBJ *Clcod + ){ + if(Clcod->Type != U_PMF_CUSTOMLINECAPOPTIONALDATA_OID)return(NULL); + const U_SERIAL_DESC List[] = { + {&Flags, 4, 1, U_LE}, + {&Cap, 4, 1, U_LE}, + {&Inset, 4, 1, U_LE}, + {&StartCap, 4, 1, U_LE}, + {&EndCap, 4, 1, U_LE}, + {&Join, 4, 1, U_LE}, + {&MiterLimit, 4, 1, U_LE}, + {&WidthScale, 4, 1, U_LE}, + {NULL, 8, 2, U_LE}, /* FillHotSpots and LineHotSpots */ + {Clcod->Data, Clcod->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_CUSTOMLINECAPDATA_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_CUSTOMLINECAPOPTIONALDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Fill U_PSEUDO_OBJ containing a U_PMF_FILLPATHOBJ object (optional) + \param Line U_PSEUDO_OBJ containing a U_PMF_LINEPATH object (optional) + + EMF+ manual 2.2.2.14, Microsoft name: EmfPlusCustomLineCapOptionalData Object +*/ +U_PSEUDO_OBJ *U_PMF_CUSTOMLINECAPOPTIONALDATA_set(const U_PSEUDO_OBJ *Fill, const U_PSEUDO_OBJ *Line){ + if(Fill && (Fill->Type != U_PMF_FILLPATHOBJ_OID))return(NULL); + if(Line && (Line->Type != U_PMF_LINEPATH_OID))return(NULL); + const U_SERIAL_DESC List[] = { + {Fill->Data, Fill->Used, 1, U_XE}, + {Line->Data, Line->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_CUSTOMLINECAPOPTIONALDATA_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_CUSTOMSTARTCAPDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Clc U_PSEUDO_OBJ containing a U_PMF_CUSTOMLINECAPDATA object + + EMF+ manual 2.2.2.15, Microsoft name: EmfPlusCustomStartCapData Object +*/ +U_PSEUDO_OBJ *U_PMF_CUSTOMSTARTCAPDATA_set(const U_PSEUDO_OBJ *Clc){ + if(Clc && (Clc->Type != U_PMF_CUSTOMLINECAP_OID))return(NULL); + const U_SERIAL_DESC List[] = { + {Clc->Data, Clc->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_CUSTOMSTARTCAPDATA_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_DASHEDLINEDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Elements Members in Lengths + \param Lengths Array of U_FLOAT holding lengths of dashes and spaces. + + EMF+ manual 2.2.2.16, Microsoft name: EmfPlusDashedLineData Object +*/ +U_PSEUDO_OBJ *U_PMF_DASHEDLINEDATA_set(int32_t Elements, const U_FLOAT *Lengths){ + if(!Lengths)return(NULL); + const U_SERIAL_DESC List[] = { + {&Elements, 4, 1, U_LE}, + {Lengths, 4, Elements, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_DASHEDLINEDATA_OID, List); + return(po); +} + +/** + \brief Utility function to create and set a U_PMF_DASHEDLINEDATA PseudoObject from one of a predefined set of patterns + \return Pointer to PseudoObject, NULL on error + \param Unit Length of the repeat unit + \param StdPat Members in Lengths + + EMF+ manual 2.2.2.16, Microsoft name: EmfPlusDashedLineData Object +*/ +U_PSEUDO_OBJ *U_PMF_DASHEDLINEDATA_set2(U_FLOAT Unit, int StdPat){ + uint32_t Elements; + uint8_t *p; + U_FLOAT SubUnit; + U_FLOAT Lengths[8]; /* This is the most dash/spaces that will be needed*/ + int i; + /* Dot = 1, Dash = 2; Long = 3, 0 = terminate pattern */ + uint8_t SB[U_DD_Types][5] = + { + {0,0,0,0,0}, // Solid + {2,0,0,0,0}, // Dash + {2,2,0,0,0}, // DashDash + {2,2,2,0,0}, // DashDashDash + {2,2,2,2,0}, // DashDashDashDash + {1,0,0,0,0}, // Dot + {1,1,0,0,0}, // DotDot + {1,1,1,0,0}, // DotDotDot + {1,1,1,1,0}, // DotDotDotDot + {2,1,0,0,0}, // DashDot + {2,2,1,0,0}, // DashDashDot + {2,2,1,1,0}, // DashDashDotDot + {2,2,2,1,0}, // DashDashDashDot + {2,1,1,0,0}, // DashDotDot + {2,1,1,1,0}, // DashDotDotDot + {2,1,2,1,0}, // DashDotDashDot + {3,0,0,0,0}, // Long + {3,3,0,0,0}, // LongLong + {3,3,3,0,0}, // LongLongLong + {3,3,3,3,0}, // LongLongLongLong + {3,1,0,0,0}, // LongDot + {3,3,1,0,0}, // LongLongDot + {3,3,1,1,0}, // LongLongDotDot + {3,3,3,1,0}, // LongLongLongDot + {3,1,1,0,0}, // LongDotDot + {3,1,1,1,0}, // LongDotDotDot + {3,1,3,1,0} // LongDotLongDot + }; + if(Unit <= 0 ){ return(NULL); } + if((StdPat <= 0) || (StdPat > U_DD_LongDotLongDot)){ return(NULL); } + p = &(SB[StdPat][0]); + for(Elements = 0; *p; p++, Elements++){} + SubUnit = Unit/((U_FLOAT) Elements); + Elements *= 2; + p = &(SB[StdPat][0]); + for(i=0; *p; p++){ + switch(*p){ + case 0: break; + case 1: /* dot */ + Lengths[i++] = SubUnit * 0.125; + Lengths[i++] = SubUnit * 0.875; + break; + case 2: /* dash */ + Lengths[i++] = SubUnit * 0.5; + Lengths[i++] = SubUnit * 0.5; + break; + case 3: /* long */ + Lengths[i++] = SubUnit * 0.75; + Lengths[i++] = SubUnit * 0.25; + break; + } + } + + U_PSEUDO_OBJ *po = U_PMF_DASHEDLINEDATA_set(Elements, Lengths); + return(po); +} + +/** + \brief Utility function to create and set a U_PMF_DASHEDLINEDATA PseudoObject from the bits that are set in a uint32_t + \return Pointer to PseudoObject, NULL on error + \param Unit Length of the repeat unit + \param BitPat uint32_t holding the bit pattern, the lowest order bit MUST be set and the highest order MUST be clear. + + Make a line with a dot/dash pattern defined by the bits in the BitPat value. If a bit is set it is drawn, + if clear it is not. Every bit drawn has length Unit/32, and consecutive drawn bits are merged together. + The lowest order bit is the first bit that may be drawn, the highest the last. + + Example: if the integer has value 0x13 the pattern produced will be: + 0 -> 2*unit/32 drawn + 2*unit/32 -> 5*unit/32 not drawn + 5*unit/32 -> 6*unit/32 drawn + 6*unit/32 -> unit not drawn + + EMF+ manual 2.2.2.16, Microsoft name: EmfPlusDashedLineData Object +*/ +U_PSEUDO_OBJ *U_PMF_DASHEDLINEDATA_set3(U_FLOAT Unit, uint32_t BitPat){ + uint32_t Elements=0; + U_FLOAT SubUnit = Unit/32.0; + U_FLOAT Lengths[32]; /* This is the most dash/spaces that will be needed*/ + if(!(0x00000001 & BitPat))return(NULL); /* Pattern must start with a drawn segment, this bit must be set */ + if( 0x80000000 & BitPat )return(NULL); /* Pattern must end with an undrawn segment, this bit must be clear */ + int i=0; + int k; + int lastType=1; + int newType=0; + uint32_t j=1; + Lengths[0]=0; + for(k=0; k<32; k++, j=j<<1){ + if(j & BitPat){ + if(!lastType){ + newType=1; + } + } + else { + if(lastType){ + newType=1; + } + } + if(newType){ + i++; + Lengths[i]=0; + Elements++; + lastType = !lastType; + newType = 0; + } + Lengths[i] += SubUnit; + } + Elements = i+1; + + U_PSEUDO_OBJ *po = U_PMF_DASHEDLINEDATA_set(Elements, Lengths); + return(po); +} + +/** + \brief Create and set a U_PMF_FILLPATHOBJ PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Path U_PSEUDO_OBJ containing a U_PMF_PATH object + + EMF+ manual 2.2.2.17, Microsoft name: EmfPlusFillPath Object +*/ +U_PSEUDO_OBJ *U_PMF_FILLPATHOBJ_set(const U_PSEUDO_OBJ *Path){ + if(Path && (Path->Type != U_PMF_PATH_OID))return(NULL); + const U_SERIAL_DESC List[] = { + {Path->Data, Path->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_FILLPATHOBJ_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_FOCUSSCALEDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param ScaleX value 0.0 <-> 1.0 + \param ScaleY value 0.0 <-> 1.0 + + EMF+ manual 2.2.2.18, Microsoft name: EmfPlusFocusScaleData Object +*/ +U_PSEUDO_OBJ *U_PMF_FOCUSSCALEDATA_set(U_FLOAT ScaleX, U_FLOAT ScaleY){ + uint32_t tmp = 2; + const U_SERIAL_DESC List[] = { + {&tmp, 4, 1, U_LE}, + {&ScaleX, 4, 1, U_LE}, + {&ScaleY, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_FOCUSSCALEDATA_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_GRAPHICSVERSION object (Signature always set to 0xDBC01) + \return Pointer to PseudoObject, NULL on error + \param GrfVersion GraphicsVersion enumeration + + EMF+ manual 2.2.2.19, Microsoft name: EmfPlusGraphicsVersion Object +*/ +U_PSEUDO_OBJ *U_PMF_GRAPHICSVERSION_set(int GrfVersion){ + uint32_t tmp; + tmp = U_GFVR_PMF << 12; /* signature, can only have this value */ + tmp |= (GrfVersion & U_GFVR_MASKLO); + const U_SERIAL_DESC List[] = { + {&tmp, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_GRAPHICSVERSION_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_GRAPHICSVERSION object Structure (Signature always set to 0xDBC01) + \return U_PMF_GRAPHICSVERSION + \param GrfVersion GraphicsVersion enumeration + + EMF+ manual 2.2.2.19, Microsoft name: EmfPlusGraphicsVersion Object +*/ +U_PMF_GRAPHICSVERSION U_PMF_GRAPHICSVERSIONOBJ_set(int GrfVersion){ + uint32_t tmp; + tmp = U_GFVR_PMF << 12; /* signature, can only have this value */ + tmp |= (GrfVersion & U_GFVR_MASKLO); + return(tmp); +} + + +/** + \brief Create and set a U_PMF_HATCHBRUSHDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Style HatchStyle enumeration + \param Fg U_PSEUDO_OBJ containing a U_ARGB object, Foreground hatch pattern line color + \param Bg U_PSEUDO_OBJ containing a U_ARGB object, Background hatch pattern line color + + EMF+ manual 2.2.2.20, Microsoft name: EmfPlusHatchBrushData Object +*/ +U_PSEUDO_OBJ *U_PMF_HATCHBRUSHDATA_set(uint32_t Style, const U_PSEUDO_OBJ *Fg, const U_PSEUDO_OBJ *Bg){ + if(!Fg ||(Fg->Type != U_PMF_ARGB_OID))return(NULL); + if(!Bg ||(Bg->Type != U_PMF_ARGB_OID))return(NULL); + const U_SERIAL_DESC List[] = { + {&Style, 4, 1, U_LE}, + {Fg->Data, Fg->Used, 1, U_XE}, + {Bg->Data, Bg->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_HATCHBRUSHDATA_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_INTEGER7 PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Value 7 bit signed integer (stored in an integer, range 63 <-> -64, inclusive) + + EMF+ manual 2.2.2.21, Microsoft name: EmfPlusInteger7 Object +*/ +U_PSEUDO_OBJ *U_PMF_INTEGER7_set(int Value){ + uint8_t utmp; + if(Value < -64 || Value > 63)return(NULL); + utmp = U_MASK_INT7 & *(unsigned int *)&Value; + U_PSEUDO_OBJ *po = U_PO_create((char *)&utmp, 1, 1, U_PMF_INTEGER7_OID); /* simple method is OK, no possibility of Endian issues */ + return(po); +} + +/** + \brief Create and set a U_PMF_INTEGER15 PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Value 15 bit signed integer (stored in an integer, range 32677 <-> -32678, inclusive) + + EMF+ manual 2.2.2.22, Microsoft name: EmfPlusInteger15 Object +*/ +U_PSEUDO_OBJ *U_PMF_INTEGER15_set(int Value){ + uint16_t utmp; + if(Value < -32678 || Value > 32677)return(NULL); + utmp = U_TEST_INT15 | (U_MASK_INT15 & *(unsigned int *)&Value); + const U_SERIAL_DESC List[] = { + {&utmp, 2, 1, U_BE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_INTEGER15_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_LANGUAGEIDENTIFIER value in 4 byte unsigned int, in NATIVE byte order + \return LID value in least significant two bytes and 0 in most significant two bytes. + \param SubLId Example: code for USA + \param PriLId Example: code for English + + EMF+ manual 2.2.2.23, Microsoft name: EmfPlusLanguageIdentifier Object +*/ +U_PMF_LANGUAGEIDENTIFIER U_PMF_LANGUAGEIDENTIFIEROBJ_set(int SubLId, int PriLId){ + U_PMF_LANGUAGEIDENTIFIER utmp32; + utmp32 = ((SubLId & U_FF_MASK_SUBLID) << U_FF_SHFT_SUBLID) | ((PriLId & U_FF_MASK_PRILID) << U_FF_SHFT_PRILID); + return(utmp32); +} + +/** + \brief Create and set a U_PMF_LANGUAGEIDENTIFIER PseudoObject + \return Pointer to PseudoObject, NULL on error + \param LId Language Identifier as produced by U_PMF_LANGUAGEIDENTIFIEROBJ_set(). + + EMF+ manual 2.2.2.23, Microsoft name: EmfPlusLanguageIdentifier Object +*/ +U_PSEUDO_OBJ *U_PMF_LANGUAGEIDENTIFIER_set(U_PMF_LANGUAGEIDENTIFIER LId){ + uint16_t utmp16; + utmp16 = (LId & U_FF_MASK_LID) << U_FF_SHFT_LID; + const U_SERIAL_DESC List[] = { + {&utmp16, 2, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_LANGUAGEIDENTIFIER_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_LINEARGRADIENTBRUSHDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Lgbd U_PMF_LINEARGRADIENTBRUSHDATA object (constant part) + \param Lgbod U_PSEUDO_OBJ containing a U_PMF_LINEARGRADIENTBRUSHOPTIONALDATA object (variable part of a U_PMF_LINEARGRADIENTBRUSHDATA object) + + + EMF+ manual 2.2.2.24, Microsoft name: EmfPlusLinearGradientBrushData Object +*/ +U_PSEUDO_OBJ *U_PMF_LINEARGRADIENTBRUSHDATA_set(const U_PMF_LINEARGRADIENTBRUSHDATA *Lgbd, const U_PSEUDO_OBJ *Lgbod){ + if(!Lgbd || !Lgbod || (Lgbod->Type != U_PMF_LINEARGRADIENTBRUSHOPTIONALDATA_OID))return(NULL); + const U_SERIAL_DESC List[] = { + {Lgbd, 4, 6, U_LE}, + {&(Lgbd->StartColor), 4, 2, U_XE}, + {&(Lgbd->StartColor), 4, 2, U_XE}, /* repeat the start/end colors. Supposedly reserved. */ +// {NULL, 4, 2, U_LE}, /* zero fill the two Reserved fields, no matter what is passed in */ + {(Lgbod->Used ? Lgbod->Data : NULL), Lgbod->Used, 1, U_XE}, /* optional Data can exist and Used can be zero, SERIAL_set would throw an error on that */ + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_LINEARGRADIENTBRUSHDATA_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_LINEARGRADIENTBRUSHOPTIONALDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Flags Bits are set that indicate which of the following were included. The caller must clear before passing it in. + \param Tm U_PSEUDO_OBJ containing a U_PMF_TRANSFORMMATRIX object + \param Bc U_PSEUDO_OBJ containing a U_PMF_BLENDCOLORS object or NULL + \param BfH U_PSEUDO_OBJ containing a U_PMF_BLENDFACTORS (H) object or NULL + \param BfV U_PSEUDO_OBJ containing a U_PMF_BLENDFACTORS (V) object or NULL (WARNING, GDI+ defines this field but does not render it. DO NOT USE.) + + + EMF+ manual 2.2.2.25, Microsoft name: EmfPlusLinearGradientBrushOptionalData Object + + + The rectangular gradients repeat in a tiled pattern. Tm can rotate and offset the gradient within each tile. + The gradient wraps when it is offset. + +*/ +U_PSEUDO_OBJ *U_PMF_LINEARGRADIENTBRUSHOPTIONALDATA_set(uint32_t *Flags, const U_PSEUDO_OBJ *Tm, + const U_PSEUDO_OBJ *Bc, const U_PSEUDO_OBJ *BfH, const U_PSEUDO_OBJ *BfV){ + if(!Flags )return(NULL); + if(Tm && (Tm->Type != U_PMF_TRANSFORMMATRIX_OID))return(NULL); + if(Bc && (Bc->Type != U_PMF_BLENDCOLORS_OID) )return(NULL); + if(BfH && (BfH->Type != U_PMF_BLENDFACTORS_OID) )return(NULL); + if(BfV && (BfV->Type != U_PMF_BLENDFACTORS_OID) )return(NULL); + if(Bc && (BfH || BfV) )return(NULL); + const U_SERIAL_DESC List[] = { + {(Tm ? Tm->Data : NULL), (Tm ? Tm->Used : 0), 1, U_XE}, + {(Bc ? Bc->Data : NULL), (Bc ? Bc->Used : 0), 1, U_XE}, + {(BfH ? BfH->Data : NULL), (BfH ? BfH->Used : 0), 1, U_XE}, + {(BfV ? BfV->Data : NULL), (BfV ? BfV->Used : 0), 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_LINEARGRADIENTBRUSHOPTIONALDATA_OID, List); + if(Tm ){ *Flags |= U_BD_Transform; } + if(Bc ){ *Flags |= U_BD_PresetColors; } + if(BfH){ *Flags |= U_BD_BlendFactorsH; } + if(BfV){ *Flags |= U_BD_BlendFactorsV; } + return(po); +} + +/** + \brief Create and set a U_PMF_LINEPATH PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Path U_PSEUDO_OBJ containing a U_PMF_PATH object + + + EMF+ manual 2.2.2.26, Microsoft name: EmfPlusLinePath Object +*/ +U_PSEUDO_OBJ *U_PMF_LINEPATH_set(const U_PSEUDO_OBJ *Path){ + if(!Path || (Path->Type != U_PMF_PATH_OID))return(NULL); + const U_SERIAL_DESC List[] = { + {&Path->Data, Path->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_LINEPATH_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_METAFILE object (NOT SUPPORTED!) + \return Null + + + EMF+ manual 2.2.2.27, Microsoft name: EmfPlusMetafile Object +*/ +U_PSEUDO_OBJ *U_PMF_METAFILE_set(void){ + return(NULL); +} + +/** + \brief Create and set a U_PMF_PALETTE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Flags PaletteStyle flags + \param Elements Members in Lengths + \param Pd Array of U_PMF_ARGB holding colors of palettes. (Palette Data) + + EMF+ manual 2.2.2.28, Microsoft name: EmfPlusPalette Object +*/ +U_PSEUDO_OBJ *U_PMF_PALETTE_set(uint32_t Flags, uint32_t Elements, const U_PMF_ARGB *Pd){ + if(!Pd)return(NULL); + const U_SERIAL_DESC List[] = { + {&Flags, 4, 1, U_LE}, + {&Elements, 4, 1, U_LE}, + {Pd, 4, Elements, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_PALETTE_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_PATHGRADIENTBRUSHDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Flags PaletteStyle flags + \param WrapMode WrapMode enumeration + \param CenterColor U_PMF_ARGB Center color + \param Center Center coordinates + \param Gradient U_PSEUDO_OBJ containing an Array of U_PMF_ARGB holding colors of Gradient + \param Boundary U_PSEUDO_OBJ containing a U_PMF_BOUNDARYPATHDATA or U_PMF_BOUNDARYPOINTDATA object. (Boundary Data) + \param Data variable part of U_PMF_LINEARGRADIENTBRUSHDATA, exact composition depends on Flags + + EMF+ manual 2.2.2.29, Microsoft name: EmfPlusPathGradientBrushData Object +*/ +U_PSEUDO_OBJ *U_PMF_PATHGRADIENTBRUSHDATA_set(uint32_t Flags, int32_t WrapMode, U_PMF_ARGB CenterColor, + U_PMF_POINTF Center, + const U_PSEUDO_OBJ *Gradient, const U_PSEUDO_OBJ *Boundary, const U_PSEUDO_OBJ *Data){ + if( (Flags & U_BD_Path) && (!Boundary || (Boundary->Type != U_PMF_BOUNDARYPATHDATA_OID)))return(NULL); + if(!(Flags & U_BD_Path) && (!Boundary || (Boundary->Type != U_PMF_BOUNDARYPOINTDATA_OID)))return(NULL); + if(!(Gradient) || (Gradient->Type != (U_PMF_ARGB_OID | U_PMF_ARRAY_OID)))return(NULL); + if(!(Flags & U_BD_Transform) && + !(Flags & U_BD_PresetColors) && + !(Flags & U_BD_BlendFactorsH) && + !(Flags & U_BD_FocusScales) && + (!Data || (Data->Type != U_PMF_PATHGRADIENTBRUSHOPTIONALDATA_OID)))return(NULL); + + const U_SERIAL_DESC List[] = { + {&Flags, 4, 1, U_LE}, + {&WrapMode, 4, 1, U_LE}, + {&CenterColor, 4, 1, U_XE}, + {&Center.X, 4, 2, U_LE}, + {Gradient->Data, Gradient->Used, 1, U_XE}, /* includes Elements */ + {Boundary->Data, Boundary->Used, 1, U_XE}, + {(Data ? Data->Data : NULL), (Data ? Data->Used : 0), 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_PATHGRADIENTBRUSHDATA_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_PATHGRADIENTBRUSHOPTIONALDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Flags PaletteStyle flags + \param Tm U_PSEUDO_OBJ containing a U_PMF_TRANSFORMMATRIX. (Transformation matrix) + \param Pd U_PSEUDO_OBJ containing a U_PMF_BLENDCOLORS or U_PMF_BLENDFACTORS object. (Pattern Data) + \param Fsd U_PSEUDO_OBJ containing a U_PMF_FOCUSSSCALEDATA object. (Focus Scale Data) + + EMF+ manual 2.2.2.30, Microsoft name: EmfPlusPathGradientBrushOptionalData Object +*/ +U_PSEUDO_OBJ *U_PMF_PATHGRADIENTBRUSHOPTIONALDATA_set(uint32_t Flags, + const U_PSEUDO_OBJ *Tm, const U_PSEUDO_OBJ *Pd, const U_PSEUDO_OBJ *Fsd){ + if(Tm && (Tm->Type != U_PMF_TRANSFORMMATRIX_OID))return(NULL); + if(Pd && !(Flags & (U_BD_PresetColors | U_BD_BlendFactorsH)))return(NULL); + if( (Flags & U_BD_PresetColors) && ((Flags & U_BD_BlendFactorsH) || !Pd || (Pd->Type != U_PMF_BLENDCOLORS_OID) ))return(NULL); + if( (Flags & U_BD_BlendFactorsH) && ((Flags & U_BD_PresetColors) || !Pd || (Pd->Type != U_PMF_BLENDFACTORS_OID)))return(NULL); + if(Fsd && !(Flags & U_BD_FocusScales))return(NULL); + if( (Flags & U_BD_FocusScales) && (!Fsd || (Fsd->Type != U_PMF_BLENDCOLORS_OID) ))return(NULL); + const U_SERIAL_DESC List[] = { + {(Tm ? Tm->Data : NULL), (Tm ? Tm->Used : 0), 1, U_XE}, + {(Pd ? Pd->Data : NULL), (Pd ? Pd->Used : 0), 1, U_XE}, + {(Fsd ? Fsd->Data : NULL), (Fsd ? Fsd->Used : 0), 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_PATHGRADIENTBRUSHOPTIONALDATA_OID, List); + return(po); +} + +/** + \brief Create and set an ARRAY of U_PMF_PATHPOINTTYPE objects + \return Pointer to PseudoObject, NULL on error + \param Elements Number of entries in Flags and Enumerations + \param Ppt Array of unsigned bytes, lower 4 bits hold the PathPointType flag upper 4 bits hold the PathPointType enumeration. + + EMF+ manual 2.2.2.31, Microsoft name: EmfPlusPathPointType Object +*/ +U_PSEUDO_OBJ *U_PMF_PATHPOINTTYPE_set(uint32_t Elements, const uint8_t *Ppt){ + if(!Elements || !Ppt)return(NULL); + const U_SERIAL_DESC List[] = { + {&Elements, 4, 1, U_LE}, + {Ppt, 1, Elements, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_PATHPOINTTYPE_OID | U_PMF_ARRAY_OID, List); + return(po); +} + +/** + \brief Create and set an ARRAY of U_PMF_PATHPOINTTYPE objects, with a preceding Elements count + \return Pointer to PseudoObject, NULL on error + \param Elements Number of elements to add. First is added once and Others Elements-1 times. + \param First Apply to first point, unsigned byte, lower 4 bits hold the PathPointType flag upper 4 bits hold the PathPointType enumeration. + \param Others Apply to all other points, unsigned byte, lower 4 bits hold the PathPointType flag upper 4 bits hold the PathPointType enumeration. + + EMF+ manual 2.2.2.31, Microsoft name: EmfPlusPathPointType Object +*/ +U_PSEUDO_OBJ *U_PMF_PATHPOINTTYPE_set2(uint32_t Elements, uint8_t First, uint8_t Others){ + if(!Elements)return(NULL); + const U_SERIAL_DESC List[] = { + {&Elements, 4, 1, U_XE}, + {&First, 1, 1, U_XE}, + {&Others, 1, Elements-1, U_RP}, /* replicate the one value N-1 times */ + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_PATHPOINTTYPE_OID | U_PMF_ARRAY_OID, List); + return(po); +} + +/** + \brief Create and set an ARRAY of U_PMF_PATHPOINTTYPERLE objects + \return Pointer to PseudoObject containing first the number of elements, then an array of U_PMF_PATHPOINTTYPERLE, NULL on error + \param Elements Number of entries in the arrays + \param Bz Array of unsigned bytes, if not zero, element has Bezier bit set + \param RL Array of unsigned bytes, Run lengths. + \param Ppte Array of unsigned bytes, PathPointType enumerations. + + EMF+ manual 2.2.2.32, Microsoft name: EmfPlusPathPointTypeRLE Object +*/ +U_PSEUDO_OBJ *U_PMF_PATHPOINTTYPERLE_set(uint32_t Elements, const uint8_t *Bz, const uint8_t *RL, const uint8_t *Ppte){ + uint8_t utmp; + if(!Bz || !RL || !Ppte)return(NULL); + /* allocate space in the structure but put no data in */ + U_PSEUDO_OBJ *po = U_PO_create(NULL, 4 + 2*Elements, 0, U_PMF_PATHPOINTTYPERLE_OID | U_PMF_ARRAY_OID); + + U_PSEUDO_OBJ *poi = U_PMF_4NUM_set(Elements); + po = U_PO_append(po, poi->Data, poi->Used); + U_PO_free(&poi); + + if(po){ + for( ;Elements; Elements--, Bz++, RL++, Ppte++){ + po = U_PO_append(po, (char *)Ppte, 1); + if(*RL > 0x3F){ /* run length too big for field */ + U_PO_free(&po); + return(NULL); + } + utmp = (*Bz ? 1 : 0) | ((*RL & 0x3F)<<2); /* bit 1 is not used and is set to 0 */ + po = U_PO_append(po, (char *)&utmp, 1); + } + } + return(po); +} + +/** + \brief Create and set a U_PMF_PENDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Unit UnitType enumeration + \param Width Width in units set by Unit + \param Pod U_PSEUDO_OBJ containing first the PenData flags then a U_PMF_PENOPTIONALDATA object (the second part + may be an empty if Flags is 0) + + + EMF+ manual 2.2.2.33, Microsoft name: EmfPlusPenData Object +*/ +U_PSEUDO_OBJ *U_PMF_PENDATA_set(uint32_t Unit, U_FLOAT Width, const U_PSEUDO_OBJ *Pod){ + if(Pod && ((Pod->Type != U_PMF_PENOPTIONALDATA_OID) || Pod->Used < 4))return(NULL); + const U_SERIAL_DESC List[] = { + {(Pod ? Pod->Data : NULL), 4, 1, U_XE}, /* the Flags field, clear if no optional data */ + {&Unit, 4, 1, U_LE}, + {&Width, 4, 1, U_LE}, + /* next is the (optional) U_PMF_PENOPTIONALDATA part or a terminator */ + {(Pod ? Pod->Data + 4 : NULL), (Pod ? Pod->Used - 4 : 0), (Pod ? 1 : 0), (Pod ? U_XE : U_XX)}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_PENDATA_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_PENOPTIONALDATA PseudoObject + \return Pointer to PseudoObject, NULL on error. Returned PO contains first the Flags, then the PO proper. + \param Flags Determines which of the values are stored. + \param Tm U_PSEUDO_OBJ containing a U_PMF_TRANSFORMMATRIX object (Transformation matrix) + \param StartCap LineCapType enumeration + \param EndCap LineCapType enumeration + \param Join LineJoinType enumeration + \param MiterLimit Maximum (miter length / line width) + \param Style LineStyle enumeration + \param DLCap DashedLineCapType enumeration + \param DLOffset Distance line start to first dash start + \param DLData U_PSEUDO_OBJ containing a U_PMF_DASHEDLINEDATA object Dash and space widths + \param PenAlignment PenAlignment enumeration + \param CmpndLineData U_PSEUDO_OBJ containing a U_PMF_COMPOUNDLINEDATA object Compount Line (parallel lines drawn instead of one) + \param CSCapData U_PSEUDO_OBJ containing a U_PMF_CUSTOMSTARTCAPDATA object Custom start cap + \param CECapData U_PSEUDO_OBJ containing a U_PMF_CUSTOMENDCAPDATA object Custom end cap + + + EMF+ manual 2.2.2.34, Microsoft name: EmfPlusPenOptionalData Object +*/ +U_PSEUDO_OBJ *U_PMF_PENOPTIONALDATA_set(uint32_t Flags, U_PSEUDO_OBJ *Tm, int32_t StartCap, int32_t EndCap, uint32_t Join, + U_FLOAT MiterLimit, int32_t Style, int32_t DLCap, U_FLOAT DLOffset, + U_PSEUDO_OBJ *DLData, int32_t PenAlignment, U_PSEUDO_OBJ *CmpndLineData, U_PSEUDO_OBJ *CSCapData, + U_PSEUDO_OBJ *CECapData + ){ + + if((Flags & U_PD_Transform) && (!Tm || (Tm->Type != U_PMF_TRANSFORMMATRIX_OID)) )return(NULL); + if((Flags & U_PD_DLData) && (!DLData || (DLData->Type != U_PMF_DASHEDLINEDATA_OID)) )return(NULL); + if((Flags & U_PD_CLData) && (!CmpndLineData || (CmpndLineData->Type != U_PMF_COMPOUNDLINEDATA_OID)) )return(NULL); + if((Flags & U_PD_CustomStartCap) && (!CSCapData || (CSCapData->Type != U_PMF_CUSTOMSTARTCAPDATA_OID)))return(NULL); + if((Flags & U_PD_CustomEndCap) &&(!CECapData || (CECapData->Type != U_PMF_CUSTOMENDCAPDATA_OID)) )return(NULL); + + /* prepend the Flags field to the PseudoObject proper */ + const U_SERIAL_DESC List[] = { + {&Flags, 4, 1, U_LE}, + {((Flags & U_PD_Transform) ? Tm->Data : NULL), ((Flags & U_PD_Transform) ? Tm->Used : 0), 1, U_XE}, + {((Flags & U_PD_StartCap ) ? (char *)&StartCap : NULL), ((Flags & U_PD_StartCap ) ? 4 : 0), 1, U_LE}, + {((Flags & U_PD_EndCap ) ? (char *)&EndCap : NULL), ((Flags & U_PD_EndCap ) ? 4 : 0), 1, U_LE}, + {((Flags & U_PD_Join ) ? (char *)&Join : NULL), ((Flags & U_PD_Join ) ? 4 : 0), 1, U_LE}, + {((Flags & U_PD_MiterLimit ) ? (char *)&MiterLimit : NULL), ((Flags & U_PD_MiterLimit ) ? 4 : 0), 1, U_LE}, + {((Flags & U_PD_LineStyle ) ? (char *)&Style : NULL), ((Flags & U_PD_LineStyle ) ? 4 : 0), 1, U_LE}, + {((Flags & U_PD_DLCap ) ? (char *)&DLCap : NULL), ((Flags & U_PD_DLCap ) ? 4 : 0), 1, U_LE}, + {((Flags & U_PD_DLOffset ) ? (char *)&DLOffset : NULL), ((Flags & U_PD_DLOffset ) ? 4 : 0), 1, U_LE}, + {((Flags & U_PD_DLData ) ? DLData->Data : NULL), ((Flags & U_PD_DLData ) ? DLData->Used : 0), 1, U_XE}, + {((Flags & U_PD_NonCenter ) ? (char *)&PenAlignment : NULL), ((Flags & U_PD_NonCenter ) ? 4 : 0), 1, U_LE}, + {((Flags & U_PD_CLData ) ? CmpndLineData->Data : NULL), ((Flags & U_PD_CLData ) ? CmpndLineData->Used : 0), 1, U_XE}, + {((Flags & U_PD_CustomStartCap) ? CSCapData->Data : NULL), ((Flags & U_PD_CustomStartCap) ? CSCapData->Used : 0), 1, U_XE}, + {((Flags & U_PD_CustomEndCap ) ? CECapData->Data : NULL), ((Flags & U_PD_CustomEndCap ) ? CECapData->Used : 0), 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_PENOPTIONALDATA_OID, List); + return(po); +} + +/** + \brief Create and set an ARRAY of U_PMF_POINT objects + \return Pointer to PseudoObject, NULL on error + \param Elements Number of pairs of points in Coords + \param Coords Array of X,Y pairs. + + EMF+ manual 2.2.2.35, Microsoft name: EmfPlusPoint Object +*/ +U_PSEUDO_OBJ *U_PMF_POINT_set(uint32_t Elements, const U_PMF_POINT *Coords){ + if(!Elements || !Coords)return(NULL); + const U_SERIAL_DESC List[] = { + {&Elements, 4, 1, U_LE}, + { Coords, 2, 2*Elements, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_POINT_OID | U_PMF_ARRAY_OID, List); + return(po); +} + +/** + \brief Create and set an ARRAY of U_PMF_POINTF objects, with a leading Elements value + \return Pointer to PseudoObject, NULL on error + \param Elements Number of pairs of points in Coords + \param Coords Array of X,Y pairs. + + EMF+ manual 2.2.2.36, Microsoft name: EmfPlusPointF Object +*/ +U_PSEUDO_OBJ *U_PMF_POINTF_set(uint32_t Elements, const U_PMF_POINTF *Coords){ + if(!Elements || !Coords)return(NULL); + const U_SERIAL_DESC List[] = { + {&Elements, 4, 1, U_LE}, + {Coords, 4, 2*Elements, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_POINTF_OID | U_PMF_ARRAY_OID, List); + return(po); +} + +/** + \brief Create and set an ARRAY of U_PMF_POINTR objects + \return Pointer to PseudoObject, NULL on error + \param Elements Number of pairs of points in Coords + \param Coords Array of X,Y pairs. These are absolute coordinates, they are converted to Relative here. + + EMF+ manual 2.2.2.37, Microsoft name: EmfPlusPointR Object +*/ +U_PSEUDO_OBJ *U_PMF_POINTR_set(uint32_t Elements, const U_PMF_POINTF *Coords){ + int X,Y; + U_FLOAT Xf,Yf; + U_PSEUDO_OBJ *poi; + /* Worst case scenario it is 4 bytes per coord, plus the count */ + U_PSEUDO_OBJ *po = U_PO_create(NULL, 4 + 4*Elements, 0, U_PMF_POINTR_OID); /* not exactly an array, so no U_PMF_ARRAY_OID */ + + poi = U_PMF_4NUM_set(Elements); + po = U_PO_append(po, poi->Data, poi->Used); + U_PO_free(&poi); + + for(Xf = Yf = 0.0 ;Elements; Elements--, Coords++){ + Xf = U_ROUND(Coords->X) - Xf; + Yf = U_ROUND(Coords->Y) - Yf; + X = ( Xf >= UINT16_MAX ? UINT16_MAX : ( Xf <= INT16_MIN ? INT16_MIN : Xf)); + Y = ( Yf >= UINT16_MAX ? UINT16_MAX : ( Yf <= INT16_MIN ? INT16_MIN : Yf)); + Xf = U_ROUND(Coords->X); + Yf = U_ROUND(Coords->Y); + + /* this is not a very efficient method, too much mucking around with memory */ + + poi = U_PMF_INTEGER7_set(X); + if(!poi)poi = U_PMF_INTEGER15_set(X); /* This one must work because of the range checking, above */ + po = U_PO_append(po, poi->Data, poi->Used); + U_PO_free(&poi); + + poi = U_PMF_INTEGER7_set(Y); + if(!poi)poi = U_PMF_INTEGER15_set(Y); /* This one must work because of the range checking, above */ + po = U_PO_append(po, poi->Data, poi->Used); + U_PO_free(&poi); + } + /* Because the values stored were some unpredictable combination of 1 and 2 bytes, the last byte may not end + on a 4 byte boundary. Make it do so by padding with up to 3 zero bytes. */ +#if 1 + int residual; + unsigned long int us, uu; + us = po->Size; /* printing size_t portably is a pain, this avoids the issue */ + uu = po->Used; + residual = 3 & po->Used; +printf("DEBUG Used:%lu residual:%d\n",uu, residual);fflush(stdout); + if(residual){ + po = U_PO_append(po, NULL, (4 - residual)); + } +printf("DEBUG Size:%lu Used:%lu \n",us,uu);fflush(stdout); +#endif + return(po); +} + +/** + \brief Create and set a U_PMF_RECT object + \return Pointer to PseudoObject, NULL on error + \param X UL X value + \param Y UL Y value + \param Width Width + \param Height Height + + EMF+ manual 2.2.2.38, Microsoft name: EmfPlusRect Object +*/ +U_PSEUDO_OBJ *U_PMF_RECT4_set(int16_t X, int16_t Y, int16_t Width, int16_t Height){ + const U_SERIAL_DESC List[] = { + {&X, 2, 1, U_LE}, + {&Y, 2, 1, U_LE}, + {&Width, 2, 1, U_LE}, + {&Height, 2, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_RECT_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_RECT object + \return Pointer to PseudoObject, NULL on error + \param Rect U_PMF_RECT structures + + EMF+ manual 2.2.2.38, Microsoft name: EmfPlusRect Object +*/ +U_PSEUDO_OBJ *U_PMF_RECT_set(U_PMF_RECT *Rect){ + const U_SERIAL_DESC List[] = { + {Rect, 2, 4, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_RECT_OID, List); + return(po); +} + +/** + \brief Create and set an array of U_PMF_RECT objects in a PseudoObject + \return Pointer to PseudoObject, NULL on error. PseudoObject contains Elements followed by the array of U_PMF_RECT objects. + \param Elements Number of elements in Rects + \param Rects Array of U_PMF_RECT structures + + EMF+ manual 2.2.2.38, Microsoft name: EmfPlusRect Object +*/ +U_PSEUDO_OBJ *U_PMF_RECTN_set(uint32_t Elements, U_PMF_RECT *Rects){ + if(!Rects){ return(NULL); } + uint32_t count = Elements; + U_SERIAL_DESC *Lptr = (U_SERIAL_DESC *) malloc(4 + (Elements * 2 * 4) + 4); + U_SERIAL_DESC *List = List; + if(!List){ return(NULL); } + *Lptr++ = (U_SERIAL_DESC){&Elements, 4, 1, U_LE}; + for(; count; count--, Lptr++, Rects++){ *Lptr = (U_SERIAL_DESC){Rects, 2, 4, U_LE}; } + *Lptr = (U_SERIAL_DESC){NULL,0,0,U_XX}; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_RECTF_OID | U_PMF_ARRAY_OID, List); + free(List); + return(po); +} + +/** + \brief Create and set a U_PMF_RECTF object in a PseudoObject + \return Pointer to PseudoObject, NULL on error + \param X UL X value + \param Y UL Y value + \param Width Width + \param Height Height + + EMF+ manual 2.2.2.39, Microsoft name: EmfPlusRectF Object +*/ +U_PSEUDO_OBJ *U_PMF_RECTF4_set(U_FLOAT X, U_FLOAT Y, U_FLOAT Width, U_FLOAT Height){ + const U_SERIAL_DESC List[] = { + {&X, 4, 1, U_LE}, + {&Y, 4, 1, U_LE}, + {&Width, 4, 1, U_LE}, + {&Height, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_RECTF_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_RECTF object in a PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Rect U_PMF_RECTF structure + + EMF+ manual 2.2.2.39, Microsoft name: EmfPlusRectF Object +*/ +U_PSEUDO_OBJ *U_PMF_RECTF_set(U_PMF_RECTF *Rect){ + const U_SERIAL_DESC List[] = { + {Rect, 4, 4, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_RECTF_OID, List); + return(po); +} + +/** + \brief Create and set an array of U_PMF_RECTF objects in a PseudoObject + \return Pointer to PseudoObject, NULL on error. PseudoObject contains Elements followed by the array of U_PMF_RECTF objects. + \param Elements Number of elements in Rects + \param Rects Array of U_PMF_RECTF structures + + EMF+ manual 2.2.2.39, Microsoft name: EmfPlusRectF Object +*/ +U_PSEUDO_OBJ *U_PMF_RECTFN_set(uint32_t Elements, U_PMF_RECTF *Rects){ + if(!Rects){ return(NULL); } + uint32_t count = Elements; + U_SERIAL_DESC *List = (U_SERIAL_DESC *) malloc((Elements + 2) * sizeof(U_SERIAL_DESC)); + U_SERIAL_DESC *Lptr = List; + if(!List){ return(NULL); } + *Lptr++ = (U_SERIAL_DESC){&Elements, 4, 1, U_LE}; + for(; count; count--, Lptr++, Rects++){ + *Lptr = (U_SERIAL_DESC){Rects, 4, 4, U_LE}; + } + *Lptr = (U_SERIAL_DESC){NULL,0,0,U_XX}; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_RECTF_OID | U_PMF_ARRAY_OID, List); + free(List); + return(po); +} + +/** + \brief Create and set a U_PMF_REGIONNODE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Type RegionNodeDataType Enumeration + \param Rnd (optional) U_PSEUDO_OBJ containing a U_PMF_REGIONNODEPATH, U_PMF_RECTF, or U_PMF_REGIONNODECHILDNODES object (Region Node Data) + + + EMF+ manual 2.2.2.40, Microsoft name: EmfPlusRegionNode Object +*/ +U_PSEUDO_OBJ *U_PMF_REGIONNODE_set(int32_t Type, const U_PSEUDO_OBJ *Rnd){ + int32_t pType; + /* make sure that the type of Rnd agrees with Type */ + if(Rnd){ + pType = U_OID_To_RNDT(Rnd->Type); + if( pType < 0){ return(NULL); } + if((pType > 0) && (pType != Type)){ return(NULL); } + if((pType == 0) && + ( + (Type < U_RNDT_And) || + (Type > U_RNDT_Complement) + ) + ){ return(NULL); } + if((Type == U_RNDT_Rect) && (Rnd->Type != U_PMF_RECTF_OID)){ return(NULL); } + if((Type == U_RNDT_Path) && (Rnd->Type != U_PMF_REGIONNODEPATH_OID)){ return(NULL); } + + } + else { /* only U_RNDT_Empty and U_RNDT_Infinite do not have data */ + if((Type != U_RNDT_Empty) || + (Type != U_RNDT_Infinite) ){ return(NULL); } + } + + + const U_SERIAL_DESC List[] = { + {&Type, 4, 1, U_LE}, + {(Rnd ? Rnd->Data : NULL), (Rnd ? Rnd->Used : 0), 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_REGIONNODE_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_REGIONNODECHILDNODES PseudoObject + \return Pointer to PseudoObject containing a U_PMF_REGIONNODECHILDNODES_OID object, NULL on error + \param Left U_PSEUDO_OBJ containing a U_PMF_REGIONNODE object + \param Right U_PSEUDO_OBJ containing a U_PMF_REGIONNODE object + + + EMF+ manual 2.2.2.41, Microsoft name: EmfPlusRegionNodeChildNodes Object +*/ +U_PSEUDO_OBJ *U_PMF_REGIONNODECHILDNODES_set(const U_PSEUDO_OBJ *Left, const U_PSEUDO_OBJ *Right){ + if(!Left || (Left->Type != U_PMF_REGIONNODE_OID)){ return(NULL); } + if(!Right || (Right->Type != U_PMF_REGIONNODE_OID)){ return(NULL); } + + const U_SERIAL_DESC List[] = { + {Left->Data, Left->Used, 1, U_XE}, + {Right->Data, Right->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_REGIONNODECHILDNODES_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_REGIONNODEPATH PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Path U_PSEUDO_OBJ containing a U_PMF_PATH object + + + EMF+ manual 2.2.2.42, Microsoft name: EmfPlusRegionNodePath Object +*/ +U_PSEUDO_OBJ *U_PMF_REGIONNODEPATH_set(const U_PSEUDO_OBJ *Path){ + if(!Path || (Path->Type != U_PMF_PATH_OID)){ return(NULL); } + /* PO Used is size_t, might be 8 bytes, value in record must be 4 bytes */ + uint32_t Used = Path->Used; + + const U_SERIAL_DESC List[] = { + {&Used, 4, 1, U_LE}, + {Path->Data, Path->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_REGIONNODEPATH_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_SOLIDBRUSHDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Color U_PSEUDO_OBJ containing a U_PMF_ARGB object + + + EMF+ manual 2.2.2.43, Microsoft name: EmfPlusSolidBrushData Object +*/ +U_PSEUDO_OBJ *U_PMF_SOLIDBRUSHDATA_set(const U_PSEUDO_OBJ *Color){ + if(!Color || (Color->Type != U_PMF_ARGB_OID)){ return(NULL); } + + const U_SERIAL_DESC List[] = { + {Color->Data, Color->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_SOLIDBRUSHDATA_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_STRINGFORMATDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param TabStopCount Entries in TabStop array + \param TabStops (optional) Array of tabstop locations + \param Ranges (optional) U_PSEUDO_OBJ containing an array of U_PMF_CHARACTERRANGE objects + + + EMF+ manual 2.2.2.44, Microsoft name: EmfPlusStringFormatData Object +*/ +U_PSEUDO_OBJ *U_PMF_STRINGFORMATDATA_set(uint32_t TabStopCount, U_FLOAT *TabStops, const U_PSEUDO_OBJ *Ranges){ + if(Ranges && (Ranges->Type != (U_PMF_CHARACTERRANGE_OID | U_PMF_ARRAY_OID))){ return(NULL); } + + const U_SERIAL_DESC List[] = { + {TabStops, TabStopCount*4, 1, U_LE}, + {(Ranges ? Ranges->Data : NULL), (Ranges ? Ranges->Used : 0), 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_STRINGFORMATDATA_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_TEXTUREBRUSHDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Flags BrushData flags + \param WrapMode WrapMode enumeration + \param Tbod U_PSEUDO_OBJ containing an U_PMF_TEXTUREBRUSHOPTIONALDATA object + + + EMF+ manual 2.2.2.45, Microsoft name: EmfPlusTextureBrushData Object +*/ +U_PSEUDO_OBJ *U_PMF_TEXTUREBRUSHDATA_set(uint32_t Flags, uint32_t WrapMode, const U_PSEUDO_OBJ *Tbod){ + if(Flags & ~U_BD_MASKB){ return(NULL); } /* a bit was set that is not supported for this record */ + if(WrapMode > U_WM_Clamp){ return(NULL); } + if(!Tbod || (Tbod->Type != (U_PMF_TEXTUREBRUSHOPTIONALDATA_OID))){ return(NULL); } + + const U_SERIAL_DESC List[] = { + {&Flags, 4, 1, U_LE}, + {&WrapMode, 4, 1, U_LE}, + {Tbod->Data, Tbod->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_TEXTUREBRUSHDATA_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_TEXTUREBRUSHOPTIONALDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Tm (optional) U_PSEUDO_OBJ containing an U_PMF_TRANSFORMMATRIX object + \param Image (optional) U_PSEUDO_OBJ containing an U_PMF_IMAGE object + + + EMF+ manual 2.2.2.46, Microsoft name: EmfPlusTextureBrushOptionalData Object +*/ +U_PSEUDO_OBJ *U_PMF_TEXTUREBRUSHOPTIONALDATA_set(const U_PSEUDO_OBJ *Tm, const U_PSEUDO_OBJ *Image){ + if(Tm && (Tm->Type != (U_PMF_TRANSFORMMATRIX_OID))){ return(NULL); } + if(Image && (Image->Type != (U_PMF_IMAGE_OID))){ return(NULL); } + + const U_SERIAL_DESC List[] = { + {(Tm ? Tm->Data : NULL), (Tm ? Tm->Used : 0), 1, U_XE}, + {(Image ? Image->Data : NULL), (Image ? Image->Used : 0), 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_TEXTUREBRUSHOPTIONALDATA_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_TRANSFORMMATRIX PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Tm U_PMF_TRANSFORMMATRIX_ object + + + EMF+ manual 2.2.2.47, Microsoft name: EmfPlusTransformMatrix Object +*/ +U_PSEUDO_OBJ *U_PMF_TRANSFORMMATRIX_set(U_PMF_TRANSFORMMATRIX *Tm){ + if(!Tm){ return(NULL); } + + const U_SERIAL_DESC List[] = { + {Tm, 4, 6, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_TRANSFORMMATRIX_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_IE_BLUR PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Radius Blur radius in pixels + \param ExpandEdge 1: expand bitmap by Radius; 0: bitmap size unchanged + + + EMF+ manual 2.2.3.1, Microsoft name: BlurEffect Object +*/ +U_PSEUDO_OBJ *U_PMF_IE_BLUR_set(U_FLOAT Radius, uint32_t ExpandEdge){ + + const U_SERIAL_DESC List[] = { + {&Radius, 4, 1, U_LE}, + {&ExpandEdge, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_IE_BLUR_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_IE_BRIGHTNESSCONTRAST PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Brightness -255 to 255, 0 is unchanged, positive increases, negative decreases + \param Contrast -100 to 100, 0 is unchanged, positive increases, negative decreases + + + EMF+ manual 2.2.3.2, Microsoft name: BrightnessContrastEffect Object +*/ +U_PSEUDO_OBJ *U_PMF_IE_BRIGHTNESSCONTRAST_set(int32_t Brightness, int32_t Contrast){ + + const U_SERIAL_DESC List[] = { + {&Brightness, 4, 1, U_LE}, + {&Contrast, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_IE_BRIGHTNESSCONTRAST_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_IE_COLORBALANCE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param CyanRed -100 to 100, 0 is unchanged, positive increases Red & decreases Cyan, negative is opposite + \param MagentaGreen -100 to 100, 0 is unchanged, positive increases Green & decreases Magenta, negative is opposite + \param YellowBlue -100 to 100, 0 is unchanged, positive increases Blue & decreases Yellow, negative is opposite + + + EMF+ manual 2.2.3.3, Microsoft name: ColorBalanceEffect Object +*/ +U_PSEUDO_OBJ *U_PMF_IE_COLORBALANCE_set(int32_t CyanRed, int32_t MagentaGreen, int32_t YellowBlue){ + + const U_SERIAL_DESC List[] = { + {&CyanRed, 4, 1, U_LE}, + {&MagentaGreen, 4, 1, U_LE}, + {&YellowBlue, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_IE_COLORBALANCE_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_IE_COLORCURVE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Adjust CurveAdjustment enumeration + \param Channel CurveChannel enumeration + \param Intensity adjustment to apply. "Adjust" determines what field this is and range values. + + + EMF+ manual 2.2.3.4, Microsoft name: ColorCurveEffect Object +*/ +U_PSEUDO_OBJ *U_PMF_IE_COLORCURVE_set(uint32_t Adjust, uint32_t Channel, int32_t Intensity){ + + const U_SERIAL_DESC List[] = { + {&Adjust, 4, 1, U_LE}, + {&Channel, 4, 1, U_LE}, + {&Intensity, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_IE_COLORCURVE_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_IE_COLORLOOKUPTABLE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param BLUT Blue color lookup table + \param GLUT Green color lookup table + \param RLUT Red color lookup table + \param ALUT Alpha color lookup table + + + + EMF+ manual 2.2.3.5, Microsoft name: ColorLookupTableEffect Object. + All tables have 256 entries. +*/ +U_PSEUDO_OBJ *U_PMF_IE_COLORLOOKUPTABLE_set(const uint8_t *BLUT, const uint8_t *GLUT, const uint8_t *RLUT, const uint8_t *ALUT){ + if(!BLUT || !GLUT || !RLUT || !ALUT)return(NULL); + + const U_SERIAL_DESC List[] = { + {BLUT, 1, 256, U_XE}, + {GLUT, 1, 256, U_XE}, + {RLUT, 1, 256, U_XE}, + {ALUT, 1, 256, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_IE_COLORLOOKUPTABLE_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_IE_COLORMATRIX PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Matrix 5 x 5 color transformation matrix, First 4 rows are [{4 multiplier values},0.0] for R,G,B,A, last Row is [{4 color translation valuess}, 1.0] + + + EMF+ manual 2.2.3.6, Microsoft name: ColorMatrixEffect Object +*/ +U_PSEUDO_OBJ *U_PMF_IE_COLORMATRIX_set(const U_FLOAT *Matrix){ + if(!Matrix)return(NULL); + + const U_SERIAL_DESC List[] = { + {Matrix, 4, 25, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_IE_COLORMATRIX_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_IE_HUESATURATIONLIGHTNESS PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Hue -180 to 180, 0 is unchanged + \param Saturation -100 to 100, 0 is unchanged + \param Lightness -100 to 100, 0 is unchanged + + + EMF+ manual 2.2.3.7, Microsoft name: HueSaturationLightnessEffect Object +*/ +U_PSEUDO_OBJ *U_PMF_IE_HUESATURATIONLIGHTNESS_set(int32_t Hue, int32_t Saturation, int32_t Lightness){ + + const U_SERIAL_DESC List[] = { + {&Hue, 4, 1, U_LE}, + {&Saturation, 4, 1, U_LE}, + {&Lightness, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_IE_HUESATURATIONLIGHTNESS_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_IE_LEVELS PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Highlight 0 to 100, 100 is unchanged + \param Midtone -100 to 0, 0 is unchanged + \param Shadow 0 to 100, 0 is unchanged + + + EMF+ manual 2.2.3.8, Microsoft name: LevelsEffect Object +*/ +U_PSEUDO_OBJ *U_PMF_IE_LEVELS_set(int32_t Highlight, int32_t Midtone, int32_t Shadow){ + + const U_SERIAL_DESC List[] = { + {&Highlight, 4, 1, U_LE}, + {&Midtone, 4, 1, U_LE}, + {&Shadow, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_IE_LEVELS_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_IE_REDEYECORRECTION PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Elements Number of members in Rects + \param Rects Array of U_RECTL rectangular area(s) to apply red eye correction + + + EMF+ manual 2.2.3.9, Microsoft name: RedEyeCorrectionEffect Object +*/ +U_PSEUDO_OBJ *U_PMF_IE_REDEYECORRECTION_set(uint32_t Elements, const U_RECTL *Rects){ + if(!Elements || !Rects){return(NULL);} + + const U_SERIAL_DESC List[] = { + {&Elements, 4, 1, U_LE}, + {Rects, 4*4, Elements,U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_IE_REDEYECORRECTION_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_IE_SHARPEN PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Radius Sharpening radius in pixels + \param Sharpen 0 to 100, 0 is unchanged + + + EMF+ manual 2.2.3.10, Microsoft name: SharpenEffect Object +*/ +U_PSEUDO_OBJ *U_PMF_IE_SHARPEN_set(U_FLOAT Radius, int32_t Sharpen){ + + const U_SERIAL_DESC List[] = { + {&Radius, 4, 1, U_LE}, + {&Sharpen, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_IE_SHARPEN_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_IE_TINT PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Hue -180 to 180, [positive==clockwise] rotation in degrees starting from blue + \param Amount -100 [add black] to 100[add white], 0 is unchanged. Change in hue on specified axis + + + EMF+ manual 2.2.3.11, Microsoft name: TintEffect Object +*/ +U_PSEUDO_OBJ *U_PMF_IE_TINT_set(const int32_t Hue, const int32_t Amount){ + + const U_SERIAL_DESC List[] = { + {&Hue, 4, 1, U_LE}, + {&Amount, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_IE_TINT_OID, List); + return(po); +} + +//! \cond +/* internal routine, not part of the API. + Returns a PseudoObject containing a U_PMR_CMN_HDR_OID object. + The type is something like U_PMR_OFFSETCLIP (the record type, NOT the U_PMR_OFFSETCLIP_OID PseudoObject Type!). + The U_PMR_RECFLAG bit is added both in the data and in the Type of the PseudoObject. + If that bit is already set no harm, no foul. +*/ + +U_PSEUDO_OBJ *U_PMR_CMN_HDR_set(uint32_t Type, uint16_t Flags, uint32_t DataSize){ + + uint32_t Size = 12 + UP4(DataSize); /* The header itself is always 12, PMR records must be a multiple of 4 */ + Type |= U_PMR_RECFLAG; + uint16_t utmp16 = Type; + const U_SERIAL_DESC List[] = { + {&utmp16, 2, 1, U_LE}, + {&Flags, 2, 1, U_LE}, /* Microsoft EMF+ manual is BE, but this field in this implementation is LE */ + {&Size, 4, 1, U_LE}, + {&DataSize, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_CMN_HDR_OID, List); + return(po); +} +//! \endcond + + +/** + \brief Create and set a U_PMR_STROKEFILLPATH PseudoObject + \return Pointer to PseudoObject, NULL on error + + + EMF+ manual mentioned in 2.1.1.1, not otherwise documented, Microsoft name: EmfPlusStrokeFillPath Record, Index 0x37 + + "This record closes any open figures in a path, strokes the outline of + the path by using the current pen, and fills its interior by using the current brush." + +*/ +U_PSEUDO_OBJ *U_PMR_STROKEFILLPATH_set(void){ + int Size = 0; + uint16_t utmp16 = 0; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_STROKEFILLPATH,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_STROKEFILLPATH_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_OFFSETCLIP PseudoObject + \return Pointer to PseudoObject, NULL on error + \param dX horizontal translation offset to apply to clipping region + \param dY vertical translation offset to apply to clipping region + + + EMF+ manual 2.3.1.1, Microsoft name: EmfPlusOffsetClip Record, Index 0x35 +*/ +U_PSEUDO_OBJ *U_PMR_OFFSETCLIP_set(U_FLOAT dX, U_FLOAT dY){ + int Size = 2*4; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_OFFSETCLIP,0,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {&dX, 4, 1, U_LE}, + {&dY, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_OFFSETCLIP_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_RESETCLIP PseudoObject + \return Pointer to PseudoObject, NULL on error + + + EMF+ manual 2.3.1.2, Microsoft name: EmfPlusResetClip Record, Index 0x31 +*/ +U_PSEUDO_OBJ *U_PMR_RESETCLIP_set(void){ + int Size = 0; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_RESETCLIP,0,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_RESETCLIP_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_SETCLIPPATH PseudoObject + \return Pointer to PseudoObject, NULL on error + \param CMenum CombineMode enumeration.. + \param PathID U_PMF_PATH object in the EMF+ object table (0-63, inclusive) + + + EMF+ manual 2.3.1.3, Microsoft name: EmfPlusSetClipPath Record, Index 0x33 +*/ +U_PSEUDO_OBJ *U_PMR_SETCLIPPATH_set(uint32_t PathID, uint32_t CMenum){ + if(PathID>63)return(NULL); + int Size=0; + uint16_t utmp16 = ((PathID & U_FF_MASK_OID8) << U_FF_SHFT_OID8) | ((CMenum & U_FF_MASK_CM4) << U_FF_SHFT_CM4); + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_SETCLIPPATH,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_SETCLIPPATH_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_SETCLIPRECT PseudoObject + \return Pointer to PseudoObject, NULL on error + \param CMenum CombineMode enumeration.. + \param Rect U_PSEUDO_OBJ containing an U_PMF_RECTF object or an array of U_PMF_RECTF objects (the first is used) + + + EMF+ manual 2.3.1.4, Microsoft name: EmfPlusSetClipRect Record, Index 0x32 +*/ +U_PSEUDO_OBJ *U_PMR_SETCLIPRECT_set(uint32_t CMenum, const U_PSEUDO_OBJ *Rect){ + int Size=4*4; + const char *start; + uint16_t utmp16 = ((CMenum & U_FF_MASK_CM4) << U_FF_SHFT_CM4); + if(Rect){ + if( Rect->Type == U_PMF_RECTF_OID){ + start = Rect->Data; + } + else if(Rect->Type == (U_PMF_RECTF_OID | U_PMF_ARRAY_OID)){ + start = Rect->Data + 4; + } + else { return(0); } + } + else { return(0); } + + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_SETCLIPRECT,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {start, 4, 4, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_SETCLIPRECT_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_SETCLIPREGION PseudoObject + \return Pointer to PseudoObject, NULL on error + \param PathID U_PMF_PATH object in the EMF+ object table (0-63, inclusive) + \param CMenum CombineMode enumeration.. + + + EMF+ manual 2.3.1.5, Microsoft name: EmfPlusSetClipRegion Record, Index 0x34 +*/ +U_PSEUDO_OBJ *U_PMR_SETCLIPREGION_set(uint32_t PathID, uint32_t CMenum){ + if(PathID>63)return(NULL); + int Size=0; + uint16_t utmp16 = ((PathID & U_FF_MASK_OID8) << U_FF_SHFT_OID8) | ((CMenum & U_FF_MASK_CM4) << U_FF_SHFT_CM4); + + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_SETCLIPREGION,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_SETCLIPREGION_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_COMMENT PseudoObject + \return Pointer to PseudoObject, NULL on error + \param cbData Number of bytes in Data, must be a multiple of 4 + \param Data Private data, may be anything. Stored in PseudoObject without adjusting byte order. + + + EMF+ manual 2.3.2.1, Microsoft name: EmfPlusComment Record, Index 0x03 +*/ +U_PSEUDO_OBJ *U_PMR_COMMENT_set(size_t cbData, const void *Data){ + if(UP4(cbData) != cbData){ return(NULL); } + int Size=cbData; + + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_COMMENT,0,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {Data, cbData, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_COMMENT_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_ENDOFFILE PseudoObject + \return Pointer to PseudoObject, NULL on error + + + EMF+ manual 2.3.3.1, Microsoft name: EmfPlusEndOfFile Record, Index 0x02 +*/ +U_PSEUDO_OBJ *U_PMR_ENDOFFILE_set(void){ + int Size=0; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_ENDOFFILE,0,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_ENDOFFILE_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_GETDC PseudoObject + \return Pointer to PseudoObject, NULL on error + + + EMF+ manual 2.3.3.2, Microsoft name: EmfPlusGetDC Record, Index 0x04 +*/ +U_PSEUDO_OBJ *U_PMR_GETDC_set(void){ + int Size=0; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_GETDC,0,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_GETDC_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_HEADER PseudoObject + \return Pointer to PseudoObject, NULL on error + \param IsDual set = Dual-mode file, clear= EMF+ only file. + \param IsVideo set = video device, clear= printer. Ignore all other bits. + \param Version U_PSEUDO_OBJ containing a U_PMF_GRAPHICSVERSION object + \param LogicalDpiX Horizontal resolution reference device in DPI + \param LogicalDpiY Vertical resolution reference device in DPI + + + EMF+ manual 2.3.3.3, Microsoft name: EmfPlusHeader Record, Index 0x01 +*/ +U_PSEUDO_OBJ *U_PMR_HEADER_set(int IsDual, int IsVideo, const U_PSEUDO_OBJ *Version, + uint32_t LogicalDpiX, uint32_t LogicalDpiY){ + if(!Version || (Version->Type != U_PMF_GRAPHICSVERSION_OID)){ return(NULL); } + int Size=Version->Used + 3*4; + uint16_t utmp16 = (IsDual ? U_PPF_DM : 0); + uint32_t Flags = (IsVideo ? U_PPF_VIDEO : 0); + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_HEADER,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {Version->Data, Version->Used, 1, U_XE}, + {&Flags, 4, 1, U_LE}, + {&LogicalDpiX, 4, 1, U_LE}, + {&LogicalDpiY, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_HEADER_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_CLEAR PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Color U_PSEUDO_OBJ containing a U_PMF_ARGB object. + + + + EMF+ manual 2.3.4.1, Microsoft name: EmfPlusClear Record, Index 0x09 + + Erase everything preceding, set background ARGB to Color. +*/ +U_PSEUDO_OBJ *U_PMR_CLEAR_set(const U_PSEUDO_OBJ *Color){ + if(!Color || (Color->Type != U_PMF_ARGB_OID)){ return(NULL); } + int Size=Color->Used; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_CLEAR,0,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {Color->Data, Color->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_CLEAR_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_DRAWARC PseudoObject + \return Pointer to PseudoObject, NULL on error + \param PenID U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + \param Start Start angle, >=0.0, degrees clockwise from 3:00 + \param Sweep Sweep angle, -360<= angle <=360, degrees clockwise from Start + \param Rect U_PSEUDO_OBJ containing a U_PMF_RECT or U_PMF_RECTF object + + + EMF+ manual 2.3.4.2, Microsoft name: EmfPlusDrawArc Record, Index 0x12 +*/ +U_PSEUDO_OBJ *U_PMR_DRAWARC_set(uint32_t PenID, U_FLOAT Start, U_FLOAT Sweep, const U_PSEUDO_OBJ *Rect){ + int ctype; + if(PenID>63)return(NULL); + if(!Rect){ return(NULL); } + else { + if( Rect->Type == U_PMF_RECT_OID ){ ctype = 1; } + else if(Rect->Type == U_PMF_RECTF_OID){ ctype = 0; } + else { return(NULL); } + } + int Size = 2*4 + Rect->Used; + uint16_t utmp16 = (ctype ? U_PPF_C : 0) | (PenID & U_FF_MASK_OID8) << U_FF_SHFT_OID8; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_DRAWARC,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {&Start, 4, 1, U_LE}, + {&Sweep, 4, 1, U_LE}, + {Rect->Data, Rect->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_DRAWARC_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_DRAWBEZIERS PseudoObject + \return Pointer to PseudoObject, NULL on error + \param PenID U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + \param Points U_PSEUDO_OBJ containing first Elements, then a U_PMF_POINT, U_PMF_POINTR or U_PMF_POINTF object + + + EMF+ manual 2.3.4.3, Microsoft name: EmfPlusDrawBeziers Record, Index 0x19 +*/ +U_PSEUDO_OBJ *U_PMR_DRAWBEZIERS_set(uint32_t PenID, const U_PSEUDO_OBJ *Points){ + int ctype, RelAbs; + if(PenID>63)return(NULL); + if(Points){ + if( Points->Type == U_PMF_POINTR_OID){ RelAbs = 1; ctype = 0; } + else if(Points->Type == (U_PMF_POINT_OID | U_PMF_ARRAY_OID)){ RelAbs = 0; ctype = 1; } + else if(Points->Type == (U_PMF_POINTF_OID | U_PMF_ARRAY_OID)){ RelAbs = 0; ctype = 0; } + else { return(NULL); } + } + else { return(NULL); } + int Size = Points->Used; + uint16_t utmp16 = (ctype ? U_PPF_C : 0) | (RelAbs ? U_PPF_P : 0) |(PenID & U_FF_MASK_OID8) << U_FF_SHFT_OID8; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_DRAWBEZIERS,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {Points->Data, Points->Used, 1, U_XE}, /* Includes Elements */ + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_DRAWBEZIERS_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_DRAWCLOSEDCURVE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param PenID U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + \param Tension Controls splines, 0 is straight line, >0 is curved + \param Points U_PSEUDO_OBJ containing a U_PMF_POINT, U_PMF_POINTR or U_PMF_POINTF object + + + EMF+ manual 2.3.4.4, Microsoft name: EmfPlusDrawClosedCurve Record, Index 0x17 + + Curve is a cardinal spline. + + References sent by MS support: + + http://alvyray.com/Memos/CG/Pixar/spline77.pdf + + http://msdn.microsoft.com/en-us/library/4cf6we5y(v=vs.110).aspx + + +*/ +U_PSEUDO_OBJ *U_PMR_DRAWCLOSEDCURVE_set(uint32_t PenID, U_FLOAT Tension, const U_PSEUDO_OBJ *Points){ + int ctype, RelAbs; + if(PenID>63)return(NULL); + if(Points){ + if( Points->Type == U_PMF_POINTR_OID){ RelAbs = 1; ctype = 0; } + else if(Points->Type == (U_PMF_POINT_OID | U_PMF_ARRAY_OID)){ RelAbs = 0; ctype = 1; } + else if(Points->Type == (U_PMF_POINTF_OID | U_PMF_ARRAY_OID)){ RelAbs = 0; ctype = 0; } + else { return(NULL); } + } + else { return(NULL); } + int Size = 4 + Points->Used; + uint16_t utmp16 = (ctype ? U_PPF_C : 0) | (RelAbs ? U_PPF_P : 0) |(PenID & U_FF_MASK_OID8) << U_FF_SHFT_OID8; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_DRAWCLOSEDCURVE,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {&Tension, 4, 1, U_LE}, + {Points->Data, Points->Used, 1, U_XE}, /* includes Elements*/ + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_DRAWCLOSEDCURVE_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_DRAWCURVE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param PenID U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + \param Tension Controls splines, 0 is straight line, >0 is curved + \param Offset The starting point in the list of points, 0 is first. + \param NSegs Number of segments to draw. Starting at Offset go NSegs straight lines, must not run out of points.. + \param Points U_PSEUDO_OBJ containing an element count then a series of U_PMF_POINT or U_PMF_POINTF object + + + EMF+ manual 2.3.4.5, Microsoft name: EmfPlusDrawCurve Record, Index 0x18 + + Curve is a cardinal spline, using doubled terminator points to generate curves for the terminal segments. + + References sent by MS support: + + http://alvyray.com/Memos/CG/Pixar/spline77.pdf + + http://msdn.microsoft.com/en-us/library/4cf6we5y(v=vs.110).aspx + +*/ +U_PSEUDO_OBJ *U_PMR_DRAWCURVE_set(uint32_t PenID, U_FLOAT Tension, uint32_t Offset, uint32_t NSegs, const U_PSEUDO_OBJ *Points){ + int ctype; + if(PenID>63)return(NULL); + if(!Points){ return(NULL); } + if(!NSegs){ return(NULL); } + else { + if( Points->Type == (U_PMF_POINT_OID | U_PMF_ARRAY_OID)){ ctype = 1; } + else if(Points->Type == (U_PMF_POINTF_OID | U_PMF_ARRAY_OID)){ ctype = 0; } + else { return(NULL); } + } + uint32_t Elements = (Points->Used - 4)/(ctype ? 4 : 8); /* This way do not need to worry about byte order */ + if(Offset + NSegs + 1 > Elements){ return(NULL); } + int Size = 3*4 + Points->Used; + uint16_t utmp16 = (ctype ? U_PPF_C : 0) |(PenID & U_FF_MASK_OID8) << U_FF_SHFT_OID8; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_DRAWCURVE,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {&Tension, 4, 1, U_LE}, + {&Offset, 4, 1, U_LE}, + {&NSegs, 4, 1, U_LE}, + {Points->Data, Points->Used, 1, U_XE}, /* Elements, points */ + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_DRAWCURVE_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_DRAWDRIVERSTRING PseudoObject + \return Pointer to PseudoObject, NULL on error + \param FontID U_PMF_FONT object in the EMF+ object table (0-63, inclusive) + \param Tension Controls splines, 0 is straight line, >0 is curved + \param BrushID U_PSEUDO_OBJ containing a U_PMF_ARGB or a U_PMF_4NUM. Color or U_PMF_BRUSH object in the EMF+ object table (0-63, inclusive) + \param DSOFlags DriverStringOptions flags + \param HasMatrix If 1 record contains a TransformMatrix field, if 0 it does not. + \param GlyphCount The number of Elements in Glyphs, must agree with the number of elements in Points. + \param Glyphs If U_DSO_CmapLookup is set in DSOFlags this is an array of UTF16LE characters, otherwise, it is an array of indices into the U_PMF_FONT object indexed by Object_ID in flags. + \param Points U_PSEUDO_OBJ containing a U_PMF_POINTF object + \param Tm U_PSEUDO_OBJ containing a U_PMF_TRANSFORMMATRIX object. Apply to Glyphs & Positions. Present if HasMatrix is 1 + + + EMF+ manual 2.3.4.6, Microsoft name: EmfPlusDrawDriverString Record, Index 0x36 +*/ +U_PSEUDO_OBJ *U_PMR_DRAWDRIVERSTRING_set(uint32_t FontID, U_FLOAT Tension, const U_PSEUDO_OBJ *BrushID, + uint32_t DSOFlags, uint32_t HasMatrix, uint32_t GlyphCount, + const uint16_t *Glyphs, const U_PSEUDO_OBJ *Points, const U_PSEUDO_OBJ *Tm){ + int btype; + if(FontID>63){ return(NULL); } + if(!Glyphs){ return(NULL); } + if(!Points || (Points->Type != (U_PMF_POINTF_OID | U_PMF_ARRAY_OID))){ return(NULL); } + uint32_t Elements = (Points->Used -4)/4; + if(GlyphCount != Elements){ return(NULL); } + if(BrushID){ + if( BrushID->Used != 4){ return(NULL); } + else if( BrushID->Type == U_PMF_ARGB_OID){ btype = 1; } + else if( BrushID->Type == U_PMF_4NUM_OID){ btype = 0; } + else { return(NULL); } + } + else { return(NULL); } + int Size = 4 + BrushID->Used + 3*4 + Elements*2 + (Points->Used - 4); + if(HasMatrix){ + if(!Tm){ return(NULL); } + else if(Tm->Type != (U_PMF_TRANSFORMMATRIX_OID)){ return(NULL); } + Size += Tm->Used; + } + uint16_t utmp16 = (btype ? U_PPF_B : 0) |(FontID & U_FF_MASK_OID8) << U_FF_SHFT_OID8; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_DRAWDRIVERSTRING,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data,ph->Used, 1, U_XE}, + {&Tension, 4, 1, U_LE}, + {BrushID->Data, BrushID->Used, 1, U_XE}, + {&DSOFlags, 4, 1, U_LE}, + {&HasMatrix, 4, 1, U_LE}, + {&Elements, 4, 1, U_LE}, + {Glyphs, 2, Elements, U_LE}, + {Points->Data + 4, Points->Used - 4, 1, U_XE}, /* omit Elements */ + {(HasMatrix ? Tm->Data : NULL), (HasMatrix ? Tm->Used : 0), 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_DRAWDRIVERSTRING_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_DRAWELLIPSE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param PenID U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + \param Rect U_PSEUDO_OBJ containing a U_PMF_RECT or U_PMF_RECTF object + + + EMF+ manual 2.3.4.7, Microsoft name: EmfPlusDrawEllipse Record, Index 0x0F +*/ +U_PSEUDO_OBJ *U_PMR_DRAWELLIPSE_set(uint32_t PenID, const U_PSEUDO_OBJ *Rect){ + if(PenID>63)return(NULL); + int ctype; + if(!Rect){ return(NULL); } + else { + if( Rect->Type == U_PMF_RECT_OID ){ ctype = 1; } + else if(Rect->Type == U_PMF_RECTF_OID){ ctype = 0; } + else { return(NULL); } + } + int Size = Rect->Used; + uint16_t utmp16 = (ctype ? U_PPF_C : 0) | (PenID & U_FF_MASK_OID8) << U_FF_SHFT_OID8; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_DRAWELLIPSE,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {Rect->Data, Rect->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_DRAWELLIPSE_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_DRAWIMAGE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param ImgID U_PMF_IMAGE object in the EMF+ object table (0-63, inclusive) + \param ImgAttrID index of a U_PMF_IMAGEATTRIBUTES object in the object table + \param SrcUnit UnitType enumeration + \param SrcRect U_PSEUDO_OBJ containing a U_PMF_RECTF object, Source region of image + \param DstRect U_PSEUDO_OBJ containing a U_PMF_RECT or U_PMF_RECTF object + + + EMF+ manual 2.3.4.8, Microsoft name: EmfPlusDrawImage Record, Index 0x1A +*/ +U_PSEUDO_OBJ *U_PMR_DRAWIMAGE_set(uint32_t ImgID, + int32_t ImgAttrID, int32_t SrcUnit, const U_PSEUDO_OBJ *SrcRect, const U_PSEUDO_OBJ *DstRect){ + int ctype; + if(ImgID>63)return(NULL); + if(!SrcRect || (SrcRect->Type != U_PMF_RECTF_OID)){ return(NULL); } + if(!DstRect){ return(NULL); } + else { + if( DstRect->Type == U_PMF_RECT_OID ){ ctype = 1; } + else if(DstRect->Type == U_PMF_RECTF_OID){ ctype = 0; } + else { return(NULL); } + } + int Size = 2*4 + SrcRect->Used + DstRect->Used; + uint16_t utmp16 = (ctype ? U_PPF_C : 0) | (ImgID & U_FF_MASK_OID8) << U_FF_SHFT_OID8; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_DRAWIMAGE,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {&ImgAttrID, 4, 1, U_LE}, + {&SrcUnit, 4, 1, U_LE}, + {SrcRect->Data, SrcRect->Used, 1, U_XE}, + {DstRect->Data, DstRect->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_DRAWIMAGE_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_DRAWIMAGEPOINTS PseudoObject + \return Pointer to PseudoObject, NULL on error + \param ImgID U_PMF_IMAGE object in the EMF+ object table (0-63, inclusive) + \param etype Set: effect from previous U_PMR_SERIALIZABLEOBJECT record will be applied; Clear: no effect applied + \param ImgAttrID index of a U_PMF_IMAGEATTRIBUTES object in the object table + \param SrcUnit UnitType enumeration + \param SrcRect U_PSEUDO_OBJ containing a U_PMF_RECTF object, Source region of image + \param Points U_PSEUDO_OBJ containing an array of 3 (U_PMF_POINT, U_PMF_POINTF, or U_PMF_POINTF) objects. These points are the UL, UR, and LL vertices of a parallelogram. + + + EMF+ manual 2.3.4.9, Microsoft name: EmfPlusDrawImagePoints Record, Index 0x1B + + + WARNING! Windows XP Preview does not show filter effects, whether or not U_PPF_E is set. They are visible if the EMF+ + file is inserted as an image into PowerPoint. +*/ +U_PSEUDO_OBJ *U_PMR_DRAWIMAGEPOINTS_set(uint32_t ImgID, int etype, + int32_t ImgAttrID, int32_t SrcUnit, const U_PSEUDO_OBJ *SrcRect, + const U_PSEUDO_OBJ *Points){ + int ctype, RelAbs; + if(ImgID>63){ return(NULL); } + if(!SrcRect || (SrcRect->Type != U_PMF_RECTF_OID)){ return(NULL); } + if(Points){ + if( Points->Type == U_PMF_POINTR_OID){ RelAbs = 1; ctype = 0; } + else if(Points->Type == (U_PMF_POINT_OID | U_PMF_ARRAY_OID)){ RelAbs = 0; ctype = 1; } + else if(Points->Type == (U_PMF_POINTF_OID | U_PMF_ARRAY_OID)){ RelAbs = 0; ctype = 0; } + else { return(NULL); } + } + else { return(NULL); } + int Size = 2*4 + SrcRect->Used + Points->Used; + uint16_t utmp16 = (ctype ? U_PPF_C : 0) | (etype ? U_PPF_E : 0) | (RelAbs ? U_PPF_P : 0) | (ImgID & U_FF_MASK_OID8) << U_FF_SHFT_OID8; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_DRAWIMAGEPOINTS,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {&ImgAttrID, 4, 1, U_LE}, + {&SrcUnit, 4, 1, U_LE}, + {SrcRect->Data, SrcRect->Used, 1, U_XE}, + {Points->Data, Points->Used, 1, U_XE}, /* includes Elements*/ + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_DRAWIMAGEPOINTS_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_DRAWLINES PseudoObject + \return Pointer to PseudoObject, NULL on error + \param PenID U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + \param dtype Set: path must be closed, Clear: path is open + \param Points U_PSEUDO_OBJ containing an array of 3 U_PMF_POINT, U_PMF_POINTR, or U_PMF_POINTF objects + + + EMF+ manual 2.3.4.10, Microsoft name: EmfPlusDrawLines Record, Index 0x0D +*/ +U_PSEUDO_OBJ *U_PMR_DRAWLINES_set(uint32_t PenID, int dtype, const U_PSEUDO_OBJ *Points){ + int ctype, RelAbs; + if(PenID>63){ return(NULL); } + if(Points){ + if( Points->Type == U_PMF_POINTR_OID){ RelAbs = 1; ctype = 0; } + else if(Points->Type == (U_PMF_POINT_OID | U_PMF_ARRAY_OID)){ RelAbs = 0; ctype = 1; } + else if(Points->Type == (U_PMF_POINTF_OID | U_PMF_ARRAY_OID)){ RelAbs = 0; ctype = 0; } + else { return(NULL); } + } + else { return(NULL); } + int Size = Points->Used; + uint16_t utmp16 = (ctype ? U_PPF_C : 0) | (dtype ? U_PPF_D : 0) | (RelAbs ? U_PPF_P : 0) | (PenID & U_FF_MASK_OID8) << U_FF_SHFT_OID8; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_DRAWLINES,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {Points->Data, Points->Used, 1, U_XE}, /* includes Elements */ + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_DRAWLINES_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_DRAWPATH PseudoObject + \return Pointer to PseudoObject, NULL on error + \param PathID U_PMF_PATH object in the EMF+ object table (0-63, inclusive) + \param PenID U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + + + EMF+ manual 2.3.4.11, Microsoft name: EmfPlusDrawPath Record, Index 0x15 +*/ +U_PSEUDO_OBJ *U_PMR_DRAWPATH_set(uint32_t PathID, uint32_t PenID){ + if(PathID>63)return(NULL); + if(PenID>63)return(NULL); + int Size = 4; + uint16_t utmp16 = (PathID & U_FF_MASK_OID8) << U_FF_SHFT_OID8; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_DRAWPATH,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {&PenID, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_DRAWPATH_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_DRAWPIE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param PenID U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + \param Start Start angle, >=0.0, degrees clockwise from 3:00 + \param Sweep Sweep angle, -360<= angle <=360, degrees clockwise from Start + \param Rect U_PSEUDO_OBJ containing a U_PMF_RECT or U_PMF_RECTF object + + + EMF+ manual 2.3.4.12, Microsoft name: EmfPlusDrawPie Record, Index 0x0D +*/ +U_PSEUDO_OBJ *U_PMR_DRAWPIE_set(uint32_t PenID, + U_FLOAT Start, U_FLOAT Sweep, const U_PSEUDO_OBJ *Rect){ + int ctype; + if(PenID>63)return(NULL); + if(!Rect){ return(NULL); } + else { + if( Rect->Type == U_PMF_RECT_OID ){ ctype = 1; } + else if(Rect->Type == U_PMF_RECTF_OID){ ctype = 0; } + else { return(NULL); } + } + int Size = 2*4 + Rect->Used; + uint16_t utmp16 = (ctype ? U_PPF_C : 0) | (PenID & U_FF_MASK_OID8) << U_FF_SHFT_OID8; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_DRAWPIE,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {&Start, 4, 1, U_LE}, + {&Sweep, 4, 1, U_LE}, + {Rect->Data, Rect->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_DRAWPIE_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_DRAWRECTS PseudoObject + \return Pointer to PseudoObject, NULL on error + \param PenID U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + \param Rects U_PSEUDO_OBJ containing 1 rect OR a count N follwed by N rects. Rects may be either U_PMF_RECT or U_PMF_RECTF + + + EMF+ manual 2.3.4.13, Microsoft name: EmfPlusDrawRects Record, Index 0x0B +*/ +U_PSEUDO_OBJ *U_PMR_DRAWRECTS_set(uint32_t PenID, const U_PSEUDO_OBJ *Rects){ + int ctype; + int just1; + uint32_t Elements=1; /* only used when a single rect is passed in, not an array, not even an array with one member*/ + if(PenID>63){ return(NULL); } + if(Rects){ + if( (Rects->Type & U_PMF_MASK_OID) == U_PMF_RECT_OID ){ ctype = 1; } + else if( (Rects->Type & U_PMF_MASK_OID) == U_PMF_RECTF_OID){ ctype = 0; } + else { return(NULL); } + } + else { return(NULL); } + just1 = (Rects->Type & U_PMF_ARRAY_OID ? 0 : 1); + int Size = Rects->Used + (just1 ? 4 : 0); /* Elements in Rects for array, not for single */ + uint16_t utmp16 = (ctype ? U_PPF_C : 0)| (PenID & U_FF_MASK_OID8) << U_FF_SHFT_OID8; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_DRAWRECTS,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {(just1 ? (char *)&Elements : NULL), (just1 ? 4: 0), 1, U_LE}, /* element count if a single Rect was passed in, empty otherwise */ + {Rects->Data, Rects->Used, 1, U_XE}, /* Elements + Array, already stored in Rects, if an array was passed in, just rect if a single */ + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_DRAWRECTS_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_DRAWSTRING PseudoObject + \return Pointer to PseudoObject, NULL on error + \param FontID U_PMF_FONT object in the EMF+ object table (0-63, inclusive) + \param BrushID U_PSEUDO_OBJ containing a U_PMF_ARGB or a U_PMF_4NUM. Color or U_PMF_BRUSH object in the EMF+ object table (0-63, inclusive) + \param FormatID U_PMF_STRINGFORMAT object in EMF+ Object Table. + \param Length Number of characters in the string. + \param Rect U_PSEUDO_OBJ containing a U_PMF_RECTF object, string's bounding box + \param Text Array of UFT-16LE unicode characters. + + + EMF+ manual 2.3.4.14, Microsoft name: EmfPlusDrawString Record, Index 0x1C +*/ +U_PSEUDO_OBJ *U_PMR_DRAWSTRING_set(uint32_t FontID, const U_PSEUDO_OBJ *BrushID, + uint32_t FormatID, uint32_t Length, const U_PSEUDO_OBJ *Rect, const uint16_t *Text){ + int btype; + if(FontID>63){ return(NULL); } + if(!Length){ return(NULL); } + if(!Rect || Rect->Type != U_PMF_RECTF_OID){ return(NULL); } + if(BrushID){ + if( BrushID->Used != 4){ return(NULL); } + else if( BrushID->Type == U_PMF_ARGB_OID){ btype = 1; } + else if( BrushID->Type == U_PMF_4NUM_OID){ btype = 0; } + else { return(NULL); } + } + else { return(NULL); } + int Size = BrushID->Used + 2*4 + Rect->Used +2*Length; + uint16_t utmp16 = (btype ? U_PPF_B : 0)| (FontID & U_FF_MASK_OID8) << U_FF_SHFT_OID8; + uint32_t pad = (0x1 & Length ? 2 : 0); + Size+=pad; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_DRAWSTRING,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {BrushID->Data, BrushID->Used, 1, U_XE}, + {&FormatID, 4, 1, U_LE}, + {&Length, 4, 1, U_LE}, + {Rect->Data, Rect->Used, 1, U_XE}, + {Text, 2*Length, 1, U_XE}, + {NULL, pad, (pad ? 1 : 0), (pad ? U_XE : U_XX)}, /* Entire record must be a multiple of 4 */ + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_DRAWSTRING_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_FILLCLOSEDCURVE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param ftype If U_WINDING use winding fill, else use fill + \param BrushID U_PSEUDO_OBJ containing a U_PMF_ARGB or a U_PMF_4NUM. Color or U_PMF_BRUSH object in the EMF+ object table (0-63, inclusive) + \param Tension Controls splines, 0 is straight line, >0 is curved + \param Points U_PSEUDO_OBJ containing a U_PMF_POINT, U_PMF_POINTR or U_PMF_POINTF object + + + EMF+ manual 2.3.4.15, Microsoft name: EmfPlusFillClosedCurve Record, Index 0x16 +*/ +U_PSEUDO_OBJ *U_PMR_FILLCLOSEDCURVE_set(int ftype, U_FLOAT Tension, const U_PSEUDO_OBJ *BrushID, const U_PSEUDO_OBJ *Points){ + int btype, ctype, RelAbs; + int Size=0; + if(BrushID){ + if( BrushID->Used != 4){ return(NULL); } + else if( BrushID->Type == U_PMF_ARGB_OID){ btype = 1; } + else if( BrushID->Type == U_PMF_4NUM_OID){ btype = 0; } + else { return(NULL); } + } + else { return(NULL); } + if(Points){ + if( Points->Type == U_PMF_POINTR_OID){ RelAbs = 1; ctype = 0; } + else if(Points->Type == (U_PMF_POINT_OID | U_PMF_ARRAY_OID)){ RelAbs = 0; ctype = 1; } + else if(Points->Type == (U_PMF_POINTF_OID | U_PMF_ARRAY_OID)){ RelAbs = 0; ctype = 0; } + else { return(NULL); } + } + else { return(NULL); } + Size = BrushID->Used + 4 + Points->Used; + uint16_t utmp16 = (btype ? U_PPF_B : 0) | (ctype ? U_PPF_C : 0) |((ftype == U_WINDING) ? U_PPF_F : 0) |(RelAbs ? U_PPF_P : 0); + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_FILLCLOSEDCURVE,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {BrushID->Data, BrushID->Used, 1, U_XE}, + {&Tension, 4, 1, U_LE}, + {Points->Data, Points->Used, 1, U_XE}, /* includes Elements */ + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_FILLCLOSEDCURVE_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_FILLELLIPSE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param BrushID U_PSEUDO_OBJ containing a U_PMF_ARGB or a U_PMF_4NUM. Color or U_PMF_BRUSH object in the EMF+ object table (0-63, inclusive) + \param Rect U_PSEUDO_OBJ containing a U_PMF_RECT or U_PMF_RECTF object + + + EMF+ manual 2.3.4.16, Microsoft name: EmfPlusFillEllipse Record, Index 0x0E +*/ +U_PSEUDO_OBJ *U_PMR_FILLELLIPSE_set(const U_PSEUDO_OBJ *BrushID, const U_PSEUDO_OBJ *Rect){ + int btype, ctype; + if(BrushID){ + if( BrushID->Used != 4){ return(NULL); } + else if( BrushID->Type == U_PMF_ARGB_OID){ btype = 1; } + else if( BrushID->Type == U_PMF_4NUM_OID){ btype = 0; } + else { return(NULL); } + } + else { return(NULL); } + if(Rect){ + if( Rect->Type == U_PMF_RECT_OID ){ ctype = 1; } + else if(Rect->Type == U_PMF_RECTF_OID){ ctype = 0; } + else { return(NULL); } + } + else { return(NULL); } + int Size = BrushID->Used + Rect->Used; + uint16_t utmp16 = (btype ? U_PPF_B : 0) | (ctype ? U_PPF_C : 0); + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_FILLELLIPSE,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {BrushID->Data, BrushID->Used, 1, U_XE}, + {Rect->Data, Rect->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_FILLELLIPSE_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_FILLPATH PseudoObject + \return Pointer to PseudoObject, NULL on error + \param PathID U_PMF_PATH object in the EMF+ object table (0-63, inclusive) + \param BrushID U_PSEUDO_OBJ containing a U_PMF_ARGB or a U_PMF_4NUM. Color or U_PMF_BRUSH object in the EMF+ object table (0-63, inclusive) + + + EMF+ manual 2.3.4.17, Microsoft name: EmfPlusFillPath Record, Index 0x14 +*/ +U_PSEUDO_OBJ *U_PMR_FILLPATH_set(uint32_t PathID, const U_PSEUDO_OBJ *BrushID){ + int btype; + int Size=0; + if(PathID>63)return(NULL); + if(BrushID){ + if( BrushID->Used != 4){ return(NULL); } + else if( BrushID->Type == U_PMF_ARGB_OID){ btype = 1; } + else if( BrushID->Type == U_PMF_4NUM_OID){ btype = 0; } + else { return(NULL); } + } + else { return(NULL); } + Size = BrushID->Used; + uint16_t utmp16 = (btype ? U_PPF_B : 0) | (PathID & U_FF_MASK_OID8) << U_FF_SHFT_OID8 ; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_FILLPATH,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {BrushID->Data, BrushID->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_FILLPATH_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_FILLPIE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Start Start angle, >=0.0, degrees clockwise from 3:00 + \param Sweep Sweep angle, -360<= angle <=360, degrees clockwise from Start + \param BrushID U_PSEUDO_OBJ containing a U_PMF_ARGB or a U_PMF_4NUM. Color or U_PMF_BRUSH object in the EMF+ object table (0-63, inclusive) + \param Rect U_PSEUDO_OBJ containing a U_PMF_RECT or U_PMF_RECTF object + + + EMF+ manual 2.3.4.18, Microsoft name: EmfPlusFillPie Record, Index 0x10 +*/ +U_PSEUDO_OBJ *U_PMR_FILLPIE_set(U_FLOAT Start, U_FLOAT Sweep, const U_PSEUDO_OBJ *BrushID, const U_PSEUDO_OBJ *Rect){ + int btype, ctype; + if(BrushID){ + if( BrushID->Used != 4){ return(NULL); } + else if( BrushID->Type == U_PMF_ARGB_OID){ btype = 1; } + else if( BrushID->Type == U_PMF_4NUM_OID){ btype = 0; } + else { return(NULL); } + } + else { return(NULL); } + if(!Rect){ return(NULL); } + else { + if( Rect->Type == U_PMF_RECT_OID ){ ctype = 1; } + else if(Rect->Type == U_PMF_RECTF_OID){ ctype = 0; } + else { return(NULL); } + } + int Size = BrushID->Used + 2*4 + Rect->Used; + uint16_t utmp16 = (btype ? U_PPF_B : 0) | (ctype ? U_PPF_C : 0); + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_FILLPIE,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {BrushID->Data, BrushID->Used, 1, U_XE}, + {&Start, 4, 1, U_LE}, + {&Sweep, 4, 1, U_LE}, + {Rect->Data, Rect->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_FILLPIE_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_FILLPOLYGON PseudoObject + \return Pointer to PseudoObject, NULL on error + \param BrushID U_PSEUDO_OBJ containing a U_PMF_ARGB or a U_PMF_4NUM. Color or U_PMF_BRUSH object in the EMF+ object table (0-63, inclusive) + \param Points U_PSEUDO_OBJ containing an array of 3 U_PMF_POINT, U_PMF_POINTR, or U_PMF_POINTF objects + + + EMF+ manual 2.3.4.19, Microsoft name: EmfPlusFillPolygon Record, Index 0x0C +*/ +U_PSEUDO_OBJ *U_PMR_FILLPOLYGON_set(const U_PSEUDO_OBJ *BrushID, const U_PSEUDO_OBJ *Points){ + int btype, ctype, RelAbs; + if(BrushID){ + if( BrushID->Used != 4){ return(NULL); } + else if( BrushID->Type == U_PMF_ARGB_OID){ btype = 1; } + else if( BrushID->Type == U_PMF_4NUM_OID){ btype = 0; } + else { return(NULL); } + } + else { return(NULL); } + if(Points){ + if( Points->Type == U_PMF_POINTR_OID){ RelAbs = 1; ctype = 0; } + else if(Points->Type == (U_PMF_POINT_OID | U_PMF_ARRAY_OID)){ RelAbs = 0; ctype = 1; } + else if(Points->Type == (U_PMF_POINTF_OID | U_PMF_ARRAY_OID)){ RelAbs = 0; ctype = 0; } + else { return(NULL); } + } + else { return(NULL); } + int Size = BrushID->Used + Points->Used; + uint16_t utmp16 = (btype ? U_PPF_B : 0) | (ctype ? U_PPF_C : 0) |(RelAbs ? U_PPF_P : 0); + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_FILLPOLYGON,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {BrushID->Data, BrushID->Used, 1, U_XE}, + {Points->Data, Points->Used, 1, U_XE}, /* includes Elements */ + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_FILLPOLYGON_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_FILLRECTS PseudoObject + \return Pointer to PseudoObject, NULL on error + \param BrushID U_PSEUDO_OBJ containing a U_PMF_ARGB or a U_PMF_4NUM. Color or U_PMF_BRUSH object in the EMF+ object table (0-63, inclusive) + \param Rects U_PSEUDO_OBJ containing 1 rect OR a count N followed by N rects. Rects may be either U_PMF_RECT or U_PMF_RECTF + + + EMF+ manual 2.3.4.20, Microsoft name: EmfPlusFillRects Record, Index 0x0A +*/ +U_PSEUDO_OBJ *U_PMR_FILLRECTS_set(const U_PSEUDO_OBJ *BrushID, const U_PSEUDO_OBJ *Rects){ + int btype, ctype; + int just1; + uint32_t Elements=1; /* only used when a single rect is passed in, not an array, not even an array with one member*/ + if(BrushID){ + if( BrushID->Used != 4){ return(NULL); } + else if( BrushID->Type == U_PMF_ARGB_OID){ btype = 1; } + else if( BrushID->Type == U_PMF_4NUM_OID){ btype = 0; } + else { return(NULL); } + } + else { return(NULL); } + if(Rects){ + if( (Rects->Type & U_PMF_MASK_OID) == U_PMF_RECT_OID ){ ctype = 1; } + else if( (Rects->Type & U_PMF_MASK_OID) == U_PMF_RECTF_OID){ ctype = 0; } + else { return(NULL); } + } + else { return(NULL); } + just1 = (Rects->Type & U_PMF_ARRAY_OID ? 0 : 1); + int Size = BrushID->Used + Rects->Used + (just1 ? 4 : 0); /* Elements in Rects for array, not for single */ + uint16_t utmp16 = (btype ? U_PPF_B : 0)|(ctype ? U_PPF_C : 0); + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_FILLRECTS,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {BrushID->Data, BrushID->Used, 1, U_XE}, + {(just1 ? (char *)&Elements : NULL), (just1 ? 4: 0), 1, U_LE}, /* element count if a single Rect was passed in, empty otherwise */ + {Rects->Data, Rects->Used, 1, U_XE}, /* Elements + Array, already stored in Rects, if an array was passed in, just rect if a single */ + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_FILLRECTS_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_FILLREGION PseudoObject + \return Pointer to PseudoObject, NULL on error + \param RgnID U_PMF_REGION object in the EMF+ object table (0-63, inclusive) + \param BrushID U_PSEUDO_OBJ containing a U_PMF_ARGB or a U_PMF_4NUM. Color or U_PMF_BRUSH object in the EMF+ object table (0-63, inclusive) + + + EMF+ manual 2.3.4.21, Microsoft name: EmfPlusFillRegion Record, Index 0x13 +*/ +U_PSEUDO_OBJ *U_PMR_FILLREGION_set(uint32_t RgnID, const U_PSEUDO_OBJ *BrushID){ + int btype; + if(BrushID){ + if( BrushID->Used != 4){ return(NULL); } + else if( BrushID->Type == U_PMF_ARGB_OID){ btype = 1; } + else if( BrushID->Type == U_PMF_4NUM_OID){ btype = 0; } + else { return(NULL); } + } + else { return(NULL); } + int Size = BrushID->Used; + uint16_t utmp16 = (btype ? U_PPF_B : 0) | (RgnID & U_FF_MASK_OID8) << U_FF_SHFT_OID8; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_FILLREGION,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {BrushID->Data, BrushID->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_FILLREGION_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_OBJECT PseudoObject from another PseudoObject + \return Pointer to PseudoObject, NULL on error + \param ObjID Index for this object in the EMF+ object table (0-63, inclusive) + \param Po U_PSEUDO_OBJ containing an object type that may be stored in the EMF+ object table +*/ +U_PSEUDO_OBJ *U_PMR_OBJECT_PO_set(uint32_t ObjID, U_PSEUDO_OBJ *Po){ + int otype = U_OID_To_OT(Po->Type); /* This will return 0 if the type is not valid for an object */ + if(!otype){ return(NULL); } + U_PSEUDO_OBJ *po = U_PMR_OBJECT_set(ObjID, otype, 0, 0, Po->Used, Po->Data); /* 0,0 = rec. not continued, TSize value (ignored) */ + return(po); +} + +/** + \brief Create and set a U_PMR_OBJECT PseudoObject + \return Pointer to PseudoObject, NULL on error + \param ObjID Index for this object in the EMF+ object table (0-63, inclusive) + \param otype ObjectType enumeration for this Object + \param ntype Set: object definition continues in next record; Clear: this is the sole object definition record + \param TSize If ntype is set the total number of data bytes split across multiple records. If ntype is clear, it is ignored. + \param cbData Object's data size, in bytes. + \param Data Object's data. Type from otype. + + + EMF+ manual 2.3.5.1, Microsoft name: EmfPlusObject Record, Index 0x13 + + Normally this is only called by U_PMR_OBJECT_PO_set(). + + U_PMR_OBJECT records can only hold a maximum of 65020 bytes of data. If the object is larger than that + then multiple U_PMR_OBJECT records are created, one after the other. If this + happens each record has cbData following ph, and the ntype flag is set. If all of the data is less than 65020 + then cbData is NOT entered following ph, and the ntype flag is clear. + + Call initially in all cases with ntype clear and TSize = 0. If the record needs to be fragmented + the function will call itself recursively to do so. + +*/ +U_PSEUDO_OBJ *U_PMR_OBJECT_set(uint32_t ObjID, int otype, int ntype, uint32_t TSize, size_t cbData, const char *Data){ + uint32_t CSize; + int Pad = UP4(TSize) - TSize; + if((otype < U_OT_Brush) || (otype > U_OT_CustomLineCap)){ return(NULL); } + if(ntype && (cbData > U_OBJRECLIM)){ return(NULL); } + U_PSEUDO_OBJ *po; + + if(!ntype && !TSize && (cbData > U_OBJRECLIM)){ + ntype = 1; + TSize = cbData; + po = U_PO_create(NULL, TSize + 16 * (1 + (TSize/cbData)), 0, U_PMR_OBJECT_OID); + if(!po)return(po); + while(cbData){ + CSize = (cbData > U_OBJRECLIM ? U_OBJRECLIM : cbData); + U_PSEUDO_OBJ *pot = U_PMR_OBJECT_set(ObjID, otype, ntype, TSize, CSize, Data); + po = U_PO_po_append(po, pot, U_PMF_KEEP_ELEMENTS); + U_PO_free(&pot); + Data += U_OBJRECLIM; + cbData -= CSize; + } + } + else { + /* Send in DataSize, U_PMR_CMN_HDR_set will adjust Header Size with 1-3 pad bytes if needed */ + uint16_t utmp16 = otype << 8 | (ntype ? U_PPF_N : 0) | (ObjID & U_FF_MASK_OID8) << U_FF_SHFT_OID8; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_OBJECT,utmp16,cbData + (ntype ? 4 : 0)); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE }, + {(ntype ? &TSize : NULL), (ntype ? 4 : 0), (ntype ? 1 : 0), U_LE }, + {Data, cbData, 1, U_XE }, + {NULL, (Pad ? Pad : 0), (Pad ? 1 : 0), (Pad ? U_XE : U_XX)}, /* Either 1-3 pad bytes or a terminator */ + {NULL,0,0,U_XX} /* terminator, possibly a second in the list, which is harmless */ + }; + po = U_PMF_SERIAL_set(U_PMR_OBJECT_OID, List); + U_PO_free(&ph); + } + return(po); +} + +/** + \brief Create and set a U_PMR_SERIALIZABLEOBJECT PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Siepb U_PSEUDO_OBJ containing a "Serialized image effects parameter block". One of the ImageEffects objects. + + EMF+ manual 2.3.5.2, Microsoft name: EmfPlusSerializableObject Record, Index 0x38 + + + This sets an ImageEffect in the renderer, which will be applied to the next EmfPlusDrawImagePoints + record that is encountered. The image effect is "consumed" by that EmfPlusDrawImagePoints record, resetting + the renderer to its original state.\n + + WARNING! Windows XP Preview does not show filter effects, whether or not U_PPF_E is set. They are visible if the EMF+ + file is inserted as an image into PowerPoint. + +*/ +U_PSEUDO_OBJ *U_PMR_SERIALIZABLEOBJECT_set(const U_PSEUDO_OBJ *Siepb){ + if(!Siepb){ return(NULL); } + uint8_t *GUID = U_OID_To_GUID(Siepb->Type); + if(!GUID){ return(NULL); } + /* PO Used is size_t, might be 8 bytes, value in record must be 4 bytes */ + uint32_t Used = Siepb->Used; + int Size = 16 + 4 + Siepb->Used; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_SERIALIZABLEOBJECT,0,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {GUID, 16, 1, U_XE}, + {&Used, 4, 1, U_LE}, + {Siepb->Data, Siepb->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_SERIALIZABLEOBJECT_OID, List); + U_PO_free(&ph); + free(GUID); + return(po); +} + +/** + \brief Create and set a U_PMR_SETANTIALIASMODE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param SMenum SmoothingMode enumeration + \param aatype Set: anti-aliasing on; Clear: anti-aliasing off + + + EMF+ manual 2.3.6.1, Microsoft name: EmfPlusSetAntiAliasMode Record, Index 0x1E +*/ +U_PSEUDO_OBJ *U_PMR_SETANTIALIASMODE_set(int SMenum, int aatype){ + int Size = 0; + uint16_t utmp16 = (aatype ? U_PPF_AA : 0) | (SMenum & U_FF_MASK_AA)<<U_FF_SHFT_AA; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_SETANTIALIASMODE,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_SETANTIALIASMODE_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_SETCOMPOSITINGMODE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param CMenum CompositingMode enumeration + + + EMF+ manual 2.3.6.2, Microsoft name: EmfPlusSetCompositingMode Record, Index 0x23 +*/ +U_PSEUDO_OBJ *U_PMR_SETCOMPOSITINGMODE_set(int CMenum){ + int Size = 0; + uint16_t utmp16 = (CMenum & U_FF_MASK_CM)<<U_FF_SHFT_CM; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_SETCOMPOSITINGMODE,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_SETCOMPOSITINGMODE_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_SETCOMPOSITINGQUALITY PseudoObject + \return Pointer to PseudoObject, NULL on error + \param CQenum CompositingQuality enumeration + + + EMF+ manual 2.3.6.3, Microsoft name: EmfPlusSetCompositingQuality Record, Index 0x24 +*/ +U_PSEUDO_OBJ *U_PMR_SETCOMPOSITINGQUALITY_set(int CQenum){ + int Size = 0; + uint16_t utmp16 = (CQenum & U_FF_MASK_CQ)<<U_FF_SHFT_CQ; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_SETCOMPOSITINGQUALITY,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_SETCOMPOSITINGQUALITY_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_SETINTERPOLATIONMODE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param IMenum InterpolationMode enumeration + + + EMF+ manual 2.3.6.4, Microsoft name: EmfPlusSetInterpolationMode Record, Index 0x21 +*/ +U_PSEUDO_OBJ *U_PMR_SETINTERPOLATIONMODE_set(int IMenum){ + int Size = 0; + uint16_t utmp16 = (IMenum & U_FF_MASK_IM)<<U_FF_SHFT_IM; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_SETINTERPOLATIONMODE,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_SETINTERPOLATIONMODE_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_SETPIXELOFFSETMODE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param POMenum PixelOffsetMode enumeration + + + EMF+ manual 2.3.6.5, Microsoft name: EmfPlusSetPixelOffsetMode Record, Index 0x22 +*/ +U_PSEUDO_OBJ *U_PMR_SETPIXELOFFSETMODE_set(int POMenum){ + int Size = 0; + uint16_t utmp16 = (POMenum & U_FF_MASK_PxOffM) << U_FF_SHFT_PxOffM; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_SETPIXELOFFSETMODE,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_SETPIXELOFFSETMODE_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_SETRENDERINGORIGIN PseudoObject + \return Pointer to PseudoObject, NULL on error + \param X X coordinate of rendering origin. + \param Y Y coordinate of rendering origin. + + + EMF+ manual 2.3.6.6, Microsoft name: EmfPlusSetRenderingOrigin Record, Index 0x1D +*/ +U_PSEUDO_OBJ *U_PMR_SETRENDERINGORIGIN_set(int32_t X, int32_t Y){ + int Size = 2*4; + uint16_t utmp16 = 0; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_SETRENDERINGORIGIN,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {&X, 4, 1, U_LE}, + {&Y, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_SETRENDERINGORIGIN_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_SETTEXTCONTRAST PseudoObject + \return Pointer to PseudoObject, NULL on error + \param TGC Text Gamma correction value (x 1000). + + + EMF+ manual 2.3.6.7, Microsoft name: EmfPlusSetTextContrast Record, Index 0x20 +*/ +U_PSEUDO_OBJ *U_PMR_SETTEXTCONTRAST_set(int TGC){ + int Size = 0; + uint16_t utmp16 = (TGC & U_FF_MASK_TGC) << U_FF_SHFT_TGC; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_SETTEXTCONTRAST,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_SETTEXTCONTRAST_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_SETTEXTRENDERINGHINT PseudoObject + \return Pointer to PseudoObject, NULL on error + \param TRHenum TextRenderingHint enumeration + + + EMF+ manual 2.3.6.8, Microsoft name: EmfPlusSetTextRenderingHint Record, Index 0x1F +*/ +U_PSEUDO_OBJ *U_PMR_SETTEXTRENDERINGHINT_set(int TRHenum){ + int Size = 0; + uint16_t utmp16 = (TRHenum & U_FF_MASK_TRH) << U_FF_SHFT_TRH; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_SETTEXTRENDERINGHINT,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_SETTEXTRENDERINGHINT_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_BEGINCONTAINER PseudoObject + \return Pointer to PseudoObject, NULL on error + \param UTenum UnitType enumeration + \param DstRect a U_PSEUDO_OBJ containing a U_PMF_RECTF object. with SrcRect specifies a transformation + \param SrcRect a U_PSEUDO_OBJ containing a U_PMF_RECTF object. with DstRect specifies a transformation + \param StackID EMF+ Object Stack Index to use for this graphics container + + + EMF+ manual 2.3.7.1, Microsoft name: EmfPlusBeginContainer Record, Index 0x27 +*/ +U_PSEUDO_OBJ *U_PMR_BEGINCONTAINER_set(int UTenum, U_PSEUDO_OBJ *DstRect, U_PSEUDO_OBJ *SrcRect, uint32_t StackID){ + if(UTenum < U_UT_World || UTenum > U_UT_Millimeter){ return(NULL); } + if(!DstRect || (DstRect->Type != U_PMF_RECTF_OID)){ return(NULL); } + if(!SrcRect || (SrcRect->Type != U_PMF_RECTF_OID)){ return(NULL); } + int Size = DstRect->Used + SrcRect->Used + 4; + uint16_t utmp16 = (UTenum & U_FF_MASK_UT) << U_FF_SHFT_UT; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_BEGINCONTAINER,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {DstRect->Data, DstRect->Used, 1, U_XE}, + {SrcRect->Data, SrcRect->Used, 1, U_XE}, + {&StackID, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_BEGINCONTAINER_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_BEGINCONTAINERNOPARAMS PseudoObject + \return Pointer to PseudoObject, NULL on error + \param StackID EMF+ Object Stack Index to use for this graphics container + + + EMF+ manual 2.3.7.2, Microsoft name: EmfPlusBeginContainerNoParams Record, Index 0x28 +*/ +U_PSEUDO_OBJ *U_PMR_BEGINCONTAINERNOPARAMS_set(int StackID){ + int Size = 4; + uint16_t utmp16 = 0; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_BEGINCONTAINERNOPARAMS,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {&StackID, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_BEGINCONTAINERNOPARAMS_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_ENDCONTAINER PseudoObject + \return Pointer to PseudoObject, NULL on error + \param StackID EMF+ Object Stack Index to use for this graphics container + + + EMF+ manual 2.3.7.3, Microsoft name: EmfPlusEndContainer Record, Index 0x29 +*/ +U_PSEUDO_OBJ *U_PMR_ENDCONTAINER_set(int StackID){ + int Size = 4; + uint16_t utmp16 = 0; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_ENDCONTAINER,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {&StackID, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_ENDCONTAINER_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_RESTORE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param StackID EMF+ Graphics State Stack to restore from. Must have been put on the GSS with a U_PMR_SAVE. + + + EMF+ manual 2.3.7.4, Microsoft name: EmfPlusRestore Record, Index 0x26 +*/ +U_PSEUDO_OBJ *U_PMR_RESTORE_set(int StackID){ + int Size = 4; + uint16_t utmp16 = 0; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_RESTORE,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {&StackID, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_RESTORE_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_SAVE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param StackID EMF+ Graphics State Stack to restore from. Must have been put on the GSS with a U_PMR_SAVE. + + + EMF+ manual 2.3.7.5, Microsoft name: EmfPlusSave Record, Index 0x25 +*/ +U_PSEUDO_OBJ *U_PMR_SAVE_set(int StackID){ + int Size = 4; + uint16_t utmp16 = 0; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_SAVE,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {&StackID, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_SAVE_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_SETTSCLIP PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Rects a U_PSEUDO_OBJ containing an array of U_PMF_RECT or U_PMF_RECTF objects. + + + EMF+ manual 2.3.8.1, Microsoft name: EmfPlusSetTSClip Record, Index 0x3A +*/ +U_PSEUDO_OBJ *U_PMR_SETTSCLIP_set(U_PSEUDO_OBJ *Rects){ + int ctype; + uint32_t Elements; + if(Rects){ + if( Rects->Type == (U_PMF_RECT_OID | U_PMF_ARRAY_OID)){ ctype = 1; Elements = (Rects->Used - 4)/8; } + else if(Rects->Type == (U_PMF_RECTF_OID | U_PMF_ARRAY_OID)){ ctype = 0; Elements = (Rects->Used - 4)/16; } + else { return(NULL); } + } + else { return(NULL); } + int Size = Rects->Used; /* Rects includes Elements */ + uint16_t utmp16 = (ctype ? U_PPF_K : 0) | (Elements & U_FF_MASK_TSC) << U_FF_SHFT_TSC; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_SETTSCLIP,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {Rects->Data, Rects->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_SETTSCLIP_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_SETTSGRAPHICS PseudoObject + \return Pointer to PseudoObject, NULL on error + \param vgatype Set: Palette is VGA basic colors; Clear: Palette is ??? + \param Tsg A U_PMF_SETTSGRAPHICS object + \param Palette (optional) a U_PSEUDO_OBJ containing a U_PMF_PALETTE object. + + + EMF+ manual 2.3.8.2, Microsoft name: EmfPlusSetTSGraphics Record, Index 0x39 +*/ +U_PSEUDO_OBJ *U_PMR_SETTSGRAPHICS_set(int vgatype, U_PMF_SETTSGRAPHICS *Tsg, U_PSEUDO_OBJ *Palette){ + if(!Tsg){ return(NULL); } + int Size = sizeof(U_PMF_SETTSGRAPHICS) + (Palette ? Palette->Used : 0); + uint16_t utmp16 = (vgatype ? U_PPF_VGA : 0) | (Palette ? U_PPF_PP : 0) ; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_SETTSGRAPHICS,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {&(Tsg->AntiAliasMode), 1, 1, U_XE}, + {&(Tsg->TextRenderHint), 1, 1, U_XE}, + {&(Tsg->CompositingMode), 1, 1, U_XE}, + {&(Tsg->CompositingQuality), 1, 1, U_XE}, + {&(Tsg->RenderOriginX), 2, 1, U_LE}, + {&(Tsg->RenderOriginY), 2, 1, U_LE}, + {&(Tsg->TextContrast), 2, 1, U_LE}, + {&(Tsg->FilterType), 1, 1, U_XE}, + {&(Tsg->PixelOffset), 1, 1, U_XE}, + {&(Tsg->WorldToDevice), 4, 6, U_LE}, + {(Palette ? Palette->Data : NULL), (Palette ? Palette->Used: 0), 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_SETTSGRAPHICS_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_MULTIPLYWORLDTRANSFORM PseudoObject + \return Pointer to PseudoObject, NULL on error + \param xmtype Set: Post multiply; Clear: Pre multiply + \param Tm a U_PSEUDO_OBJ containing a U_PMF_TRANSFORMMATRIX. (Transformation matrix) + + + EMF+ manual 2.3.9.1, Microsoft name: EmfPlusMultiplyWorldTransform Record, Index 0x2C +*/ +U_PSEUDO_OBJ *U_PMR_MULTIPLYWORLDTRANSFORM_set(int xmtype, U_PSEUDO_OBJ *Tm){ + if(!Tm || (Tm->Type != U_PMF_TRANSFORMMATRIX_OID)){ return(NULL); } + int Size = Tm->Used; + uint16_t utmp16 = (xmtype ? U_PPF_XM : 0); + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_MULTIPLYWORLDTRANSFORM,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {Tm->Data, Tm->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_MULTIPLYWORLDTRANSFORM_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_RESETWORLDTRANSFORM PseudoObject + \return Pointer to PseudoObject, NULL on error + + + EMF+ manual 2.3.9.2, Microsoft name: EmfPlusResetWorldTransform Record, Index 0x2B +*/ +U_PSEUDO_OBJ *U_PMR_RESETWORLDTRANSFORM_set(void){ + int Size = 0; + uint16_t utmp16 = 0; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_RESETWORLDTRANSFORM,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_RESETWORLDTRANSFORM_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_ROTATEWORLDTRANSFORM PseudoObject + \return Pointer to PseudoObject, NULL on error + \param xmtype Set: Post multiply; Clear: Pre multiply + \param Angle Rotation angle, in degrees + + + EMF+ manual 2.3.9.3, Microsoft name: EmfPlusRotateWorldTransform Record, Index 0x2F +*/ +U_PSEUDO_OBJ *U_PMR_ROTATEWORLDTRANSFORM_set(int xmtype, U_FLOAT Angle){ + int Size = 4; + uint16_t utmp16 = (xmtype ? U_PPF_XM : 0); + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_ROTATEWORLDTRANSFORM,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {&Angle, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_ROTATEWORLDTRANSFORM_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_SCALEWORLDTRANSFORM PseudoObject + \return Pointer to PseudoObject, NULL on error + \param xmtype Set: Post multiply; Clear: Pre multiply + \param X Scale in X + \param Y Scale in Y + + EMF+ manual 2.3.9.4, Microsoft name: EmfPlusScaleWorldTransform Record, Index 0x2E +*/ +U_PSEUDO_OBJ *U_PMR_SCALEWORLDTRANSFORM_set(int xmtype, U_FLOAT X, U_FLOAT Y){ + int Size = 2*4; + uint16_t utmp16 = (xmtype ? U_PPF_XM : 0); + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_SCALEWORLDTRANSFORM,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {&X, 4, 1, U_LE}, + {&Y, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_SCALEWORLDTRANSFORM_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_SETPAGETRANSFORM PseudoObject + \return Pointer to PseudoObject, NULL on error + \param PUenum Page Unit, in UnitType enumeration + \param Scale Scale factor to convert page space to device space + + + + EMF+ manual 2.3.9.5, Microsoft name: EmfPlusSetPageTransform Record, Index 0x30 + + Defines Page Space -> Device Space transformation +*/ +U_PSEUDO_OBJ *U_PMR_SETPAGETRANSFORM_set(int PUenum, U_FLOAT Scale){ + int Size = 4; + uint16_t utmp16 = (PUenum & U_FF_MASK_PU) << U_FF_SHFT_PU; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_SETPAGETRANSFORM,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {&Scale, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_SETPAGETRANSFORM_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_SETWORLDTRANSFORM PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Tm a U_PSEUDO_OBJ containing a U_PMF_TRANSFORMMATRIX. (Transformation matrix) + + + + EMF+ manual 2.3.9.6, Microsoft name: EmfPlusSetWorldTransform Record, Index 0x2A + + Defines World Space -> Page Space transformation +*/ +U_PSEUDO_OBJ *U_PMR_SETWORLDTRANSFORM_set(U_PSEUDO_OBJ *Tm){ + if(!Tm || (Tm->Type != U_PMF_TRANSFORMMATRIX_OID)){ return(NULL); } + int Size = Tm->Used; + uint16_t utmp16 = 0; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_SETWORLDTRANSFORM,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {Tm->Data, Tm->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_SETWORLDTRANSFORM_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_TRANSLATEWORLDTRANSFORM PseudoObject + \return Pointer to PseudoObject, NULL on error + \param xmtype Set: Post multiply; Clear: Pre multiply + \param Dx X offset + \param Dy Y offset + + + EMF+ manual 2.3.9.7, Microsoft name: EmfPlusTranslateWorldTransform Record, Index 0x2D +*/ +U_PSEUDO_OBJ *U_PMR_TRANSLATEWORLDTRANSFORM_set(int xmtype, U_FLOAT Dx, U_FLOAT Dy){ + int Size = 2*4; + uint16_t utmp16 = (xmtype ? U_PPF_XM : 0); + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_TRANSLATEWORLDTRANSFORM,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {&Dx, 4, 1, U_LE}, + {&Dy, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_TRANSLATEWORLDTRANSFORM_OID, List); + U_PO_free(&ph); + return(po); +} + + +//! \cond +/* core _get functions, not accessed outside of this routine */ + +/* get copies of up to 0-6 consecutive 4 byte values and a pointer to the rest */ +int U_PMF_CORE1_get(const char *contents, void *v1, void *v2, void *v3, void *v4, void *v5, void *v6, const char **vR){ + if(v1){ U_PMF_MEMCPY_SRCSHIFT(v1, &contents, 4); + if(v2){ U_PMF_MEMCPY_SRCSHIFT(v2, &contents, 4); + if(v3){ U_PMF_MEMCPY_SRCSHIFT(v3, &contents, 4); + if(v4){ U_PMF_MEMCPY_SRCSHIFT(v4, &contents, 4); + if(v5){ U_PMF_MEMCPY_SRCSHIFT(v5, &contents, 4); + if(v6){ U_PMF_MEMCPY_SRCSHIFT(v6, &contents, 4); }}}}}} + if(vR){ *vR = contents; } + return(1); +} +//! \endcond + + +/** + \brief Get data from a U_PMF_BRUSH object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Version EmfPlusGraphicsVersion object + \param Type BrushType Enumeration + \param Data one of the 5 types of Brush data + + EMF+ manual 2.2.1.1, Microsoft name: EmfPlusBrush Object +*/ +int U_PMF_BRUSH_get(const char *contents, uint32_t *Version, uint32_t *Type, const char **Data){ + if(!contents || !Version || !Type || !Data){ return(0); } + U_PMF_SERIAL_get(&contents, Version, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Type, 4, 1, U_LE); + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_CUSTOMLINECAP object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Version EmfPlusGraphicsVersion object + \param Type CustomLineCapData Enumeration + \param Data one of the 2 types of Linecap data + + EMF+ manual 2.2.1.2, Microsoft name: EmfPlusCustomLineCap Object +*/ +int U_PMF_CUSTOMLINECAP_get(const char *contents, uint32_t *Version, uint32_t *Type, const char **Data){ + if(!contents || !Version || !Type || !Data){ return(0); } + U_PMF_SERIAL_get(&contents, Version, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Type, 4, 1, U_LE); + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_FONT object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Version EmfPlusGraphicsVersion object + \param EmSize em size in units of SizeUnit + \param SizeUnit UnitType enumeration + \param FSFlags FontStyle flags + \param Length Number of Unicode Characters in FamilyName + \param Data Unicode (UTF-16LE) name of font family + + EMF+ manual 2.2.1.3, Microsoft name: EmfPlusFont Object +*/ +int U_PMF_FONT_get(const char *contents, uint32_t *Version, U_FLOAT *EmSize, uint32_t *SizeUnit, + int32_t *FSFlags, uint32_t *Length, const char **Data){ + if(!contents || !Version || !EmSize || !SizeUnit || !FSFlags || !Length || !Data){ return(0); } + U_PMF_SERIAL_get(&contents, Version, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, EmSize, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, SizeUnit, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, FSFlags, 4, 1, U_LE); + contents += 4; /* Reserved field, which is ignored */ + U_PMF_SERIAL_get(&contents, Length, 4, 1, U_LE); + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + + +/** + \brief Get data from a U_PMF_IMAGE object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Version EmfPlusGraphicsVersion object + \param Type ImageDataType Enumeration + \param Data one of the 2 types of image data + + EMF+ manual 2.2.1.4, Microsoft name: EmfPlusImage Object +*/ +int U_PMF_IMAGE_get(const char *contents, uint32_t *Version, uint32_t *Type, const char **Data){ + if(!contents || !Version || !Type){ return(0); } + U_PMF_SERIAL_get(&contents, Version, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Type, 4, 1, U_LE); + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_IMAGEATTRIBUTES object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Version EmfPlusGraphicsVersion object + \param WrapMode WrapMode object + \param ClampColor EmfPlusARGB object + \param ObjectClamp ObjectClamp Identifiers + + EMF+ manual 2.2.1.5, Microsoft name: EmfPlusImageAttributes Object +*/ +int U_PMF_IMAGEATTRIBUTES_get(const char *contents, uint32_t *Version, uint32_t *WrapMode, uint32_t *ClampColor, uint32_t *ObjectClamp){ + if(!contents || !Version || !WrapMode || !ClampColor || !ObjectClamp){ return(0); } + U_PMF_SERIAL_get(&contents, Version, 4, 1, U_LE); + contents += 4; /* Skip Reserved 1*/ + U_PMF_SERIAL_get(&contents, WrapMode, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, ClampColor, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, ObjectClamp,4, 1, U_LE); + /* Skip Reserved 2*/ + return(1); +} + +/** + \brief Get data from a U_PMF_PATH object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Version EmfPlusGraphicsVersion object + \param Count Number of points and point types in this object + \param Flags PathPoint Flags + \param Points array of points type PMFPointR, PMFPoint, or PMFPointF + \param Types array of U_PMF_PATHPOINTTYPERLE and/or U_PMF_PATHPOINTTYPE + + EMF+ manual 2.2.1.6, Microsoft name: EmfPlusPath Object +*/ +int U_PMF_PATH_get(const char *contents, uint32_t *Version, uint32_t *Count, uint16_t *Flags, const char **Points, const char **Types){ + if(!contents || !Version || !Count || !Flags || !Points || !Types){ return(0); } + U_PMF_SERIAL_get(&contents, Version, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Count, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Flags, 2, 1, U_LE); + contents+=2; /* reserved */ + U_PMF_PTRSAV_SHIFT(Points, &contents, 0); + if(*Flags & U_PPF_P){ + int killme = U_PMF_LEN_REL715(contents,*Count); //DEBUG + printf("DEBUG U_PMF_PATH_get count:%d LENREL715:%d\n",*Count,killme);fflush(stdout); + contents += killme; + } + else if(*Flags & U_PPF_C){ contents += *Count * sizeof(U_PMF_POINT); } + else { contents += *Count * sizeof(U_PMF_POINTF); } + U_PMF_PTRSAV_SHIFT(Types, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_PEN object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Version EmfPlusGraphicsVersion object + \param Type must be zero + \param PenData Pen description + \param Brush Brush Description + + EMF+ manual 2.2.1.7, Microsoft name: EmfPlusPen Object +*/ +int U_PMF_PEN_get(const char *contents, uint32_t *Version, uint32_t *Type, const char **PenData, const char **Brush){ + if(!contents || !Type || !PenData || !Brush){ return(0); } + U_PMF_SERIAL_get(&contents, Version, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Type, 4, 1, U_LE); + U_PMF_PTRSAV_SHIFT(PenData, &contents, 0); + *Brush = *PenData + U_PMF_LEN_PENDATA(*PenData); + return(1); +} + +/** + \brief Get data from a U_PMF_REGION object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Version EmfPlusGraphicsVersion object + \param Count Number of CHILD nodes. This is one less than the total number of U_PMF_REGIONNODE objects in Nodes. + \param Nodes Nodes defining region + + EMF+ manual 2.2.1.8, Microsoft name: EmfPlusRegion Object +*/ +int U_PMF_REGION_get(const char *contents, uint32_t *Version, uint32_t *Count, const char **Nodes){ + if(!contents || !Version || !Count || !Nodes){ return(0); } + U_PMF_SERIAL_get(&contents, Version, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Count, 4, 1, U_LE); + U_PMF_PTRSAV_SHIFT(Nodes, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_STRINGFORMAT object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Sfs pointer to U_PMF_STRINGFORMAT structure, with no variable part + \param Data pointer to variable part + + EMF+ manual 2.2.1.9, Microsoft name: EmfPlusStringFormat Object +*/ +int U_PMF_STRINGFORMAT_get(const char *contents, U_PMF_STRINGFORMAT *Sfs, const char **Data){ + if(!contents || !Sfs || !Data){ return(0); } + U_PMF_SERIAL_get(&contents, Sfs, 4, 15, U_LE); + *Data = contents; + return(1); +} + +/** + \brief Get data from a U_PMF_ARGB object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Blue Blue color (0-255) + \param Green Green color (0-255) + \param Red Red color (0-255) + \param Alpha Alpha (0-255) + + EMF+ manual 2.2.2.1, Microsoft name: EmfPlusARGB Object +*/ +int U_PMF_ARGB_get(const char *contents, uint8_t *Blue, uint8_t *Green, uint8_t *Red, uint8_t *Alpha){ + if(!contents || !Blue || !Green || !Red || !Alpha){ return(0); } + U_PMF_SERIAL_get(&contents, Blue, 1, 1, U_XE); + U_PMF_SERIAL_get(&contents, Green, 1, 1, U_XE); + U_PMF_SERIAL_get(&contents, Red, 1, 1, U_XE); + U_PMF_SERIAL_get(&contents, Alpha, 1, 1, U_XE); + return(1); +} + +/** + \brief Get data from a U_PMF_BITMAP object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Bs pointer to U_PMF_BITMAP structure, with no variable part + \param Data pointer to variable part + + EMF+ manual 2.2.2.2, Microsoft name: EmfPlusBitmap Object +*/ +int U_PMF_BITMAP_get(const char *contents, U_PMF_BITMAP *Bs, const char **Data){ + if(!contents || !Bs || !Data){ return(0); } + U_PMF_SERIAL_get(&contents, Bs, 4, 5, U_LE); + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_BITMAPDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Ps pointer to U_PMF_PALETTE structure, with no variable part + \param Colors Color part of U_PMF_PALETTE object + \param Data An array of bytes, meaning depends on fields in U_PMF_BITMAP object and the PixelFormat enumeration. + + EMF+ manual 2.2.2.3, Microsoft name: EmfPlusBitmapData Object +*/ +int U_PMF_BITMAPDATA_get(const char *contents, U_PMF_PALETTE *Ps, const char **Colors, const char **Data){ + if(!contents || !Ps || !Colors || !Data ){ return(0); } + U_PMF_SERIAL_get(&contents, Ps, 4, 2, U_LE); + U_PMF_PTRSAV_SHIFT(Colors, &contents, Ps->Elements * sizeof(U_PMF_ARGB)); + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_BLENDCOLORS object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Elements Number of members in Positions and Colors + \param Positions Caller must free. Pointer to memory holding positions along gradient line. + \param Colors Caller must NOT free memory ,Pointer to memory holding colors at positions on gradient line. + + EMF+ manual 2.2.2.4, Microsoft name: EmfPlusBlendColors Object +*/ +int U_PMF_BLENDCOLORS_get(const char *contents, uint32_t *Elements, U_FLOAT **Positions, const char **Colors){ + if(!contents || !Positions || !Colors){ return(0); } + U_PMF_SERIAL_get(&contents, Elements, 4, 1, U_LE); + if(!U_PMF_SERIAL_array_copy_get(&contents, (void **)Positions, 4, *Elements, U_LE,1)){ return(0); } + U_PMF_PTRSAV_SHIFT(Colors, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_BLENDFACTORS object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Elements members in each array + \param Positions Caller must free. Pointer to memory holding positions along gradient line. + \param Factors Caller must free. Pointer to memory holding blending factors, 0.0->1.0 values, inclusive along gradient line. + + EMF+ manual 2.2.2.5, Microsoft name: EmfPlusBlendFactors Object +*/ +int U_PMF_BLENDFACTORS_get(const char *contents, uint32_t *Elements, U_FLOAT **Positions, U_FLOAT **Factors){ + if(!contents || !Elements || !Positions || !Factors){ return(0); } + U_PMF_SERIAL_get(&contents, Elements, 4, 1, U_LE); + if(!U_PMF_SERIAL_array_copy_get(&contents, (void **)Positions, 4, *Elements, U_LE, 1)){ return(0); } + if(!U_PMF_SERIAL_array_copy_get(&contents, (void **)Factors, 4, *Elements, U_LE, 1)){ + free(*Positions); + return(0); + } + return(1); +} + +/** + \brief Get data from a U_PMF_BOUNDARYPATHDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Size bytes in Data + \param Data boundary of the brush + + EMF+ manual 2.2.2.6, Microsoft name: EmfPlusBoundaryPathData Object +*/ +int U_PMF_BOUNDARYPATHDATA_get(const char *contents, int32_t *Size, const char **Data){ + if(!contents || !Size || !Data){ return(0); } + U_PMF_SERIAL_get(&contents, Size, 4, 1, U_LE); + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_BOUNDARYPOINTDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Elements Members in POints + \param Points Caller must free. Pointer to memory holding points along gradient line. Boundary of the brush. + + EMF+ manual 2.2.2.7, Microsoft name: EmfPlusBoundaryPointData Object +*/ +int U_PMF_BOUNDARYPOINTDATA_get(const char *contents, int32_t *Elements, U_PMF_POINTF **Points){ + if(!contents || !Elements || !Points){ return(0); } + U_PMF_SERIAL_get(&contents, Elements, 4, 1, U_LE); + if(!U_PMF_SERIAL_array_copy_get(&contents, (void **)Points, 4, *Elements * 2, U_LE, 1)){ return(0); } + return(1); +} + +/** + \brief Get data from a U_PMF_CHARACTERRANGE object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param First First position in range + \param Length Range length + + EMF+ manual 2.2.2.8, Microsoft name: EmfPlusCharacterRange Object +*/ +int U_PMF_CHARACTERRANGE_get(const char *contents, int32_t *First, int32_t *Length){ + if(!contents || !First || !Length){ return(0); } + U_PMF_SERIAL_get(&contents, First, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Length, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMF_COMPOUNDLINEDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Elements Members in the array + \param Widths Caller must free. Pointer to memory holding Line or gap widths (0.0 <-> 1.0, fraction of total line width ). + + EMF+ manual 2.2.2.9, Microsoft name: EmfPlusCompoundLineData Object +*/ +int U_PMF_COMPOUNDLINEDATA_get(const char *contents, int32_t *Elements, U_FLOAT **Widths){ + if(!contents || !Elements || !Widths){ return(0); } + U_PMF_SERIAL_get(&contents, Elements, 4, 1, U_LE); + *Widths = (U_FLOAT *)malloc(*Elements * sizeof(U_FLOAT)); + if(!*Widths){ return(0); } + U_PMF_SERIAL_get(&contents, *Widths, 4, *Elements, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMF_COMPRESSEDIMAGE object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Data Stored image in one of the supported formats. + + EMF+ manual 2.2.2.10, Microsoft name: EmfPlusCompressedImage Object + + + This function does not do anything useful, but it is included so that all objects have a corresponding _get(). +*/ +int U_PMF_COMPRESSEDIMAGE_get(const char *contents, const char **Data){ + if(!contents || !Data){ return(0); } + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_CUSTOMENDCAPDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Size Bytes in Data + \param Data Description of linecap + + EMF+ manual 2.2.2.11, Microsoft name: EmfPlusCustomEndCapData Object +*/ +int U_PMF_CUSTOMENDCAPDATA_get(const char *contents, int32_t *Size, const char **Data){ + if(!contents || !Size || !Data){ return(0); } + U_PMF_SERIAL_get(&contents, Size, 4, 1, U_LE); + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_CUSTOMLINECAPARROWDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Ccad pointer to U_PMF_CUSTOMLINECAPARROWDATA structure + + EMF+ manual 2.2.2.12, Microsoft name: EmfPlusCustomLineCapArrowData Object +*/ +int U_PMF_CUSTOMLINECAPARROWDATA_get(const char *contents, U_PMF_CUSTOMLINECAPARROWDATA *Ccad){ + if(!contents || !Ccad){ return(0); } + U_PMF_SERIAL_get(&contents, Ccad, 4, 13, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMF_CUSTOMLINECAPDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Clcd pointer to U_PMF_CUSTOMLINECAPDATA structure, with no variable part + \param Data variable part of U_PMF_CUSTOMLINECAPDATA + + EMF+ manual 2.2.2.13, Microsoft name: EmfPlusCustomLineCapData Object +*/ +int U_PMF_CUSTOMLINECAPDATA_get(const char *contents, U_PMF_CUSTOMLINECAPDATA *Clcd, const char **Data){ + if(!contents || !Clcd){ return(0); } + U_PMF_SERIAL_get(&contents, Clcd, 4, 12, U_LE); + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_CUSTOMLINECAPOPTIONALDATA object + \return on success 3,5, or 7 (for varying combinations of data present) or 1 (no data is present), 0 on error + \param contents Record from which to extract data + \param Flags bits set to indicate the presence of FillData and/or LineData + \param FillData Path to fill (optional) + \param LineData Path to stroke (optional) + + EMF+ manual 2.2.2.14, Microsoft name: EmfPlusCustomLineCapOptionalData Object +*/ +int U_PMF_CUSTOMLINECAPOPTIONALDATA_get(const char *contents, uint32_t Flags, const char **FillData, const char **LineData){ + uint32_t length; + int status = 1; + if(!contents){ return(0); } + if(Flags & U_CLCD_FillPath){ + if(!FillData){ return(0); } + U_PMF_SERIAL_get(&contents, &length, 4, 1, U_LE); + contents -= 4; /* undo the unneeded shift from preceding */ + U_PMF_PTRSAV_SHIFT(FillData, &contents, 4 + length); + status += 2; + } + else { *FillData = NULL; } + + if(Flags & U_CLCD_LinePath){ + if(!LineData){ return(0); } + U_PMF_PTRSAV_SHIFT(LineData, &contents, 0); + status += 4; + } + else { *LineData = NULL; } + return(status); +} + +/** + \brief Get data from a U_PMF_CUSTOMSTARTCAPDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Size Bytes in Data + \param Data Description of linecap + + EMF+ manual 2.2.2.15, Microsoft name: EmfPlusCustomStartCapData Object +*/ +int U_PMF_CUSTOMSTARTCAPDATA_get(const char *contents, int32_t *Size, const char **Data){ + if(!contents || !Size || !Data){ return(0); } + U_PMF_SERIAL_get(&contents, Size, 4, 1, U_LE); + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_DASHEDLINEDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Elements Members in the array + \param Lengths Caller must free. Pointer to memory holding lengths of dashes and spaces. + + EMF+ manual 2.2.2.16, Microsoft name: EmfPlusDashedLineData Object +*/ +int U_PMF_DASHEDLINEDATA_get(const char *contents, int32_t *Elements, U_FLOAT **Lengths){ + if(!contents || !Elements || !Lengths){ return(0); } + U_PMF_SERIAL_get(&contents, Elements, 4, 1, U_LE); + *Lengths = (U_FLOAT *)malloc(*Elements * sizeof(U_FLOAT)); + if(!*Lengths){ return(0); } + U_PMF_SERIAL_get(&contents, *Lengths, 4, *Elements, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMF_FILLPATHOBJ object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Size Bytes in Data + \param Data Path specification + + EMF+ manual 2.2.2.17, Microsoft name: EmfPlusFillPath Object +*/ +int U_PMF_FILLPATHOBJ_get(const char *contents, int32_t *Size, const char **Data){ + if(!contents || !Size || !Data){ return(0); } + U_PMF_SERIAL_get(&contents, Size, 4, 1, U_LE); + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_FOCUSSCALEDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Count must be 2 + \param ScaleX value 0.0 <-> 1.0 + \param ScaleY value 0.0 <-> 1.0 + + EMF+ manual 2.2.2.18, Microsoft name: EmfPlusFocusScaleData Object +*/ +int U_PMF_FOCUSSCALEDATA_get(const char *contents, uint32_t *Count, U_FLOAT *ScaleX, U_FLOAT *ScaleY){ + if(!contents || !Count || !ScaleX || !ScaleY){ return(0); } + U_PMF_SERIAL_get(&contents, Count, 4, 1, U_LE); + if(*Count != 2){ return(0); } + U_PMF_SERIAL_get(&contents, ScaleX, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, ScaleY, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMF_GRAPHICSVERSION object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Signature Must be U_GFVR_PMF (0xDBC01) + \param GrfVersion GraphicsVersion enumeration + + EMF+ manual 2.2.2.19, Microsoft name: EmfPlusGraphicsVersion Object +*/ +int U_PMF_GRAPHICSVERSION_get(const char *contents, int *Signature, int *GrfVersion){ + if(!contents || !Signature || !GrfVersion){ return(0); } + uint32_t tmp; + memcpy(&tmp, contents, 4); + *Signature = tmp >> 12; + *GrfVersion = tmp & U_GFVR_MASKLO; + return(1); +} + +/** + \brief Get data from a U_PMF_HATCHBRUSHDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Style HatchStyle enumeration + \param Foreground Hatch pattern line color + \param Background Hatch pattern bkground color + + EMF+ manual 2.2.2.20, Microsoft name: EmfPlusHatchBrushData Object +*/ +int U_PMF_HATCHBRUSHDATA_get(const char *contents, uint32_t *Style, U_PMF_ARGB *Foreground, U_PMF_ARGB *Background){ + if(!contents || !Style || !Foreground || !Background){ return(0); } + U_PMF_SERIAL_get(&contents, Style, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Foreground, 4, 1, U_XE); + U_PMF_SERIAL_get(&contents, Background, 4, 1, U_XE); + return(1); +} + +/** + \brief Get data from a U_PMF_INTEGER7 object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Value 7 bit signed integer (stored in an integer) + + EMF+ manual 2.2.2.21, Microsoft name: EmfPlusInteger7 Object +*/ +int U_PMF_INTEGER7_get(const char **contents, U_FLOAT *Value){ + if(!contents || !*contents || !Value){ return(0); } + uint8_t tmp; + if(**contents & U_TEST_INT7)return(0); /* this bit must be 0 in this object type */ + U_PMF_SERIAL_get(contents, &tmp, 1, 1, U_XE); + if(tmp & U_SIGN_INT7){ + tmp |= U_TEST_INT7; /* now it has the bit pattern of a signed int8_t */ + *Value = *(int8_t *)&tmp; + } + else { + *Value = tmp; + } + return(1); +} + +/** + \brief Get data from a U_PMF_INTEGER15 object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Value 15 bit signed integer (stored in an integer) + + EMF+ manual 2.2.2.22, Microsoft name: EmfPlusInteger15 Object +*/ +int U_PMF_INTEGER15_get(const char **contents, U_FLOAT *Value){ + if(!contents || !*contents || !Value){ return(0); } + uint16_t tmp; + if(!(**contents & U_TEST_INT7))return(0); /* this bit must be 1 in this object type */ + U_PMF_SERIAL_get(contents, &tmp, 2, 1, U_BE); + tmp &= U_MASK_INT15; /* drop the 7/15 flag from the most significant bit */ + if(tmp & U_SIGN_INT15){ + tmp |= U_TEST_INT15; /* now it has the bit pattern of a signed int16_t */ + *Value = *(int16_t *)&tmp; + } + else { + *Value = tmp; + } + return(1); +} + +/** + \brief Get data from a U_PMF_LANGUAGEIDENTIFIER object + \return 1 on success, 0 on error + \param LId U_PMF_LANGUAGEIDENTIFIER from which to extract data + \param SubLId Example: code for USA + \param PriLId Example: code for English + + + + EMF+ manual 2.2.2.23, Microsoft name: EmfPlusLanguageIdentifier Object + + This type is defined as 16 bits in the manual section, but it is only ever used as part of a 32 bit field! +*/ +int U_PMF_LANGUAGEIDENTIFIER_get(U_PMF_LANGUAGEIDENTIFIER LId, int *SubLId, int *PriLId){ + if(!SubLId || !PriLId){ return(0); } + *SubLId = (LId >> U_FF_SHFT_SUBLID ) & U_FF_MASK_SUBLID; + *PriLId = (LId >> U_FF_SHFT_PRILID ) & U_FF_MASK_PRILID; + /* 16 bits above that are not used */ + return(1); +} + +/** + \brief Get data from a U_PMF_LINEARGRADIENTBRUSHDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Lgbd U_PMF_LINEARGRADIENTBRUSHDATA structure, with no variable part + \param Data variable part of U_PMF_LINEARGRADIENTBRUSHDATA + + EMF+ manual 2.2.2.24, Microsoft name: EmfPlusLinearGradientBrushData Object +*/ +int U_PMF_LINEARGRADIENTBRUSHDATA_get(const char *contents, U_PMF_LINEARGRADIENTBRUSHDATA *Lgbd, const char **Data){ + if(!contents || !Lgbd || !Data){ return(0); } + U_PMF_SERIAL_get(&contents, Lgbd, 4, 6, U_LE); /* Flags, WrapMode, RectF*/ + U_PMF_SERIAL_get(&contents, &(Lgbd->StartColor), 4, 4, U_XE); /* StartColor, EndColor, Reserved1 & 2 */ + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_LINEARGRADIENTBRUSHOPTIONALDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Flags BrushData flags - indicates which of the following date fields are present. + \param Tm Transformation matrix + \param Bc U_PMF_BLENDCOLORS object or NULL + \param BfH U_PMF_BLENDFACTORS (H) object or NULL + \param BfV U_PMF_BLENDFACTORS (V) object or NULL (WARNING, GDI+ defines this field but does not render it. DO NOT USE.) + + EMF+ manual 2.2.2.25, Microsoft name: EmfPlusLinearGradientBrushOptionalData Object +*/ +int U_PMF_LINEARGRADIENTBRUSHOPTIONALDATA_get(const char *contents, uint32_t Flags, U_PMF_TRANSFORMMATRIX *Tm, + const char **Bc, const char **BfH, const char **BfV){ + uint32_t Elements; + if(!contents || !Tm|| !Bc || !BfH || !BfV){ return(0); } + *Bc = *BfH = *BfV = NULL; + if(Flags & U_BD_Transform)U_PMF_SERIAL_get(&contents, Tm, 4, 6, U_LE); + if(Flags & U_BD_PresetColors){ + U_PMF_PTRSAV_SHIFT(Bc, &contents, 0); + } + else if(Flags & U_BD_BlendFactorsH){ + U_PMF_SERIAL_get(&contents, &Elements, 4, 1, U_LE); /* starts with a 4 byte count*/ + contents-=4; /* back up to the front of the count, as it is part of the data field */ + U_PMF_PTRSAV_SHIFT(BfH, &contents, 4 + 8*Elements); /* 4 byte count + 2 * 4bytes * Elements */ + if(Flags & U_BD_BlendFactorsV){ + U_PMF_PTRSAV_SHIFT(BfV, &contents, 0); + } + } + else if(Flags & U_BD_BlendFactorsV){ + U_PMF_PTRSAV_SHIFT(BfV, &contents, 0); + } + return(1); +} + +/** + \brief Get data from a U_PMF_LINEPATH object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Size Bytes in Data + \param Data Outline path + + EMF+ manual 2.2.2.26, Microsoft name: EmfPlusLinePath Object +*/ +int U_PMF_LINEPATH_get(const char *contents, int32_t *Size, const char **Data){ + if(!contents || !Size || !Data){ return(0); } + U_PMF_SERIAL_get(&contents, Size, 4, 1, U_LE); + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_METAFILE object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Type + \param Size Bytes in Data + \param Data Various types of data, like an EMF metafile, WMF metafile, another EMF+ metafile + + EMF+ manual 2.2.2.27, Microsoft name: EmfPlusMetafile Object +*/ +int U_PMF_METAFILE_get(const char *contents, uint32_t *Type, uint32_t *Size, const char **Data){ + if(!contents || !Type || !Size || !Data){ return(0); } + U_PMF_SERIAL_get(&contents, &Type, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, &Size, 4, 1, U_LE); + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_PALETTE object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Flags PaletteStyle flags + \param Elements Members in the array + \param Colors Palette data (array of colors) + + EMF+ manual 2.2.2.28, Microsoft name: EmfPlusPalette Object +*/ +int U_PMF_PALETTE_get(const char *contents, uint32_t *Flags, uint32_t *Elements, const char **Colors){ + if(!contents || !Flags || !Elements || !Colors){ return(0); } + U_PMF_SERIAL_get(&contents, &Flags, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, &Elements, 4, 1, U_LE); + U_PMF_PTRSAV_SHIFT(Colors, &contents, 0); + return(1); + +} + +/** + \brief Get data from a U_PMF_PATHGRADIENTBRUSHDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Pgbd constant part of U_PMF_PATHGRADIENTBRUSHDATA object + \param Gradient variable part of U_PMF_LINEARGRADIENTBRUSHDATA, Color Gradient with Elements members + \param Boundary variable part of U_PMF_LINEARGRADIENTBRUSHDATA, U_PMF_BOUNDARYPATHDATA object if BrushDataPath bit set in Flag, else U_PMF_BOUNDARYPOINTDATA object + \param Data variable part of U_PMF_LINEARGRADIENTBRUSHDATA, exact composition depends on Flags + + EMF+ manual 2.2.2.29, Microsoft name: EmfPlusPathGradientBrushData Object +*/ +int U_PMF_PATHGRADIENTBRUSHDATA_get(const char *contents, U_PMF_PATHGRADIENTBRUSHDATA *Pgbd, const char **Gradient, const char **Boundary, const char **Data){ + if(!contents || !Pgbd || !Gradient || !Boundary || !Data){ return(0); } + uint32_t Size; + U_PMF_SERIAL_get(&contents, Pgbd, 4, 2, U_LE); /* Flags and WrapMode*/ + U_PMF_SERIAL_get(&contents, &(Pgbd->CenterColor), 4, 1, U_XE); + U_PMF_SERIAL_get(&contents, &(Pgbd->Center), 4, 3, U_LE); /* Center and Elements */ + U_PMF_PTRSAV_SHIFT(Gradient, &contents, Pgbd->Elements * sizeof(U_PMF_ARGB)); + U_PMF_PTRSAV_SHIFT(Boundary, &contents, 0); + U_PMF_SERIAL_get(&contents, &Size, 4, 1, U_LE); /* The first 4 bytes of the Boundary are always a size */ + if(Pgbd->Flags & U_BD_Path){ contents += Size; } // U_PMF_BOUNDARYPATHDATA + else { contents += Size*2*sizeof(U_FLOAT); } // U_PMF_BOUNDARYPOINTDATA + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_PATHGRADIENTBRUSHOPTIONALDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Flags bits set to indicate the presence of FillData and/or LineData + \param Matrix Transformation matrix + \param Pattern Blend Pattern + \param Data Focus scales for the brush + + EMF+ manual 2.2.2.30, Microsoft name: EmfPlusPathGradientBrushOptionalData Object +*/ +int U_PMF_PATHGRADIENTBRUSHOPTIONALDATA_get(const char *contents, uint32_t Flags, U_PMF_TRANSFORMMATRIX *Matrix, const char **Pattern, const char **Data){ + if(!contents || !Flags || !Matrix || !Pattern || !Data){ return(0); } + U_PMF_SERIAL_get(&contents, &Flags, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Matrix, 4, 6, U_LE); + U_PMF_PTRSAV_COND(Data, contents, (Flags & (U_BD_PresetColors | U_BD_BlendFactorsH))); + U_PMF_PTRSAV_COND(Data, contents, (Flags & U_BD_FocusScales)); + return(1); +} + +/** + \brief Get data from a U_PMF_PATHPOINTTYPE object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Flags PathPointType flags + \param Type PathPointType enumeration + + EMF+ manual 2.2.2.31, Microsoft name: EmfPlusPathPointType Object + + Note: order of 4bit fields appears to be shown in the LE column, not as + documented in the BE column. +*/ +int U_PMF_PATHPOINTTYPE_get(const char *contents, int *Flags, int *Type){ + if(!contents || !Flags || !Type){ return(0); } + uint8_t tmp; + memcpy(&tmp, contents, 1); + *Flags =(tmp & U_PTP_MASK) >> U_PTP_SHIFT; + *Type = (tmp & U_PPT_MASK); + return(1); +} + +/** + \brief Get data from a U_PMF_PATHPOINTTYPERLE object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Bezier Set: Bezier curve, Clear: straight line + \param RL Run Length + \param Ppt PathPointType enumeration + + EMF+ manual 2.2.2.32, Microsoft name: EmfPlusPathPointTypeRLE Object +*/ +int U_PMF_PATHPOINTTYPERLE_get(const char *contents, int *Bezier, int *RL, int *Ppt){ + if(!contents || !Bezier || !RL || !Ppt){ return(0); } + uint16_t tmp; + U_PMF_SERIAL_get(&contents, &tmp, 2, 1, U_LE); + *Bezier = tmp & U_PPF_BZ; + *RL = (tmp >> U_FF_SHFT_RL) & U_FF_MASK_RL; + *Ppt = (tmp >> U_FF_SHFT_PPT) & U_FF_MASK_PPT; + return(1); +} + +/** + \brief Get data from a U_PMF_PENDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Flags PenData flags + \param Unit UnitType enumeration + \param Width Width in units set by Unit + \param Data Optional pen data, exact composition depends on Flags + + EMF+ manual 2.2.2.33, Microsoft name: EmfPlusPenData Object +*/ +int U_PMF_PENDATA_get(const char *contents, uint32_t *Flags, uint32_t *Unit, U_FLOAT *Width, const char **Data){ + if(!contents || !Flags || !Unit || !Width || !Data){ return(0); } + U_PMF_SERIAL_get(&contents, Flags, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Unit, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Width, 4, 1, U_LE); + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_PENOPTIONALDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Flags; PenData Flags - indicated which of the many fields are present. + \param Matrix; Transformation matrix + \param StartCap LineCapType enumeration + \param EndCap LineCapType enumeration + \param Join LineJoinType enumeration + \param MiterLimit Maximum (miter length / line width) + \param Style LineStyle enumeration + \param DLCap DashedLineCapType enumeration + \param DLOffset Distance line start to first dash start + \param DLData Dash and space widths + \param Alignment PenAlignment enumeration + \param CmpndLineData Compount Line (parallel lines drawn instead of one) + \param CSCapData Custom start cap + \param CECapData Custom end cap + + EMF+ manual 2.2.2.34, Microsoft name: EmfPlusPenOptionalData Object + + This object consists of a large number of optional and or variable values, which + are returned, or not, depending on bits in Flags. +*/ +int U_PMF_PENOPTIONALDATA_get( + const char *contents, + uint32_t Flags, // determines which fields are filled + U_PMF_TRANSFORMMATRIX *Matrix, + int32_t *StartCap, + int32_t *EndCap, + uint32_t *Join, + U_FLOAT *MiterLimit, + int32_t *Style, + int32_t *DLCap, + U_FLOAT *DLOffset, + const char **DLData, + int32_t *Alignment, + const char **CmpndLineData, + const char **CSCapData, + const char **CECapData){ + if(!contents || + !Flags || !Matrix || !StartCap || !EndCap || + !Join || !MiterLimit || !Style || !DLCap || + !DLOffset || !DLData || !Alignment || !CmpndLineData || + !CSCapData || !CECapData){ return(0); } + + if(Flags & U_PD_Transform){ U_PMF_SERIAL_get(&contents, Matrix, 4, 6, U_LE); } + if(Flags & U_PD_StartCap){ U_PMF_SERIAL_get(&contents, StartCap, 4, 1, U_LE); } + if(Flags & U_PD_EndCap){ U_PMF_SERIAL_get(&contents, EndCap, 4, 1, U_LE); } + if(Flags & U_PD_Join){ U_PMF_SERIAL_get(&contents, Join, 4, 1, U_LE); } + if(Flags & U_PD_MiterLimit){ U_PMF_SERIAL_get(&contents, MiterLimit, 4, 1, U_LE); } + if(Flags & U_PD_LineStyle){ U_PMF_SERIAL_get(&contents, Style, 4, 1, U_LE); } + if(Flags & U_PD_DLCap){ U_PMF_SERIAL_get(&contents, DLCap, 4, 1, U_LE); } + if(Flags & U_PD_DLOffset){ U_PMF_SERIAL_get(&contents, DLOffset, 4, 1, U_LE); } + if(Flags & U_PD_DLData){ U_PMF_PTRSAV_SHIFT( DLData, &contents, U_PMF_LEN_FLOATDATA(contents)); } + if(Flags & U_PD_NonCenter){ U_PMF_SERIAL_get(&contents, Alignment, 4, 1, U_LE); } + if(Flags & U_PD_CLData){ U_PMF_PTRSAV_SHIFT( CmpndLineData, &contents, U_PMF_LEN_FLOATDATA(contents)); } + if(Flags & U_PD_CustomStartCap){ U_PMF_PTRSAV_SHIFT( CSCapData, &contents, U_PMF_LEN_BYTEDATA(contents)); } + if(Flags & U_PD_CustomEndCap){ U_PMF_PTRSAV_SHIFT( CECapData, &contents, U_PMF_LEN_BYTEDATA(contents)); } + return(1); +} + +/** + \brief Get data from a U_PMF_POINT object + \return 1 on success, 0 on error + \param contents Record from which to extract data. On return position is offset by sizeof(U_PMF_POINT). + \param X X coordinate + \param Y Y coordinate + + EMF+ manual 2.2.2.35, Microsoft name: EmfPlusPoint Object +*/ +int U_PMF_POINT_get(const char **contents, U_FLOAT *X, U_FLOAT *Y){ + if(!contents || !X || !Y){ return(0); } + int16_t tmp; + U_PMF_SERIAL_get(contents, &tmp, 2, 1, U_LE); *X = tmp; + U_PMF_SERIAL_get(contents, &tmp, 2, 1, U_LE); *Y = tmp; + return(1); +} + +/** + \brief Get data from a U_PMF_POINTF object + \return 1 on success, 0 on error + \param contents Record from which to extract data. On return position is offset by sizeof(U_PMF_POINTF). + \param X X coordinate + \param Y Y coordinate + + EMF+ manual 2.2.2.36, Microsoft name: EmfPlusPointF Object +*/ +int U_PMF_POINTF_get(const char **contents, U_FLOAT *X, U_FLOAT *Y){ + if(!contents || !X || !Y){ return(0); } + U_PMF_SERIAL_get(contents, X, 4, 1, U_LE); + U_PMF_SERIAL_get(contents, Y, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMF_POINTR object + \return size in bytes traversed on success, 0 on error + \param contents Record from which to extract data. On return position is offset by returned size. + \param X X coordinate + \param Y Y coordinate + + EMF+ manual 2.2.2.37, Microsoft name: EmfPlusPointR Object +*/ +int U_PMF_POINTR_get(const char **contents, U_FLOAT *X, U_FLOAT *Y){ + if(!contents || !*contents | !X || !Y){ return(0); } + int size=0; + + if( U_PMF_INTEGER7_get( contents, X)){ size +=1; } + else if(U_PMF_INTEGER15_get(contents, X)){ size +=2; } + else { return(0); } + + if( U_PMF_INTEGER7_get( contents, Y)){ size +=1; } + else if(U_PMF_INTEGER15_get(contents, Y)){ size +=2; } + else { return(0); } + + return(size); +} + +/** + \brief Get data from a variable POINTS object, which may be U_PMF_POINTS, U_PMF_POINTF, or U_PMF_POINTR. + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Flags Record flags (bits U_PPF_C and U_PPF_P are referenced) + \param Elements Number of points to retrieve. + \param Points Caller must free. Array of U_PMF_POINTF coordinates. +*/ +int U_PMF_VARPOINTS_get(const char **contents, uint16_t Flags, int Elements, U_PMF_POINTF **Points){ + U_PMF_POINTF *pts = (U_PMF_POINTF *)malloc(Elements * sizeof(U_PMF_POINTF)); + U_FLOAT XF, YF; + U_FLOAT XFS, YFS; + + if(!contents || !*contents || !Points){ return(0); } + *Points = pts; + for(XFS = YFS = 0.0; Elements; Elements--, pts++){ + if(Flags & U_PPF_P){ + U_PMF_POINTR_get(contents, &XF, &YF); + XFS += XF; /* position relative to previous point, first point is always 0,0 */ + YFS += YF; + pts->X = XFS; + pts->Y = YFS; + } + else if(Flags & U_PPF_C){ + (void) U_PMF_POINT_get(contents, &XF, &XF); + pts->X = XF; + pts->Y = YF; + } + else { + (void) U_PMF_POINTF_get(contents, &(pts->X), &(pts->Y)); + } + } + return(1); +} + +/** + \brief Get data from a U_PMF_RECT object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param X UL X value + \param Y UL Y value + \param Width Width + \param Height Height + + EMF+ manual 2.2.2.38, Microsoft name: EmfPlusRect Object +*/ +int U_PMF_RECT_get(const char **contents, int16_t *X, int16_t *Y, int16_t *Width, int16_t *Height){ + if(!contents || !X || !Y|| !Width || !Height){ return(0); } + U_PMF_SERIAL_get(contents, X, 2, 1, U_LE); + U_PMF_SERIAL_get(contents, Y, 2, 1, U_LE); + U_PMF_SERIAL_get(contents, Width, 2, 1, U_LE); + U_PMF_SERIAL_get(contents, Height, 2, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMF_RECTF object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param X UL X value + \param Y UL Y value + \param Width Width + \param Height Height + + EMF+ manual 2.2.2.39, Microsoft name: EmfPlusRectF Object +*/ +int U_PMF_RECTF_get(const char **contents, U_FLOAT *X, U_FLOAT *Y, U_FLOAT *Width, U_FLOAT *Height){ + if(!contents || !X || !Y|| !Width || !Height){ return(0); } + U_PMF_SERIAL_get(contents, X, 4, 1, U_LE); + U_PMF_SERIAL_get(contents, Y, 4, 1, U_LE); + U_PMF_SERIAL_get(contents, Width, 4, 1, U_LE); + U_PMF_SERIAL_get(contents, Height, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a variable RECTS object, which may be U_PMF_RECT or U_PMF_RECTF + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Flags Record flags (bit U_PPF_C is referenced) + \param Elements Number of rects to retrieve. + \param Rects Caller must free. Array of U_PMF_RECTF coordinates. + + Rects in record may be either U_PMF_RECT or U_PMF_RECTF, but this function always + returns U_PMF_RECTF +*/ +int U_PMF_VARRECTS_get(const char **contents, uint16_t Flags, int Elements, U_PMF_RECTF **Rects){ + int16_t X16, Y16, Width, Height; + if(!contents || !*contents || !Rects){ return(0); } + U_PMF_RECTF *rts = (U_PMF_RECTF *)malloc(Elements * sizeof(U_PMF_RECTF)); + if(!rts){ + *Rects = NULL; + return(0); + } + + *Rects = rts; + for(; Elements; Elements--, rts++){ + if(Flags & U_PPF_C){ + (void) U_PMF_RECT_get(contents, &X16, &Y16, &Width, &Height); + rts->X = X16; + rts->Y = Y16; + rts->Width = Width; + rts->Height = Height; + } + else { + (void) U_PMF_RECTF_get(contents, &(rts->X), &(rts->Y), &(rts->Width), &(rts->Height)); + } + } + return(1); +} + +/** + \brief Get data from a U_PMF_REGIONNODE object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Type RegionNodeDataType + \param Data Depending on Type: U_PMF_REGIONNODEPATH, U_PMF_RECTF, or U_PMF_REGIONNODECHILDNODES + + + EMF+ manual 2.2.2.40, Microsoft name: EmfPlusRegionNode Object +*/ +int U_PMF_REGIONNODE_get(const char *contents, uint32_t *Type, const char **Data){ + if(!contents || !Type|| !Data){ return(0); } + U_PMF_SERIAL_get(&contents, Type, 4, 1, U_LE); + U_PMF_PTRSAV_COND(Data, contents, !(*Type == U_RNDT_Empty || *Type == U_RNDT_Infinite )); + return(1); +} + +/** + There is no U_PMF_REGIONNODECHILDNODES_get! + + The Region object is recursive allowing U_PMF_REGIONNODECHILDNODES -> + U_PMF_REGIONNODE -> U_PMF_REGIONNODECHILDNODES etc. + So the data stored in each node must be handled as the tree is followed recursively. + + See U_PMF_REGIONNODECHILDNODES_print() and U_PMF_REGIONNODE_print() for an example. + + + EMF+ manual 2.2.2.41, Microsoft name: EmfPlusRegionNodeChildNodes Object +*/ + +/** + \brief Get data from a U_PMF_REGIONNODEPATH object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Size Bytes in Data + \param Data Boundary of region node + + EMF+ manual 2.2.2.42, Microsoft name: EmfPlusRegionNodePath Object +*/ +int U_PMF_REGIONNODEPATH_get(const char *contents, int32_t *Size, const char **Data){ + if(!contents || !Size || !Data){ return(0); } + U_PMF_SERIAL_get(&contents, Size, 4, 1, U_LE); + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_SOLIDBRUSHDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Color Color of brush + + EMF+ manual 2.2.2.43, Microsoft name: EmfPlusSolidBrushData Object +*/ +int U_PMF_SOLIDBRUSHDATA_get(const char *contents, U_PMF_ARGB *Color){ + if(!contents || !Color){ return(0); } + U_PMF_SERIAL_get(&contents, Color, 4, 1, U_XE); + return(1); +} + +/** + \brief Get data from a U_PMF_STRINGFORMATDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param TabStopCount Entries in TabStop array + \param RangeCount Entries in CharRange array + \param TabStops Array of tabstop locations + \param CharRange Array of character ranges in the text + + EMF+ manual 2.2.2.44, Microsoft name: EmfPlusStringFormatData Object +*/ +int U_PMF_STRINGFORMATDATA_get(const char *contents, uint32_t TabStopCount, uint32_t RangeCount, + const U_FLOAT **TabStops, const U_PMF_CHARACTERRANGE **CharRange){ + if(!contents || !TabStops|| !CharRange){ return(0); } + *TabStops = NULL; + if(TabStopCount > 0){ U_PMF_SERIAL_get(&contents, TabStops, 4, TabStopCount, U_LE); } + *CharRange = NULL; + if(RangeCount > 0){ U_PMF_SERIAL_get(&contents, CharRange, 4, 2*RangeCount, U_LE); } + return(1); +} + +/** + \brief Get data from a U_PMF_TEXTUREBRUSHDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Flags BrushData flags + \param WrapMode WrapMode enumeration + \param Data Optional texture data + + EMF+ manual 2.2.2.45, Microsoft name: EmfPlusTextureBrushData Object +*/ +int U_PMF_TEXTUREBRUSHDATA_get(const char *contents, uint32_t *Flags, int32_t *WrapMode, const char **Data){ + if(!contents || !Flags || !WrapMode || !Data){ return(0); } + U_PMF_SERIAL_get(&contents, Flags, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, WrapMode, 4, 1, U_LE); + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_TEXTUREBRUSHOPTIONALDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param HasImage True if this object has an Image + \param Matrix Transformation matrix, present if Flag BrushDataTransform is set. + \param Image Image that contains the texture. + + + EMF+ manual 2.2.2.46, Microsoft name: EmfPlusTextureBrushOptionalData Object +*/ +int U_PMF_TEXTUREBRUSHOPTIONALDATA_get(const char *contents, int HasImage, U_PMF_TRANSFORMMATRIX *Matrix, const char **Image){ + if(!contents || !Matrix || !Image){ return(0); } + U_PMF_SERIAL_get(&contents, Matrix, 4, 6, U_LE); + U_PMF_PTRSAV_COND(Image, contents, HasImage); + return(1); +} + +/** + \brief Get data from a U_PMF_TRANSFORMMATRIX object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Matrix Transformation matrix, present if Flag BrushDataTransform is set. + + EMF+ manual 2.2.2.47, Microsoft name: EmfPlusTransformMatrix Object +*/ +int U_PMF_TRANSFORMMATRIX_get(const char *contents, U_PMF_TRANSFORMMATRIX *Matrix){ + if(!contents || !Matrix){ return(0); } + U_PMF_SERIAL_get(&contents, Matrix, 4, 6, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMF_IE_BLUR object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Radius Blur radius in pixels + \param ExpandEdge 1: expand bitmap by Radius; 0: bitmap size unchanged + + EMF+ manual 2.2.3.1, Microsoft name: BlurEffect Object +*/ +int U_PMF_IE_BLUR_get(const char *contents, U_FLOAT *Radius, uint32_t *ExpandEdge){ + if(!contents || !Radius || !ExpandEdge){ return(0); } + U_PMF_SERIAL_get(&contents, Radius, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, ExpandEdge, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMF_IE_BRIGHTNESSCONTRAST object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Brightness -255 to 255, 0 is unchanged, positive increases, negative decreases + \param Contrast -100 to 100, 0 is unchanged, positive increases, negative decreases + + EMF+ manual 2.2.3.2, Microsoft name: BrightnessContrastEffect Object +*/ +int U_PMF_IE_BRIGHTNESSCONTRAST_get(const char *contents, int32_t *Brightness, int32_t *Contrast){ + if(!contents || !Brightness || !Contrast){ return(0); } + U_PMF_SERIAL_get(&contents, Brightness, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Contrast, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMF_IE_COLORBALANCE object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param CyanRed -100 to 100, 0 is unchanged, positive increases Red & decreases Cyan, negative is opposite + \param MagentaGreen -100 to 100, 0 is unchanged, positive increases Green & decreases Magenta, negative is opposite + \param YellowBlue -100 to 100, 0 is unchanged, positive increases Blue & decreases Yellow, negative is opposite + + EMF+ manual 2.2.3.3, Microsoft name: ColorBalanceEffect Object +*/ +int U_PMF_IE_COLORBALANCE_get(const char *contents, int32_t *CyanRed, int32_t *MagentaGreen, int32_t *YellowBlue){ + if(!contents || !CyanRed || !MagentaGreen || !YellowBlue){ return(0); } + U_PMF_SERIAL_get(&contents, CyanRed, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, MagentaGreen, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, YellowBlue, 4, 1, U_LE); + return(1); +} + + +/** + \brief Get data from a U_PMF_IE_COLORCURVE object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Adjust CurveAdjustment enumeration + \param Channel CurveChannel enumeration + \param Intensity adjustment to apply. "Adjust" determines what field this is and range values. + + EMF+ manual 2.2.3.4, Microsoft name: ColorCurveEffect Object +*/ +int U_PMF_IE_COLORCURVE_get(const char *contents, uint32_t *Adjust, uint32_t *Channel, int32_t *Intensity){ + if(!contents || !Adjust || !Channel || !Intensity){ return(0); } + U_PMF_SERIAL_get(&contents, Adjust, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Channel, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Intensity, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMF_IE_COLORLOOKUPTABLE object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param BLUT Blue color lookup table + \param GLUT Green color lookup table + \param RLUT Red color lookup table + \param ALUT Alpha color lookup table + + EMF+ manual 2.2.3.5, Microsoft name: ColorLookupTableEffect Object +*/ +int U_PMF_IE_COLORLOOKUPTABLE_get(const char *contents, + const uint8_t **BLUT, const uint8_t **GLUT, const uint8_t **RLUT, const uint8_t **ALUT){ + if(!contents || !BLUT || !GLUT || !RLUT || !ALUT){ return(0); } + U_PMF_PTRSAV_SHIFT((const char **)BLUT, &contents, 256); + U_PMF_PTRSAV_SHIFT((const char **)GLUT, &contents, 256); + U_PMF_PTRSAV_SHIFT((const char **)RLUT, &contents, 256); + U_PMF_PTRSAV_SHIFT((const char **)ALUT, &contents, 256); + return(1); +} + +/** + \brief Get data from a U_PMF_IE_COLORMATRIX object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Matrix 5 x 5 color transformation matrix, First 4 rows are [{4 multiplier values},0.0] for R,G,B,A, last Row is [{4 color translation valuess}, 1.0] + + EMF+ manual 2.2.3.6, Microsoft name: ColorMatrixEffect Object +*/ +int U_PMF_IE_COLORMATRIX_get(const char *contents, U_PMF_IE_COLORMATRIX *Matrix){ + if(!contents || !Matrix){ return(0); } + U_PMF_SERIAL_get(&contents, Matrix, 4, 5*5, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMF_IE_HUESATURATIONLIGHTNESS object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Hue -180 to 180, 0 is unchanged + \param Saturation -100 to 100, 0 is unchanged + \param Lightness -100 to 100, 0 is unchanged + + EMF+ manual 2.2.3.7, Microsoft name: HueSaturationLightnessEffect Object +*/ +int U_PMF_IE_HUESATURATIONLIGHTNESS_get(const char *contents, int32_t *Hue, int32_t *Saturation, int32_t *Lightness){ + if(!contents || !Hue || !Saturation || !Lightness){ return(0); } + U_PMF_SERIAL_get(&contents, Hue, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Saturation, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Lightness, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMF_IE_LEVELS object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Highlight 0 to 100, 100 is unchanged + \param Midtone -100 to 100, 0 is unchanged + \param Shadow 0 to 100, 0 is unchanged + + EMF+ manual 2.2.3.8, Microsoft name: LevelsEffect Object +*/ +int U_PMF_IE_LEVELS_get(const char *contents, int32_t *Highlight, int32_t *Midtone, int32_t *Shadow){ + if(!contents || !Highlight || !Midtone || !Shadow){ return(0); } + U_PMF_SERIAL_get(&contents, Highlight, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Midtone, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Shadow, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMF_IE_REDEYECORRECTION object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Elements Number of members in Rects + \param Rects Caller must free. Pointer to memory holding an array of U_RECTL. + + EMF+ manual 2.2.3.9, Microsoft name: RedEyeCorrectionEffect Object +*/ +int U_PMF_IE_REDEYECORRECTION_get(const char *contents, int32_t *Elements, U_RECTL **Rects){ + if(!contents || !Elements || !Rects){ return(0); } + U_PMF_SERIAL_get(&contents, Elements, 4, 1, U_LE); + *Rects = (U_RECTL *) malloc(*Elements * sizeof(U_RECTL)); + if(!*Rects){ return(0); } + U_PMF_SERIAL_get(&contents, *Rects, 4, *Elements * 4, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMF_IE_SHARPEN object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Radius Sharpening radius in pixels + \param Sharpen 0 to 100, 0 is unchanged + + EMF+ manual 2.2.3.10, Microsoft name: SharpenEffect Object +*/ +int U_PMF_IE_SHARPEN_get(const char *contents, U_FLOAT *Radius, int32_t *Sharpen){ + if(!contents || !Radius || !Sharpen){ return(0); } + U_PMF_SERIAL_get(&contents, Radius, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Sharpen, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMF_IE_TINT object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Hue -180 to 180, [positive==clockwise] rotation in degrees starting from blue + \param Amount -100 [add black] to 100[add white], 0 is unchanged. Change in hue on specified axis + + EMF+ manual 2.2.3.11, Microsoft name: TintEffect Object +*/ +int U_PMF_IE_TINT_get(const char *contents, int32_t *Hue, int32_t *Amount){ + if(!contents || !Hue || !Amount){ return(0); } + U_PMF_SERIAL_get(&contents, Hue, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Amount, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_OFFSETCLIP record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header (ignore flags) + \param dX horizontal translation offset to apply to clipping region + \param dY vertical translation offset to apply to clipping region + + EMF+ manual 2.3.1.1, Microsoft name: EmfPlusOffsetClip Record, Index 0x35 +*/ +int U_PMR_OFFSETCLIP_get(const char *contents, U_PMF_CMN_HDR *Header, + U_FLOAT *dX, U_FLOAT *dY){ + if(!contents){ return(0); } + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, dX, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, dY, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_RESETCLIP record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header (ignore flags) + + EMF+ manual 2.3.1.2, Microsoft name: EmfPlusResetClip Record, Index 0x31 +*/ +int U_PMR_RESETCLIP_get(const char *contents, U_PMF_CMN_HDR *Header){ + if(!contents){ return(0); } + U_PMF_CMN_HDR_get(&contents, Header); + return(1); +} + +/** + \brief Get data from a U_PMR_SETCLIPPATH record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param CMenum CombineMode enumeration.. + \param PathID U_PMF_PATH object in the EMF+ object table (0-63, inclusive) + + EMF+ manual 2.3.1.3, Microsoft name: EmfPlusSetClipPath Record, Index 0x33 +*/ +int U_PMR_SETCLIPPATH_get(const char *contents, U_PMF_CMN_HDR *Header, + uint32_t *PathID, int *CMenum){ + if(!contents || !PathID || !CMenum){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *CMenum = (Flags >> U_FF_SHFT_CM4) & U_FF_MASK_CM4; + *PathID = (Flags >> U_FF_SHFT_OID8) & U_FF_MASK_OID8; + U_PMF_CMN_HDR_get(&contents, Header); + return(1); +} + +/** + \brief Get data from a U_PMR_SETCLIPRECT record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header (ignore flags) + \param CMenum Combine mode enumeration. + \param Rect Rectangle used with CombineMode enumeration from Header.Flags + + EMF+ manual 2.3.1.4, Microsoft name: EmfPlusSetClipRect Record, Index 0x32 +*/ +int U_PMR_SETCLIPRECT_get(const char *contents, U_PMF_CMN_HDR *Header, + int *CMenum, + U_PMF_RECTF *Rect){ + if(!contents || !CMenum || !Rect ){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *CMenum = (Flags >> U_FF_SHFT_CM4) & U_FF_MASK_CM4; + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, Rect, 4, 4, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_SETCLIPREGION record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param CMenum CombineMode enumeration.. + \param PathID U_PMF_PATH object in the EMF+ object table (0-63, inclusive) + + EMF+ manual 2.3.1.5, Microsoft name: EmfPlusSetClipRegion Record, Index 0x34 +*/ +int U_PMR_SETCLIPREGION_get(const char *contents, U_PMF_CMN_HDR *Header, + uint32_t *PathID, int *CMenum){ + if(!contents || !PathID || !CMenum){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *CMenum = (Flags >> U_FF_SHFT_CM4) & U_FF_MASK_CM4; + *PathID = (Flags >> U_FF_SHFT_OID8) & U_FF_MASK_OID8; + U_PMF_CMN_HDR_get(&contents, Header); + return(1); +} + +/** + \brief Get data from a U_PMR_COMMENT record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header (ignore flags) + \param Data Private data, may be anything + + EMF+ manual 2.3.2.1, Microsoft name: EmfPlusComment Record, Index 0x03 +*/ +int U_PMR_COMMENT_get(const char *contents, U_PMF_CMN_HDR *Header, + const char **Data){ + if(!contents || !Data){ return(0); } + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMR_ENDOFFILE record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header (ignore flags) + + EMF+ manual 2.3.3.1, Microsoft name: EmfPlusEndOfFile Record, Index 0x02 +*/ +int U_PMR_ENDOFFILE_get(const char *contents, U_PMF_CMN_HDR *Header){ + if(!contents){ return(0); } + U_PMF_CMN_HDR_get(&contents, Header); + return(1); +} + +/** + \brief Get data from a U_PMR_GETDC record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header (ignore flags) + + EMF+ manual 2.3.3.2, Microsoft name: EmfPlusGetDC Record, Index 0x04 +*/ +int U_PMR_GETDC_get(const char *contents, U_PMF_CMN_HDR *Header){ + if(!contents){ return(0); } + U_PMF_CMN_HDR_get(&contents, Header); + return(1); +} + +/** + \brief Get data from a U_PMR_HEADER record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header (ignore flags) + \param Version EmfPlusGraphicsVersion object + \param IsDual set = Dual-mode file, clear= EMF+ only file. + \param IsVideo set = video device, clear= printer. Ignore all other bits. + \param LogicalDpiX Horizontal resolution reference device in DPI + \param LogicalDpiY Vertical resolution reference device in DPI + + EMF+ manual 2.3.3.3, Microsoft name: EmfPlusHeader Record, Index 0x01 +*/ +int U_PMR_HEADER_get(const char *contents, U_PMF_CMN_HDR *Header, + U_PMF_GRAPHICSVERSION *Version, int *IsDual, int *IsVideo, uint32_t *LogicalDpiX, uint32_t *LogicalDpiY){ + if(!contents || !Version || !IsDual || !IsVideo || !LogicalDpiX || !LogicalDpiY){ return(0); } + uint32_t tmp; + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *IsDual = (Flags & U_PPF_DM ? 1 : 0 ); + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, Version, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, &tmp, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, LogicalDpiX, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, LogicalDpiY, 4, 1, U_LE); + *IsVideo = (tmp & U_PPF_VIDEO ? 1 : 0 ); + return(1); +} + +/** + \brief Get data from a U_PMR_CLEAR record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header (ignore flags) + \param Color Erase everything preceding, set background ARGB color. + + EMF+ manual 2.3.4.1, Microsoft name: EmfPlusClear Record, Index 0x09 +*/ +int U_PMR_CLEAR_get(const char *contents, U_PMF_CMN_HDR *Header, + U_PMF_ARGB *Color){ + if(!contents || !Color){ return(0); } + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, Color, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_DRAWARC record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param PenID U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + \param ctype Set: int16_t coordinates; Clear: U_FLOAT coordinates + \param Start Start angle, >=0.0, degrees clockwise from 3:00 + \param Sweep Sweep angle, -360<= angle <=360, degrees clockwise from Start + \param Rect Caller must free. Bounding rectangle. Coordinate type set by ctype. + + EMF+ manual 2.3.4.2, Microsoft name: EmfPlusDrawArc Record, Index 0x12 +*/ +int U_PMR_DRAWARC_get(const char *contents, U_PMF_CMN_HDR *Header, + uint32_t *PenID, int *ctype, + U_FLOAT *Start, U_FLOAT *Sweep, + U_PMF_RECTF *Rect){ + if(!contents || !PenID || !ctype || !Start || !Sweep || !Rect){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *ctype = (Flags & U_PPF_C ? 1 : 0 ); + *PenID = (Flags >> U_FF_SHFT_OID8) & U_FF_MASK_OID8; + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, Start, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Sweep, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Rect, 4, 4, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_DRAWBEZIERS record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param PenID U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + \param ctype Set: int16_t coordinates; Clear: U_FLOAT coordinates + \param RelAbs Set: Coordinates are relative; Clear: Coordinates are absolute and their type is set by ctype + \param Elements Number of members in the Data array + \param Points Caller must free. Array of U_POINT_F = Sequence of points to connect. Coordinate type set by ctype and RelAbs. + + EMF+ manual 2.3.4.3, Microsoft name: EmfPlusDrawBeziers Record, Index 0x19 +*/ +int U_PMR_DRAWBEZIERS_get(const char *contents, U_PMF_CMN_HDR *Header, + uint32_t *PenID, int *ctype, int *RelAbs, + uint32_t *Elements, + U_PMF_POINTF **Points){ + if(!contents || !PenID || !ctype || !RelAbs || !Elements || !Points){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *ctype = (Flags & U_PPF_C ? 1 : 0 ); + *RelAbs = (Flags & U_PPF_P ? 1 : 0 ); + *PenID = (Flags >> U_FF_SHFT_OID8) & U_FF_MASK_OID8; + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, Elements, 4, 1, U_LE); + U_PMF_VARPOINTS_get(&contents, Flags, *Elements, Points); + return(1); +} + +/** + \brief Get data from a U_PMR_DRAWCLOSEDCURVE record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param PenID U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + \param ctype Set: int16_t coordinates; Clear: U_FLOAT coordinates + \param RelAbs Set: Coordinates are relative; Clear: Coordinates are absolute and their type is set by ctype + \param Tension Controls splines, 0 is straight line, >0 is curved + \param Elements Number of members in the Data array + \param Points Caller must free. Array of U_POINT_F = Sequence of points to connect. Coordinate type set by ctype and RelAbs. + + EMF+ manual 2.3.4.4, Microsoft name: EmfPlusDrawClosedCurve Record, Index 0x17 +*/ +int U_PMR_DRAWCLOSEDCURVE_get(const char *contents, U_PMF_CMN_HDR *Header, + uint32_t *PenID, int *ctype, int *RelAbs, + U_FLOAT *Tension, uint32_t *Elements, + U_PMF_POINTF **Points){ + if(!contents || !PenID || !ctype || !RelAbs || !Tension || !Elements || !Points){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *ctype = (Flags & U_PPF_C ? 1 : 0 ); + *RelAbs = (Flags & U_PPF_P ? 1 : 0 ); + *PenID = (Flags >> U_FF_SHFT_OID8) & U_FF_MASK_OID8; + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, Tension, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Elements, 4, 1, U_LE); + U_PMF_VARPOINTS_get(&contents, Flags, *Elements, Points); + return(1); +} + +/** + \brief Get data from a U_PMR_DRAWCURVE record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param PenID U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + \param ctype Set: int16_t coordinates; Clear: U_FLOAT coordinates + \param Tension Controls splines, 0 is straight line, >0 is curved + \param Offset Element in Points that is the spline's starting point + \param NSegs Number of segments + \param Elements Number of members in Data array + \param Points Caller must free. Array of U_POINT_F = Sequence of points to connect. Coordinate type set by ctype and RelAbs. + + EMF+ manual 2.3.4.5, Microsoft name: EmfPlusDrawCurve Record, Index 0x18 +*/ +int U_PMR_DRAWCURVE_get(const char *contents, U_PMF_CMN_HDR *Header, + uint32_t *PenID, int *ctype, + U_FLOAT *Tension, uint32_t *Offset, uint32_t *NSegs, uint32_t *Elements, + U_PMF_POINTF **Points){ + if(!contents || !PenID || !ctype || !Tension || !Offset || !NSegs || !Elements || !Points){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *ctype = (Flags & U_PPF_C ? 1 : 0 ); + *PenID = (Flags >> U_FF_SHFT_OID8) & U_FF_MASK_OID8; + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, Tension, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Offset, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, NSegs, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Elements, 4, 1, U_LE); + U_PMF_VARPOINTS_get(&contents, Flags, *Elements, Points); + return(1); +} + +/** + \brief Get data from a U_PMR_DRAWDRIVERSTRING record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param FontID U_PMF_FONT object in the EMF+ object table (0-63, inclusive) + \param btype Set: BrushID is an U_PFM_ARGB; Clear: index of U_PMF_BRUSH object in EMF+ object table. + \param Tension Controls splines, 0 is straight line, >0 is curved + \param BrushID Color or index of U_PMF_BRUSH object in the EMF+ object table, depends on Flags bit0 + \param DSOFlags DriverStringOptions flags + \param HasMatrix If 1 record contains a TransformMatrix field, if 0 it does not. + \param Elements Number of members in Glyphs and Positions array + \param Glyphs Caller must free. If U_DSO_CmapLookup is set in DSOFlags this is an array of UTF16LE characters, otherwise, it is an array of indices into the U_PMF_FONT object indexed by Object_ID in flags. + \param Points Caller must free. Coordinates of each member of Glyphs. U_DSO_RealizedAdvance set in DSOFlags Relative then positions are calculated relative to the first glyph which is stored in Positions, otherwise, all glyph positions are stored in Positions. + \param Matrix Caller must free. Transformation to apply to Glyphs & Positions. Present if HasMatrix is 1 + + EMF+ manual 2.3.4.6, Microsoft name: EmfPlusDrawDriverString Record, Index 0x36 +*/ +int U_PMR_DRAWDRIVERSTRING_get(const char *contents, U_PMF_CMN_HDR *Header, + uint32_t *FontID, int *btype, + U_FLOAT *Tension, uint32_t *BrushID, uint32_t *DSOFlags, uint32_t *HasMatrix, uint32_t *Elements, + uint16_t **Glyphs, U_PMF_POINTF **Points, U_PMF_TRANSFORMMATRIX **Matrix){ + if(!contents || !FontID || !btype || !Tension || !BrushID || + !DSOFlags || !HasMatrix || !Elements || !Glyphs || !Points || !Matrix){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *btype = (Flags & U_PPF_B ? 1 : 0 ); + *FontID = (Flags >> U_FF_SHFT_OID8) & U_FF_MASK_OID8; + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, Tension, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, BrushID, 4, 1, (*btype ? U_XE : U_LE)); /* color is not byte swapped, ID integer is */ + U_PMF_SERIAL_get(&contents, DSOFlags, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, HasMatrix, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Elements, 4, 1, U_LE); + if(!U_PMF_SERIAL_array_copy_get(&contents, (void **)Glyphs, 2, *Elements, U_LE, (*DSOFlags & U_DSO_CmapLookup))){ return(0); } + if(!U_PMF_SERIAL_array_copy_get(&contents, (void **)Points, 4, *Elements *2, U_LE, (*DSOFlags & U_DSO_RealizedAdvance))){ return(0); } + if(!U_PMF_SERIAL_array_copy_get(&contents, (void **)Matrix, 4, 6, U_LE, (*HasMatrix))){ return(0); } + return(1); +} + +/** + \brief Get data from a U_PMR_DRAWELLIPSE record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param PenID U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + \param ctype Set: int16_t coordinates; Clear: U_FLOAT coordinates + \param Rect Caller must free. Bounding rectangle. Coordinate type set by ctype. + + EMF+ manual 2.3.4.7, Microsoft name: EmfPlusDrawEllipse Record, Index 0x0F +*/ +int U_PMR_DRAWELLIPSE_get(const char *contents, U_PMF_CMN_HDR *Header, + uint32_t *PenID, int *ctype, + U_PMF_RECTF *Rect){ + if(!contents || !PenID || !ctype || !Rect){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *ctype = (Flags & U_PPF_C ? 1 : 0 ); + *PenID = (Flags >> U_FF_SHFT_OID8) & U_FF_MASK_OID8; + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, Rect, 4, 4, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_DRAWIMAGE record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param ImgID U_PMF_IMAGE object in the EMF+ object table (0-63, inclusive) + \param ctype Set: int16_t coordinates; Clear: U_FLOAT coordinates + \param ImgAttrID index of a U_PMF_IMAGEATTRIBUTES object in the object table + \param SrcUnit UnitType enumeration + \param SrcRect Region of image + \param DstRect Destination rectangle for image. Coordinate type set by ctype. + + EMF+ manual 2.3.4.8, Microsoft name: EmfPlusDrawImage Record, Index 0x1A +*/ +int U_PMR_DRAWIMAGE_get(const char *contents, U_PMF_CMN_HDR *Header, + uint32_t *ImgID, int *ctype, + uint32_t *ImgAttrID, int32_t *SrcUnit, U_PMF_RECTF *SrcRect, + U_PMF_RECTF *DstRect){ + if(!contents || !ImgID || !ctype || !ImgAttrID || !SrcUnit || !SrcRect || !DstRect){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *ctype = (Flags & U_PPF_C ? 1 : 0 ); + *ImgID = (Flags >> U_FF_SHFT_OID8) & U_FF_MASK_OID8; + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, ImgAttrID, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, SrcUnit, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, SrcRect, 4, 4, U_LE); + U_PMF_SERIAL_get(&contents, DstRect, 4, 4, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_DRAWIMAGEPOINTS record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param ImgID U_PMF_IMAGE object in the EMF+ object table (0-63, inclusive) + \param ctype Set: int16_t coordinates; Clear: U_FLOAT coordinates + \param etype Set: effect from previous U_PMR_SERIALIZABLEOBJECT record will be applied; Clear: no effect applied + \param RelAbs Set: Data is relative, Clear: if it is absolute + \param ImgAttrID EmfPlusImageAttributes object + \param SrcUnit UnitType enumeration + \param SrcRect Region of image + \param Elements Number of members in Points, must be 3 + \param Points Caller must free. 3 points of a parallelogram.. Coordinate type set by ctype and RelAbs. + + EMF+ manual 2.3.4.9, Microsoft name: EmfPlusDrawImagePoints Record, Index 0x1B +*/ +int U_PMR_DRAWIMAGEPOINTS_get(const char *contents, U_PMF_CMN_HDR *Header, + uint32_t *ImgID, int *ctype, int *etype, int *RelAbs, + uint32_t *ImgAttrID, int32_t *SrcUnit, U_PMF_RECTF *SrcRect, uint32_t *Elements, + U_PMF_POINTF **Points){ + if(!contents || !ImgID || !ctype || !etype || !RelAbs || !ImgAttrID || !SrcUnit || !Elements || !Points){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *ctype = (Flags & U_PPF_C ? 1 : 0 ); + *etype = (Flags & U_PPF_E ? 1 : 0 ); + *RelAbs = (Flags & U_PPF_P ? 1 : 0 ); + *ImgID = (Flags >> U_FF_SHFT_OID8) & U_FF_MASK_OID8; + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, ImgAttrID, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, SrcUnit, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, SrcRect, 4, 4, U_LE); + U_PMF_SERIAL_get(&contents, Elements, 4, 1, U_LE); + U_PMF_VARPOINTS_get(&contents, Flags, *Elements, Points); + return(1); +} + +/** + \brief Get data from a U_PMR_DRAWLINES record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param PenID U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + \param ctype Set: int16_t coordinates; Clear: U_FLOAT coordinates + \param dtype Set: path must be closed, Clear: path is open + \param RelAbs Set: Coordinates are relative; Clear: Coordinates are absolute and their type is set by ctype + \param Elements Number of members in Points + \param Points Caller must free. Array of U_POINT_F = Sequence of points to connect. Coordinate type set by ctype and RelAbs. + + EMF+ manual 2.3.4.10, Microsoft name: EmfPlusDrawLines Record, Index 0x0D +*/ +int U_PMR_DRAWLINES_get(const char *contents, U_PMF_CMN_HDR *Header, + uint32_t *PenID, int *ctype, int *dtype, int *RelAbs, + uint32_t *Elements, + U_PMF_POINTF **Points){ + if(!contents || !PenID || !ctype || !dtype || !RelAbs || !Elements || !Points){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *ctype = (Flags & U_PPF_C ? 1 : 0 ); + *dtype = (Flags & U_PPF_D ? 1 : 0 ); + *RelAbs = (Flags & U_PPF_P ? 1 : 0 ); + *PenID = (Flags >> U_FF_SHFT_OID8) & U_FF_MASK_OID8; + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, Elements, 4, 1, U_LE); + U_PMF_VARPOINTS_get(&contents, Flags, *Elements, Points); + return(1); +} + +/** + \brief Get data from a U_PMR_DRAWPATH record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param PathID U_PMF_PATH object in the EMF+ object table (0-63, inclusive) + \param PenID U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + + EMF+ manual 2.3.4.11, Microsoft name: EmfPlusDrawPath Record, Index 0x15 +*/ +int U_PMR_DRAWPATH_get(const char *contents, U_PMF_CMN_HDR *Header, + uint32_t *PathID, uint32_t *PenID){ + if(!contents || !PathID || !PenID){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *PathID = (Flags >> U_FF_SHFT_OID8) & U_FF_MASK_OID8; + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, PenID, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_DRAWPIE record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param PenID U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + \param ctype Set: int16_t coordinates; Clear: U_FLOAT coordinates + \param Start Start angle, >=0.0, degrees clockwise from 3:00 + \param Sweep Sweep angle, -360<= angle <=360, degrees clockwise from Start + \param Rect Caller must free. Bounding rectangle. Coordinate type set by ctype. + + EMF+ manual 2.3.4.12, Microsoft name: EmfPlusDrawPie Record, Index 0x0D +*/ +int U_PMR_DRAWPIE_get(const char *contents, U_PMF_CMN_HDR *Header, + uint32_t *PenID, int *ctype, + U_FLOAT *Start, U_FLOAT *Sweep, + U_PMF_RECTF *Rect){ + if(!contents || !PenID || !ctype || !Start || !Sweep || !Rect){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *ctype = (Flags & U_PPF_C ? 1 : 0 ); + *PenID = (Flags >> U_FF_SHFT_OID8) & U_FF_MASK_OID8; + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, Start, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Sweep, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Rect, 4, 4, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_DRAWRECTS record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param PenID U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + \param ctype Set: int16_t coordinates; Clear: U_FLOAT coordinates + \param Elements Number of members in Rects + \param Rects Caller must free. Array of U_PMF_RECTF rectangles to draw. + + EMF+ manual 2.3.4.13, Microsoft name: EmfPlusDrawRects Record, Index 0x0B + + Rects in record may be either U_PMF_RECT or U_PMF_RECTF, but this function always + returns U_PMF_RECTF +*/ +int U_PMR_DRAWRECTS_get(const char *contents, U_PMF_CMN_HDR *Header, + uint32_t *PenID, int *ctype, + uint32_t *Elements, + U_PMF_RECTF **Rects){ + if(!contents || !PenID || !Elements || !Rects){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *PenID = (Flags >> U_FF_SHFT_OID8) & U_FF_MASK_OID8; + *ctype = (Flags & U_PPF_C ? 1 : 0 ); + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, Elements, 4, 1, U_LE); + U_PMF_VARRECTS_get(&contents, Flags, *Elements, Rects); + return(1); +} + +/** + \brief Get data from a U_PMR_DRAWSTRING record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param FontID U_PMF_FONT object in the EMF+ object table (0-63, inclusive) + \param btype Set: BrushID is an U_PFM_ARGB; Clear: index of U_PMF_BRUSH object in EMF+ object table. + \param BrushID Color or index of U_PMF_BRUSH object in the EMF+ object table, depending on btype. + \param FormatID U_PMF_STRINGFORMAT object in EMF+ Object Table. + \param Elements Number of characters in the string. + \param Rect String's bounding box. + \param String Caller must free. Array of UFT-16LE unicode characters. + + EMF+ manual 2.3.4.14, Microsoft name: EmfPlusDrawString Record, Index 0x1C +*/ +int U_PMR_DRAWSTRING_get(const char *contents, U_PMF_CMN_HDR *Header, + uint32_t *FontID, int *btype, + uint32_t *BrushID, uint32_t *FormatID, uint32_t *Elements, U_PMF_RECTF *Rect, + uint16_t **String){ + if(!contents || !FontID || !btype || !BrushID || !FormatID || !Elements || !String){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *btype = (Flags & U_PPF_B ? 1 : 0 ); + *FontID = (Flags >> U_FF_SHFT_OID8) & U_FF_MASK_OID8; + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, BrushID, 4, 1, (*btype ? U_XE : U_LE)); /* color is not byte swapped, ID integer is */ + U_PMF_SERIAL_get(&contents, FormatID, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Elements, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Rect, 4, 4, U_LE); + if(!U_PMF_SERIAL_array_copy_get(&contents, (void **)String, 2, *Elements, U_XE, 1)){ return(0); } + return(1); +} + +/** + \brief Get data from a U_PMR_FILLCLOSEDCURVE record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param btype Set: BrushID is an U_PFM_ARGB; Clear: is index of U_PMF_BRUSH object in EMF+ object table. + \param ctype Set: int16_t coordinates; Clear: U_FLOAT coordinates + \param ftype Set: winding fill; Clear: alternate fill + \param RelAbs Set: Coordinates are relative; Clear: Coordinates are absolute and their type is set by ctype + \param BrushID Color or index of U_PMF_BRUSH object in the EMF+ object table, depending on btype. + \param Tension Controls splines, 0 is straight line, >0 is curved + \param Elements Number of members in Points + \param Points Caller must free. Array of U_POINT_F = Sequence of points to connect. Coordinate type set by ctype and RelAbs. + + EMF+ manual 2.3.4.15, Microsoft name: EmfPlusFillClosedCurve Record, Index 0x16 +*/ +int U_PMR_FILLCLOSEDCURVE_get(const char *contents, U_PMF_CMN_HDR *Header, + int *btype, int *ctype, int *ftype, int *RelAbs, + uint32_t *BrushID, U_FLOAT *Tension, uint32_t *Elements, + U_PMF_POINTF **Points){ + if(!contents || !btype || !ctype || !ftype || !RelAbs || !BrushID || !Tension || !Elements || !Points){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *btype = (Flags & U_PPF_B ? 1 : 0 ); + *ctype = (Flags & U_PPF_C ? 1 : 0 ); + *ftype = (Flags & U_PPF_F ? 1 : 0 ); + *RelAbs = (Flags & U_PPF_P ? 1 : 0 ); + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, BrushID, 4, 1, (*btype ? U_XE : U_LE)); /* color is not byte swapped, ID integer is */ + U_PMF_SERIAL_get(&contents, Tension, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Elements, 4, 1, U_LE); + U_PMF_VARPOINTS_get(&contents, Flags, *Elements, Points); + return(1); +} + +/** + \brief Get data from a U_PMR_FILLELLIPSE record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param btype Set: BrushID is an U_PFM_ARGB; Clear: is index of U_PMF_BRUSH object in EMF+ object table. + \param ctype Set: int16_t coordinates; Clear: U_FLOAT coordinates + \param BrushID Color or index of U_PMF_BRUSH object in the EMF+ object table, depending on btype. + \param Rect Caller must free. Bounding box for elliptical pie segment being drawn. Coordinate type set by ctype. + + EMF+ manual 2.3.4.16, Microsoft name: EmfPlusFillEllipse Record, Index 0x0E +*/ +int U_PMR_FILLELLIPSE_get(const char *contents, U_PMF_CMN_HDR *Header, + int *btype, int *ctype, + uint32_t *BrushID, + U_PMF_RECTF *Rect){ + if(!contents || !btype || !ctype || !BrushID || !Rect){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *btype = (Flags & U_PPF_B ? 1 : 0 ); + *ctype = (Flags & U_PPF_C ? 1 : 0 ); + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, BrushID, 4, 1, (*btype ? U_XE : U_LE)); /* color is not byte swapped, ID integer is */ + U_PMF_SERIAL_get(&contents, Rect, 4, 4, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_FILLPATH record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param btype Set: BrushID is an U_PFM_ARGB; Clear: is index of U_PMF_BRUSH object in EMF+ object table. + \param PathID U_PMF_PATH object in the EMF+ object table (0-63, inclusive) + \param BrushID Color or index of U_PMF_BRUSH object in the EMF+ object table, depending on btype. + + EMF+ manual 2.3.4.17, Microsoft name: EmfPlusFillPath Record, Index 0x14 + + Note: U_PMF_FILLPATHOBJ is the object, U_PMF_FILLPATH is the file record +*/ +int U_PMR_FILLPATH_get(const char *contents, U_PMF_CMN_HDR *Header, + uint32_t *PathID, int *btype, + uint32_t *BrushID){ + if(!contents || !PathID || !btype || !BrushID){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *btype = (Flags & U_PPF_B ? 1 : 0 ); + *PathID = (Flags >> U_FF_SHFT_OID8) & U_FF_MASK_OID8; + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, BrushID, 4, 1, (*btype ? U_XE : U_LE)); /* color is not byte swapped, ID integer is */ + return(1); +} + +/** + \brief Get data from a U_PMR_FILLPIE record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param btype Set: BrushID is an U_PFM_ARGB; Clear: is index of U_PMF_BRUSH object in EMF+ object table. + \param ctype Set: int16_t coordinates; Clear: U_FLOAT coordinates + \param BrushID Color or index of U_PMF_BRUSH object in the EMF+ object table, depending on btype. + \param Start Start angle, >=0.0, degrees clockwise from 3:00 + \param Sweep Sweep angle, -360<= angle <=360, degrees clockwise from Start + \param Rect Bounding box for elliptical pie segment being filled. Coordinate type set by ctype. + + EMF+ manual 2.3.4.18, Microsoft name: EmfPlusFillPie Record, Index 0x10 +*/ +int U_PMR_FILLPIE_get(const char *contents, U_PMF_CMN_HDR *Header, + int *btype, int *ctype, + uint32_t *BrushID, U_FLOAT *Start, U_FLOAT *Sweep, + U_PMF_RECTF *Rect){ + if(!contents || !btype || !ctype || !BrushID || !Start || !Sweep || !Rect){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *btype = (Flags & U_PPF_B ? 1 : 0 ); + *ctype = (Flags & U_PPF_C ? 1 : 0 ); + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, BrushID, 4, 1, (*btype ? U_XE : U_LE)); /* color is not byte swapped, ID integer is */ + U_PMF_SERIAL_get(&contents, Start, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Sweep, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Rect, 4, 4, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_FILLPOLYGON record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param btype Set: BrushID is an U_PFM_ARGB; Clear: is index of U_PMF_BRUSH object in EMF+ object table. + \param ctype Set: int16_t coordinates; Clear: U_FLOAT coordinates + \param RelAbs Set: U_PMF_PathPointTypeRLE and/or U_PMF_PathPointType objects; Clear: only U_PMF_PathPointType + \param BrushID Color or index of U_PMF_BRUSH object in the EMF+ object table, depending on btype. + \param Elements Number of members in Data. + \param Points Sequence of points to connect with line segments. Coordinate type set by ctype and RelAbs. + + EMF+ manual 2.3.4.19, Microsoft name: EmfPlusFillPolygon Record, Index 0x0C +*/ +int U_PMR_FILLPOLYGON_get(const char *contents, U_PMF_CMN_HDR *Header, + int *btype, int *ctype, int *RelAbs, + uint32_t *BrushID, uint32_t *Elements, + U_PMF_POINTF **Points){ + if(!contents || !btype || !ctype || !RelAbs || !BrushID || !Elements || !Points){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *btype = (Flags & U_PPF_B ? 1 : 0 ); + *ctype = (Flags & U_PPF_C ? 1 : 0 ); + *RelAbs = (Flags & U_PPF_R ? 1 : 0 ); + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, BrushID, 4, 1, (*btype ? U_XE : U_LE)); /* color is not byte swapped, ID integer is */ + U_PMF_SERIAL_get(&contents, Elements, 4, 1, U_LE); + U_PMF_VARPOINTS_get(&contents, Flags, *Elements, Points); + return(1); +} + +/** + \brief Get data from a U_PMR_FILLRECTS record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param btype Set: BrushID is an U_PFM_ARGB; Clear: is index of U_PMF_BRUSH object in EMF+ object table. + \param ctype Set: int16_t coordinates; Clear: U_FLOAT coordinates + \param BrushID Color or index of U_PMF_BRUSH object in the EMF+ object table, depending on btype. + \param Elements Number of members in Data. + \param Rects Caller must free. Array of U_PMF_RECTF rectangles to draw. + + EMF+ manual 2.3.4.20, Microsoft name: EmfPlusFillRects Record, Index 0x0A + + EMF+ files have been encountered where BrushID must be a color, because it has a value like FFFF0000 but + the flags are set wrong, so that U_PPF_B is not set. Detect these by BrushID >63 for btype=0 and correct. + If the opposite problem occurs it cannot be reliably detected, so it cannot be corrected. + + Rects in record may be either U_PMF_RECT or U_PMF_RECTF, but this function always + returns U_PMF_RECTF +*/ +int U_PMR_FILLRECTS_get(const char *contents, U_PMF_CMN_HDR *Header, + int *btype, int *ctype, + uint32_t *BrushID, uint32_t *Elements, + U_PMF_RECTF **Rects){ + if(!contents || !btype || !ctype || !BrushID || !Elements || !Rects){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *btype = (Flags & U_PPF_B ? 1 : 0 ); + *ctype = (Flags & U_PPF_C ? 1 : 0 ); + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, BrushID, 4, 1, (*btype ? U_XE : U_LE)); /* color is not byte swapped, ID integer is */ + U_PMF_SERIAL_get(&contents, Elements, 4, 1, U_LE); + U_PMF_VARRECTS_get(&contents, Flags, *Elements, Rects); + /* correct btype, if necessary, for invalid EMF+ input */ + if((*BrushID > 63) & !*btype)*btype=1; + return(1); +} + + +/** + \brief Get data from a U_PMR_FILLREGION record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param RgnID U_PMF_REGION object in the EMF+ object table (0-63, inclusive) + \param btype Set: BrushID is an U_PFM_ARGB; Clear: is index of U_PMF_BRUSH object in EMF+ object table. + \param ctype Set: int16_t coordinates; Clear: U_FLOAT coordinates + \param BrushID Color or index of U_PMF_BRUSH object in the EMF+ object table, depending on btype. + + EMF+ manual 2.3.4.21, Microsoft name: EmfPlusFillRegion Record, Index 0x13 +*/ +int U_PMR_FILLREGION_get(const char *contents, U_PMF_CMN_HDR *Header, + uint32_t *RgnID, int *btype, int *ctype, + uint32_t *BrushID){ + if(!contents || !RgnID || !btype || !ctype || !BrushID){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *btype = (Flags & U_PPF_B ? 1 : 0 ); + *ctype = (Flags & U_PPF_C ? 1 : 0 ); + *RgnID = (Flags >> U_FF_SHFT_OID8) & U_FF_MASK_OID8; + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, BrushID, 4, 1, (*btype ? U_XE : U_LE)); /* color is not byte swapped, ID integer is */ + return(1); +} + +/** + \brief Get data from a U_PMR_OBJECT record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param ObjID Index for this object in the EMF+ object table (0-63, inclusive) + \param otype ObjectType enumeration + \param ntype Set: object definition continue bit is set + \param TSize If ntype is set, holds the total number of data bytes split across multiple records. If ntype is clear, has no meaning. + \param Data Object's data. Type from otype. + + EMF+ manual 2.3.5.1, Microsoft name: EmfPlusObject Record, Index 0x13 + + OTHER NOTES: + All objects are to be stored in the same table and retrieved by index. + Documentation indicates that this table contains only 64 slots, although the index + field which references it can code for values 0-127. + If a new object has the same index as an existing object the old one is deleted and + the new one goes into its storage slot. + The continuation bit (U_PPF_N) is documented as indicating that the object is continued into + the next record. Examination of emf+ records in emf files produced by PowerPoint 2003 + show that changing the ObjID also serves as a continued record terminator, and that it apparently + overrides the value for the continue bit. That is, even though the preceding records said + that it was continued, the change of ObjID terminates that preceding record without adding + any more data to it. In one example the sequential emf+ records were: + ObjID type size continue + 0 5 65008 Y + 0 5 65008 Y + 0 5 63104 Y + 1 8 24 N + A DrawImagePoints record followed that referenced ObjID 0. + Examination of the records with continue set showed that data in each + was preceded by a uint32_t size value equivalent to the size of the + data that had been split across multiple records, in this case + 0x0002F254 = 193108. It is not clear at present if this size value + will also be present at the end of a continued series that terminates + by not using the continue bit, rather than changing the ObjID. +*/ +int U_PMR_OBJECT_get(const char *contents, U_PMF_CMN_HDR *Header, + uint32_t *ObjID, int *otype, int *ntype, uint32_t *TSize, + const char **Data){ + if(!contents || !ObjID || !otype || !ntype || !Data){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *ntype = (Flags & U_PPF_N ? 1 : 0 ); + *ObjID = (Flags >> U_FF_SHFT_OID8) & U_FF_MASK_OID8; + *otype = (Flags >> U_FF_SHFT_OT) & U_FF_MASK_OT; + U_PMF_CMN_HDR_get(&contents, Header); + if(*ntype){ U_PMF_SERIAL_get(&contents, TSize, 4, 1, U_LE); } + else { *TSize = 0; } + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMR_SERIALIZABLEOBJECT record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param GUID ImageEffects identifier. + \param Size Bytes in Data. + \param Data "Serialized image effects parameter block". One of the ImageEffects objects. + + EMF+ manual 2.3.5.2, Microsoft name: EmfPlusSerializableObject Record, Index 0x38 +*/ +int U_PMR_SERIALIZABLEOBJECT_get(const char *contents, U_PMF_CMN_HDR *Header, + uint8_t *GUID, uint32_t *Size, + const char **Data){ + if(!contents || !GUID || !Size || !Data){ return(0); } + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, GUID, 1, 16, U_XE); + U_PMF_SERIAL_get(&contents, Size, 4, 1, U_LE); + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMR_SETANTIALIASMODE record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param SMenum SmoothingMode enumeration + \param aatype Set: anti-aliasing on; Clear: anti-aliasing off + + EMF+ manual 2.3.6.1, Microsoft name: EmfPlusSetAntiAliasMode Record, Index 0x1E +*/ +int U_PMR_SETANTIALIASMODE_get(const char *contents, U_PMF_CMN_HDR *Header, + int *SMenum, int *aatype){ + if(!contents || !SMenum || !aatype){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *aatype = (Flags & U_PPF_AA ? 1 : 0 ); + *SMenum = (Flags >> U_FF_SHFT_AA) & U_FF_MASK_AA; + U_PMF_CMN_HDR_get(&contents, Header); + return(1); +} + +/** + \brief Get data from a U_PMR_SETCOMPOSITINGMODE record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param CMenum CompositingMode enumeration + + EMF+ manual 2.3.6.2, Microsoft name: EmfPlusSetCompositingMode Record, Index 0x23 +*/ +int U_PMR_SETCOMPOSITINGMODE_get(const char *contents, U_PMF_CMN_HDR *Header, + int *CMenum){ + if(!contents || !CMenum){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *CMenum = (Flags >> U_FF_SHFT_CM) & U_FF_MASK_CM; + U_PMF_CMN_HDR_get(&contents, Header); + return(1); +} + +/** + \brief Get data from a U_PMR_SETCOMPOSITINGQUALITY record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param CQenum CompositingQuality enumeration + + EMF+ manual 2.3.6.3, Microsoft name: EmfPlusSetCompositingQuality Record, Index 0x24 +*/ +int U_PMR_SETCOMPOSITINGQUALITY_get(const char *contents, U_PMF_CMN_HDR *Header, + int *CQenum){ + if(!contents || !CQenum){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *CQenum = (Flags >> U_FF_SHFT_CQ) & U_FF_MASK_CQ; + U_PMF_CMN_HDR_get(&contents, Header); + return(1); +} + +/** + \brief Get data from a U_PMR_SETINTERPOLATIONMODE record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param IMenum InterpolationMode enumeration + + EMF+ manual 2.3.6.4, Microsoft name: EmfPlusSetInterpolationMode Record, Index 0x21 +*/ +int U_PMR_SETINTERPOLATIONMODE_get(const char *contents, U_PMF_CMN_HDR *Header, + int *IMenum){ + if(!contents || !IMenum){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *IMenum = (Flags >> U_FF_SHFT_IM) & U_FF_MASK_IM; + U_PMF_CMN_HDR_get(&contents, Header); + return(1); +} + +/** + \brief Get data from a U_PMR_SETPIXELOFFSETMODE record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param POMenum PixelOffsetMode enumeration. + + EMF+ manual 2.3.6.5, Microsoft name: EmfPlusSetPixelOffsetMode Record, Index 0x22 +*/ +int U_PMR_SETPIXELOFFSETMODE_get(const char *contents, U_PMF_CMN_HDR *Header, + int *POMenum){ + if(!contents || !POMenum){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *POMenum = (Flags >> U_FF_SHFT_PxOffM) & U_FF_MASK_PxOffM; + U_PMF_CMN_HDR_get(&contents, Header); + return(1); +} + +/** + \brief Get data from a U_PMR_SETRENDERINGORIGIN record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header. + \param X X coordinate of rendering origin. + \param Y Y coordinate of rendering origin. + + EMF+ manual 2.3.6.6, Microsoft name: EmfPlusSetRenderingOrigin Record, Index 0x1D +*/ +int U_PMR_SETRENDERINGORIGIN_get(const char *contents, U_PMF_CMN_HDR *Header, + int32_t *X, int32_t *Y){ + if(!contents || !X || !Y){ return(0); } + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, X, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Y, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_SETTEXTCONTRAST record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header. + \param TGC Text Gamma correction value (x 1000). + + EMF+ manual 2.3.6.7, Microsoft name: EmfPlusSetTextContrast Record, Index 0x20 +*/ +int U_PMR_SETTEXTCONTRAST_get(const char *contents, U_PMF_CMN_HDR *Header, + int *TGC){ + if(!contents || !TGC){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *TGC = (Flags >> U_FF_SHFT_TGC) & U_FF_MASK_TGC; + U_PMF_CMN_HDR_get(&contents, Header); + return(1); +} + +/** + \brief Get data from a U_PMR_SETTEXTRENDERINGHINT record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header. + \param TRHenum TextRenderingHint enumeration + + EMF+ manual 2.3.6.8, Microsoft name: EmfPlusSetTextRenderingHint Record, Index 0x1F +*/ +int U_PMR_SETTEXTRENDERINGHINT_get(const char *contents, U_PMF_CMN_HDR *Header, + int *TRHenum){ + if(!contents || !TRHenum){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *TRHenum = (Flags >> U_FF_SHFT_TRH) & U_FF_MASK_TRH; + U_PMF_CMN_HDR_get(&contents, Header); + return(1); +} + +/** + \brief Get data from a U_PMR_BEGINCONTAINER record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param UTenum UnitType enumeration + \param DstRect with SrcRect specifies a transformation + \param SrcRect with DstRect specifies a transformation + \param StackID EMF+ Object Stack Index to use for this graphics container + + EMF+ manual 2.3.7.1, Microsoft name: EmfPlusBeginContainer Record, Index 0x27 +*/ +int U_PMR_BEGINCONTAINER_get(const char *contents, U_PMF_CMN_HDR *Header, + int *UTenum, + U_PMF_RECTF *DstRect, U_PMF_RECTF *SrcRect, uint32_t *StackID){ + if(!contents || !UTenum || !DstRect || !SrcRect || !StackID){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *UTenum = (Flags >> U_FF_SHFT_UT) & U_FF_MASK_UT; + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, DstRect, 4, 4, U_LE); + U_PMF_SERIAL_get(&contents, SrcRect, 4, 4, U_LE); + U_PMF_SERIAL_get(&contents, StackID, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_BEGINCONTAINERNOPARAMS record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param StackID EMF+ Object Stack Index to use for this graphics container + + EMF+ manual 2.3.7.2, Microsoft name: EmfPlusBeginContainerNoParams Record, Index 0x28 +*/ +int U_PMR_BEGINCONTAINERNOPARAMS_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *StackID){ + if(!contents || !StackID){ return(0); } + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, StackID, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_ENDCONTAINER record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param StackID EMF+ Object Stack Index of this graphics container + + EMF+ manual 2.3.7.3, Microsoft name: EmfPlusEndContainer Record, Index 0x29 +*/ +int U_PMR_ENDCONTAINER_get(const char *contents, U_PMF_CMN_HDR *Header, + uint32_t *StackID){ + if(!contents || !StackID){ return(0); } + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, StackID, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_RESTORE record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param StackID State (level) to restore from the EMF+ Graphics Stack. Must have been put on the GS with a U_PMR_SAVE. + + EMF+ manual 2.3.7.4, Microsoft name: EmfPlusRestore Record, Index 0x26 +*/ +int U_PMR_RESTORE_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *StackID){ + if(!contents || !StackID){ return(0); } + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, StackID, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_SAVE record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param StackID State (level) to save.on the EMF+ Graphics Stack + + EMF+ manual 2.3.7.5, Microsoft name: EmfPlusSave Record, Index 0x25 +*/ +int U_PMR_SAVE_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *StackID){ + if(!contents || !StackID){ return(0); } + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, StackID, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_SETTSCLIP record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param ctype Set: int16_t coordinates; Clear: U_FLOAT coordinates + \param Elements Number of members in Data. + \param Rects Caller must free. Array of rectangles to draw. Coordinate type set by ctype. + + EMF+ manual 2.3.8.1, Microsoft name: EmfPlusSetTSClip Record, Index 0x3A +*/ +int U_PMR_SETTSCLIP_get(const char *contents, U_PMF_CMN_HDR *Header, + int *ctype, uint32_t *Elements, + U_PMF_RECTF **Rects){ + if(!contents || !ctype || !Elements || !Rects){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *ctype = (Flags & U_PPF_K ? 1 : 0 ); + *Elements = (Flags >> U_FF_SHFT_TSC) & U_FF_MASK_TSC; + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_VARRECTS_get(&contents, Flags, *Elements, Rects); + return(1); +} + +/** + \brief Get data from a U_PMR_SETTSGRAPHICS record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param vgatype Set: Palette is VGA basic colors; Clear: Palette is ??? + \param pptype Set: Palette is present; Clear: Palette is absent. + \param AntiAliasMode SmoothingMode enumeration + \param TextRenderHint TextRenderingHint enumeration + \param CompositingMode CompositingMode enumeration + \param CompositingQuality CompositingQuality enumeration + \param RenderOriginX Origin X for halftoning and dithering + \param RenderOriginY Origin Y for halftoning and dithering + \param TextContrast Gamma correction, range 0 to 12 + \param FilterType FilterType enumeraton + \param PixelOffset PixelOffsetMode enumeration + \param WorldToDevice world to device transform + \param Data Palette (optional) + + EMF+ manual 2.3.8.2, Microsoft name: EmfPlusSetTSGraphics Record, Index 0x39 +*/ +int U_PMR_SETTSGRAPHICS_get(const char *contents, U_PMF_CMN_HDR *Header, + int *vgatype, int *pptype, + uint8_t *AntiAliasMode, uint8_t *TextRenderHint, uint8_t *CompositingMode, uint8_t *CompositingQuality, + int16_t *RenderOriginX, int16_t *RenderOriginY, uint16_t *TextContrast, uint8_t *FilterType, + uint8_t *PixelOffset, U_PMF_TRANSFORMMATRIX *WorldToDevice, + const char **Data){ + if(!contents || !vgatype || !pptype || + !AntiAliasMode || !TextRenderHint || !CompositingMode || !CompositingQuality || + !RenderOriginX || !RenderOriginY || !TextContrast || !FilterType || + !PixelOffset || !WorldToDevice || !Data){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *vgatype = (Flags & U_PPF_VGA ? 1 : 0 ); + *pptype = (Flags & U_PPF_PP ? 1 : 0 ); + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, AntiAliasMode, 1, 1, U_XE); + U_PMF_SERIAL_get(&contents, TextRenderHint, 1, 1, U_XE); + U_PMF_SERIAL_get(&contents, CompositingMode, 1, 1, U_XE); + U_PMF_SERIAL_get(&contents, CompositingQuality, 1, 1, U_XE); + U_PMF_SERIAL_get(&contents, RenderOriginX, 2, 1, U_LE); + U_PMF_SERIAL_get(&contents, RenderOriginY, 2, 1, U_LE); + U_PMF_SERIAL_get(&contents, TextContrast, 2, 1, U_LE); + U_PMF_SERIAL_get(&contents, FilterType, 1, 1, U_XE); + U_PMF_SERIAL_get(&contents, WorldToDevice, 4, 6, U_LE); + U_PMF_PTRSAV_COND(Data, contents, *pptype); + return(1); +} + +/** + \brief Get data from a U_PMR_MULTIPLYWORLDTRANSFORM record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param xmtype Set: Post multiply; Clear: Pre multiply + \param Matrix Transformation matrix + + EMF+ manual 2.3.9.1, Microsoft name: EmfPlusMultiplyWorldTransform Record, Index 0x2C +*/ +int U_PMR_MULTIPLYWORLDTRANSFORM_get(const char *contents, U_PMF_CMN_HDR *Header, + int *xmtype, + U_PMF_TRANSFORMMATRIX *Matrix){ + if(!contents || !xmtype || !Matrix){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *xmtype = (Flags & U_PPF_XM ? 1 : 0 ); + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, Matrix, 4, 6, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_RESETWORLDTRANSFORM record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + + EMF+ manual 2.3.9.2, Microsoft name: EmfPlusResetWorldTransform Record, Index 0x2B +*/ +int U_PMR_RESETWORLDTRANSFORM_get(const char *contents, U_PMF_CMN_HDR *Header){ + if(!contents){ return(0); } + U_PMF_CMN_HDR_get(&contents, Header); + return(1); +} + +/** + \brief Get data from a U_PMR_ROTATEWORLDTRANSFORM record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param xmtype Set: Post multiply; Clear: Pre multiply + \param Angle Rotation angle, in degrees + + EMF+ manual 2.3.9.3, Microsoft name: EmfPlusRotateWorldTransform Record, Index 0x2F +*/ +int U_PMR_ROTATEWORLDTRANSFORM_get(const char *contents, U_PMF_CMN_HDR *Header, + int *xmtype, + U_FLOAT *Angle){ + if(!contents || !xmtype || !Angle){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *xmtype = (Flags & U_PPF_XM ? 1 : 0 ); + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, Angle, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_SCALEWORLDTRANSFORM record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param xmtype Set: Post multiply; Clear: Pre multiply. + \param Sx X scale factor. + \param Sy Y scale factor. + + EMF+ manual 2.3.9.4, Microsoft name: EmfPlusScaleWorldTransform Record, Index 0x2E +*/ +int U_PMR_SCALEWORLDTRANSFORM_get(const char *contents, U_PMF_CMN_HDR *Header, + int *xmtype, + U_FLOAT *Sx, U_FLOAT *Sy){ + if(!contents || !xmtype || !Sx || !Sy){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *xmtype = (Flags & U_PPF_XM ? 1 : 0 ); + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, Sx, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Sy, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_SETPAGETRANSFORM record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param PUenum Page Unit, UnitType enumeration + \param Scale Scale factor to convert page space to device space + + EMF+ manual 2.3.9.5, Microsoft name: EmfPlusSetPageTransform Record, Index 0x30 +*/ +int U_PMR_SETPAGETRANSFORM_get(const char *contents, U_PMF_CMN_HDR *Header, + int *PUenum, + U_FLOAT *Scale){ + if(!contents || !PUenum || !Scale){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *PUenum = (Flags >> U_FF_SHFT_PU) & U_FF_MASK_PU; + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, Scale, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_SETWORLDTRANSFORM record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param Matrix Transformation matrix + + EMF+ manual 2.3.9.6, Microsoft name: EmfPlusSetWorldTransform Record, Index 0x2A +*/ +int U_PMR_SETWORLDTRANSFORM_get(const char *contents, U_PMF_CMN_HDR *Header, + U_PMF_TRANSFORMMATRIX *Matrix){ + if(!contents || !Matrix){ return(0); } + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, Matrix, 4, 6, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_TRANSLATEWORLDTRANSFORM record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param xmtype Set: Post multiply; Clear: Pre multiply + \param Dx X offset + \param Dy Y offset + + EMF+ manual 2.3.9.7, Microsoft name: EmfPlusTranslateWorldTransform Record, Index 0x2D +*/ +int U_PMR_TRANSLATEWORLDTRANSFORM_get(const char *contents, U_PMF_CMN_HDR *Header, + int *xmtype, + U_FLOAT *Dx, U_FLOAT *Dy){ + if(!contents || !xmtype || !Dx || !Dy){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *xmtype = (Flags & U_PPF_XM ? 1 : 0 ); + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, Dx, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Dy, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_STROKEFILLPATH record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header (ignore flags) + + + EMF+ manual mentioned in 2.1.1.1, not otherwise documented, Microsoft name: EmfPlusStrokeFillPath Record, Index 0x37 + + "This record closes any open figures in a path, strokes the outline of + the path by using the current pen, and fills its interior by using the current brush." +*/ +int U_PMR_STROKEFILLPATH_get(const char *contents, U_PMF_CMN_HDR *Header){ + if(!contents){ return(0); } + U_PMF_CMN_HDR_get(&contents, Header); + return(1); +} + +/** + \brief Get data from a U_PMR_MULTIFORMATSTART record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header (ignore flags) + + EMF+ manual mentioned in 2.1.1.1, reserved, not otherwise documented, Microsoft name: EmfPlusMultiFormatStart Record, Index 0x05 +*/ +int U_PMR_MULTIFORMATSTART_get(const char *contents, U_PMF_CMN_HDR *Header){ + if(!contents){ return(0); } + U_PMF_CMN_HDR_get(&contents, Header); + return(1); +} + +/** + \brief Get data from a U_PMR_MULTIFORMATSECTION record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header (ignore flags) + + EMF+ manual mentioned in 2.1.1.1, reserved, not otherwise documented, Microsoft name: EmfPlusMultiFormatSection Record, Index 0x06 +*/ +int U_PMR_MULTIFORMATSECTION_get(const char *contents, U_PMF_CMN_HDR *Header){ + if(!contents){ return(0); } + U_PMF_CMN_HDR_get(&contents, Header); + return(1); +} + +/** + \brief Get data from a U_PMR_MULTIFORMATEND record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header (ignore flags) + + EMF+ manual mentioned in 2.1.1.1, reserved, not otherwise documented, Microsoft name: EmfPlusMultiFormatEnd Record, Index 0x06 +*/ +int U_PMR_MULTIFORMATEND_get(const char *contents, U_PMF_CMN_HDR *Header){ + if(!contents){ return(0); } + U_PMF_CMN_HDR_get(&contents, Header); + return(1); +} + + +#ifdef __cplusplus +} +#endif diff --git a/src/libuemf/upmf.h b/src/libuemf/upmf.h new file mode 100644 index 000000000..48fc9bf53 --- /dev/null +++ b/src/libuemf/upmf.h @@ -0,0 +1,3177 @@ +/** + @file upmf.h + + @brief Structures, definitions, and function prototypes for EMF+ files. + + EMF+ file Record structure derived from Microsoft's EMF+ Information pdf, releade date July 5,2012, link from + here: + + http://msdn.microsoft.com/en-us/library/cc230724.aspx + + If the direct link fails the document may be found + by searching for: "[MS-EMFPLUS]: Enhanced Metafile Format Plus Extensions " + + EMR records and structures are EMF or common with EMF+ + PMR records and structures are specific to EMF+ + + Using PMF instead of EMF+ because "+" is a problem in symbol names. + + ***************************************************************************************** + * WARNING: Microsoft's EMF+ documentation is little-endian for everything EXCEPT * + * bitfields, which are big-endian. See section 1.3.2 * + * That documentation also uses 0 as the MOST significant bit, N-1 as the least. * + * This code is little-endian throughout, and 0 is the LEAST significant bit * + ***************************************************************************************** + +*/ + +/* +File: upmf.h +Version: 0.0.2 +Date: 04-NOV-2013 +Author: David Mathog, Biology Division, Caltech +email: mathog@caltech.edu +Copyright: 2013 David Mathog and California Institute of Technology (Caltech) +*/ + +#ifndef _UPMF_ +#define _UPMF_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> +#include <stdbool.h> +#include "uemf.h" + + +/** \defgroup U_PMF_PMF_Misc PMF Miscellaneous defines + @{ +*/ +#define U_PMF_DROP_ELEMENTS 1 //!< Remove leading Elements value from data. +#define U_PMF_KEEP_ELEMENTS 0 //!< Retain leading Elements value from data. + +#define U_SEG_NEW 1 //!< start a new segment in the path +#define U_SEG_OLD 0 //!< continue the old (current) segment in the path + +#define U_FILTER_APPLY 1 //!< With U_PMR_DRAWIMAGEPOINTS_set, use whatever filter has been set up up. +#define U_FILTER_IGNORE 0 //!< With U_PMR_DRAWIMAGEPOINTS_set, ignore whatever filter has been set up up. +#define U_OBJRECLIM 65020 //!< Longest U_PMR_OBJECT that GDI+ will process + // used 9728 to test fragmenting of emitted object records + +/** @} */ + +/** \defgroup U_PMF_DD_ PMF "standard" custom Dash Dot patterns for lines. + + U_DD_DASH, U_DD_DOT, U_DD_DASHDOT, and U_DD_DASHDOTDOT are the only ones with corresponding + standard EMF and EMF+ dash/dot patterns. + + These values are used to tell U_PMF_DASHEDLINEDATA_set2() to create one of 27 custom line patterns. + Other custom line patterns may be created using U_PMF_DASHEDLINEDATA_set(), but this provides an easier + way to get the same result if one of these patterns is acceptable. + + The length is divided by 2X the number of elements, so dashdash has twice as many + dashes of half the length as just dash. + + Dot is 1/8 of (sub)unit length + Dash is 1/2 of (sub)unit length + Long is 3/4 of (sub)unit length + Example: DotDot has (sub)unit length 1/2, so each dot will be 1/16 of unit length. + + @{ +*/ +#define U_DD_Solid 0 //!< Solid line. +#define U_DD_Dash 1 //!< Dash line. +#define U_DD_DashDash 2 //!< Dash Dash line. +#define U_DD_DashDashDash 3 //!< Dash Dash Dash line. +#define U_DD_DashDashDashDash 4 //!< Dash Dash Dash Dash line. +#define U_DD_Dot 5 //!< Dot line. +#define U_DD_DotDot 6 //!< Dot Dot line. +#define U_DD_DotDotDot 7 //!< Dot Dot Dot line. +#define U_DD_DotDotDotDot 8 //!< Dot Dot Dot Dot line. +#define U_DD_DashDot 9 //!< Dash Dot line. +#define U_DD_DashDashDot 10 //!< Dash Dash Dot line. +#define U_DD_DashDashDotDot 11 //!< Dash Dash Dot Dot line. +#define U_DD_DashDashDashDot 12 //!< Dash Dash Das hDot line. +#define U_DD_DashDotDot 13 //!< Dash Dot Dot line. +#define U_DD_DashDotDotDot 14 //!< Dash Dot Dot Dot line. +#define U_DD_DashDotDashDot 15 //!< Dash Dot Dash Dot line. +#define U_DD_Long 16 //!< Long line. +#define U_DD_LongLong 17 //!< Long Long line. +#define U_DD_LongLongLong 18 //!< Long Long Long line. +#define U_DD_LongLongLongLong 19 //!< Long Long Long Long line. +#define U_DD_LongDot 20 //!< Long Dot line. +#define U_DD_LongLongDot 21 //!< Long Long Dot line. +#define U_DD_LongLongDotDot 22 //!< Long Long Dot Dot line. +#define U_DD_LongLongLongDot 23 //!< Long Long Long Dot line. +#define U_DD_LongDotDot 24 //!< Long Dot Dot line. +#define U_DD_LongDotDotDot 25 //!< Long Dot Dot Dot line. +#define U_DD_LongDotLongDot 26 //!< Long Dot Long Dot line. +#define U_DD_Types 27 //!< Types + +/** @} */ + + +/** \defgroup U_PMF_PMR_Qualifiers PMF RecordType Enumeration + EMF+ manual 2.1.1.1, Microsoft name: RecordType Enumeration + @{ +*/ +#define U_PMR_HEADER 0x0001 //!< U_PMRHeader record +#define U_PMR_ENDOFFILE 0x0002 //!< U_PMREndOfFile record +#define U_PMR_COMMENT 0x0003 //!< U_PMRComment record +#define U_PMR_GETDC 0x0004 //!< U_PMRGetDC record +#define U_PMR_MULTIFORMATSTART 0x0005 //!< U_PMRMultiFormatStart record +#define U_PMR_MULTIFORMATSECTION 0x0006 //!< U_PMRMultiFormatSection record +#define U_PMR_MULTIFORMATEND 0x0007 //!< U_PMRMultiFormatEnd record +#define U_PMR_OBJECT 0x0008 //!< U_PMRObject record +#define U_PMR_CLEAR 0x0009 //!< U_PMRClear record +#define U_PMR_FILLRECTS 0x000A //!< U_PMRFillRects record +#define U_PMR_DRAWRECTS 0x000B //!< U_PMRDrawRects record +#define U_PMR_FILLPOLYGON 0x000C //!< U_PMRFillPolygon record +#define U_PMR_DRAWLINES 0x000D //!< U_PMRDrawLines record +#define U_PMR_FILLELLIPSE 0x000E //!< U_PMRFillEllipse record +#define U_PMR_DRAWELLIPSE 0x000F //!< U_PMRDrawEllipse record +#define U_PMR_FILLPIE 0x0010 //!< U_PMRFillPie record +#define U_PMR_DRAWPIE 0x0011 //!< U_PMRDrawPie record +#define U_PMR_DRAWARC 0x0012 //!< U_PMRDrawArc record +#define U_PMR_FILLREGION 0x0013 //!< U_PMRFillRegion record +#define U_PMR_FILLPATH 0x0014 //!< U_PMRFillPath record +#define U_PMR_DRAWPATH 0x0015 //!< U_PMRDrawPath record +#define U_PMR_FILLCLOSEDCURVE 0x0016 //!< U_PMRFillClosedCurve record +#define U_PMR_DRAWCLOSEDCURVE 0x0017 //!< U_PMRDrawClosedCurve record +#define U_PMR_DRAWCURVE 0x0018 //!< U_PMRDrawCurve record +#define U_PMR_DRAWBEZIERS 0x0019 //!< U_PMRDrawBeziers record +#define U_PMR_DRAWIMAGE 0x001A //!< U_PMRDrawImage record +#define U_PMR_DRAWIMAGEPOINTS 0x001B //!< U_PMRDrawImagePoints record +#define U_PMR_DRAWSTRING 0x001C //!< U_PMRDrawString record +#define U_PMR_SETRENDERINGORIGIN 0x001D //!< U_PMRSetRenderingOrigin record +#define U_PMR_SETANTIALIASMODE 0x001E //!< U_PMRSetAntiAliasMode record +#define U_PMR_SETTEXTRENDERINGHINT 0x001F //!< U_PMRSetTextRenderingHint record +#define U_PMR_SETTEXTCONTRAST 0x0020 //!< U_PMRSetTextContrast record +#define U_PMR_SETINTERPOLATIONMODE 0x0021 //!< U_PMRSetInterpolationMode record +#define U_PMR_SETPIXELOFFSETMODE 0x0022 //!< U_PMRSetPixelOffsetMode record +#define U_PMR_SETCOMPOSITINGMODE 0x0023 //!< U_PMRSetCompositingMode record +#define U_PMR_SETCOMPOSITINGQUALITY 0x0024 //!< U_PMRSetCompositingQuality record +#define U_PMR_SAVE 0x0025 //!< U_PMRSave record +#define U_PMR_RESTORE 0x0026 //!< U_PMRRestore record +#define U_PMR_BEGINCONTAINER 0x0027 //!< U_PMRBeginContainer record +#define U_PMR_BEGINCONTAINERNOPARAMS 0x0028 //!< U_PMRBeginContainerNoParams record +#define U_PMR_ENDCONTAINER 0x0029 //!< U_PMREndContainer record +#define U_PMR_SETWORLDTRANSFORM 0x002A //!< U_PMRSetWorldTransform record +#define U_PMR_RESETWORLDTRANSFORM 0x002B //!< U_PMRResetWorldTransform record +#define U_PMR_MULTIPLYWORLDTRANSFORM 0x002C //!< U_PMRMultiplyWorldTransform record +#define U_PMR_TRANSLATEWORLDTRANSFORM 0x002D //!< U_PMRTranslateWorldTransform record +#define U_PMR_SCALEWORLDTRANSFORM 0x002E //!< U_PMRScaleWorldTransform record +#define U_PMR_ROTATEWORLDTRANSFORM 0x002F //!< U_PMRRotateWorldTransform record +#define U_PMR_SETPAGETRANSFORM 0x0030 //!< U_PMRSetPageTransform record +#define U_PMR_RESETCLIP 0x0031 //!< U_PMRResetClip record +#define U_PMR_SETCLIPRECT 0x0032 //!< U_PMRSetClipRect record +#define U_PMR_SETCLIPPATH 0x0033 //!< U_PMRSetClipPath record +#define U_PMR_SETCLIPREGION 0x0034 //!< U_PMRSetClipRegion record +#define U_PMR_OFFSETCLIP 0x0035 //!< U_PMROffsetClip record +#define U_PMR_DRAWDRIVERSTRING 0x0036 //!< U_PMRDrawDriverstring record +#define U_PMR_STROKEFILLPATH 0x0037 //!< U_PMRStrokeFillPath record +#define U_PMR_SERIALIZABLEOBJECT 0x0038 //!< U_PMRSerializableObject record +#define U_PMR_SETTSGRAPHICS 0x0039 //!< U_PMRSetTSGraphics record +#define U_PMR_SETTSCLIP 0x003A //!< U_PMRSetTSClip record +#define U_PMR_RECFLAG 0x4000 //!< In EMF+ files the type is one of the above + this flag +#define U_PMR_TYPE_MASK 0x003F //!< mask for EMF+ types +#define U_PMR_MIN 1 //!< Minimum U_PMR_ value. +#define U_PMR_MAX 58 //!< Maximum U_PMR_ value. + +/** @} */ + +/** \defgroup U_PMF_PID_Values PMF Identifiers for PseudoObjects + These are used by the *_set routines to identify types of PseudoObject. + Note that records are U_PMR_*_OID and other objects are U_PMF_*_OID + The numbers are derived from the EMF+ manual sections, as in 2.2.1.3 become + 02020103. Numbers 40000000 and up are not derived from manual setions. + @{ +*/ +#define U_UNDEFINED_OID 0x00000000 //!< Undefined PseudoObject +#define U_PMF_BRUSH_OID 0x02020101 //!< PMF_BRUSH PseudoObject type. +#define U_PMF_CUSTOMLINECAP_OID 0x02020102 //!< PMF_CUSTOMLINECAP PseudoObject type. +#define U_PMF_FONT_OID 0x02020103 //!< PMF_FONT PseudoObject type. +#define U_PMF_IMAGE_OID 0x02020104 //!< PMF_IMAGE PseudoObject type. +#define U_PMF_IMAGEATTRIBUTES_OID 0x02020105 //!< PMF_IMAGEATTRIBUTES PseudoObject type. +#define U_PMF_PATH_OID 0x02020106 //!< PMF_PATH PseudoObject type. +#define U_PMF_PEN_OID 0x02020107 //!< PMF_PEN PseudoObject type. +#define U_PMF_REGION_OID 0x02020108 //!< PMF_REGION PseudoObject type. +#define U_PMF_STRINGFORMAT_OID 0x02020109 //!< PMF_STRINGFORMAT PseudoObject type. +#define U_PMF_ARGB_OID 0x02020201 //!< PMF_ARGB PseudoObject type. +#define U_PMF_BITMAP_OID 0x02020202 //!< PMF_BITMAP PseudoObject type. +#define U_PMF_BITMAPDATA_OID 0x02020203 //!< PMF_BITMAPDATA PseudoObject type. +#define U_PMF_BLENDCOLORS_OID 0x02020204 //!< PMF_BLENDCOLORS PseudoObject type. +#define U_PMF_BLENDFACTORS_OID 0x02020205 //!< PMF_BLENDFACTORS PseudoObject type. +#define U_PMF_BOUNDARYPATHDATA_OID 0x02020206 //!< PMF_BOUNDARYPATHDATA PseudoObject type. +#define U_PMF_BOUNDARYPOINTDATA_OID 0x02020207 //!< PMF_BOUNDARYPOINTDATA PseudoObject type. +#define U_PMF_CHARACTERRANGE_OID 0x02020208 //!< PMF_CHARACTERRANGE PseudoObject type. +#define U_PMF_COMPOUNDLINEDATA_OID 0x02020209 //!< PMF_COMPOUNDLINEDATA PseudoObject type. +#define U_PMF_COMPRESSEDIMAGE_OID 0x02020210 //!< PMF_COMPRESSEDIMAGE PseudoObject type. +#define U_PMF_CUSTOMENDCAPDATA_OID 0x02020211 //!< PMF_CUSTOMENDCAPDATA PseudoObject type. +#define U_PMF_CUSTOMLINECAPARROWDATA_OID 0x02020212 //!< PMF_CUSTOMLINECAPARROWDATA PseudoObject type. +#define U_PMF_CUSTOMLINECAPDATA_OID 0x02020213 //!< PMF_CUSTOMLINECAPDATA PseudoObject type. +#define U_PMF_CUSTOMLINECAPOPTIONALDATA_OID 0x02020214 //!< PMF_CUSTOMLINECAPOPTIONALDATA PseudoObject type. +#define U_PMF_CUSTOMSTARTCAPDATA_OID 0x02020215 //!< PMF_CUSTOMSTARTCAPDATA PseudoObject type. +#define U_PMF_DASHEDLINEDATA_OID 0x02020216 //!< PMF_DASHEDLINEDATA PseudoObject type. +#define U_PMF_FILLPATHOBJ_OID 0x02020217 //!< PMF_FILLPATHOBJ PseudoObject type. +#define U_PMF_FOCUSSCALEDATA_OID 0x02020218 //!< PMF_FOCUSSCALEDATA PseudoObject type. +#define U_PMF_GRAPHICSVERSION_OID 0x02020219 //!< PMF_GRAPHICSVERSION PseudoObject type. +#define U_PMF_HATCHBRUSHDATA_OID 0x02020220 //!< PMF_HATCHBRUSHDATA PseudoObject type. +#define U_PMF_INTEGER7_OID 0x02020221 //!< PMF_INTEGER7 PseudoObject type. +#define U_PMF_INTEGER15_OID 0x02020222 //!< PMF_INTEGER15 PseudoObject type. +#define U_PMF_LANGUAGEIDENTIFIER_OID 0x02020223 //!< PMF_LANGUAGEIDENTIFIER PseudoObject type. +#define U_PMF_LINEARGRADIENTBRUSHDATA_OID 0x02020224 //!< PMF_LINEARGRADIENTBRUSHDATA PseudoObject type. +#define U_PMF_LINEARGRADIENTBRUSHOPTIONALDATA_OID 0x02020225 //!< PMF_LINEARGRADIENTBRUSHOPTIONALDATA PseudoObject type. +#define U_PMF_LINEPATH_OID 0x02020226 //!< PMF_LINEPATH PseudoObject type. +#define U_PMF_METAFILE_OID 0x02020227 //!< PMF_METAFILE PseudoObject type. +#define U_PMF_PALETTE_OID 0x02020228 //!< PMF_PALETTE PseudoObject type. +#define U_PMF_PATHGRADIENTBRUSHDATA_OID 0x02020229 //!< PMF_PATHGRADIENTBRUSHDATA PseudoObject type. +#define U_PMF_PATHGRADIENTBRUSHOPTIONALDATA_OID 0x02020230 //!< PMF_PATHGRADIENTBRUSHOPTIONALDATA PseudoObject type. +#define U_PMF_PATHPOINTTYPE_OID 0x02020231 //!< PMF_PATHPOINTTYPE PseudoObject type. +#define U_PMF_PATHPOINTTYPERLE_OID 0x02020232 //!< PMF_PATHPOINTTYPERLE PseudoObject type. +#define U_PMF_PENDATA_OID 0x02020233 //!< PMF_PENDATA PseudoObject type. +#define U_PMF_PENOPTIONALDATA_OID 0x02020234 //!< PMF_PENOPTIONALDATA PseudoObject type. +#define U_PMF_POINT_OID 0x02020235 //!< PMF_POINT PseudoObject type. +#define U_PMF_POINTF_OID 0x02020236 //!< PMF_POINTF PseudoObject type. +#define U_PMF_POINTR_OID 0x02020237 //!< PMF_POINTR PseudoObject type. +#define U_PMF_RECT_OID 0x02020238 //!< PMF_RECT PseudoObject type. +#define U_PMF_RECTF_OID 0x02020239 //!< PMF_RECTF PseudoObject type. +#define U_PMF_REGIONNODE_OID 0x02020240 //!< PMF_REGIONNODE PseudoObject type. +#define U_PMF_REGIONNODECHILDNODES_OID 0x02020241 //!< PMF_REGIONNODECHILDNODES PseudoObject type. +#define U_PMF_REGIONNODEPATH_OID 0x02020242 //!< PMF_REGIONNODEPATH PseudoObject type. +#define U_PMF_SOLIDBRUSHDATA_OID 0x02020243 //!< PMF_SOLIDBRUSHDATA PseudoObject type. +#define U_PMF_STRINGFORMATDATA_OID 0x02020244 //!< PMF_STRINGFORMATDATA PseudoObject type. +#define U_PMF_TEXTUREBRUSHDATA_OID 0x02020245 //!< PMF_TEXTUREBRUSHDATA PseudoObject type. +#define U_PMF_TEXTUREBRUSHOPTIONALDATA_OID 0x02020246 //!< PMF_TEXTUREBRUSHOPTIONALDATA PseudoObject type. +#define U_PMF_TRANSFORMMATRIX_OID 0x02020247 //!< PMF_TRANSFORMMATRIX PseudoObject type. +#define U_PMF_IE_BLUR_OID 0x02020301 //!< PMF_IE_BLUR PseudoObject type. +#define U_PMF_IE_BRIGHTNESSCONTRAST_OID 0x02020302 //!< PMF_IE_BRIGHTNESSCONTRAST PseudoObject type. +#define U_PMF_IE_COLORBALANCE_OID 0x02020303 //!< PMF_IE_COLORBALANCE PseudoObject type. +#define U_PMF_IE_COLORCURVE_OID 0x02020304 //!< PMF_IE_COLORCURVE PseudoObject type. +#define U_PMF_IE_COLORLOOKUPTABLE_OID 0x02020305 //!< PMF_IE_COLORLOOKUPTABLE PseudoObject type. +#define U_PMF_IE_COLORMATRIX_OID 0x02020306 //!< PMF_IE_COLORMATRIX PseudoObject type. +#define U_PMF_IE_HUESATURATIONLIGHTNESS_OID 0x02020307 //!< PMF_IE_HUESATURATIONLIGHTNESS PseudoObject type. +#define U_PMF_IE_LEVELS_OID 0x02020308 //!< PMF_IE_LEVELS PseudoObject type. +#define U_PMF_IE_REDEYECORRECTION_OID 0x02020309 //!< PMF_IE_REDEYECORRECTION PseudoObject type. +#define U_PMF_IE_SHARPEN_OID 0x02020310 //!< PMF_IE_SHARPEN PseudoObject type. +#define U_PMF_IE_TINT_OID 0x02020311 //!< PMF_IE_TINT PseudoObject type. +#define U_PMR_STROKEFILLPATH_OID 0x02010101 //!< PMR_STROKEFILLPATH PseudoObject type. (Mentioned in passing here). +#define U_PMR_OFFSETCLIP_OID 0x02030101 //!< PMR_OFFSETCLIP PseudoObject type. +#define U_PMR_RESETCLIP_OID 0x02030102 //!< PMR_RESETCLIP PseudoObject type. +#define U_PMR_SETCLIPPATH_OID 0x02030103 //!< PMR_SETCLIPPATH PseudoObject type. +#define U_PMR_SETCLIPRECT_OID 0x02030104 //!< PMR_SETCLIPRECT PseudoObject type. +#define U_PMR_SETCLIPREGION_OID 0x02030105 //!< PMR_SETCLIPREGION PseudoObject type. +#define U_PMR_COMMENT_OID 0x02030201 //!< PMR_COMMENT PseudoObject type. +#define U_PMR_ENDOFFILE_OID 0x02030301 //!< PMR_ENDOFFILE PseudoObject type. +#define U_PMR_GETDC_OID 0x02030302 //!< PMR_GETDC PseudoObject type. +#define U_PMR_HEADER_OID 0x02030303 //!< PMR_HEADER PseudoObject type. +#define U_PMR_CLEAR_OID 0x02030401 //!< PMR_CLEAR PseudoObject type. +#define U_PMR_DRAWARC_OID 0x02030402 //!< PMR_DRAWARC PseudoObject type. +#define U_PMR_DRAWBEZIERS_OID 0x02030403 //!< PMR_DRAWBEZIERS PseudoObject type. +#define U_PMR_DRAWCLOSEDCURVE_OID 0x02030404 //!< PMR_DRAWCLOSEDCURVE PseudoObject type. +#define U_PMR_DRAWCURVE_OID 0x02030405 //!< PMR_DRAWCURVE PseudoObject type. +#define U_PMR_DRAWDRIVERSTRING_OID 0x02030406 //!< PMR_DRAWDRIVERSTRING PseudoObject type. +#define U_PMR_DRAWELLIPSE_OID 0x02030407 //!< PMR_DRAWELLIPSE PseudoObject type. +#define U_PMR_DRAWIMAGE_OID 0x02030408 //!< PMR_DRAWIMAGE PseudoObject type. +#define U_PMR_DRAWIMAGEPOINTS_OID 0x02030409 //!< PMR_DRAWIMAGEPOINTS PseudoObject type. +#define U_PMR_DRAWLINES_OID 0x02030410 //!< PMR_DRAWLINES PseudoObject type. +#define U_PMR_DRAWPATH_OID 0x02030411 //!< PMR_DRAWPATH PseudoObject type. +#define U_PMR_DRAWPIE_OID 0x02030412 //!< PMR_DRAWPIE PseudoObject type. +#define U_PMR_DRAWRECTS_OID 0x02030413 //!< PMR_DRAWRECTS PseudoObject type. +#define U_PMR_DRAWSTRING_OID 0x02030414 //!< PMR_DRAWSTRING PseudoObject type. +#define U_PMR_FILLCLOSEDCURVE_OID 0x02030415 //!< PMR_FILLCLOSEDCURVE PseudoObject type. +#define U_PMR_FILLELLIPSE_OID 0x02030416 //!< PMR_FILLELLIPSE PseudoObject type. +#define U_PMR_FILLPATH_OID 0x02030417 //!< PMR_FILLPATH PseudoObject type. +#define U_PMR_FILLPIE_OID 0x02030418 //!< PMR_FILLPIE PseudoObject type. +#define U_PMR_FILLPOLYGON_OID 0x02030419 //!< PMR_FILLPOLYGON PseudoObject type. +#define U_PMR_FILLRECTS_OID 0x02030420 //!< PMR_FILLRECTS PseudoObject type. +#define U_PMR_FILLREGION_OID 0x02030421 //!< PMR_FILLREGION PseudoObject type. +#define U_PMR_OBJECT_OID 0x02030501 //!< PMR_OBJECT PseudoObject type. +#define U_PMR_SERIALIZABLEOBJECT_OID 0x02030502 //!< PMR_SERIALIZABLEOBJECT PseudoObject type. +#define U_PMR_SETANTIALIASMODE_OID 0x02030601 //!< PMR_SETANTIALIASMODE PseudoObject type. +#define U_PMR_SETCOMPOSITINGMODE_OID 0x02030602 //!< PMR_SETCOMPOSITINGMODE PseudoObject type. +#define U_PMR_SETCOMPOSITINGQUALITY_OID 0x02030603 //!< PMR_SETCOMPOSITINGQUALITY PseudoObject type. +#define U_PMR_SETINTERPOLATIONMODE_OID 0x02030604 //!< PMR_SETINTERPOLATIONMODE PseudoObject type. +#define U_PMR_SETPIXELOFFSETMODE_OID 0x02030605 //!< PMR_SETPIXELOFFSETMODE PseudoObject type. +#define U_PMR_SETRENDERINGORIGIN_OID 0x02030606 //!< PMR_SETRENDERINGORIGIN PseudoObject type. +#define U_PMR_SETTEXTCONTRAST_OID 0x02030607 //!< PMR_SETTEXTCONTRAST PseudoObject type. +#define U_PMR_SETTEXTRENDERINGHINT_OID 0x02030608 //!< PMR_SETTEXTRENDERINGHINT PseudoObject type. +#define U_PMR_BEGINCONTAINER_OID 0x02030701 //!< PMR_BEGINCONTAINER PseudoObject type. +#define U_PMR_BEGINCONTAINERNOPARAMS_OID 0x02030702 //!< PMR_BEGINCONTAINERNOPARAMS PseudoObject type. +#define U_PMR_ENDCONTAINER_OID 0x02030703 //!< PMR_ENDCONTAINER PseudoObject type. +#define U_PMR_RESTORE_OID 0x02030704 //!< PMR_RESTORE PseudoObject type. +#define U_PMR_SAVE_OID 0x02030705 //!< PMR_SAVE PseudoObject type. +#define U_PMR_SETTSCLIP_OID 0x02030801 //!< PMR_SETTSCLIP PseudoObject type. +#define U_PMR_SETTSGRAPHICS_OID 0x02030802 //!< PMR_SETTSGRAPHICS PseudoObject type. +#define U_PMR_MULTIPLYWORLDTRANSFORM_OID 0x02030901 //!< PMR_MULTIPLYWORLDTRANSFORM PseudoObject type. +#define U_PMR_RESETWORLDTRANSFORM_OID 0x02030902 //!< PMR_RESETWORLDTRANSFORM PseudoObject type. +#define U_PMR_ROTATEWORLDTRANSFORM_OID 0x02030903 //!< PMR_ROTATEWORLDTRANSFORM PseudoObject type. +#define U_PMR_SCALEWORLDTRANSFORM_OID 0x02030904 //!< PMR_SCALEWORLDTRANSFORM PseudoObject type. +#define U_PMR_SETPAGETRANSFORM_OID 0x02030905 //!< PMR_SETPAGETRANSFORM PseudoObject type. +#define U_PMR_SETWORLDTRANSFORM_OID 0x02030906 //!< PMR_SETWORLDTRANSFORM PseudoObject type. +#define U_PMR_TRANSLATEWORLDTRANSFORM_OID 0x02030907 //!< PMR_TRANSLATEWORLDTRANSFORM PseudoObject type. +#define U_PMR_TRANSLATEWORLDTRANSFORM_OID 0x02030907 //!< PMR_TRANSLATEWORLDTRANSFORM PseudoObject type. +#define U_PMR_CMN_HDR_OID 0x40000000 //!< PMR_CMN_HDR PseudoObject type. +#define U_PMF_4NUM_OID 0x40000001 //!< PMF_4NUM PseudoObject type. PseudoObject contains a 4 unsigned int in EMF+ file byte order, used in some contexts to indicate an object index number.. +#define U_PMF_RAW_OID 0x40000002 //!< PMF_RAW PseudoObject type. Raw data: no preceding elements, data has native endianness. +#define U_PMF_ARRAY_OID 0x80000000 //!< PMF_ARRAY PseudoObject type modifier. PseudoObject contains an array of the data type revealed when this bit is cleared. +#define U_PMF_MASK_OID 0x7FFFFFFF //!< PMF_MASK. Select PseudoObject data type without regard to PMF_ARRAY. + +/** @} */ + + +/** \defgroup U_PMF_BDT_ PMF BitmapDataType Enumeration + For + EMF+ manual 2.1.1.2, Microsoft name: BitmapDataType Enumeration (U_BDT_*) + @{ +*/ +#define U_BDT_Pixel 0x00 //!< Data is a bitmap. +#define U_BDT_Compressed 0x01 //!< Data is a compressed bitmap (like a PNG). +/** @} */ + +/** \defgroup U_PMF_BT_ PMF BrushType Enumeration + For + EMF+ manual 2.1.1.3, Microsoft name: BrushType Enumeration (U_BT_*) + @{ +*/ +#define U_BT_SolidColor 0x00 //!< Solid Color brush. +#define U_BT_HatchFill 0x01 //!< Hatch Fill brush. +#define U_BT_TextureFill 0x02 //!< Texture Fill brush. +#define U_BT_PathGradient 0x03 //!< Path Gradient brush. +#define U_BT_LinearGradient 0x04 //!< Linear Gradient brush. +/** @} */ + +/** \defgroup U_PMF_CM_ PMF CombineMode Enumeration + For + EMF+ manual 2.1.1.4, Microsoft name: CombineMode Enumeration (U_CM_*) + @{ +*/ +#define U_CM_Replace 0x00 //!< Region becomes new region. +#define U_CM_Intersect 0x01 //!< Region becomes intersection of existing region and new region. +#define U_CM_Union 0x02 //!< Region becomes union of existing and new regions. +#define U_CM_XOR 0x03 //!< Region becomes XOR of existing and new regions. +#define U_CM_Exclude 0x04 //!< Region becomes part of existing region not in new region. +#define U_CM_Complement 0x05 //!< Region becomes part of new region not in existing region. +/** @} */ + +/** \defgroup U_PMF_CMS_ PMF CompositingMode Enumeration + For + EMF+ manual 2.1.1.5, Microsoft name: CompositingMode Enumeration (U_CMS_* [S==Source]) + @{ +*/ +#define U_CMS_Over 0x00 //!< Source is alpha blends with destination. +#define U_CMS_Copy 0x01 //!< Source over writes destination. +/** @} */ + +/** \defgroup U_PMF_CQ_ PMF CompositingQuality Enumeration + For + EMF+ manual 2.1.1.6, Microsoft name: CompositingQuality Enumeration (U_CQ_*) + @{ +*/ +#define U_CQ_Default 0x01 //!< Default compositing quality +#define U_CQ_HighSpeed 0x02 //!< High Speed compositing quality +#define U_CQ_HighQuality 0x03 //!< High Quality compositing quality +#define U_CQ_GammaCorrected 0x04 //!< Gamma Corrected compositing quality +#define U_CQ_AssumeLinear 0x05 //!< Assume Linear compositing quality +/** @} */ + +/** \defgroup U_PMF_CA_ PMF CurveAdjustments Enumeration + For + EMF+ manual 2.1.1.7, Microsoft name: CurveAdjustments Enumeration (U_CA_*) + @{ +*/ +#define U_CA_Exposure 0x00 //!< Exposure color curve adjustment +#define U_CA_Density 0x01 //!< Density color curve adjustment +#define U_CA_Contrast 0x02 //!< Contrast color curve adjustment +#define U_CA_Highlight 0x03 //!< Highlight color curve adjustment +#define U_CA_Shadow 0x04 //!< Shadow color curve adjustment +#define U_CA_Midtone 0x05 //!< Midtone color curve adjustment +#define U_CA_WhiteSaturation 0x06 //!< White Saturation color curve adjustment +#define U_CA_BlackSaturation 0x07 //!< Black Saturation color curve adjustment +/** @} */ + +/** \defgroup U_PMF_CC_ PMF CurveChannel Enumeration + For + EMF+ manual 2.1.1.8, Microsoft name: CurveChannel Enumeration (U_CC_*) + @{ +*/ +#define U_CC_All 0x00 //!< All color channels +#define U_CC_Red 0x01 //!< Red color channel +#define U_CC_Green 0x02 //!< Green color channel +#define U_CC_Blue 0x03 //!< Blue color channel +/** @} */ + +/** \defgroup U_PMF_CLCDT_ PMF CustomLineCapDataType Enumeration + For + EMF+ manual 2.1.1.9, Microsoft name: CustomLineCapDataType Enumeration (U_CLCDT_*) + @{ +*/ +#define U_CLCDT_Default 0x00 //!< Default custom line cap +#define U_CLCDT_AdjustableArrow 0x01 //!< Adjustable Arrow custom line cap +/** @} */ + +/** \defgroup U_PMF_DLCT_ PMF DashedLineCapType Enumeration + For + EMF+ manual 2.1.1.10, Microsoft name: DashedLineCapType Enumeration (U_DLCT_*) + @{ +*/ +#define U_DLCT_Flat 0x00 //!< Flat dashed line cap +#define U_DLCT_Round 0x02 //!< Round dashed line cap +#define U_DLCT_Triangle 0x03 //!< Triangle dashed line cap +/** @} */ + +/** \defgroup U_PMF_FT_ PMF FilterType Enumeration + For + EMF+ manual 2.1.1.11, Microsoft name: FilterType Enumeration (U_FT_*) + @{ +*/ +#define U_FT_None 0x00 //!< No filtering +#define U_FT_Point 0x01 //!< Point filtering +#define U_FT_Linear 0x02 //!< Linear filtering +#define U_FT_Triangle 0x03 //!< Triangle filtering +#define U_FT_Box 0x04 //!< Box filtering +#define U_FT_PyramidalQuad 0x06 //!< Pyramidal Quad filtering +#define U_FT_GaussianQuad 0x07 //!< Gaussian Quad filtering +/** @} */ + +/** \defgroup U_PMF_GV_ PMF GraphicsVersion Enumeration + For + EMF+ manual 2.1.1.12, Microsoft name: GraphicsVersion Enumeration (U_GV_*) + @{ +*/ +#define U_GV_1 0x01 //!< 1 graphics version +#define U_GV_1_1 0x02 //!< 1.1 graphics version +/** @} */ + +/** \defgroup U_PMF_HSP_ PMF HatchStyle Enumeration + For + EMF+ manual 2.1.1.13, Microsoft name: HatchStyle Enumeration (U_HSP_* [U_HS_ already used for EMF]) + @{ +*/ +#define U_HSP_Horizontal 0x00000000 //!< Horizontal +#define U_HSP_Vertical 0x00000001 //!< Vertical +#define U_HSP_ForwardDiagonal 0x00000002 //!< Forward Diagonal +#define U_HSP_BackwardDiagonal 0x00000003 //!< Backward Diagonal +#define U_HSP_LargeGrid 0x00000004 //!< Large Grid +#define U_HSP_DiagonalCross 0x00000005 //!< Diagonal Cross +#define U_HSP_05Percent 0x00000006 //!< 05 Percent +#define U_HSP_10Percent 0x00000007 //!< 10 Percent +#define U_HSP_20Percent 0x00000008 //!< 20 Percent +#define U_HSP_25Percent 0x00000009 //!< 25 Percent +#define U_HSP_30Percent 0x0000000A //!< 30 Percent +#define U_HSP_40Percent 0x0000000B //!< 40 Percent +#define U_HSP_50Percent 0x0000000C //!< 50 Percent +#define U_HSP_60Percent 0x0000000D //!< 60 Percent +#define U_HSP_70Percent 0x0000000E //!< 70 Percent +#define U_HSP_75Percent 0x0000000F //!< 75 Percent +#define U_HSP_80Percent 0x00000010 //!< 80 Percent +#define U_HSP_90Percent 0x00000011 //!< 90 Percent +#define U_HSP_LightDownwardDiagonal 0x00000012 //!< Light Downward Diagonal +#define U_HSP_LightUpwardDiagonal 0x00000013 //!< Light Upward Diagonal +#define U_HSP_DarkDownwardDiagonal 0x00000014 //!< Dark Downward Diagonal +#define U_HSP_DarkUpwardDiagonal 0x00000015 //!< Dark Upward Diagonal +#define U_HSP_WideDownwardDiagonal 0x00000016 //!< Wide Downward Diagonal +#define U_HSP_WideUpwardDiagonal 0x00000017 //!< Wide Upward Diagonal +#define U_HSP_LightVertical 0x00000018 //!< Light Vertical +#define U_HSP_LightHorizontal 0x00000019 //!< Light Horizontal +#define U_HSP_NarrowVertical 0x0000001A //!< Narrow Vertical +#define U_HSP_NarrowHorizontal 0x0000001B //!< Narrow Horizontal +#define U_HSP_DarkVertical 0x0000001C //!< Dark Vertical +#define U_HSP_DarkHorizontal 0x0000001D //!< Dark Horizontal +#define U_HSP_DashedDownwardDiagonal 0x0000001E //!< Dashed Downward Diagonal +#define U_HSP_DashedUpwardDiagonal 0x0000001F //!< Dashed Upward Diagonal +#define U_HSP_DashedHorizontal 0x00000020 //!< Dashed Horizontal +#define U_HSP_DashedVertical 0x00000021 //!< Dashed Vertical +#define U_HSP_SmallConfetti 0x00000022 //!< Small Confetti +#define U_HSP_LargeConfetti 0x00000023 //!< LargeC onfetti +#define U_HSP_ZigZag 0x00000024 //!< Zig Zag +#define U_HSP_Wave 0x00000025 //!< Wave +#define U_HSP_DiagonalBrick 0x00000026 //!< Diagonal Brick +#define U_HSP_HorizontalBrick 0x00000027 //!< Horizontal Brick +#define U_HSP_Weave 0x00000028 //!< Weave +#define U_HSP_Plaid 0x00000029 //!< Plaid +#define U_HSP_Divot 0x0000002A //!< Divot +#define U_HSP_DottedGrid 0x0000002B //!< DottedGrid +#define U_HSP_DottedDiamond 0x0000002C //!< DottedDiamond +#define U_HSP_Shingle 0x0000002D //!< Shingle +#define U_HSP_Trellis 0x0000002E //!< Trellis +#define U_HSP_Sphere 0x0000002F //!< Sphere +#define U_HSP_SmallGrid 0x00000030 //!< Small Grid +#define U_HSP_SmallCheckerBoard 0x00000031 //!< Small Checker Board +#define U_HSP_LargeCheckerBoard 0x00000032 //!< Large Checker Board +#define U_HSP_OutlinedDiamond 0x00000033 //!< Outlined Diamond +#define U_HSP_SolidDiamond 0x00000034 //!< Solid Diamond +/** @} */ + +/** \defgroup U_PMF_HKP_ PMF HotkeyPrefix Enumeration + For + EMF+ manual 2.1.1.14, Microsoft name: HotkeyPrefix Enumeration (U_HKP_*) + @{ +*/ +#define U_HKP_None 0x00 //!< No hot key prefix +#define U_HKP_Show 0x01 //!< Show hot key prefix +#define U_HKP_Hide 0x02 //!< Hide hot key prefix +/** @} */ + +/** \defgroup U_PMF_IDT_ PMF ImageDataType Enumeration + For + EMF+ manual 2.1.1.15, Microsoft name: ImageDataType Enumeration (U_IDT_*) + @{ +*/ +#define U_IDT_Unknown 0x00 //!< Unknown image data type +#define U_IDT_Bitmap 0x01 //!< Bitmap image data type +#define U_IDT_Metafile 0x02 //!< Metafile image data type +/** @} */ + +/** \defgroup U_PMF_IM_ PMF InterpolationMode Enumeration + For + EMF+ manual 2.1.1.16, Microsoft name: InterpolationMode Enumeration (U_IM_*) + @{ +*/ +#define U_IM_Default 0x00 //!< Default interpolation mode +#define U_IM_LowQuality 0x01 //!< Low Quality interpolation mode +#define U_IM_HighQuality 0x02 //!< High Quality interpolation mode +#define U_IM_Bilinear 0x03 //!< Bilinear interpolation mode +#define U_IM_Bicubic 0x04 //!< Bicubic interpolation mode +#define U_IM_NearestNeighbor 0x05 //!< Nearest Neighbor interpolation mode +#define U_IM_HighQualityBilinear 0x06 //!< High Quality Bilinear interpolation mode +#define U_IM_HighQualityBicubic 0x07 //!< High Quality Bicubic interpolation mode +/** @} */ + +/** \defgroup U_PMF_LID_ PMF LanguageIdentifier Enumeration + For + EMF+ manual 2.1.1.17, Microsoft name: LanguageIdentifier Enumeration (U_LID_*) + @{ +*/ +#define U_LID_LANG_NEUTRAL 0x0000 //!< LANG_NEUTRAL +#define U_LID_zh_CHS 0x0004 //!< zh_CHS +#define U_LID_LANG_INVARIANT 0x007F //!< LANG_INVARIANT +#define U_LID_LANG_NEUTRAL_USER_DEFAULT 0x0400 //!< LANG_NEUTRAL_USER_DEFAULT +#define U_LID_ar_SA 0x0401 //!< ar_SA +#define U_LID_bg_BG 0x0402 //!< bg_BG +#define U_LID_ca_ES 0x0403 //!< ca_ES +#define U_LID_zh_CHT 0x0404 //!< zh_CHT +#define U_LID_cs_CZ 0x0405 //!< cs_CZ +#define U_LID_da_DK 0x0406 //!< da_DK +#define U_LID_de_DE 0x0407 //!< de_DE +#define U_LID_el_GR 0x0408 //!< el_GR +#define U_LID_en_US 0x0409 //!< en_US +#define U_LID_es_Tradnl_ES 0x040A //!< es_Tradnl_ES +#define U_LID_fi_FI 0x040B //!< fi_FI +#define U_LID_fr_FR 0x040C //!< fr_FR +#define U_LID_he_IL 0x040D //!< he_IL +#define U_LID_hu_HU 0x040E //!< hu_HU +#define U_LID_is_IS 0x040F //!< is_IS +#define U_LID_it_IT 0x0410 //!< it_IT +#define U_LID_ja_JA 0x0411 //!< ja_JA +#define U_LID_ko_KR 0x0412 //!< ko_KR +#define U_LID_nl_NL 0x0413 //!< nl_NL +#define U_LID_nb_NO 0x0414 //!< nb_NO +#define U_LID_pl_PL 0x0415 //!< pl_PL +#define U_LID_pt_BR 0x0416 //!< pt_BR +#define U_LID_rm_CH 0x0417 //!< rm_CH +#define U_LID_ro_RO 0x0418 //!< ro_RO +#define U_LID_ru_RU 0x0419 //!< ru_RU +#define U_LID_hr_HR 0x041A //!< hr_HR +#define U_LID_sk_SK 0x041B //!< sk_SK +#define U_LID_sq_AL 0x041C //!< sq_AL +#define U_LID_sv_SE 0x041D //!< sv_SE +#define U_LID_th_TH 0x041E //!< th_TH +#define U_LID_tr_TR 0x041F //!< tr_TR +#define U_LID_ur_PK 0x0420 //!< ur_PK +#define U_LID_id_ID 0x0421 //!< id_ID +#define U_LID_uk_UA 0x0422 //!< uk_UA +#define U_LID_be_BY 0x0423 //!< be_BY +#define U_LID_sl_SI 0x0424 //!< sl_SI +#define U_LID_et_EE 0x0425 //!< et_EE +#define U_LID_lv_LV 0x0426 //!< lv_LV +#define U_LID_lt_LT 0x0427 //!< lt_LT +#define U_LID_tg_TJ 0x0428 //!< tg_TJ +#define U_LID_fa_IR 0x0429 //!< fa_IR +#define U_LID_vi_VN 0x042A //!< vi_VN +#define U_LID_hy_AM 0x042B //!< hy_AM +#define U_LID_az_Latn_AZ 0x042C //!< az_Latn_AZ +#define U_LID_eu_ES 0x042D //!< eu_ES +#define U_LID_wen_DE 0x042E //!< wen_DE +#define U_LID_mk_MK 0x042F //!< mk_MK +#define U_LID_st_ZA 0x0430 //!< st_ZA +#define U_LID_tn_ZA 0x0432 //!< tn_ZA +#define U_LID_xh_ZA 0x0434 //!< xh_ZA +#define U_LID_zu_ZA 0x0435 //!< zu_ZA +#define U_LID_af_ZA 0x0436 //!< af_ZA +#define U_LID_ka_GE 0x0437 //!< ka_GE +#define U_LID_fa_FA 0x0438 //!< fa_FA +#define U_LID_hi_IN 0x0439 //!< hi_IN +#define U_LID_mt_MT 0x043A //!< mt_MT +#define U_LID_se_NO 0x043B //!< se_NO +#define U_LID_ga_GB 0x043C //!< ga_GB +#define U_LID_ms_MY 0x043E //!< ms_MY +#define U_LID_kk_KZ 0x043F //!< kk_KZ +#define U_LID_ky_KG 0x0440 //!< ky_KG +#define U_LID_sw_KE 0x0441 //!< sw_KE +#define U_LID_tk_TM 0x0442 //!< tk_TM +#define U_LID_uz_Latn_UZ 0x0443 //!< uz_Latn_UZ +#define U_LID_tt_Ru 0x0444 //!< tt_Ru +#define U_LID_bn_IN 0x0445 //!< bn_IN +#define U_LID_pa_IN 0x0446 //!< pa_IN +#define U_LID_gu_IN 0x0447 //!< gu_IN +#define U_LID_or_IN 0x0448 //!< or_IN +#define U_LID_ta_IN 0x0449 //!< ta_IN +#define U_LID_te_IN 0x044A //!< te_IN +#define U_LID_kn_IN 0x044B //!< kn_IN +#define U_LID_ml_IN 0x044C //!< ml_IN +#define U_LID_as_IN 0x044D //!< as_IN +#define U_LID_mr_IN 0x044E //!< mr_IN +#define U_LID_sa_IN 0x044F //!< sa_IN +#define U_LID_mn_MN 0x0450 //!< mn_MN +#define U_LID_bo_CN 0x0451 //!< bo_CN +#define U_LID_cy_GB 0x0452 //!< cy_GB +#define U_LID_km_KH 0x0453 //!< km_KH +#define U_LID_lo_LA 0x0454 //!< lo_LA +#define U_LID_gl_ES 0x0456 //!< gl_ES +#define U_LID_kok_IN 0x0457 //!< kok_IN +#define U_LID_sd_IN 0x0459 //!< sd_IN +#define U_LID_syr_SY 0x045A //!< syr_SY +#define U_LID_si_LK 0x045B //!< si_LK +#define U_LID_iu_Cans_CA 0x045D //!< iu_Cans_CA +#define U_LID_am_ET 0x045E //!< am_ET +#define U_LID_ne_NP 0x0461 //!< ne_NP +#define U_LID_fy_NL 0x0462 //!< fy_NL +#define U_LID_ps_AF 0x0463 //!< ps_AF +#define U_LID_fil_PH 0x0464 //!< fil_PH +#define U_LID_div_MV 0x0465 //!< div_MV +#define U_LID_ha_Latn_NG 0x0468 //!< ha_Latn_NG +#define U_LID_yo_NG 0x046A //!< yo_NG +#define U_LID_quz_BO 0x046B //!< quz_BO +#define U_LID_nzo_ZA 0x046C //!< nzo_ZA +#define U_LID_ba_RU 0x046D //!< ba_RU +#define U_LID_lb_LU 0x046E //!< lb_LU +#define U_LID_kl_GL 0x046F //!< kl_GL +#define U_LID_ig_NG 0x0470 //!< ig_NG +#define U_LID_so_SO 0x0477 //!< so_SO +#define U_LID_ii_CN 0x0478 //!< ii_CN +#define U_LID_arn_CL 0x047A //!< arn_CL +#define U_LID_moh_CA 0x047C //!< moh_CA +#define U_LID_br_FR 0x047E //!< br_FR +#define U_LID_ug_CN 0x0480 //!< ug_CN +#define U_LID_ mi_NZ 0x0481 //!< mi_NZ +#define U_LID_oc_FR 0x0482 //!< oc_FR +#define U_LID_co_FR 0x0483 //!< co_FR +#define U_LID_gsw_FR 0x0484 //!< gsw_FR +#define U_LID_sah_RU 0x0485 //!< sah_RU +#define U_LID_qut_GT 0x0486 //!< qut_GT +#define U_LID_rw_RW 0x0487 //!< rw_RW +#define U_LID_wo_SN 0x0488 //!< wo_SN +#define U_LID_gbz_AF 0x048C //!< gbz_AF +#define U_LID_LANG_NEUTRAL_SYS_DEFAULT 0x0800 //!< LANG_NEUTRAL_SYS_DEFAULT +#define U_LID_ar_IQ 0x0801 //!< ar_IQ +#define U_LID_zh_CN 0x0804 //!< zh_CN +#define U_LID_de_CH 0x0807 //!< de_CH +#define U_LID_en_GB 0x0809 //!< en_GB +#define U_LID_es_MX 0x080A //!< es_MX +#define U_LID_fr_BE 0x080C //!< fr_BE +#define U_LID_it_CH 0x0810 //!< it_CH +#define U_LID_ko_Johab_KR 0x0812 //!< ko_Johab_KR +#define U_LID_nl_BE 0x0813 //!< nl_BE +#define U_LID_nn_NO 0x0814 //!< nn_NO +#define U_LID_pt_PT 0x0816 //!< pt_PT +#define U_LID_sr_Latn_SP 0x081A //!< sr_Latn_SP +#define U_LID_sv_FI 0x081D //!< sv_FI +#define U_LID_ur_IN 0x0820 //!< ur_IN +#define U_LID_lt_C_LT 0x0827 //!< lt_C_LT +#define U_LID_az_Cyrl_AZ 0x082C //!< az_Cyrl_AZ +#define U_LID_wee_DE 0x082E //!< wee_DE +#define U_LID_se_SE 0x083B //!< se_SE +#define U_LID_ga_IE 0x083C //!< ga_IE +#define U_LID_ms_BN 0x083E //!< ms_BN +#define U_LID_uz_Cyrl_UZ 0x0843 //!< uz_Cyrl_UZ +#define U_LID_bn_BD 0x0845 //!< bn_BD +#define U_LID_mn_Mong_CN 0x0850 //!< mn_Mong_CN +#define U_LID_sd_PK 0x0859 //!< sd_PK +#define U_LID_iu_Latn_CA 0x085D //!< iu_Latn_CA +#define U_LID_tzm_Latn_DZ 0x085F //!< tzm_Latn_DZ +#define U_LID_quz_EC 0x086B //!< quz_EC +#define U_LID_LANG_NEUTRAL_CUSTOM_DEFAULT 0x0C00 //!< LANG_NEUTRAL_CUSTOM_DEFAULT +#define U_LID_ar_EG 0x0C01 //!< ar_EG +#define U_LID_zh_HK 0x0C04 //!< zh_HK +#define U_LID_de_AT 0x0C07 //!< de_AT +#define U_LID_en_AU 0x0C09 //!< en_AU +#define U_LID_es_ES 0x0C0A //!< es_ES +#define U_LID_fr_CA 0x0C0C //!< fr_CA +#define U_LID_sr_Cyrl_CS 0x0C1A //!< sr_Cyrl_CS +#define U_LID_se_FI 0x0C3B //!< se_FI +#define U_LID_quz_PE 0x0C6B //!< quz_PE +#define U_LID_LANG_NEUTRAL_CUSTOM 0x1000 //!< LANG_NEUTRAL_CUSTOM +#define U_LID_ar_LY 0x1001 //!< ar_LY +#define U_LID_zh_SG 0x1004 //!< zh_SG +#define U_LID_de_LU 0x1007 //!< de_LU +#define U_LID_en_CA 0x1009 //!< en_CA +#define U_LID_es_GT 0x100A //!< es_GT +#define U_LID_fr_CH 0x100C //!< fr_CH +#define U_LID_hr_BA 0x101A //!< hr_BA +#define U_LID_smj_NO 0x103B //!< smj_NO +#define U_LID_LANG_NEUTRAL_CUSTOM_DEFAULT_MUI 0x1400 //!< LANG_NEUTRAL_CUSTOM_DEFAULT_MUI +#define U_LID_ar_DZ 0x1401 //!< ar_DZ +#define U_LID_zh_MO 0x1404 //!< zh_MO +#define U_LID_de_LI 0x1407 //!< de_LI +#define U_LID_en_NZ 0x1409 //!< en_NZ +#define U_LID_es_CR 0x140A //!< es_CR +#define U_LID_fr_LU 0x140C //!< fr_LU +#define U_LID_bs_Latn_BA 0x141A //!< bs_Latn_BA +#define U_LID_smj_SE 0x143B //!< smj_SE +#define U_LID_ar_MA 0x1801 //!< ar_MA +#define U_LID_en_IE 0x1809 //!< en_IE +#define U_LID_es_PA 0x180A //!< es_PA +#define U_LID_ar_MC 0x180C //!< ar_MC +#define U_LID_sr_Latn_BA 0x181A //!< sr_Latn_BA +#define U_LID_sma_NO 0x183B //!< sma_NO +#define U_LID_ar_TN 0x1C01 //!< ar_TN +#define U_LID_en_ZA 0x1C09 //!< en_ZA +#define U_LID_es_DO 0x1C0A //!< es_DO +#define U_LID_sr_Cyrl_BA 0x1C1A //!< sr_Cyrl_BA +#define U_LID_sma_SE 0x1C3B //!< sma_SE +#define U_LID_ar_OM 0x2001 //!< ar_OM +#define U_LID_el_2_GR 0x2008 //!< el_2_GR +#define U_LID_en_JM 0x2009 //!< en_JM +#define U_LID_es_VE 0x200A //!< es_VE +#define U_LID_bs_Cyrl_BA 0x201A //!< bs_Cyrl_BA +#define U_LID_sms_FI 0x203B //!< sms_FI +#define U_LID_ar_YE 0x2401 //!< ar_YE +#define U_LID_ar_029 0x2409 //!< ar_029 +#define U_LID_es_CO 0x240A //!< es_CO +#define U_LID_smn_FI 0x243B //!< smn_FI +#define U_LID_ar_SY 0x2801 //!< ar_SY +#define U_LID_en_BZ 0x2809 //!< en_BZ +#define U_LID_es_PE 0x280A //!< es_PE +#define U_LID_ar_JO 0x2C01 //!< ar_JO +#define U_LID_en_TT 0x2C09 //!< en_TT +#define U_LID_es_AR 0x2C0A //!< es_AR +#define U_LID_ar_LB 0x3001 //!< ar_LB +#define U_LID_en_ZW 0x3009 //!< en_ZW +#define U_LID_es_EC 0x300A //!< es_EC +#define U_LID_ar_KW 0x3401 //!< ar_KW +#define U_LID_en_PH 0x3409 //!< en_PH +#define U_LID_es_CL 0x340A //!< es_CL +#define U_LID_ar_AE 0x3801 //!< ar_AE +#define U_LID_es_UY 0x380A //!< es_UY +#define U_LID_ar_BH 0x3C01 //!< ar_BH +#define U_LID_es_PY 0x3C0A //!< es_PY +#define U_LID_ar_QA 0x4001 //!< ar_QA +#define U_LID_en_IN 0x4009 //!< en_IN +#define U_LID_es_BO 0x400A //!< es_BO +#define U_LID_en_MY 0x4409 //!< en_MY +#define U_LID_es_SV 0x440A //!< es_SV +#define U_LID_en_SG 0x4809 //!< en_SG +#define U_LID_es_HN 0x480A //!< es_HN +#define U_LID_es_NI 0x4C0A //!< es_NI +#define U_LID_es_PR 0x500A //!< es_PR +#define U_LID_es_US 0x540A //!< es_US +#define U_LID_zh_Hant 0x7C04 //!< zh_Hant +#define U_LID_SEC_MASK 0xFB00 //!< Mask for region part of LID +#define U_LID_PRI_MASK 0x03FF //!< MASK for languagepart of LID +/** @} */ + +/** \defgroup U_PMF_LCT_ PMF LineCapType Enumeration + For + EMF+ manual 2.1.1.18, Microsoft name: LineCapType Enumeration (U_LCT_*) + @{ +*/ +#define U_LCT_Flat 0x00 //!< Flat line cap +#define U_LCT_Square 0x01 //!< Square line cap +#define U_LCT_Round 0x02 //!< Round line cap +#define U_LCT_Triangle 0x03 //!< Triangle line cap +#define U_LCT_NoAnchor 0x10 //!< No Anchor line cap +#define U_LCT_SquareAnchor 0x11 //!< Square Anchor line cap +#define U_LCT_RoundAnchor 0x12 //!< Round Anchor line cap +#define U_LCT_DiamondAnchor 0x13 //!< Diamond Anchor line cap +#define U_LCT_ArrowAnchor 0x14 //!< Arrow Anchor line cap +#define U_LCT_AnchorMask 0xF0 //!< Ancho rMask line cap +#define U_LCT_Custom 0xFF //!< Custom line cap +/** @} */ + +/** \defgroup U_PMF_LJT_ PMF LineJoinType Enumeration + For + EMF+ manual 2.1.1.19, Microsoft name: LineJoinType Enumeration (U_LJT_*) + @{ +*/ +#define U_LJT_Miter 0x00 //!< Miter line join +#define U_LJT_Bevel 0x01 //!< Bevel line join +#define U_LJT_Round 0x02 //!< Round line join +#define U_LJT_MiterClipped 0x03 //!< Miter Clipped line join +/** @} */ + +/** \defgroup U_PMF_LS_ PMF LineStyle Enumeration + For + EMF+ manual 2.1.1.20, Microsoft name: LineStyle Enumeration (U_LS_*) + @{ +*/ +#define U_LS_Solid 0x00 //!< Solid line +#define U_LS_Dash 0x01 //!< Dashed line +#define U_LS_Dot 0x02 //!< Dotted line +#define U_LS_DashDot 0x03 //!< Dash Dot line +#define U_LS_DashDotDot 0x04 //!< Dash Dot Dot line +#define U_LS_Custom 0x05 //!< Custom line +/** @} */ + +/** \defgroup U_PMF_MDT_ PMF MetafileDataType Enumeration + For + EMF+ manual 2.1.1.21, Microsoft name: MetafileDataType Enumeration (U_MDT_*) + @{ +*/ +#define U_MDT_Wmf 0x01 //!< WMF metafile +#define U_MDT_WmfPlaceable 0x02 //!< WMF placeable metafile +#define U_MDT_Emf 0x03 //!< EMF metafile +#define U_MDT_EmfPlusOnly 0x04 //!< EMF+ single mode metafile +#define U_MDT_EmfPlusDual 0x05 //!< EMF+ dual mode metafile +/** @} */ + +/** \defgroup U_PMF_OT_ PMF ObjectType Enumeration + For + EMF+ manual 2.1.1.22, Microsoft name: ObjectType Enumeration (U_OT_*) + @{ +*/ +#define U_OT_Invalid 0x00 //!< Invalid object +#define U_OT_Brush 0x01 //!< Brush object +#define U_OT_Pen 0x02 //!< Pen object +#define U_OT_Path 0x03 //!< Path object +#define U_OT_Region 0x04 //!< Region object +#define U_OT_Image 0x05 //!< Image object +#define U_OT_Font 0x06 //!< Font object +#define U_OT_StringFormat 0x07 //!< StringFormat object +#define U_OT_ImageAttributes 0x08 //!< ImageAttributes object +#define U_OT_CustomLineCap 0x09 //!< CustomLineCap object +/** @} */ + +/** \defgroup U_PMF_PPT_ PMF PathPointType Enumeration + For + EMF+ manual 2.1.1.23, Microsoft name: PathPointType Enumeration (U_PPT_*) + @{ +*/ +#define U_PPT_Start 0x00 //!< Start of path +#define U_PPT_Line 0x01 //!< Line path +#define U_PPT_Bezier 0x03 //!< Bezier path +#define U_PPT_MASK 0x0F //!< MASK for bits in flag +/** @} */ + +/** \defgroup U_PMF_PA_ PMF PenAlignment Enumeration + For + EMF+ manual 2.1.1.24, Microsoft name: PenAlignment Enumeration (U_PA_*) + @{ +*/ +#define U_PA_Center 0x00 //!< Center pen alignment +#define U_PA_Inset 0x01 //!< Inset pen alignment +#define U_PA_Left 0x02 //!< Left pen alignment +#define U_PA_Outset 0x03 //!< Outset pen alignment +#define U_PA_Right 0x04 //!< Right pen alignment +/** @} */ + +/** \defgroup U_PMF_PF_ PMF PixelFormat Enumeration + For U_PMF_BITMAP PxFormat field + EMF+ manual 2.1.1.25, Microsoft name: PixelFormat Enumeration (U_PF_*) + + Bitmap for this 32 bit value is: + 0-9 ignored + 10 Set: 32 bit ARGB; Clear: !32 bit ARGB + 11 Set: 16 bits/channel; Clear: !16 bits + 12 Set: colors premultiplied by alpha; Clear: !premultiplied + 13 Set: has Alpha; Clear: !has Alpha + 14 Set: Windows GDI supports; Clear: !Windows GDI supports + 15 Set: uses LUT; Clear !uses LUT + 16-23 = total number of BITS per pixel + 24-31 = pixel format enumeration index (0->15) + @{ +*/ +#define U_PF_Undefined 0x00000000 //!< undefined Pixel Format +#define U_PF_1bppIndexed 0x00030101 //!< monochrome with LUT +#define U_PF_4bppIndexed 0x00030402 //!< 4 bit with LUT +#define U_PF_8bppIndexed 0x00030803 //!< 8 bit with LUT +#define U_PF_16bppGrayScale 0x00101004 //!< 16 bits grey values +#define U_PF_16bppRGB555 0x00021005 //!< 16 bit RGB values (5,5,5,(1 ignored)) +#define U_PF_16bppRGB565 0x00021006 //!< 16 bit RGB values (5,6,5) +#define U_PF_16bppARGB1555 0x00061007 //!< 16 bit ARGB values (1 alpha, 5,5,5 colors) +#define U_PF_24bppRGB 0x00021808 //!< 24 bit RGB values (8,8.8) +#define U_PF_32bppRGB 0x00022009 //!< 32 bit RGB value (8,8,8,(8 ignored)) +#define U_PF_32bppARGB 0x0026200A //!< 32 bit ARGB values (8 alpha,8,8,8) +#define U_PF_32bppPARGB 0x000E200B //!< 32 bit PARGB values (8,8,8,8, but RGB already multiplied by A) +#define U_PF_48bppRGB 0x0010300C //!< 48 bit RGB (16,16,16) +#define U_PF_64bppARGB 0x0034400D //!< 64 bit ARGB (16 alpha, 16,16,16) +#define U_PF_64bppPARGB 0x001A400E //!< 64 bit PARGB (16,16,16,16, but RGB already multiplied by A) +/** @} */ + +/** \defgroup U_PMF_POM_ PMF PixelOffsetMode Enumeration + For + EMF+ manual 2.1.1.26, Microsoft name: PixelOffsetMode Enumeration (U_POM_*) + @{ +*/ +#define U_POM_Default 0x00 //!< center at {0.0,0.0} +#define U_POM_HighSpeed 0x01 //!< center at {0.0,0.0} +#define U_POM_HighQuality 0x02 //!< center at {0.5,0.5} +#define U_POM_None 0x03 //!< center at {0.0,0.0} +#define U_POM_Half 0x04 //!< center at {0.5,0.5} +/** @} */ + +/** \defgroup U_PMF_RNDT_ PMF RegionNodeDataType Enumeration + For + EMF+ manual 2.1.1.27, Microsoft name: RegionNodeDataType Enumeration (U_RNDT_*) + @{ +*/ +#define U_RNDT_Kids 0x00000000 //!< One of the next 5 is to be applied +#define U_RNDT_And 0x00000001 //!< AND the child nodes +#define U_RNDT_Or 0x00000002 //!< OR the child nodes +#define U_RNDT_Xor 0x00000003 //!< XOR the child nodes +#define U_RNDT_Exclude 0x00000004 //!< Part of 1st child node not in 2nd child node +#define U_RNDT_Complement 0x00000005 //!< Part of 2nd child node not in 1st child node +#define U_RNDT_Rect 0x10000000 //!< Child node is a rectangle +#define U_RNDT_Path 0x10000001 //!< Child node is a path +#define U_RNDT_Empty 0x10000002 //!< Child node is empty +#define U_RNDT_Infinite 0x10000003 //!< Child node has infinite extent (?) +/** @} */ + +/** \defgroup U_PMF_SM_ PMF SmoothingMode Enumeration + For + EMF+ manual 2.1.1.28, Microsoft name: SmoothingMode Enumeration (U_SM_*) + @{ +*/ +#define U_SM_Default 0x00 //!< Default smoothing +#define U_SM_HighSpeed 0x01 //!< High Speed smoothing +#define U_SM_HighQuality 0x02 //!< High Quality smoothing +#define U_SM_None 0x03 //!< No smoothing +#define U_SM_AntiAlias8x4 0x04 //!< Anti Alias 8x4 smoothing +#define U_SM_AntiAlias8x8 0x05 //!< Anti Alias 8x8 smoothing +/** @} */ + +/** \defgroup U_PMF_SA_ PMF StringAlignment Enumeration + For + EMF+ manual 2.1.1.29, Microsoft name: StringAlignment Enumeration (U_SA_*) + + Note, that unlike EMF these are with respect to the bounding rectangle, not to a single point. So + to draw centered text, for instance, U_SA_Center must be used, and the bounding rectangle must also be + centered. + + For horizontal positioning of L->R text Near is all the way left in the box, Far is all the way right, + and Center puts the center of the text in the center of the box. + + For vertical positioning things are a little strange. Near is a certain distance down from the top, Far is a + certain distance up from the bottom, and center puts the center of the text in the center of the box. The + "certain distance" is not specified in the EMF+ documentation. See the function U_PMR_drawstring() for an + implementation that places text on the baseline. + @{ +*/ +#define U_SA_Near 0x00 //!< Position near +#define U_SA_Center 0x01 //!< Position center +#define U_SA_Far 0x02 //!< Position far +/** @} */ + +/** \defgroup U_PMF_SDS_ PMF StringDigitSubstitution Enumeration + For + EMF+ manual 2.1.1.30, Microsoft name: StringDigitSubstitution Enumeration (U_SDS_*) + @{ +*/ +#define U_SDS_User 0x00 //!< Digit substitution is set by implementation +#define U_SDS_None 0x01 //!< No Digit substitution +#define U_SDS_National 0x02 //!< Digit substitution by official locale +#define U_SDS_Traditional 0x03 //!< Digit substitution by traditional locale +/** @} */ + +/** \defgroup U_PMF_ST_ PMF StringTrimming Enumeration + For + EMF+ manual 2.1.1.31, Microsoft name: StringTrimming Enumeration (U_ST_*) + @{ +*/ +#define U_ST_None 0x00 //!< no string trimming +#define U_ST_Character 0x01 //!< Trim at Character +#define U_ST_Word 0x02 //!< Trim at Word +#define U_ST_EllipsisCharacter 0x03 //!< Trim at Ellipsis Character +#define U_ST_EllipsisWord 0x04 //!< Trim at Ellipsis Word +#define U_ST_EllipsisPath 0x05 //!< Trim at Ellipsis Path +/** @} */ + +/** \defgroup U_PMF_TRH_ PMF TextRenderingHint Enumeration + For + EMF+ manual 2.1.1.32, Microsoft name: TextRenderingHint Enumeration (U_TRH_*) + @{ +*/ +#define U_TRH_SystemDefault 0x00 //!< System Default +#define U_TRH_SingleBitPerPixelGridFit 0x01 //!< Single Bit Per Pixel Grid Fit +#define U_TRH_SingleBitPerPixel 0x02 //!< Single Bit Per Pixel +#define U_TRH_AntialiasGridFit 0x03 //!< Antialias Grid Fit +#define U_TRH_Antialias 0x04 //!< Antialias +#define U_TRH_ClearTypeGridFit 0x05 //!< ClearType Grid Fit +/** @} */ + +/** \defgroup U_PMF_UT_ PMF UnitType Enumeration + For + EMF+ manual 2.1.1.33, Microsoft name: UnitType Enumeration (U_UT_*) + @{ +*/ +#define U_UT_World 0x00 //!< World units +#define U_UT_Display 0x01 //!< Display units +#define U_UT_Pixel 0x02 //!< Pixel units +#define U_UT_Point 0x03 //!< Point units +#define U_UT_Inch 0x04 //!< Inch units +#define U_UT_Document 0x05 //!< Document units +#define U_UT_Millimeter 0x06 //!< Millimeter units +/** @} */ + +/** \defgroup U_PMF_WM_ PMF WrapMode Enumeration + For + EMF+ manual 2.1.1.34, Microsoft name: WrapMode Enumeration (U_WM_*) + @{ +*/ +#define U_WM_Tile 0x00000000 //!< Tile +#define U_WM_TileFlipX 0x00000001 //!< Reverse horizontally then tile +#define U_WM_TileFlipY 0x00000002 //!< Reverse vertically then tile +#define U_WM_TileFlipXY 0x00000003 //!< Reverse horizontally and vertically then tile +#define U_WM_Clamp 0x00000004 //!< Clamp pattern to the object boundary +/** @} */ + +/** \defgroup U_PMF_BD_ PMF BrushData Flags + For + EMF+ manual 2.1.2.1, Microsoft name: BrushData Flags (U_BD_*) + + Bit flags allowed in brush object types. Each bit indicates a type of object which is included. + There are 5 brush types abbreviated A through E, and each uses a subset of the + BrushData Flags, as summarized in the following table: + + Bits Brush____Type EMF+ Manual + used Abbrev. Name + 5 A U_PMF_LINEARGRADIENTBRUSHDATA 2.2.2.24 + 6 B U_PMF_PATHGRADIENTBRUSHDATA 2.2.2.29 + 3 C U_PMF_TEXTUREBRUSHDATA 2.2.2.45 + 0 D U_PMF_HATCHBRUSHDATA 2.2.2.20 + 0 E U_PMF_SOLIDBRUSHDATA 2.2.2.45 + @{ +*/ +#define U_BD_None 0x0000 //!< no bits set +#define U_BD_Path 0x0001 //!< Path, in {B} +#define U_BD_Transform 0x0002 //!< Transform in {ABC} +#define U_BD_PresetColors 0x0004 //!< PresetColors in {AB} +#define U_BD_BlendFactorsH 0x0008 //!< BlendFactorsH in {AB} +#define U_BD_BlendFactorsV 0x0010 //!< BlendFactorsV in {A} - Note, not actually implemented in GDI+. +#define U_BD_NoBit 0x0020 //!< unused bit +#define U_BD_FocusScales 0x0040 //!< Focus Scales in {B} +#define U_BD_IsGammaCorrected 0x0080 //!< GammaCorrected in {ABC} +#define U_BD_DoNotTransform 0x0100 //!< Ignore world to device transform in {C} +#define U_BD_MASKA 0x009E //!< all bits that MAY be set in A +#define U_BD_MASKB 0x00CF //!< all bits that MAY be set in B +#define U_BD_MASKC 0x0182 //!< all bits that MAY be set in C +/** @} */ + +/** \defgroup U_PMF_CLCD_ PMF CustomLineCapData Flags + For + EMF+ manual 2.1.2.2, Microsoft name: CustomLineCapData Flags (U_CLCD_*) + @{ +*/ +#define U_CLCD_None 0x00 //!< no bits set +#define U_CLCD_FillPath 0x01 //!< Fill Path +#define U_CLCD_LinePath 0x02 //!< Line Path +/** @} */ + +/** \defgroup U_PMF_DSO_ PMF DriverStringOptions Flags + For + EMF+ manual 2.1.2.3, Microsoft name: DriverStringOptions Flags (U_DSO_*) + @{ +*/ +#define U_DSO_None 0x00 //!< no bits set +#define U_DSO_CmapLookup 0x01 //!< Set: value is a Unicode character; Clear: value is an index into Glyph table in a font +#define U_DSO_Vertical 0x02 //!< Set: draw string verically; Clear: draw horizontally +#define U_DSO_RealizedAdvance 0x04 /**< Set: U_PMF_DRAWDRIVERSTRING Positions field specifies only position of first of Glyphs field, + with the rest calculated from font information; Clear: Positions specifies coordinates for each Glyphs member.*/ +#define U_DSO_LimitSubpixel 0x08 //!< Set: use less memory to cache anti-aliased glyphs; Clear: use more +/** @} */ + +/** \defgroup U_PMF_FS_ PMF FontStyle Flags + For + EMF+ manual 2.1.2.4, Microsoft name: FontStyle Flags (U_FS_*) +# @{ +*/ +#define U_FS_None 0x00 //!< no bits set +#define U_FS_Bold 0x01 //!< Bold +#define U_FS_Italic 0x02 //!< Italic +#define U_FS_Underline 0x04 //!< Underline +#define U_FS_Strikeout 0x08 //!< Strikeout +/** @} */ + +/** \defgroup U_PMF_PLTS_ PMF PaletteStyle Flags + For + EMF+ manual 2.1.2.5, Microsoft name: PaletteStyle Flags (U_PLTS_*) + @{ +*/ +#define U_PLTS_None 0x00 //!< no bits set +#define U_PLTS_HasAlpha 0x01 //!< Has Alpha +#define U_PLTS_GrayScale 0x02 //!< Gray Scale +#define U_PLTS_Halftone 0x04 //!< Halftone +/** @} */ + +/** \defgroup U_PMF_PTP_ PMF PathPointType Flags + For + EMF+ manual 2.1.2.6, Microsoft name: PathPointType Flags (U_PTP_*) + @{ +*/ +#define U_PTP_None 0x00 //!< no bits set +#define U_PTP_DashMode 0x10 //!< Dash Mode +#define U_PTP_PathMarker 0x20 //!< Path Marker +#define U_PTP_NoBit 0x40 //!< unused bit +#define U_PTP_CloseSubpath 0x80 //!< CloseSubpath +#define U_PTP_NotClose 0x70 //!< Everything but close +#define U_PTP_MASK 0xF0 //!< Everything +#define U_PTP_SHIFT 4 //!< offset to this bitfield +/** @} */ + +/** \defgroup U_PMF_PD_ PMF PenData Flags + For + EMF+ manual 2.1.2.7, Microsoft name: PenData Flags (U_PD_*) + +If bit is set the corresponding object must be specfied in the OptionalData field + + @{ +*/ +#define U_PD_None 0x0000 //!< no bits set +#define U_PD_Transform 0x0001 //!< Transform +#define U_PD_StartCap 0x0002 //!< Start Cap +#define U_PD_EndCap 0x0004 //!< End Cap +#define U_PD_Join 0x0008 //!< Join +#define U_PD_MiterLimit 0x0010 //!< Miter Limit +#define U_PD_LineStyle 0x0020 //!< Line Style +#define U_PD_DLCap 0x0040 //!< Dashed Line Cap +#define U_PD_DLOffset 0x0080 //!< Dashed Line Offset +#define U_PD_DLData 0x0100 //!< Dashed Line Data +#define U_PD_NonCenter 0x0200 //!< Alignment must be specified with optinal data +#define U_PD_CLData 0x0400 //!< Compound Line Data +#define U_PD_CustomStartCap 0x0800 //!< Custom Start Cap +#define U_PD_CustomEndCap 0x1000 //!< Custom End Cap +/** @} */ + +/** \defgroup U_PMF_SF_ PMF StringFormat Flags + For EmfPlusStringFormat + EMF+ manual 2.1.2.8, Microsoft name: StringFormat Flags (U_SF_*) + @{ +*/ +#define U_SF_None 0x00000000 //!< no bits set +#define U_SF_DirectionRightToLeft 0x00000001 //!< text Right to Left +#define U_SF_DirectionVertical 0x00000002 //!< text Left to Right +#define U_SF_NoFitBlackBox 0x00000004 //!< text not restricted to layout bbox +#define U_SF_NoBit4 0x00000008 //!< unused bit +#define U_SF_NoBit5 0x00000010 //!< unused bit +#define U_SF_DisplayFormatControl 0x00000020 //!< control codes display as "representative" glyphs +#define U_SF_NoBit7 0x00000040 //!< unused bit +#define U_SF_NoBit8 0x00000080 //!< unused bit +#define U_SF_NoBit9 0x00000100 //!< unused bit +#define U_SF_NoBit10 0x00000200 //!< unused bit +#define U_SF_NoFontFallback 0x00000400 //!< show as missing glyph if not in font +#define U_SF_MeasureTrailingSpaces 0x00000800 //!< trailing spaces included in line length +#define U_SF_NoWrap 0x00001000 //!< text does not wrap +#define U_SF_LineLimit 0x00002000 //!< emit whole lines if not clipped +#define U_SF_NoClip 0x00004000 //!< text is not clipped +#define U_SF_BypassGDI 0x80000000 //!< use implementation specific text rendering instead of GDI +/** @} */ + +/** \defgroup U_PMF_IE_ PMF ImageEffects Identifiers + For + EMF+ manual 2.1.3.1, Microsoft name: ImageEffects Identifiers (U_IE_*) + @{ +*/ +#define U_IE_BlurEffectGuid "{633C80A4-1843-482B-9EF2-BE2834C5FDD4}" //!< Blur Effect +#define U_IE_BrightnessContrastEffectGuid "{D3A1DBE1-8EC4-4C17-9F4C-EA97AD1C343D}" //!< Brightness Contrast Effect +#define U_IE_ColorBalanceEffectGuid "{537E597D-251E-48DA-9664-29CA496B70F8}" //!< Color Balance Effect +#define U_IE_ColorCurveEffectGuid "{DD6A0022-58E4-4A67-9D9B-D48EB881A53D}" //!< Color Curve Effect +#define U_IE_ColorLookupTableEffectGuid "{A7CE72A9-0F7F-40D7-B3CC-D0C02D5C3212}" //!< Color Lookup Table Effect +#define U_IE_ColorMatrixEffectGuid "{718F2615-7933-40E3-A511-5F68FE14DD74}" //!< Color Matrix Effect +#define U_IE_HueSaturationLightnessEffectGuid "{8B2DD6C3-EB07-4D87-A5F0-7108E26A9C5F}" //!< Hue Saturation Lightness Effect +#define U_IE_LevelsEffectGuid "{99C354EC-2A31-4F3A-8C34-17A803B33A25}" //!< Levels Effect +#define U_IE_RedEyeCorrectionEffectGuid "{74D29D05-69A4-4266-9549-3CC52836B632}" //!< Red Eye Correction Effect +#define U_IE_SharpenEffectGuid "{63CBF3EE-C526-402C-8F71-62C540BF5142}" //!< Sharpen Effect +#define U_IE_TintEffectGuid "{1077AF00-2848-4441-9489-44AD4C2D7A2C}" //!< Tint Effect +/** @} */ + +/** \defgroup U_PMF_IEE_ PMF ImageEffects Enumerators + based on U_IE_ + These may be used by a parser to set up for a switch() statement. + @{ +*/ +#define U_IEE_Unknown 0 //!< none of the following +#define U_IEE_BlurEffectGuid 1 //!< Blur Effect +#define U_IEE_BrightnessContrastEffectGuid 2 //!< Brightness Contrast Effect +#define U_IEE_ColorBalanceEffectGuid 3 //!< Color Balance Effect +#define U_IEE_ColorCurveEffectGuid 4 //!< Color Curve Effect +#define U_IEE_ColorLookupTableEffectGuid 5 //!< Color Lookup Table Effect +#define U_IEE_ColorMatrixEffectGuid 6 //!< Color Matrix Effect +#define U_IEE_HueSaturationLightnessEffectGuid 7 //!< Hue Saturation Lightness Effect +#define U_IEE_LevelsEffectGuid 8 //!< Levels Effect +#define U_IEE_RedEyeCorrectionEffectGuid 9 //!< Red Eye Correction Effect +#define U_IEE_SharpenEffectGuid 10 //!< Sharpen Effect +#define U_IEE_TintEffectGuid 11 //!< Tint Effect +/** @} */ + +/** \defgroup U_PMF_OC_ PMF ObjectClamp Identifiers + For U_PMF_IMAGEATTRIBUTES ObjectClamp field + EMF+ manual 2.2.1.5, Microsoft name: ImageEffects Identifiers (U_OC_*) + @{ +*/ +#define U_OC_Rect 0x00 //!< Clamp object to rectangle. +#define U_OC_Bitmap 0x01 //!< Clamp object to bitmap. +/** @} */ + +/** \defgroup U_PMF_PPF_ PMF PathPoint Flags + For U_PMF_PATH Flags field + For U_PMF_CMN_HDR Flags field + EMF+ manual 2.2.1.6, Microsoft name: PathPoint Flags (U_PPF_*) + For U_PMF_CMN_HDR Flags the bits are scattered all over the EMF+ manual. + NOTE: bitfields in manual are BIG endian and MSB 0. + This code reads the 16 bit flag field as LITTLE endian and uses LSB 0. + The values shown are AFTER the data has been read into a uint16_t and the byte order set + appropriately. + All of these come out of a 16 bit field. + @{ +*/ +#define U_PPF_B 0x8000 //!< 15 Set: BrushID is an U_PFM_ARGB; Clear: is index of U_PMF_BRUSH object in EMF+ object table. +#define U_PPF_BZ 0x8000 //!< 15 Set: Points are on a Bezier curve; Clear: Points are on a line +#define U_PPF_N 0x8000 //!< 15 Set: object definition continues in next record; Clear: this is the final object definition record +#define U_PPF_K 0x8000 //!< 15 Set: int16_t coordinates; Clear: use U_FLOAT coordinates +#define U_PPF_C 0x4000 //!< 14 Set: int16_t coordinates; Clear: use U_FLOAT coordinates +#define U_PPF_XM 0x2000 //!< 13 Set: Post multiply matrix; Clear: Pre multiply matrix +#define U_PPF_F 0x2000 //!< 13 Set: winding fill; Clear: alternate fill +#define U_PPF_E 0x2000 //!< 13 Set: effect from previous U_PMF_SERIALIZABLEOBJECT record will be applied,; Clear: no effect applied +#define U_PPF_R 0x1000 //!< 12 Set: U_PMF_PathPointTypeRLE and/or U_PMF_PathPointType objects; Clear: only U_PMF_PathPointType +#define U_PPF_P 0x0800 //!< 11 Set: relative coordinates; Clear absolute coordinates +#define U_PPF_D 0x0400 //!< 10 Set: draw path closed; Clear: draw path open +#define U_PPF_VGA 0x0002 //!< 1 Set: Palette is VGA basic colors; Clear: Palette is ??? +#define U_PPF_PP 0x0001 //!< 0 Set: Palette field is present; Clear: Palette field is absent +#define U_PPF_DM 0x0001 //!< 0 Set: Dual-mode file; Clear: EMF+ only file +#define U_PPF_AA 0x0001 //!< 0 Set: anti-aliasing on; Clear: anti-aliasing off +#define U_PPF_VIDEO 0x0001 //!< 0 Set: reference device is video display; Clear: reference devis is printer +/** @} */ + +/** \defgroup U_PMF_FF_ PMF Masks and offsets for 16 bit flag fields + Documenting the OBSERVED positions of fields in 16 bit flag integers + after they have been read in Little Ended from files. + + Note, some of these are used in more than one record type, only a single reference is provided + @{ +*/ + +#define U_FF_MASK_SUBLID 0x003F //!< EMF+ manual 2.2.2.23, Microsoft name: EmfPlusLanguageIdentifier +#define U_FF_SHFT_SUBLID 0x000A //!< EMF+ manual 2.2.2.23, Microsoft name: EmfPlusLanguageIdentifier +#define U_FF_MASK_PRILID 0x03FF //!< EMF+ manual 2.2.2.23, Microsoft name: EmfPlusLanguageIdentifier +#define U_FF_SHFT_PRILID 0x0000 //!< EMF+ manual 2.2.2.23, Microsoft name: EmfPlusLanguageIdentifier +#define U_FF_MASK_LID 0xFFFF //!< EMF+ manual 2.2.2.23, Microsoft name: EmfPlusLanguageIdentifier +#define U_FF_SHFT_LID 0x0000 //!< EMF+ manual 2.2.2.23, Microsoft name: EmfPlusLanguageIdentifier +#define U_FF_MASK_RL 0x003F //!< EMF+ manual 2.2.2.32, Microsoft name: EmfPlusPathPointTypeRLE +#define U_FF_SHFT_RL 0x0008 //!< EMF+ manual 2.2.2.32, Microsoft name: EmfPlusPathPointTypeRLE +#define U_FF_MASK_PPT 0x00FF //!< EMF+ manual 2.2.2.32, Microsoft name: EmfPlusPathPointTypeRLE +#define U_FF_SHFT_PPT 0x0000 //!< EMF+ manual 2.2.2.32, Microsoft name: EmfPlusPathPointTypeRLE +/* the next one is used most places an object ID is specified */ +#define U_FF_MASK_OID8 0x00FF //!< EMF+ manual 2.3.1.3, Microsoft name: EmfPlusSetClipPath +#define U_FF_SHFT_OID8 0x0000 //!< EMF+ manual 2.3.1.3, Microsoft name: EmfPlusSetClipPath +#define U_FF_MASK_CM4 0x000F //!< EMF+ manual 2.3.1.3, Microsoft name: EmfPlusSetClipPath +#define U_FF_SHFT_CM4 0x0008 //!< EMF+ manual 2.3.1.3, Microsoft name: EmfPlusSetClipPath +#define U_FF_MASK_OT 0x003F //!< EMF+ manual 2.3.5.1, Microsoft name: EmfPlusObject +#define U_FF_SHFT_OT 0x0008 //!< EMF+ manual 2.3.5.1, Microsoft name: EmfPlusObject +#define U_FF_MASK_AA 0x007F //!< EMF+ manual 2.3.6.1, Microsoft name: EmfPlusSetAntiAliasMode +#define U_FF_SHFT_AA 0x0001 //!< EMF+ manual 2.3.6.1, Microsoft name: EmfPlusSetAntiAliasMode +#define U_FF_MASK_CM 0x00FF //!< EMF+ manual 2.3.6.2, Microsoft name: EmfPlusSetCompositingMode +#define U_FF_SHFT_CM 0x0000 //!< EMF+ manual 2.3.6.2, Microsoft name: EmfPlusSetCompositingMode +#define U_FF_MASK_CQ 0x00FF //!< EMF+ manual 2.3.6.3, Microsoft name: EmfPlusSetCompositingQuality +#define U_FF_SHFT_CQ 0x0000 //!< EMF+ manual 2.3.6.3, Microsoft name: EmfPlusSetCompositingQuality +#define U_FF_MASK_IM 0x00FF //!< EMF+ manual 2.3.6.4, Microsoft name: EmfPlusSetInterpolationMode +#define U_FF_SHFT_IM 0x0000 //!< EMF+ manual 2.3.6.4, Microsoft name: EmfPlusSetInterpolationMode +#define U_FF_MASK_PxOffM 0x00FF //!< EMF+ manual 2.3.6.5, Microsoft name: EmfPlusSetPixelOffsetMode +#define U_FF_SHFT_PxOffM 0x0000 //!< EMF+ manual 2.3.6.5, Microsoft name: EmfPlusSetPixelOffsetMode +#define U_FF_MASK_TGC 0x0FFF //!< EMF+ manual 2.3.6.7, Microsoft name: EmfPlusSetTextContrast +#define U_FF_SHFT_TGC 0x0000 //!< EMF+ manual 2.3.6.7, Microsoft name: EmfPlusSetTextContrast +#define U_FF_MASK_TRH 0x00FF //!< EMF+ manual 2.3.6.8, Microsoft name: EmfPlusSetTextRenderingHint +#define U_FF_SHFT_TRH 0x0000 //!< EMF+ manual 2.3.6.8, Microsoft name: EmfPlusSetTextRenderingHint +#define U_FF_MASK_UT 0x00FF //!< EMF+ manual 2.3.7.1, Microsoft name: EmfPlusBeginContainer +#define U_FF_SHFT_UT 0x0008 //!< EMF+ manual 2.3.7.1, Microsoft name: EmfPlusBeginContainer +#define U_FF_MASK_TSC 0x7FFF //!< EMF+ manual 2.3.8.1, Microsoft name: EmfPlusSetTSClip +#define U_FF_SHFT_TSC 0x0000 //!< EMF+ manual 2.3.8.1, Microsoft name: EmfPlusSetTSClip +#define U_FF_MASK_PU 0x00FF //!< EMF+ manual 2.3.9.5, Microsoft name: EmfPlusSetPageTransform +#define U_FF_SHFT_PU 0x0000 //!< EMF+ manual 2.3.9.5, Microsoft name: EmfPlusSetPageTransform +/** @} */ + + +/** \defgroup U_PMF_GFVR_ PMF MetafileSignature + For U_PMF_GRAPHICSVERSION Signature field + EMF+ manual 2.2.2.19, Microsoft name: (none) (U_GFVR_*) + @{ +*/ +#define U_GFVR_PMF 0x000DBC01 //!< indicates an EMF+ metafile +#define U_GFVR_MASKHI 0xFFFFF000 //!< mask for the signature bit field (20 bits) +#define U_GFVR_MASKLO 0x00000FFF //!< mask for the version bit field (12 bits) +/** @} */ + +/** \defgroup U_PMF_XM_ PMF Matrix Multiplication Enumerator + For U_PMF_RotateWorldTransform and others + EMF+ manual 2.3.9.3, Microsoft name: (none) (U_XM_*) + @{ +*/ +#define U_XM_PostX 1 //!< Post Multiply change to current Transformation Matrix +#define U_XM_PreX 0 //!< Pre Multiply change to current Transformation Matrix +/** @} */ + + +/* Utility objects, not defined in EMF+ spec */ + +/** @brief Used to accumulate data for objects continued over multiple records. + see EMF+ manual 2.3.5.1 +*/ +typedef struct { + char *accum; /**< data accumulates here */ + uint32_t space; /**< bytes allocated */ + uint32_t used; /**< bytes in use */ + int Type; /**< ObjectType enumeration */ + int Id; /**< Object ID */ +} U_OBJ_ACCUM; + +/** @brief Holds EMF+ objects and records in EMF+ file format byte order. +*/ +typedef struct { + char *Data; /**< Buffer that hold's the PseudoObject's data */ + size_t Size; /**< Number of bytes allocated in Data (may be >Used if padding is present) */ + size_t Used; /**< Number of data bytes that are stored in Data */ + uint32_t Type; /**< Type numbers are from manual section: 1.2.3.4 -> 10203040 */ +} U_PSEUDO_OBJ; + +/** @brief DoublePseudoObject holds pairs of PseudoObjects. Used for constructing paths along with their types. + The data stored in the PsuedoObjects maintains LittleEndian-ness, as expected in the final file. + The type is U_RAW_OID, and there is no elements count at the beginning of Data +*/ +typedef struct { + uint32_t Elements; /**< Element count, applies to both PseudoObjects */ + U_PSEUDO_OBJ *poPoints; /**< Points in path */ + U_PSEUDO_OBJ *poTypes; /**< Types of points in path */ +} U_DPSEUDO_OBJ; + +/** @brief Serializer description records. + +An array of these are passed to U_PMF_SERIAL_set() to construct EMF+ objects from their component parts. +The U_PMF_SERIAL_set() function should not ever be called directly by end user code. +*/ +typedef struct { + const void *Ptr; /**< Pointer to the first byte of the data field. + Each data field is an array of a basic type of Units + bytes repeated Reps times */ + size_t Units; /**< Number of bytes in each unit of each data field. */ + size_t Reps; /**< MNumber of repeats of Units in eah data field. */ + int TE; /**< (Target Endian). Only relevant for Units of 2 or 4*/ +} U_SERIAL_DESC; + +/** @brief FontInfoParams hold font information that is needed by U_PMR_drawstring so that it can + place text on the baseline. This must be extracted from the font file using + an appropriate utility. (See testbed_pmf.c for a table of these values for some + common fonts.) +*/ +typedef struct { + char *name; /**< Font name (like "Arial") */ + int Ascent; /**< in Font units (positive) */ + int Descent; /**< in Font units (negative) */ + int LineGap; /**< in Font units (positive) */ + int EmSize; /**< Y extent of Em square, usually 2048 */ + int yMax; /**< in Font units (positive) */ + int yMin; /**< in Font units (negative) */ +} U_FontInfoParams; + + + +/* EMF+ objects */ + +/** @brief EMF+ manual 2.2.1.1, Microsoft name: EmfPlusBrush Object + +variable part of object follows structure: + uint32_t Data[]; // one of the 5 types of Brush data (2.2.2 20, 24, 29, 43, or 45) +*/ +typedef struct { + uint32_t Version; //!< EmfPlusGraphicsVersion object + uint32_t Type; //!< BrushType Enumeration +} U_PMF_BRUSH; + +/** @brief EMF+ manual 2.2.1.2, Microsoft name: EmfPlusCustomLineCap Object */ +typedef struct { +/*@{*/ + uint32_t Version; //!< EmfPlusGraphicsVersion object + uint32_t Type; //!< BrushType Enumeration +/* variable part of object, not part of structure + uint32_t Data[]; //!< one of the 2 types of Linecap data (2.2.2 12, 13) +*/ +/*@}*/ +} U_PMF_CUSTOMLINECAP; + +/** @brief EMF+ manual 2.2.1.3, Microsoft name: EmfPlusFont Object */ +typedef struct { +/*@{*/ + uint32_t Version; //!< EmfPlusGraphicsVersion object + U_FLOAT EmSize; //!< em size in units of SizeUnit + uint32_t SizeUnit; //!< UnitType enumeration + int32_t FSFlags; //!< FontStyle flags + uint32_t Reserved; //!< ignored + uint32_t Length; //!< Number of Unicode Characters in FamilyName +/* variable part of object, not part of structure + uint16_t FamilyName[]; //!< Unicode (UTF-16LE) name of font family +*/ +/*@}*/ +} U_PMF_FONT; + +/** @brief EMF+ manual 2.2.1.4, Microsoft name: EmfPlusImage Object */ +typedef struct { +/*@{*/ + uint32_t Version; //!< EmfPlusGraphicsVersion object + uint32_t Type; //!< ImageDataType Enumeration +/* variable part of object, not part of structure + uint32_t Data[]; //!< one of the 2 types of image data (2.2.2 2 or 27) +*/ +/*@}*/ +} U_PMF_IMAGE; + +/** @brief EMF+ manual 2.2.2.1, Microsoft name: EmfPlusARGB Object, out of order, needed for 2.2.1.5 */ +typedef struct { +/*@{*/ + uint8_t Blue; //!< Blue color (0-255) + uint8_t Green; //!< Green color (0-255) + uint8_t Red; //!< Red color (0-255) + uint8_t Alpha; //!< Alpha (0-255) +/*@}*/ +} U_PMF_ARGB; + +/** @brief EMF+ manual 2.2.1.5, Microsoft name: EmfPlusImageAttributes Object */ +typedef struct { + /*@{*/ + uint32_t Version; //!< EmfPlusGraphicsVersion object + uint32_t Reserved1; //!< ignored + uint32_t WrapMode; //!< WrapMode object + U_PMF_ARGB ClampColor; //!< EmfPlusARGB object + int32_t ObjectClamp; //!< ObjectClamp Identifiers + uint32_t Reserved2; //!< ignored +/*@}*/ +} U_PMF_IMAGEATTRIBUTES; + +/** @brief EMF+ manual 2.2.1.6, Microsoft name: EmfPlusPath Object */ +typedef struct { +/*@{*/ + uint32_t Version; //!< EmfPlusGraphicsVersion object + uint32_t Count; //!< points and point types in this object + uint16_t Flags; //!< PathPoint Flags +/* variable part of object, not part of structure + points array of points like: + U_PPF_P U_PPF_C Type + 1 x U_PMF_POINTR + 0 1 U_PMF_POINT + 0 0 U_PMF_POINTF + types array of:. + U_PPF_R Type + 1 U_PMF_PATHPOINTTYPERLE and/or U_PMF_PATHPOINTTYPE + 0 U_PMF_PathPointType (only) + alignment padding up to 3 bytes +*/ +/*@}*/ +} U_PMF_PATH; + +/** @brief EMF+ manual 2.2.1.7, Microsoft name: EmfPlusPen Object */ + +typedef struct { + uint32_t Version; //!< EmfPlusGraphicsVersion object + uint32_t type; //!< must be zero +/* variable part of object, not part of structure + U_PMF_PENDATA pen + U_PMF_BRUSH brush +*/ +} U_PMF_PEN; + +/** @brief EMF+ manual 2.2.2.40, Microsoft name: EmfPlusRegionNode Object, out of order, needed for 2.2.1.8 */ +typedef struct { + uint32_t Type; //!< RegionNodeDataType +/* variable part of object, not part of structure, will be absent in object for some types + data data is a tree made up of some combination of these objects + U_PMF_REGIONNODEPATH 2.2.2.42 terminal node + U_PMF_RECTF 2.2.2.39 terminal node + U_PMF_REGIONNODECHILDNODES 2.2.2.41 non-terminal node +*/ +} U_PMF_REGIONNODE; + +/** @brief EMF+ manual 2.2.1.8, Microsoft name: EmfPlusRegion Object */ +typedef struct { + uint32_t Version; //!< EmfPlusGraphicsVersion object + uint32_t Elements; //!< Number of members in Nodes array +/* variable part of object, not part of structure, will be absent in object for some types + U_PMF_REGIONNODE Nodes[1]; //!< Nodes defining region +*/ +} U_PMF_REGION; + +/** @brief EMF+ manual 2.2.2.23, Microsoft name: EmfPlusLanguageIdentifier Object, out of order, needed for 2.2.1.9 + +Bit fields are not used in structs in this implementation, these are serialized/deserialized in +the corresponding routines. Bitfields in the FILE (LITTLE endian here, manual uses BIG endian) are: + int SubLId : 6; Example: code for USA + int PriLId : 10; Example: code for English + +This type is defined as 16 bits in the manual section, but it is only ever used as part of a 32 bit field! +*/ +typedef uint32_t U_PMF_LANGUAGEIDENTIFIER; + +/** @brief EMF+ manual 2.2.1.9, Microsoft name: EmfPlusStringFormat Object */ +typedef struct { + uint32_t Version; //!< EmfPlusGraphicsVersion object + uint32_t Flags; //!< StringFormat flags + U_PMF_LANGUAGEIDENTIFIER + Language; //!< String's Language + uint32_t StringAlignment; //!< StringAlignment enumeration. + uint32_t LineAlign; //!< StringAlignment enumeration. + uint32_t DigitSubstitution; //!< StringDigitSubstitution enumeration + U_PMF_LANGUAGEIDENTIFIER + DigitLanguage; //!< Digit's Language (overrides Language, above) + U_FLOAT FirstTabOffset; //!< the number of spaces to the first tab stop. + int32_t HotkeyPrefix; //!< HotkeyPrefix enumeration + U_FLOAT LeadingMargin; //!< space before starting position (text) of a string + U_FLOAT TrailingMargin; //!< space after last position (text) of a string + U_FLOAT Tracking; //!< horizontal space alotted per character/font specification per character + uint32_t Trimming; //!< StringTrimming enumeration + uint32_t TabStopCount; //!< Number of tab stops in data field. + uint32_t RangeCount; //!< Number of U_PMF_CHARACTERRANGE objects in data field. +/* variable part of object, not part of structure. + U_PMF_STRINGFORMATDATA data + + Note that U_PMF_STRINGFORMATDATA has no struct as it is entirely variable + and the size of the two fields in it are specified by the two preceding fields in this object type. +*/ +} U_PMF_STRINGFORMAT; + +/** U_PMF_ARGB EMF+ manual 2.2.2.1, Microsoft name: EmfPlusARGB Object, defined above, before 2.2.1.6*/ + +/** @brief EMF+ manual 2.2.2.2, Microsoft name: EmfPlusBitmap Object */ +typedef struct { + int32_t Width; //!< Width in pixels + int32_t Height; //!< Height in pixels + int32_t Stride; //!< length in bytes of 1 scan line (multiple of 4) + uint32_t PxFormat; //!< PixelFormat enumeration + uint32_t Type; //!< BitmapDataType enumeration (section 2.1.1.2). +/* variable part of object, not part of structure. + (various types) BitmapData //!< is either an U_PMF_BITMAPDATA or U_PMF_COMPRESSEDIMAGE object +*/ +} U_PMF_BITMAP; + +/** U_PMF_BITMAPDATA EMF+ manual 2.2.2.3, Microsoft name: EmfPlusBitmapData Object +U_PMF_BITMAPDATA is an entirely variable object, there is no corresponding struct. It consists of + + Colors U_PMF_PALETTE object + PixelData An array of bytes, meaning depends on fields in U_PMF_BITMAP object and the PixelFormat enumeration. + +*/ + +/** @brief EMF+ manual 2.2.2.4, Microsoft name: EmfPlusBlendColors Object + For Pattern field of U_PMF_LINEARGRADIENTBRUSHOPTIONALDATA +*/ +typedef struct { + uint32_t Elements; //!< members in each array +/* variable part of object, not part of structure. + U_FLOAT Positions //!< positions along gradient line. The first position MUST be 0.0 and the last MUST be 1.0. + U_PMF_ARGB Colors //!< colors at positions on gradient line +*/ +} U_PMF_BLENDCOLORS; + +/** @brief EMF+ manual 2.2.2.5, Microsoft name: EmfPlusBlendFactors Object */ +typedef struct { + uint32_t Elements; //!< Members in each array +/* variable part of object, not part of structure. + U_FLOAT Positions //!< positions along gradient line. The first position MUST be 0.0 and the last MUST be 1.0. + U_FLOAT Factors //!< blending factors, 0.0->1.0 values, inclusive +*/ +} U_PMF_BLENDFACTORS; + +/** @brief EMF+ manual 2.2.2.6, Microsoft name: EmfPlusBoundaryPathData Object */ +typedef struct { + int32_t Size; //!< Bytes in Data +/* variable part of object, not part of structure. + U_PMF_PATH Data //!< Boundary of the brush +*/ +} U_PMF_BOUNDARYPATHDATA; + +/** @brief EMF+ manual 2.2.2.7, Microsoft name: EmfPlusBoundaryPointData Object */ +typedef struct { + int32_t Elements; //!< Members in the array +/* variable part of object, not part of structure. + U_PMF_POINTF Points //!< Boundary of the brush +*/ +} U_PMF_BOUNDARYPOINTDATA; + +/** @brief EMF+ manual 2.2.2.8, Microsoft name: EmfPlusCharacterRange Object */ +typedef struct { + int32_t First; //!< First position in range + int32_t Length; //!< Range length +} U_PMF_CHARACTERRANGE; + +/** @brief EMF+ manual 2.2.2.9, Microsoft name: EmfPlusCompoundLineData Object +Compound lines are pens that draw several parallel lines at once. The data here +alternates (sub)line width (as fraction of total width and gaps (also as fraction +of total width). +*/ +typedef struct { + int32_t Elements; //!< Members in the array +/* variable part of object, not part of structure. + U_FLOAT Data //!< Line or gap width (0.0 <-> 1.0, fraction of total line width ) +*/ +} U_PMF_COMPOUNDLINEDATA; + +/** @brief EMF+ manual 2.2.2.10, Microsoft name: EmfPlusCompressedImage Object +Holds an EXIF, GIF, JFIF, PNG, or TIFF image. + For U_PMF_BITMAP BitmapData field + + object has no assocated struct! + U_PMF_COMPRESSEDIMAGE +*/ + +/** @brief EMF+ manual 2.2.2.11, Microsoft name: EmfPlusCustomEndCapData Object */ +typedef struct { + int32_t Size; //!< Bytes in Data +/* variable part of object, not part of structure. + U_PMF_CUSTOMLINECAP Data //!< Description of linecap +*/ +} U_PMF_CUSTOMENDCAPDATA; + +/** @brief EMF+ manual 2.2.2.12, Microsoft name: EmfPlusCustomLineCapArrowData Object */ +typedef struct { + U_FLOAT Width; //!< Arrow cap width (is multiplied by line width before draw) + U_FLOAT Height; //!< Arrow cap length (is multiplied by line width before draw) + U_FLOAT MiddleInset; //!< Pixels between outer edge and filled region + uint32_t FillState; //!< If set, fill, otherwise, only border + uint32_t StartCap; //!< LineCap enumeration (type of cap) + uint32_t EndCap; //!< LineCap enumeration + uint32_t Join; //!< LineJoin enumeration + U_FLOAT MiterLimit; //!< Maximum (miter length / line width) + U_FLOAT WidthScale; //!< Scale for U_PMF_CUSTOMLINECAP object + U_FLOAT FillHotSpot[2]; //!< must be 0.0, 0.0 + U_FLOAT LineHotSpot[2]; //!< must be 0.0, 0.0 +} U_PMF_CUSTOMLINECAPARROWDATA; + +/** @brief EMF+ manual 2.2.2.13, Microsoft name: EmfPlusCustomLineCapData Object */ +typedef struct { + uint32_t Flags; //!< CustomLineCapData flags + uint32_t Cap; //!< LineCap enumeration (type of cap) + U_FLOAT Inset; //!< Distance line cap start -> line end + uint32_t StartCap; //!< LineCap enumeration + uint32_t EndCap; //!< LineCap enumeration + uint32_t Join; //!< LineJoin enumeration + U_FLOAT MiterLimit; //!< Maximum (miter length / line width) + U_FLOAT WidthScale; //!< Scale for U_PMF_CUSTOMLINECAP object + U_FLOAT FillHotSpot[2]; //!< must be 0.0, 0.0 + U_FLOAT LineHotSpot[2]; //!< must be 0.0, 0.0 +/* variable part of object, not part of structure. + U_PMF_CUSTOMLINECAPOPTIONALDATA Data //!< meaning determined by Flags +*/ +} U_PMF_CUSTOMLINECAPDATA; + +/** U_PMF_CUSTOMLINECAPOPTIONALDATA EMF+ manual 2.2.2.14, Microsoft name: EmfPlusCustomLineCapOptionalData Object + + object has no assocated struct! + + U_PMF_FILLPATHO FillData; //!< path to fill (optional) + U_PMF_LINEPATH LineData; //!< path to stroke (optional) +*/ + +/** @brief EMF+ manual 2.2.2.15, Microsoft name: EmfPlusCustomStartCapData Object */ +typedef struct { + int32_t Size; //!< Bytes in Data +/* variable part of object, not part of structure. + U_PMF_CUSTOMLINECAP Data //!< Description of linecap +*/ +} U_PMF_CUSTOMSTARTCAPDATA; + +/** @brief EMF+ manual 2.2.2.16, Microsoft name: EmfPlusDashedLineData Object */ +typedef struct { + int32_t Elements; //!< Elements in Data +/* variable part of object, not part of structure. + U_FLOAT Data; //!< Array of lengths of dashes and spaces +*/ +} U_PMF_DASHEDLINEDATA; + +/** @brief EMF+ manual 2.2.2.17, Microsoft name: EmfPlusFillPath Object +Note: U_PMF_FILLPATHOBJ is the object, U_PMF_FILLPATH is the file record +*/ + +typedef struct { + int32_t Size; //!< Bytes in Data +/* variable part of object, not part of structure. + U_PMF_PATH Data; //!< Path specification +*/ +} U_PMF_FILLPATHO; + +/** @brief EMF+ manual 2.2.2.18, Microsoft name: EmfPlusFocusScaleData Object + for U_PMF_PATHGRADIENTBRUSHOPTIONALDATA data field + +Used with path gradient brushes. May be used to expand the center color +of a gradient, which would otherwise only be found at the center point. +The expanded area is the width, height X scale factor, but in no case +less than 1 pixel. + +*/ +typedef struct { + uint32_t Count; //!< must be 2 + U_FLOAT ScaleX; //!< value 0.0 <-> 1.0 + U_FLOAT ScaleY; //!< value 0.0 <-> 1.0 +} U_PMF_FOCUSSCALEDATA; + +/** @brief EMF+ manual 2.2.2.19, Microsoft name: EmfPlusGraphicsVersion Object + +Bit fields are not used in structs in this implementation, these are serialized/deserialized in +the corresponding routines. Bitfields in the FILE (LITTLE endian here, manual uses BIG endian) are: + unsigned int GrfVersion : 12; GraphicsVersion enumeration + unsigned int Signature : 20; Must be U_GFVR_PMF (0xDBC01) + @{ +*/ +typedef uint32_t U_PMF_GRAPHICSVERSION; //!< EMF+ manual 2.2.2.19, Microsoft name: EmfPlusGraphicsVersion Object +/** @} */ + +/** @brief EMF+ manual 2.2.2.20, Microsoft name: EmfPlusHatchBrushData Object */ +typedef struct { + uint32_t Style; //!< HatchStyle enumeration + U_PMF_ARGB Foreground; //!< Hatch pattern line color + U_PMF_ARGB Background; //!< Hatch pattern bkground color +} U_PMF_HATCHBRUSHDATA; + +/** \defgroup U_PMF_Int7 PMF 7 bit signed integer + @brief EMF+ manual 2.2.2.21, Microsoft name: EmfPlusInteger7 Object + + bit 7 U_INT7 Clear in Integer7 objects + bits 0-6 7 bit signed integer value + @{ +*/ +#define U_TEST_INT7 0x80 //!< This bit is clear in Integer7 objects. +#define U_SIGN_INT7 0x40 //!< Sign bit on an Integer7 object. +#define U_MASK_INT7 0x7F //!< xMask to retrieve integer7 bits. +/** @} */ + +/** \defgroup U_PMF_Int15 PMF 15 bit signed integer + @brief EMF+ manual 2.2.2.22, Microsoft name: EmfPlusInteger15 Object + + bit 15 U_INT15 Set in Integer15 objects + bits 0-15 15 bit signed integer value + + This is the one data type that really does seem to be stored into the file in Big Endian order. + It has to be this way because the bit that determines if data is int7 or int15 must be in the first byte + the parser sees, and that byte is the high order byte. + @{ +*/ +#define U_TEST_INT15 0x8000 //!< This bit is set in Integer15 objects. +#define U_SIGN_INT15 0x4000 //!< Sign bit on an Integer15 object. +#define U_MASK_INT15 0x7FFF //!< Mask to retrieve integer15 bits. +/** @} */ + +/* EMF+ manual 2.2.2.23, Microsoft name: EmfPlusLanguageIdentifier Object, defined above, before 2.2.1.9 */ + +/** @brief EMF+ manual 2.2.2.39, Microsoft name: EmfPlusRectF Object, out of order, needed for 2.2.2.24 */ +typedef struct { + U_FLOAT X; //!< UL X value + U_FLOAT Y; //!< UL Y value + U_FLOAT Width; //!< Width + U_FLOAT Height; //!< Height +} U_PMF_RECTF; + +/** @brief EMF+ manual 2.2.2.24, Microsoft name: EmfPlusLinearGradientBrushData Object +Manual says that Reserved1 and Reserved2 must be ignored. In practice if Reserved1 is not set to StartColor +and Reserved2 is not set to EndColor, then XP Preview will not display the gradient. +*/ +typedef struct { + uint32_t Flags; //!< BrushData flags + int32_t WrapMode; //!< WrapMode enumeration + U_PMF_RECTF RectF; //!< UL=start, LR=end of gradient + U_PMF_ARGB StartColor; //!< Gradient start color + U_PMF_ARGB EndColor; //!< Gradient end color + uint32_t Reserved1; //!< ignore + uint32_t Reserved2; //!< ignore +/* variable part of object, not part of structure. + U_PMF_LINEARGRADIENTBRUSHOPTIONALDATA data; //!< presence and meaning depend on Flags field +*/ +} U_PMF_LINEARGRADIENTBRUSHDATA; + +/** @brief EMF+ manual 2.2.2.47, Microsoft name: EmfPlusTransformMatrix Object, out of order, needed for 2.2.2.25 */ +typedef struct { + U_FLOAT m11; //!< Rotation matrix m11 element + U_FLOAT m12; //!< Rotation matrix m12 element + U_FLOAT m21; //!< Rotation matrix m21 element + U_FLOAT m22; //!< Rotation matrix m22 element + U_FLOAT dX; //!< Translation in X + U_FLOAT dY; //!< Translation in Y +} U_PMF_TRANSFORMMATRIX; + +/** NOT DOCUMENTED. Encountered in actual EmfPlusLinearGradientBrushOptionalData Object made by PowerPoint 2003. This + structure is needed for the next. */ +typedef struct { + U_FLOAT m11; //!< Rotation matrix m11 element + U_FLOAT m12; //!< Rotation matrix m12 element + U_FLOAT m21; //!< Rotation matrix m21 element + U_FLOAT m22; //!< Rotation matrix m22 element +} U_PMF_ROTMATRIX; + +/** @brief EMF+ manual 2.2.2.25, Microsoft name: EmfPlusLinearGradientBrushOptionalData Object + For U_PMF_LINEARGRADIENTBRUSHDATA data field +*/ +typedef struct { + U_PMF_ROTMATRIX Matrix; //!< Rotation matrix, Manuals says that this should be Transformation matrix, but last two values are missing +/* variable part of object, not part of structure. + (various) pattern; //!< Presence and meaning depend on Flags field, see below + + Flag values + U_BD_PresetColors U_BD_BlendFactorsH U_BD_BlendFactorsV pattern(s) present? + 0 0 0 none + 1 0 0 U_PMF_BLENDCOLORS + 0 1 0 U_PMF_BLENDFACTORS + 0 0 1 U_PMF_BLENDFACTORS + 0 1 1 U_PMF_BLENDFACTORS, U_PMF_BLENDFACTORS +*/ +} U_PMF_LINEARGRADIENTBRUSHOPTIONALDATA; + +/** @brief EMF+ manual 2.2.2.26, Microsoft name: EmfPlusLinePath Object */ +typedef struct { + int32_t Size; //!< Bytes in Data +/* variable part of object, not part of structure. + U_PMF_PATH Data; //!< Outline path +*/ +} U_PMF_LINEPATH; + +/** @brief EMF+ manual 2.2.2.27, Microsoft name: EmfPlusMetafile Object */ +typedef struct { + uint32_t Type; //!< MetaFileDatatype enumeration + uint32_t Size; //!< Bytes in Data +/* variable part of object, not part of structure. + U_PMF_IMAGE Data; //!< Various types of data, like an EMF metafile, WMF metafile, another EMF+ metafile +*/ +} U_PMF_METAFILE; + +/** @brief EMF+ manual 2.2.2.28, Microsoft name: EmfPlusPalette Object */ +typedef struct { + uint32_t Flags; //!< PaletteStyle flags + uint32_t Elements; //!< elements in Data +/* variable part of object, not part of structure. + U_PMF_ARGB Data; //!< Palette data (array of colors) +*/ +} U_PMF_PALETTE; + +/** @brief EMF+ manual 2.2.2.36, Microsoft name: EmfPlusPointF Object, out of order, needed for 2.2.2.29 */ +typedef struct { + U_FLOAT X; //!< UL X value + U_FLOAT Y; //!< UL Y value +} U_PMF_POINTF; + +/** @brief EMF+ manual 2.2.2.29, Microsoft name: EmfPlusPathGradientBrushData Object */ +typedef struct { + uint32_t Flags; //!< BrushData flags + int32_t WrapMode; //!< WrapMode enumeration + U_PMF_ARGB CenterColor; //!< Gradient center color + U_PMF_POINTF Center; //!< Center coordinates + uint32_t Elements; //!< Number of elements in gradient (not counting center) +/* variable part of object, not part of structure. + U_PMF_ARGB Gradient; //!< Color Gradient with Elements members + (varies) Boundary; //!< U_PMF_BOUNDARYPATHDATA object if BrushDataPath bit set in Flag, else U_PMF_BOUNDARYPOINTDATA object + U_PMF_GRADIENTBRUSHOPTIONALDATA data; //!< exact composition depends on Flags +*/ +} U_PMF_PATHGRADIENTBRUSHDATA; + +/** EMF+ manual 2.2.2.30, Microsoft name: EmfPlusPathGradientBrushOptionalData Object + for U_PMF_PATHGRADIENTNBRUSHDATA data field +*/ +/* Entire thing is variable or optional. +typedef struct { + U_PMF_TRANSFORMMATRIX Matrix; //!< Optional Transformation matrix + U_PMF_BLENDCOLORS Pattern; //!< presence and meaning depend on Flags field + Flag values + U_BD_PresetColors U_BD_BlendFactorsH pattern? + 0 0 none + 1 0 U_PMF_BLENDCOLORS + 0 1 U_PMF_BLENDFACTORS + U_PMF_FOCUSSSCALEDATA data //!< Present if U_BD_FocusScales bit set in Flags in U_PMF_PATHGRADIENTNBRUSHDATA object +} U_PMF_PATHGRADIENTBRUSHOPTIONALDATA; +*/ + +/** \defgroup U_PMF_PPTYPE PMF Path Point Types + @brief EMF+ manual 2.2.2.31, Microsoft name: EmfPlusPathPointType Object + +Bitfields in the FILE (LITTLE endian here, manual uses BIG endian) are: + bits 4-7 PathPointType flags + bits 0-3 PathPointType enumeration +*/ + +/** \defgroup U_PMF_PPTYPERLE PMF Run Length Encoded Path Point Types + @brief EMF+ manual 2.2.2.32, Microsoft name: EmfPlusPathPointTypeRLE Object + +U_PMF_PATHPOINTTYPERLE fields specify point types in a path where the path is Run Length Encoded. +Bit fields are not used in structs in this implementation, these are serialized/deserialized in +the corresponding routines. Bitfields in the FILE (LITTLE endian here, manual uses BIG endian) are: + bit 15 Set: Bezier curve; Clear: straight line + bit 14 ignored + bits 8-13 Run count + bits 0-7 PathPointType enumeration + @{ +*/ +typedef uint16_t U_PMF_PATHPOINTTYPERLE; //!< EMF+ manual 2.2.2.32, Microsoft name: EmfPlusPathPointTypeRLE Object +/** @} */ + +/** @brief EMF+ manual 2.2.2.33, Microsoft name: EmfPlusPenData Object + +Variable part of object follows structure: + U_PMF_PENOPTIONALDATA data; Optional pen data, exact composition depends on Flags +*/ +typedef struct { + uint32_t Flags; //!< PenData flags + uint32_t Unit; //!< UnitType enumeration + U_FLOAT Width; //!< Width in units set by Unit +} U_PMF_PENDATA; + +/** @brief EMF+ manual 2.2.2.34, Microsoft name: EmfPlusPenOptionalData Object + +Every part of this object is variable or optional, there is no corresponding struct + + Present if Flag What is it + U_PMF_TRANSFORMMATRIX Matrix //!< U_PD_Transform Transformation matrix + int32_t StartCap //!< U_PD_StartCap LineCapType enumeration + int32_t EndCap //!< U_PD_EndCap LineCapType enumeration + uint32_t Join //!< U_PD_Join LineJoinType enumeration + U_FLOAT MiterLimit //!< U_PD_MiterLimit Maximum (miter length / line width) + int32_t Style //!< U_PD_LineStyle LineStyle enumeration + int32_t DLCap //!< U_PD_DLCap DashedLineCapType enumeration + U_FLOAT DLOffset //!< U_PD_DLOffset Distance line start to first dash start + U_PMF_DASHEDLINEDATA DLData //!< U_PD_DLData Dash and space widths + int32_t PenAlignment //!< U_PD_NonCenter PenAlignment enumeration + U_PMF_COMPOUNDLINEDATA CLData //!< U_PD_CompoundLineData Compount Line (parallel lines drawn instead of one) + U_PMF_CUSTOMSTARTCAPDATA CSCapData //!< U_PD_CustomStartCap Custom start cap + U_PMF_CUSTOMENDCAPDATA CECapData //!< U_PD_CustomEndCap Custom end cap + */ + +/** @brief EMF+ manual 2.2.2.35, Microsoft name: EmfPlusPoint Object */ +typedef struct { + int16_t X; //!< X coordinate + int16_t Y; //!< Y coordinate +} U_PMF_POINT; + +/** U_PMF_POINTF EMF+ manual 2.2.2.36, Microsoft name: EmfPlusPointF Object, defined above, before 2.2.2.29 */ + +/** U_PMF_POINTR EMF+ manual 2.2.2.37, Microsoft name: EmfPlusPointR Object + For U_PMF_DRAWBEZIERS data field (optionally). + Both parts of this object are variable, there is no corresponding struct. + Any combination of the two allowed types of integer is valid. + + (varies) X; //!< U_PMF_INTEGER7 or U_PMF_INTEGER15 + (varies) Y; //!< U_PMF_INTEGER7 or U_PMF_INTEGER15 + +*/ + +/** @brief EMF+ manual 2.2.2.38, Microsoft name: EmfPlusRect Object */ +typedef struct { + int16_t X; //!< UL X value + int16_t Y; //!< UL Y value + int16_t Width; //!< Width + int16_t Height; //!< Height +} U_PMF_RECT; + +/** U_PMF_RECTF EMF+ manual 2.2.2.39, Microsoft name: EmfPlusRectF Object, defined above, before 2.2.2.24 */ + +/** U_PMF_REGIONNODE EMF+ manual 2.2.2.40, Microsoft name: EmfPlusRegionNode Object, defined above, before 2.2.1.8 */ + +/** U_PMF_REGIONNODECHILDNODES EMF+ manual 2.2.2.41, Microsoft name: EmfPlusRegionNodeChildNodes Object + For U_PMF_REGIONNODE data field (optionally). + Both parts of this object are variable, there is no corresponding struct. + U_PMF_REGIONNODE Left; //!< Left child + U_PMF_REGIONNODE Right; //!< Right child +*/ + +/** @brief EMF+ manual 2.2.2.42, Microsoft name: EmfPlusRegionNodePath Object */ +typedef struct { + int32_t Size; //!< Bytes in Data +/* variable part of object, not part of structure. + U_PMF_PATH Data; //!< Boundary of region node +*/ +} U_PMF_REGIONNODEPATH; + +/** @brief EMF+ manual 2.2.2.43, Microsoft name: EmfPlusSolidBrushData Object + For U_PMF_BRUSH data field (one type of brush) +*/ +typedef struct { + U_PMF_ARGB Color; //!< Color of brush +} U_PMF_SOLIDBRUSHDATA; + +/** U_PMF_STRINGFORMATDATA EMF+ manual 2.2.2.44, Microsoft name: EmfPlusStringFormatData Object + Both parts of this object are variable and optional, there is no corresponding struct + U_FLOAT TabStops[]; //!< Array of tabstop locations + U_PMF_CHARACTERRANGE CharRange[]; //!< Array of character ranges in the text +*/ + +/** @brief EMF+ manual 2.2.2.45, Microsoft name: EmfPlusTextureBrushData Object */ +typedef struct { + uint32_t Flags; //!< BrushData flags + int32_t WrapMode; //!< WrapMode enumeration +/* variable part of object, not part of structure. + U_PMF_TEXTUREBRUSHOPTIONALDATA data; //!< Optional texture data +*/ +} U_PMF_TEXTUREBRUSHDATA; + +/** U_PMF_TEXTUREBRUSHOPTIONALDATA EMF+ manual 2.2.2.46, Microsoft name: EmfPlusTextureBrushOptionalData Object + +Every part of this object is variable or optional, there is no corresponding struct + + U_PMF_TRANSFORMMATRIX Matrix; Transformation matrix, present if Flag BrushDataTransform is set. + U_PMF_IMAGE Image Image that contains the texture. Present if the PMR record that includes this object still has space + for an U_PMF_IMAGE after all the other variable and optional data + within it has been accounted for. +*/ + +/** U_PMF_TRANSFORMMATRIX EMF+ manual 2.2.2.47, Microsoft name: EmfPlusTransformMatrix Object, defined above, before 2.2.2.25 */ + +/** common structure present at the beginning of all(*) EMF+ records */ +typedef struct { + uint16_t Type; //!< Recordtype enumeration (what this record is) + uint16_t Flags; //!< Flags (meaning varies by record type) + uint32_t Size; //!< Bytes in record, including this struct (will be a multiple of 4) + uint32_t DataSize; //!< Bytes of data that follow, may not be a multiple of 4. +} U_PMF_CMN_HDR; + +/** These are the Image Effect Objects 2.2.3.* They specify parameters for "filters" that may be applied to bitmaps. */ + +/** @brief EMF+ manual 2.2.3.1, Microsoft name: BlurEffect Object */ +typedef struct { + U_FLOAT Radius; //!< Blur radius in pixels + uint32_t ExpandEdge; //!< 1: expand bitmap by Radius; 0: bitmap size unchanged +} U_PMF_IE_BLUR; + + +/** @brief EMF+ manual 2.2.3.2, Microsoft name: BrightnessContrastEffect Object */ +typedef struct { + int32_t Brightness; //!< -255 to 255, 0 is unchanged, positive increases, negative decreases + int32_t Contrast; //!< -100 to 100, 0 is unchanged, positive increases, negative decreases +} U_PMF_IE_BRIGHTNESSCONTRAST; + +/** @brief EMF+ manual 2.2.3.3, Microsoft name: ColorBalanceEffect Object */ +typedef struct { + int32_t CyanRed; //!< -100 to 100, 0 is unchanged, positive increases Red & decreases Cyan, negative is opposite + int32_t MagentaGreen; //!< -100 to 100, 0 is unchanged, positive increases Green & decreases Magenta, negative is opposite + int32_t YellowBlue; //!< -100 to 100, 0 is unchanged, positive increases Blue & decreases Yellow, negative is opposite +} U_PMF_IE_COLORBALANCE; + +/** @brief EMF+ manual 2.2.3.4, Microsoft name: ColorCurveEffect Object + Adjust Range + Exposure -255 to 255, 0 is unchanged + Density -255 to 255, 0 is unchanged + Contrast -100 to 100, 0 is unchanged + Highlight -100 to 100, 0 is unchanged + Shadow -100 to 100, 0 is unchanged + WhiteSaturation 0 to 255 + BlackSaturation 0 to 255 +*/ +typedef struct { + uint32_t Adjust; //!< CurveAdjustment enumeration + uint32_t Channel; //!< CurveChannel enumeration + int32_t Intensity; //!< adjustment to apply. "Adjust" determines what field this is and range values. +} U_PMF_IE_COLORCURVE; + +/** @brief EMF+ manual 2.2.3.5, Microsoft name: ColorLookupTableEffect Object */ +typedef struct { + uint8_t BLUT[256]; //!< Blue color lookup table + uint8_t GLUT[256]; //!< Green color lookup table + uint8_t RLUT[256]; //!< Red color lookup table + uint8_t ALUT[256]; //!< Alpha color lookup table +} U_PMF_IE_COLORLOOKUPTABLE; + +/** @brief EMF+ manual 2.2.3.6, Microsoft name: ColorMatrixEffect Object */ +typedef struct { + U_FLOAT M[5][5]; //!< 5 x 5 color transformation matrix, First 4 rows are [{4 multiplier values},0.0] for R,G,B,A, last Row is [{4 color translation valuess}, 1.0] +} U_PMF_IE_COLORMATRIX; + +/** @brief EMF+ manual 2.2.3.7, Microsoft name: HueSaturationLightnessEffect Object */ +typedef struct { + int32_t Hue; //!< -180 to 180, 0 is unchanged + int32_t Saturation; //!< -100 to 100, 0 is unchanged + int32_t Lightness; //!< -100 to 100, 0 is unchanged +} U_PMF_IE_HUESATURATIONLIGHTNESS; + +/** @brief EMF+ manual 2.2.3.8, Microsoft name: LevelsEffect Object */ +typedef struct { + int32_t Highlight; //!< 0 to 100, 100 is unchanged + int32_t Midtone; //!< -100 to 100, 0 is unchanged + int32_t Shadow; //!< 0 to 100, 0 is unchanged +} U_PMF_IE_LEVELS; + +/** @brief EMF+ manual 2.2.3.9, Microsoft name: RedEyeCorrectionEffect Object */ +typedef struct { + int32_t Elements; //!< Number of members in Rects +/* variable part of object, not included in structure + U_RECTL Rects[]; //!< Array of rectangular area(s) to apply red eye correction +*/ +} U_PMF_IE_REDEYECORRECTION; + +/** @brief EMF+ manual 2.2.3.10, Microsoft name: SharpenEffect Object */ +typedef struct { + U_FLOAT Radius; //!< Sharpening radius in pixels + int32_t Sharpen; //!< 0 to 100, 0 is unchanged +} U_PMF_IE_SHARPEN; + +/** @brief EMF+ manual 2.2.3.11, Microsoft name: TintEffect Object */ +typedef struct { + int32_t Hue; //!< -180 to 180, [positive==clockwise] rotation in degrees starting from blue + int32_t Amount; //!< -100 [add black] to 100[add white], 0 is unchanged. Change in hue on specified axis +} U_PMF_IE_TINT; + +/* ************************** EMF+ Records ******************************** */ + +/** @brief EMF+ manual 2.3.1.1, Microsoft name: EmfPlusOffsetClip Record, Index 0x35 */ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header (ignore flags) + U_FLOAT dX; //!< horizontal translation offset to apply to clipping region + U_FLOAT dY; //!< vertical translation offset to apply to clipping region +} U_PMF_OFFSETCLIP; + +/** @brief U_PMF_RESETCLIP EMF+ manual 2.3.1.2, Microsoft name: EmfPlusResetClip Record, Index 0x31 */ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header (ignore flags) +} U_PMF_RESETCLIP; + +/** @brief EMF+ manual 2.3.1.3, Microsoft name: EmfPlusSetClipPath Record, Index 0x33 + +flags (LITTLE endian here, manual uses BIG endian) + bits 8-11 CombineMode enumeration + bits 0-7 Index of an U_PMF_PATH object in the EMF+ object table (0-63, inclusive) +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header +} U_PMF_SETCLIPPATH; + +/** @brief EMF+ manual 2.3.1.4, Microsoft name: EmfPlusSetClipRect Record, Index 0x32 + +flags (LITTLE endian here, manual uses BIG endian) + bits 8-11 CombineMode enumeration +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + U_PMF_RECTF Rect; //!< Rectangle used with CombineMode enumeration from Header.Flags +} U_PMF_SETCLIPRECT; + +/** @brief EMF+ manual 2.3.1.5, Microsoft name: EmfPlusSetClipRegion Record, Index 0x34 + + flags (LITTLE endian here, manual uses BIG endian) + bits 12-15 CombineMode enumeration + bits 0-7 Index of an U_PMF_REGION object in the EMF+ object table (0-63, inclusive) +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header +} U_PMF_SETCLIPREGION; + +/** @brief EMF+ manual 2.3.2.1, Microsoft name: EmfPlusComment Record, Index 0x03 + + variable part of record, not included in structure + char data[]; //!< Private data, may be anything +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header (ignore flags and set to zero) +} U_PMF_COMMENT; + +/** @brief EMF+ manual 2.3.3.1, Microsoft name: EmfPlusEndOfFile Record, Index 0x02 */ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header (ignore flags and set to zero) +} U_PMF_ENDOFFILE; + +/** @brief EMF+ manual 2.3.3.2, Microsoft name: EmfPlusGetDC Record, Index 0x04 */ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header (ignore flags and set to zero) +} U_PMF_GETDC; + +/** @brief EMF+ manual 2.3.3.3, Microsoft name: EmfPlusHeader Record, Index 0x01 + + flags (LITTLE endian here, manual uses BIG endian) + bit 0 Set indicates "dual mode" EMF+ +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header (ignore flags and set to zero) + U_PMF_GRAPHICSVERSION Version; //!< EmfPlusGraphicsVersion object + uint32_t EmfPlusFlags; //!< Reference device 0 bit: set = video device, clear= printer. Ignore all other bits. + uint32_t LogicalDpiX; //!< Horizontal resolution reference device in DPI + uint32_t LogicalDpiY; //!< Vertical resolution reference device in DPI +} U_PMF_HEADER; + +/** @brief EMF+ manual 2.3.4.1, Microsoft name: EmfPlusClear Record, Index 0x09 */ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header (ignore flags and set to zero) + U_PMF_ARGB Color; //!< Erase everything preceding, set background ARGB color. +} U_PMF_CLEAR; + +/** @brief EMF+ manual 2.3.4.2, Microsoft name: EmfPlusDrawArc Record, Index 0x12 + + flags (LITTLE endian here, manual uses BIG endian) + bit 9 U_PPF_C Set: Rect is U_PMF_RECT; Clear: Rect is U_PMF_RECTF + bits 0-7 Index of an U_PMF_PEN object in the EMF+ object table (0-63, inclusive) +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + U_FLOAT Start; //!< Start angle, >=0.0, degrees clockwise from 3:00 + U_FLOAT Sweep; //!< Sweep angle, -360<= angle <=360, degrees clockwise from Start +/* variable part of record, not included in structure + U_RECT or U_RECTF Rect; //!< Bounding box for elliptical arc being drawn. +*/ +} U_PMF_DRAWARC; + +/** @brief EMF+ manual 2.3.4.3, Microsoft name: EmfPlusDrawBeziers Record, Index 0x19 + flags (LITTLE endian here, manual uses BIG endian) + bit 9 U_PPF_C Set: int16_t coordinates; Clear: U_FLOAT coordinates (IGNORE if bit 4 is set) + bit 12 U_PPF_P Set: Coordinates are relative; Clear: they are absolute + bits 0-7 Index of an U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + + bit1 bit4 Type of Data + 1 0 U_EMF_POINT + 0 0 U_EMF_POINTF + 0 1 U_EMF_POINTR +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + uint32_t Elements; //!< Number of members in the Points array +/* + variable part of record, not included in structure + (varies) Points; //!< Points, for type see table above +*/ +} U_PMF_DRAWBEZIERS; + +/** @brief EMF+ manual 2.3.4.4, Microsoft name: EmfPlusDrawClosedCurve Record, Index 0x17 + + flags (LITTLE endian here, manual uses BIG endian) + bit 9 U_PPF_C Set: int16_t coordinates; Clear: U_FLOAT coordinates (IGNORE if bit 4 is set) + bit 12 U_PPF_P Set: Coordinates are relative; Clear: they are absolute + bits 0-7 Index of an U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + + bit1 bit4 Type of Data + 1 0 U_EMF_POINT + 0 0 U_EMF_POINTF + 0 1 U_EMF_POINTR + +Curve is a cardinal spline. +References sent by MS support: + +http://alvyray.com/Memos/CG/Pixar/spline77.pdf +http://msdn.microsoft.com/en-us/library/4cf6we5y(v=vs.110).aspx + +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + U_FLOAT Tension; //!< Controls splines, 0 is straight line, >0 is curved +/* + variable part of record, not included in structure + (varies) Points; //!< Points, for type see table above +*/ +} U_PMF_DRAWCLOSEDCURVE; + +/** @brief EMF+ manual 2.3.4.5, Microsoft name: EmfPlusDrawCurve Record, Index 0x18 + flags (LITTLE endian here, manual uses BIG endian) + bit 9 U_PPF_C Set: int16_t coordinates; Clear: U_FLOAT coordinates (IGNORE if bit 4 is set) + bits 0-7 Index of an U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + + bit1 Type of Data + 1 U_EMF_POINT + 0 U_EMF_POINTF + +Curve is a cardinal spline, using doubled terminator points to generate curves for the terminal segments. +References sent by MS support: + +http://alvyray.com/Memos/CG/Pixar/spline77.pdf +http://msdn.microsoft.com/en-us/library/4cf6we5y(v=vs.110).aspx +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + U_FLOAT Tension; //!< Controls splines, 0 is straight line, >0 is curved + uint32_t Offset; //!< Element in Points that is the spline's starting point + uint32_t NSegs; //!< Number of segments + uint32_t Elements; //!< Number of members in Points array +/* + variable part of record, not included in structure + (varies) Points; //!< Points, for type see table above +*/ +} U_PMF_DRAWCURVE; + +/** @brief EMF+ manual 2.3.4.6, Microsoft name: EmfPlusDrawDriverString Record, Index 0x36 + + flags (LITTLE endian here, manual uses BIG endian) +. bit 15 U_PPF_B Set: BrushID is an U_PFM_ARGB; Clear: is index of U_PMF_BRUSH object in EMF+ object table + bits 0-7 Index of an U_PMF_FONT object in the EMF+ object table (0-63, inclusive) +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + U_FLOAT Tension; //!< Controls splines, 0 is straight line, >0 is curved + uint32_t BrushID; //!< Color or index to Brush object, depends on Flags bit0 + uint32_t DSOFlags; //!< DriverStringOptions flags + uint32_t HasMatrix; //!< If 1 record contains a TransformMatrix field, if 0 it does not. + uint32_t Elements; //!< Number of members in Glyphs and Positions array +/* + variable part of record, not included in structure + uint16_t Glyphs; //!< If U_DSO_CmapLookup is set in DSOFlags this is an array + of UTF16LE characters, otherwise, it is an array of indices into the U_PMF_FONT + object indexed by Object_ID in flags. + U_PMF_POINTF Positions; //!< Coordinates of each member of Glyphs. U_DSO_RealizedAdvance set in DSOFlags + Relative then positions are calculated relative to the first glyph which is stored + in Positions, otherwise, all glyph positions are stored in Positions. + U_PMF_TRANSFORMMATRIX Matrix; //!< Transformation to apply to Glyphs & Positions. Present if HasMatrix is 1 +*/ +} U_PMF_DRAWDRIVERSTRING; + +/** @brief EMF+ manual 2.3.4.7, Microsoft name: EmfPlusDrawEllipse Record, Index 0x0F + + flags (LITTLE endian here, manual uses BIG endian) + bit 9 U_PPF_C Set: Rect is U_PMF_RECT; Clear: Rect is U_PMF_RECTF + bits 0-7 Index of an U_PMF_PEN object in the EMF+ object table (0-63, inclusive) +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header +/* + variable part of record, not included in structure + (varies) Rect; //!< Bounding rectangle, data type set by bit1 of Header.Flags +*/ +} U_PMF_DRAWELLIPSE; + +/** @brief EMF+ manual 2.3.4.8, Microsoft name: EmfPlusDrawImage Record, Index 0x1A + + flags (LITTLE endian here, manual uses BIG endian) + bit 9 U_PPF_C Set: DstRect is U_PMF_RECT; Clear: DstRect is U_PMF_RECTF + bits 0-7 Index of an U_PMF_Image object in the EMF+ object table (0-63, inclusive) +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + uint32_t ImgAttrID; //!< EmfPlusImageAttributes object + int32_t SrcUnit; //!< UnitType enumeration + U_PMF_RECTF SrcRect; //!< Region of image +/* + variable part of record, not included in structure + (varies) DstRect; //!< Destination rectangle for image. Type controlled by bit1 of Header.Flags +*/ +} U_PMF_DRAWIMAGE; + +/** @brief EMF+ manual 2.3.4.9, Microsoft name: EmfPlusDrawImagePoints Record, Index 0x1B + + flags (LITTLE endian here, manual uses BIG endian) + bit 14 U_PPF_C Set: Points is U_PMF_POINT; Clear: Points is U_PMF_POINTF + bit 13 U_PPF_E Set: effect from previous U_PMF_SERIALIZABLEOBJECT record will be applied; Clear: no effect applied + bit 11 U_PPF_P Set: Points has relative coordinates; Clear: Points has absolute coordinates + bits 0-7 Index of an U_PMF_Image object in the EMF+ object table (0-63, inclusive) + + bit1 bit4 Type of Data + 1 0 U_EMF_POINT + 0 0 U_EMF_POINTF + 0 1 U_EMF_POINTR + + WARNING! Windows XP Preview does not show filter effects, whether or not U_PPF_E is set. They are visible if the EMF+ + file is inserted as an image into PowerPoint. +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + uint32_t ImgAttrID; //!< EmfPlusImageAttributes object + int32_t SrcUnit; //!< UnitType enumeration + U_PMF_RECTF SrcRect; //!< Region of image + uint32_t Elements; //!< Number of members in Points, must be 3 +/* + variable part of record, not included in structure + (varies) Points; //!< 3 points of a parallelogram. Type from bit1 and bit4 of Header.Flags, see table above +*/ +} U_PMF_DRAWIMAGEPOINTS; + +/** @brief EMF+ manual 2.3.4.10, Microsoft name: EmfPlusDrawLines Record, Index 0x0D + + flags (LITTLE endian here, manual uses BIG endian) + bit 9 U_PPF_C Set: Points is U_PMF_POINT; Clear: Points is U_PMF_POINTF + bit 10 U_PPF_D Set: close shape by connecting last point to first; Clear: leave path open + bit 12 U_PPF_P Set: Points has relative coordinates; Clear: Points has absolute coordinates + bits 0-7 Index of an U_PMF_Image object in the EMF+ object table (0-63, inclusive) + + bit1 bit4 Type of Data + 1 0 U_EMF_POINT + 0 0 U_EMF_POINTF + 0 1 U_EMF_POINTR +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + uint32_t Elements; //!< Number of members in Points +/* + variable part of record, not included in structure + (varies) Points; //!< Sequence of points to connect with line segments. Type from bit1 and bit4 of Header.Flags, see table above +*/ +} U_PMF_DRAWLINES; + +/** @brief EMF+ manual 2.3.4.11, Microsoft name: EmfPlusDrawPath Record, Index 0x15 + + flags (LITTLE endian here, manual uses BIG endian) + bits 0-7 Index of an U_PMF_PATH object in the EMF+ object table (0-63, inclusive) +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + uint32_t PenID; //!< U_PMF_PEN object in the EMF+ object table (0-63, inclusive) +} U_PMF_DRAWPATH; + +/** @brief EMF+ manual 2.3.4.12, Microsoft name: EmfPlusDrawPie Record, Index 0x0D + + flags (LITTLE endian here, manual uses BIG endian) + bit 9 U_PPF_C Set: Rect is U_PMF_RECT; Clear: Rect is U_PMF_RECTF + bits 0-7 Index of an U_PMF_Pen object in the EMF+ object table (0-63, inclusive) +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + U_FLOAT Start; //!< Start angle, >=0.0, degrees clockwise from 3:00 + U_FLOAT Sweep; //!< Sweep angle, -360<= angle <=360, degrees clockwise from Start +/* + variable part of record, not included in structure + U_RECT or U_RECTF Rect; //!< Bounding box for elliptical pie segment being drawn. Type from bit1 of Header.Flags, see above +*/ +} U_PMF_DRAWPIE; + +/** @brief EMF+ manual 2.3.4.13, Microsoft name: EmfPlusDrawRects Record, Index 0x0B + + flags (LITTLE endian here, manual uses BIG endian) + bit 9 U_PPF_C Set: Rect is U_PMF_RECT; Clear: Rect is U_PMF_RECTF + bits 0-7 Index of an U_PMF_Pen object in the EMF+ object table (0-63, inclusive) +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + uint32_t Elements; //!< Number of members in Rects +/* + variable part of record, not included in structure + U_RECT or U_RECTF Rects; //!< Array of rectangles to draw. Type from bit1 of Header.Flags, see above +*/ +} U_PMF_DRAWRECTS; + +/** @brief EMF+ manual 2.3.4.14, Microsoft name: EmfPlusDrawString Record, Index 0x1C + + flags (LITTLE endian here, manual uses BIG endian) + bit 15 U_PPF_B Set: BrushID is an U_PFM_ARGB; Clear: is index of U_PMF_BRUSH object in EMF+ object table. + bits 0-7 Index of an U_PMF_FONT object in the EMF+ object table (0-63, inclusive) +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + uint32_t BrushID; //!< Color or index to Brush object, depends on Flags bit0 + uint32_t FormatID; //!< U_PMF_STRINGFORMAT object in EMF+ Object Table. + uint32_t Length; //!< Number of characters in the string. + U_PMF_RECTF Rect; //!< String's bounding box. +/* + variable part of record, not included in structure + uint16_t String; //!< Array of UFT-16LE unicode characters. +*/ +} U_PMF_DRAWSTRING; + +/** @brief EMF+ manual 2.3.4.15, Microsoft name: EmfPlusFillClosedCurve Record, Index 0x16 + + flags (LITTLE endian here, manual uses BIG endian) + bit 15 U_PPF_B Set: BrushID is an U_PFM_ARGB; Clear: is index of U_PMF_BRUSH object in EMF+ object table. + bit 9 U_PPF_C Set: Points is U_PMF_POINT; Clear: Points is U_PMF_POINTF + bit 10 U_PPF_F Set: winding fill; Clear: alternate fill + bit 12 U_PPF_P Set: Points has relative coordinates; Clear: Points has absolute coordinates + + bit1 bit4 Type of Data + 1 0 U_EMF_POINT + 0 0 U_EMF_POINTF + 0 1 U_EMF_POINTR +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + uint32_t BrushID; //!< Color or index to Brush object, depends on Header.Flags bit0 + U_FLOAT Tension; //!< Controls splines, 0 is straight line, >0 is curved + uint32_t Elements; //!< Number of members in Points +/* + variable part of record, not included in structure + (varies) Points; //!< Sequence of points to connect. Type from bit1 and bit4 of Header.Flags, see table above +*/ +} U_PMF_FILLCLOSEDCURVE; + +/** @brief EMF+ manual 2.3.4.16, Microsoft name: EmfPlusFillEllipse Record, Index 0x0E + + flags (LITTLE endian here, manual uses BIG endian) + bit 15 U_PPF_B Set: BrushID is an U_PFM_ARGB; Clear: is index of U_PMF_BRUSH object in EMF+ object table. + bit 9 U_PPF_C Set: Rect is U_PMF_RECT; Clear: Rect is U_PMF_RECTF +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + uint32_t BrushID; //!< Color or index to Brush object, depends on Header.Flags bit0 +/* + variable part of record, not included in structure + U_RECT or U_RECTF Rect; //!< Bounding box for elliptical pie segment being drawn. Type from bit1 of Header.Flags, see above +*/ +} U_PMF_FILLELLIPSE; + +/** @brief EMF+ manual 2.3.4.17, Microsoft name: EmfPlusFillPath Record, Index 0x14 +Note: U_PMF_FILLPATHOBJ is the object, U_PMF_FILLPATH is the file record + + flags (LITTLE endian here, manual uses BIG endian) + bit 15 U_PPF_B Set: BrushID is an U_PFM_ARGB; Clear: is index of U_PMF_BRUSH object in EMF+ object table. + bits 0-7 Index of an U_PMF_PATH object in the EMF+ object table (0-63, inclusive) +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + uint32_t BrushID; //!< Color or index to Brush object, depends on Header.Flags bit0 +} U_PMF_FILLPATH; + +/** @brief EMF+ manual 2.3.4.18, Microsoft name: EmfPlusFillPie Record, Index 0x10 + + flags (LITTLE endian here, manual uses BIG endian) + bit 15 U_PPF_B Set: BrushID is an U_PFM_ARGB; Clear: is index of U_PMF_BRUSH object in EMF+ object table. + bit 9 U_PPF_C Set: Rect is U_PMF_RECT; Clear: Rect is U_PMF_RECTF +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + uint32_t BrushID; //!< Color or index to Brush object, depends on Header.Flags bit0 + U_FLOAT Start; //!< Start angle, >=0.0, degrees clockwise from 3:00 + U_FLOAT Sweep; //!< Sweep angle, -360<= angle <=360, degrees clockwise from Start +/* + variable part of record, not included in structure + U_RECT or U_RECTF Rect; //!< Bounding box for elliptical pie segment being filled. Type from bit1 of Header.Flags, see above +*/ +} U_PMF_FILLPIE; + +/** @brief EMF+ manual 2.3.4.19, Microsoft name: EmfPlusFillPolygon Record, Index 0x0C + + flags (LITTLE endian here, manual uses BIG endian) + bit 15 U_PPF_B Set: BrushID is an U_PFM_ARGB; Clear: is index of U_PMF_BRUSH object in EMF+ object table. + bit 9 U_PPF_C Set: Points is U_PMF_POINT; Clear: Points is U_PMF_POINTF + bit 12 U_PPF_P Set: Points has relative coordinates; Clear: Points has absolute coordinates + + bit1 bit4 Type of Data + 1 0 U_EMF_POINT + 0 0 U_EMF_POINTF + 0 1 U_EMF_POINTR +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + uint32_t BrushID; //!< Color or index to Brush object, depends on Header.Flags bit0 + uint32_t Elements; //!< Number of members in Points +/* + variable part of record, not included in structure + (varies) Points; //!< Sequence of points to connect with line segments. Type from bit1 and bit4 of Header.Flags, see table above +*/ +} U_PMF_FILLPOLYGON; + +/** @brief EMF+ manual 2.3.4.20, Microsoft name: EmfPlusFillRects Record, Index 0x0A + + flags (LITTLE endian here, manual uses BIG endian) + bit 15 U_PPF_B Set: BrushID is an U_PFM_ARGB; Clear: is index of U_PMF_BRUSH object in EMF+ object table. + bit 9 U_PPF_C Set: Rect is U_PMF_RECT; Clear: Rect is U_PMF_RECTF +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + uint32_t BrushID; //!< Color or index to Brush object, depends on Header.Flags bit0 + uint32_t Elements; //!< Number of members in Rects +/* + variable part of record, not included in structure + U_RECT or U_RECTF Rects; //!< Array of rectangles to draw. Type from bit1 of Header.Flags, see above +*/ +} U_PMF_FILLRECTS; + +/** @brief EMF+ manual 2.3.4.21, Microsoft name: EmfPlusFillRegion Record, Index 0x13 + + flags (LITTLE endian here, manual uses BIG endian) + bit 15 U_PPF_B Set: BrushID is an U_PFM_ARGB; Clear: is index of U_PMF_BRUSH object in EMF+ object table. + bits 0-7 Index of an U_PMF_REGION object in the EMF+ object table (0-63, inclusive) +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + uint32_t BrushID; //!< Color or index to Brush object, depends on Header.Flags bit0 +} U_PMF_FILLREGION; + +/** @brief EMF+ manual 2.3.5.1, Microsoft name: EmfPlusObject Record, Index 0x13 + + flags (LITTLE endian here, manual uses BIG endian) + bit 15 U_PPF_N Set: object definition continues in next record; Clear: this is the final object definition record + bits 8-14 Type of object being created, ObjectType enumeration + bits 0-7 Index of an U_PMF_REGION object in the EMF+ object table (0-63, inclusive) +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header +/* + variable part of record, not included in structure + uint8_t Data; //!< Object's data. Type from bits1-7 and bits8-15 of Header.Flags, see above +*/ +} U_PMF_OBJECT; + +/** @brief EMF+ manual 2.3.5.2, Microsoft name: EmfPlusSerializableObject Record, Index 0x38 + + WARNING! Windows XP Preview does not show filter effects, whether or not U_PPF_E is set. They are visible if the EMF+ + file is inserted as an image into PowerPoint. + +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header (ignore flags and set to zero) + uint8_t GUID[16]; //!< ImageEffects identifier. Composed of Data1[4]-Data2[2]-Data3[2]-Data4[8] + //!< Data1-Data3 are stored as little endian integers. Data4 is stored big endian (like a string) + uint32_t Size; //!< Bytes in Data. +/* + variable part of record, not included in structure + uint8_t Data; //!< "Serialized image effects parameter block". One of the ImageEffects objects. +*/ +} U_PMF_SERIALIZABLEOBJECT; + +/** @brief EMF+ manual 2.3.6.1, Microsoft name: EmfPlusSetAntiAliasMode Record, Index 0x1E + + flags (LITTLE endian here, manual uses BIG endian) + bits 7-1 SmoothingMode enumeration + bit 0 U_PPF_AA Set: anti-aliasing on; Clear: anti-aliasing off +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header +} U_PMF_SETANTIALIASMODE; + +/** @brief EMF+ manual 2.3.6.2, Microsoft name: EmfPlusSetCompositingMode Record, Index 0x23 + + flags (LITTLE endian here, manual uses BIG endian) + bits 0-7 CompositingMode enumeration +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header +} U_PMF_SETCOMPOSITINGMODE; + +/** @brief EMF+ manual 2.3.6.3, Microsoft name: EmfPlusSetCompositingQuality Record, Index 0x24 + + flags (LITTLE endian here, manual uses BIG endian) + bits 0-7 CompositingQuality enumeration +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header +} U_PMF_SETCOMPOSITINGQUALITY; + +/** @brief EMF+ manual 2.3.6.4, Microsoft name: EmfPlusSetInterpolationMode Record, Index 0x21 + + flags (LITTLE endian here, manual uses BIG endian) + bits 0-7 InterpolationMode enumeration +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header +} U_PMF_SETINTERPOLATIONMODE; + +/** @brief EMF+ manual 2.3.6.5, Microsoft name: EmfPlusSetPixelOffsetMode Record, Index 0x22 + + flags (LITTLE endian here, manual uses BIG endian) + bits 0-7 PixelOffsetMode enumeration +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header +} U_PMF_SETPIXELOFFSETMODE; + +/** @brief EMF+ manual 2.3.6.6, Microsoft name: EmfPlusSetRenderingOrigin Record, Index 0x1D */ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header (ignore flags and set to zero) + int32_t X; //!< X coordinate of rendering origin + int32_t Y; //!< Y coordinate of rendering origin +} U_PMF_SETRENDERINGORIGIN; + +/** @brief EMF+ manual 2.3.6.7, Microsoft name: EmfPlusSetTextContrast Record, Index 0x20 + + flags (LITTLE endian here, manual uses BIG endian) + bits 12-0 1000 x Gamma correction value. Range 1000-2200 = gamma 1.0-2.2 +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header +} U_PMF_SETTEXTCONTRAST; + +/** @brief EMF+ manual 2.3.6.8, Microsoft name: EmfPlusSetTextRenderingHint Record, Index 0x1F + + flags (LITTLE endian here, manual uses BIG endian) + bits 0-7 TextRenderingHint enumeration +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header +} U_PMF_SETTEXTRENDERINGHINT; + +/** @brief EMF+ manual 2.3.7.1, Microsoft name: EmfPlusBeginContainer Record, Index 0x27 + + flags (LITTLE endian here, manual uses BIG endian) + bits 8-15 UnitType enumeration + bits 0-7 (all zero) +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + U_PMF_RECTF DstRect; //!< with SrcRect specifies a transformation + U_PMF_RECTF SrcRect; //!< with DstRect specifies a transformation + uint32_t Index; //!< Index to apply to this graphics container +} U_PMF_BEGINCONTAINER; + +/** @brief EMF+ manual 2.3.7.2, Microsoft name: EmfPlusBeginContainerNoParams Record, Index 0x28 */ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header (ignore flags and set to zero) + uint32_t Index; //!< Index to apply to this graphics container +} U_PMF_BEGINCONTAINERNOPARAMS; + +/** @brief EMF+ manual 2.3.7.3, Microsoft name: EmfPlusEndContainer Record, Index 0x29 */ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header (ignore flags and set to zero) + uint32_t Index; //!< Index of container being closed, from U_PMF_BEGINCONTAINERNOPARAMS or U_PMF_BEGINCONTAINER +} U_PMF_ENDCONTAINER; + +/** @brief EMF+ manual 2.3.7.4, Microsoft name: EmfPlusRestore Record, Index 0x26 */ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header (ignore flags and set to zero) + uint32_t Index; //!< Index of Graphics State being restored, from U_PMF_SAVE +} U_PMF_RESTORE; + +/** @brief EMF+ manual 2.3.7.5, Microsoft name: EmfPlusSave Record, Index 0x25 */ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header (ignore flags and set to zero) + uint32_t Index; //!< Index of Graphics State being saved +} U_PMF_SAVE; + +/** @brief EMF+ manual 2.3.8.1, Microsoft name: EmfPlusSetTSClip Record, Index 0x3A + + flags (LITTLE endian here, manual uses BIG endian) + bit 15 U_PPF_K Set: Rect is U_PMF_RECT; Clear: Rect is U_PMF_RECTF + bits 14-0 Number of rectangles in Rects field +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header +/* + variable part of record, not included in structure + U_RECT or U_RECTF Rects; //!< Array of rectangles to draw. Type from bit0 of Header.Flags, see above +*/ +} U_PMF_SETTSCLIP; + +/** @brief EMF+ manual 2.3.8.2, Microsoft name: EmfPlusSetTSGraphics Record, Index 0x39 + + flags (LITTLE endian here, manual uses BIG endian) + bit 1 U_PPF_VGA Set: Palette is VGA basic colors; Clear: Palette is a U_PMF_PALETTE object. + bit 0 U_PPF_PP Set: Palette field is present; Clear: Palette field is absent +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + uint8_t AntiAliasMode; //!< SmoothingMode enumeration + uint8_t TextRenderHint; //!< TextRenderingHint enumeration + uint8_t CompositingMode; //!< CompositingMode enumeration + uint8_t CompositingQuality; //!< CompositingQuality enumeration + int16_t RenderOriginX; //!< Origin X for halftoning and dithering + int16_t RenderOriginY; //!< Origin Y for halftoning and dithering + uint16_t TextContrast; //!< Gamma correction, range 0 to 12 + uint8_t FilterType; //!< FilterType enumeraton + uint8_t PixelOffset; //!< PixelOffsetMode enumeration + U_PMF_TRANSFORMMATRIX WorldToDevice; //!< world to device transform +/* + optional part of record, not included in structure + U_PMF_PALETTE Palette; //!< Present if bit15 of Header.Flags is set +*/ +} U_PMF_SETTSGRAPHICS; + +/** @brief EMF+ manual 2.3.9.1, Microsoft name: EmfPlusMultiplyWorldTransform Record, Index 0x2C + + flags (LITTLE endian here, manual uses BIG endian) + bit 13 U_PPF_XM Set: Post multiply; Clear: Pre multiply +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + U_PMF_TRANSFORMMATRIX Matrix; //!< Transformation matrix +} U_PMF_MULTIPLYWORLDTRANSFORM; + +/** @brief EMF+ manual 2.3.9.2, Microsoft name: EmfPlusResetWorldTransform Record, Index 0x2B +Sets transformation matrix to identity matrix. +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header (ignore flags and set to zero) +} U_PMF_RESETWORLDTRANSFORM; + +/** @brief EMF+ manual 2.3.9.3, Microsoft name: EmfPlusRotateWorldTransform Record, Index 0x2F + Construct transformation matrix from Angle: + sin(Angle) cos(Angle) 0 + cos(Angle) -sin(Angle) 0 + Multiply this against current world space transform, result becomes new world space transform. + + flags (LITTLE endian here, manual uses BIG endian) + bit 13 U_PPF_XM Set: Post multiply; Clear: Pre multiply +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + U_FLOAT Angle; //!< Rotation angle, in degrees +} U_PMF_ROTATEWORLDTRANSFORM; + +/** @brief EMF+ manual 2.3.9.4, Microsoft name: EmfPlusScaleWorldTransform Record, Index 0x2E + Construct transformation matrix: + Sx 0 0 + 0 Sy 0 + Multiply this against current world space transform, result becomes new world space transform. + + flags (LITTLE endian here, manual uses BIG endian) + bit 13 U_PPF_XM Set: Post multiply; Clear: Pre multiply +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + U_FLOAT Sx; //!< X scale factor + U_FLOAT Sy; //!< Y scale factor +} U_PMF_SCALEWORLDTRANSFORM; + +/** @brief EMF+ manual 2.3.9.5, Microsoft name: EmfPlusSetPageTransform Record, Index 0x30 + flags (LITTLE endian here, manual uses BIG endian) + bits 0-7 UnitType enumeration +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + U_FLOAT Scale; //!< Scale factor to convert page space to device space +} U_PMF_SETPAGETRANSFORM; + + +/** @brief EMF+ manual 2.3.9.6, Microsoft name: EmfPlusSetWorldTransform Record, Index 0x2A */ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header (ignore flags and set to zero) + U_PMF_TRANSFORMMATRIX Matrix; //!< Transformation matrix +} U_PMF_SETWORLDTRANSFORM; + +/** @brief EMF+ manual 2.3.9.7, Microsoft name: EmfPlusTranslateWorldTransform Record, Index 0x2D + Construct transformation matrix: + 1 0 Dx + 0 1 Dy + Multiply this against current world space transform, result becomes new world space transform. + + flags (LITTLE endian here, manual uses BIG endian) + bit 13 U_PPF_XM Set: Post multiply; Clear: Pre multiply +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + U_FLOAT Dx; //!< X offset + U_FLOAT Dy; //!< Y offset +} U_PMF_TRANSLATEWORLDTRANSFORM; + +//! \cond + +/* EMF+ prototypes (helper functions) */ +void U_PMR_write(U_PSEUDO_OBJ *po, U_PSEUDO_OBJ *sum, EMFTRACK *et); +int U_PMR_drawline(uint32_t PenID, uint32_t PathID, U_PMF_POINTF Start, U_PMF_POINTF End, int Dashed, U_PSEUDO_OBJ *sum, EMFTRACK *et); +int U_PMR_drawstring( const char *string, int Vpos, uint32_t FontID, const U_PSEUDO_OBJ *BrushID, uint32_t FormatID, + U_PMF_STRINGFORMAT Sfs, const char *FontName, U_FLOAT Height, U_FontInfoParams *fip, uint32_t FontFlags, + U_FLOAT x, U_FLOAT y, U_PSEUDO_OBJ *sum, EMFTRACK *et); +U_PMF_POINT *POINTF_To_POINT16_LE(U_PMF_POINTF *points, int count); +int U_PMF_LEN_REL715(const char *contents, int Elements); +int U_PMF_LEN_FLOATDATA(const char *contents); +int U_PMF_LEN_BYTEDATA(const char *contents); +int U_PMF_LEN_PENDATA(const char *PenData); +int U_PMF_LEN_OPTPENDATA(const char *PenData, uint32_t Flags); +char *U_PMF_CURLYGUID_set(uint8_t *GUID); +int U_PMF_KNOWNCURLYGUID_set(const char *string); +void U_PMF_MEMCPY_SRCSHIFT(void *Dst, const char **Src, size_t Size); +void U_PMF_MEMCPY_DSTSHIFT(char **Dst, const void *Src, size_t Size); +void U_PMF_REPCPY_DSTSHIFT(char **Dst, const void *Src, size_t Size, size_t Reps); +void U_PMF_PTRSAV_SHIFT(const char **Dst, const char **Src, size_t Size); +uint16_t U_PMF_HEADERFLAGS_get(const char *contents); +int U_PMF_CMN_HDR_get(const char **contents, U_PMF_CMN_HDR *Header); +int U_OID_To_OT(uint32_t OID); +int U_OID_To_BT(uint32_t OID); +int U_OID_To_CLCDT(uint32_t OID); +int U_OID_To_IDT(uint32_t OID); +int U_OID_To_RNDT(uint32_t OID); +uint8_t *U_OID_To_GUID(uint32_t OID); +int U_OA_append(U_OBJ_ACCUM *oa, const char *data, int size, int Type, int Id); +int U_OA_clear(U_OBJ_ACCUM *oa); +int U_OA_release(U_OBJ_ACCUM *oa); +U_PSEUDO_OBJ *U_PO_create(char *Data, size_t Size, size_t Use, uint32_t Type); +U_PSEUDO_OBJ *U_PO_append(U_PSEUDO_OBJ *po, const char *Data, size_t Size); +U_PSEUDO_OBJ *U_PO_po_append(U_PSEUDO_OBJ *po, U_PSEUDO_OBJ *src, int StripE); +int U_PO_free(U_PSEUDO_OBJ **po); +U_DPSEUDO_OBJ *U_PATH_create(int Elements, const U_PMF_POINTF *Points, uint8_t First, uint8_t Others); +int U_DPO_free(U_DPSEUDO_OBJ **dpo); +int U_DPO_clear(U_DPSEUDO_OBJ *dpo); +int U_PATH_moveto(U_DPSEUDO_OBJ *path, U_PMF_POINTF Point, uint8_t Flags); +int U_PATH_lineto(U_DPSEUDO_OBJ *path, U_PMF_POINTF Point, uint8_t Flags); +int U_PATH_closepath(U_DPSEUDO_OBJ *path); +int U_PATH_polylineto(U_DPSEUDO_OBJ *path, uint32_t Elements, const U_PMF_POINTF *Points, uint8_t Flags, uint8_t StartSeg); +int U_PATH_polybezierto(U_DPSEUDO_OBJ *path, uint32_t Elements, const U_PMF_POINTF *Points, uint8_t Flags, uint8_t StartSeg); +int U_PATH_polygon(U_DPSEUDO_OBJ *Path, uint32_t Elements, const U_PMF_POINTF *Points, uint8_t Flags); +int U_PATH_arcto(U_DPSEUDO_OBJ *Path, U_FLOAT Start, U_FLOAT Sweep, U_FLOAT Rot, U_PMF_RECTF *Rect, uint8_t Flags, int StartSeg); +U_PMF_POINTF *pointfs_transform(U_PMF_POINTF *points, int count, U_XFORM xform); +U_PMF_RECTF *rectfs_transform(U_PMF_RECTF *rects, int count, U_XFORM xform); +U_PMF_TRANSFORMMATRIX tm_for_gradrect(U_FLOAT Angle, U_FLOAT w, U_FLOAT h, U_FLOAT x, U_FLOAT y, U_FLOAT Periods); +U_PSEUDO_OBJ *U_PMR_drawfill(uint32_t PathID, uint32_t PenID, const U_PSEUDO_OBJ *BrushID); + + +char *U_pmr_names(unsigned int idx); + +/* EMF+ prototypes (objects_set) */ + +U_PSEUDO_OBJ *U_PMF_BRUSH_set(uint32_t Version, const U_PSEUDO_OBJ *po); +U_PSEUDO_OBJ *U_PMF_CUSTOMLINECAP_set(uint32_t Version, const U_PSEUDO_OBJ *po); +U_PSEUDO_OBJ *U_PMF_FONT_set(uint32_t Version, U_FLOAT EmSize, uint32_t SizeUnit, + int32_t FSFlags, uint32_t Length, const uint16_t *Font); +U_PSEUDO_OBJ *U_PMF_IMAGE_set(uint32_t Version, const U_PSEUDO_OBJ *po); +U_PSEUDO_OBJ *U_PMF_IMAGEATTRIBUTES_set(uint32_t Version, uint32_t WrapMode, uint32_t ClampColor, uint32_t ObjectClamp); +U_PSEUDO_OBJ *U_PMF_PATH_set(uint32_t Version, const U_PSEUDO_OBJ *Points, const U_PSEUDO_OBJ *Types); +U_PSEUDO_OBJ *U_PMF_PATH_set2(uint32_t Version, const U_DPSEUDO_OBJ *Path); +U_PSEUDO_OBJ *U_PMF_PATH_set3(uint32_t Version, const U_DPSEUDO_OBJ *Path); +U_PSEUDO_OBJ *U_PMF_PEN_set(uint32_t Version, const U_PSEUDO_OBJ *PenData, const U_PSEUDO_OBJ *Brush); +U_PSEUDO_OBJ *U_PMF_REGION_set(uint32_t Version, uint32_t Count, const U_PSEUDO_OBJ *Nodes); +U_PSEUDO_OBJ *U_PMF_STRINGFORMAT_set(U_PMF_STRINGFORMAT *Sfs, const U_PSEUDO_OBJ *Sfd); +U_PSEUDO_OBJ *U_PMF_4NUM_set(uint32_t BrushID); +U_PSEUDO_OBJ *U_PMF_ARGB_set(uint8_t Alpha, uint8_t Red, uint8_t Green, uint8_t Blue); +U_PSEUDO_OBJ *U_PMF_ARGBN_set(uint32_t Count, U_PMF_ARGB *Colors); +U_PMF_ARGB U_PMF_ARGBOBJ_set(uint8_t Alpha, uint8_t Red, uint8_t Green, uint8_t Blue); +U_PSEUDO_OBJ *U_PMF_BITMAP_set(const U_PMF_BITMAP *Bs, const U_PSEUDO_OBJ *Bm); +U_PSEUDO_OBJ *U_PMF_BITMAPDATA_set( const U_PSEUDO_OBJ *Ps, int cbBm, const char *Bm); +U_PSEUDO_OBJ *U_PMF_BLENDCOLORS_set(uint32_t Elements, const U_FLOAT *Positions, const U_PSEUDO_OBJ *Colors); +U_PSEUDO_OBJ *U_PMF_BLENDCOLORS_linear_set(uint32_t Elements,U_PMF_ARGB StartColor, U_PMF_ARGB EndColor); +U_PSEUDO_OBJ *U_PMF_BLENDFACTORS_set(uint32_t Elements, const U_FLOAT *Positions, const U_FLOAT *Factors); +U_PSEUDO_OBJ *U_PMF_BLENDFACTORS_linear_set(uint32_t Elements, U_FLOAT StartFactor, U_FLOAT EndFactor); +U_PSEUDO_OBJ *U_PMF_BOUNDARYPATHDATA_set(const U_PSEUDO_OBJ *Path); +U_PSEUDO_OBJ *U_PMF_BOUNDARYPOINTDATA_set(uint32_t Elements, const U_PMF_POINTF *Points); +U_PSEUDO_OBJ *U_PMF_CHARACTERRANGE_set(int32_t First, int32_t Length); +U_PSEUDO_OBJ *U_PMF_COMPOUNDLINEDATA_set(int32_t Elements, const char *Widths); +U_PSEUDO_OBJ *U_PMF_COMPRESSEDIMAGE_set(int32_t cbImage, const char *Image); +U_PSEUDO_OBJ *U_PMF_CUSTOMENDCAPDATA_set(const U_PSEUDO_OBJ *Clc); +U_PSEUDO_OBJ *U_PMF_CUSTOMLINECAPARROWDATA_set(U_FLOAT Width, U_FLOAT Height, + U_FLOAT MiddleInset, uint32_t FillState, uint32_t StartCap, uint32_t EndCap, uint32_t Join, + U_FLOAT MiterLimit, U_FLOAT WidthScale); +U_PSEUDO_OBJ *U_PMF_CUSTOMLINECAPDATA_set(uint32_t Flags, uint32_t Cap, + U_FLOAT Inset, uint32_t StartCap, uint32_t EndCap, + uint32_t Join, U_FLOAT MiterLimit, U_FLOAT WidthScale, + const U_PSEUDO_OBJ *Clcod); +U_PSEUDO_OBJ *U_PMF_CUSTOMLINECAPOPTIONALDATA_set(const U_PSEUDO_OBJ *Fill, const U_PSEUDO_OBJ *Line); +U_PSEUDO_OBJ *U_PMF_CUSTOMSTARTCAPDATA_set(const U_PSEUDO_OBJ *Clc); +U_PSEUDO_OBJ *U_PMF_DASHEDLINEDATA_set(int32_t Elements, const U_FLOAT *Lengths); +U_PSEUDO_OBJ *U_PMF_DASHEDLINEDATA_set2(U_FLOAT Unit, int StdPat); +U_PSEUDO_OBJ *U_PMF_DASHEDLINEDATA_set3(U_FLOAT Unit, uint32_t BitPat); +U_PSEUDO_OBJ *U_PMF_FILLPATHOBJ_set(const U_PSEUDO_OBJ *Path); +U_PSEUDO_OBJ *U_PMF_FOCUSSCALEDATA_set(U_FLOAT ScaleX, U_FLOAT ScaleY); +U_PSEUDO_OBJ *U_PMF_GRAPHICSVERSION_set(int GrfVersion); +U_PMF_GRAPHICSVERSION U_PMF_GRAPHICSVERSIONOBJ_set(int GrfVersion); +U_PSEUDO_OBJ *U_PMF_HATCHBRUSHDATA_set(uint32_t Style, const U_PSEUDO_OBJ *Fg, const U_PSEUDO_OBJ *Bg); +U_PSEUDO_OBJ *U_PMF_INTEGER7_set(int value); +U_PSEUDO_OBJ *U_PMF_INTEGER15_set(int value); +U_PMF_LANGUAGEIDENTIFIER U_PMF_LANGUAGEIDENTIFIEROBJ_set(int SubLId, int PriLId); +U_PSEUDO_OBJ *U_PMF_LANGUAGEIDENTIFIER_set(U_PMF_LANGUAGEIDENTIFIER LId); +U_PSEUDO_OBJ *U_PMF_LINEARGRADIENTBRUSHDATA_set(const U_PMF_LINEARGRADIENTBRUSHDATA *Lgbd, const U_PSEUDO_OBJ *Lgbod); +U_PSEUDO_OBJ *U_PMF_LINEARGRADIENTBRUSHOPTIONALDATA_set(uint32_t *Flags, const U_PSEUDO_OBJ *Tm, const U_PSEUDO_OBJ *Bc, const U_PSEUDO_OBJ *BfH, const U_PSEUDO_OBJ *BfV); +U_PSEUDO_OBJ *U_PMF_LINEPATH_set(const U_PSEUDO_OBJ *Path); +U_PSEUDO_OBJ *U_PMF_METAFILE_set(void); +U_PSEUDO_OBJ *U_PMF_PALETTE_set(uint32_t Flags, uint32_t Elements, const U_PMF_ARGB *Pd); +U_PSEUDO_OBJ *U_PMF_PATHGRADIENTBRUSHDATA_set(uint32_t Flags, int32_t WrapMode, U_PMF_ARGB CenterColor, + U_PMF_POINTF Center, const U_PSEUDO_OBJ *Gradient, const U_PSEUDO_OBJ *Boundary, const U_PSEUDO_OBJ *Data); +U_PSEUDO_OBJ *U_PMF_PATHGRADIENTBRUSHOPTIONALDATA_set(uint32_t Flags, + const U_PSEUDO_OBJ *Tm, const U_PSEUDO_OBJ *Pd, const U_PSEUDO_OBJ *Fsd); +U_PSEUDO_OBJ *U_PMF_PATHPOINTTYPE_set(uint32_t Elements, const uint8_t *Ppt); +U_PSEUDO_OBJ *U_PMF_PATHPOINTTYPE_set2(uint32_t Elements, uint8_t Start, uint8_t Others); +U_PSEUDO_OBJ *U_PMF_PATHPOINTTYPERLE_set(uint32_t Elements, const uint8_t *Bz, const uint8_t *RL, const uint8_t *Ppte); +U_PSEUDO_OBJ *U_PMF_PENDATA_set(uint32_t Unit, U_FLOAT Width, const U_PSEUDO_OBJ *Pod); +U_PSEUDO_OBJ *U_PMF_PENOPTIONALDATA_set(uint32_t Flags, U_PSEUDO_OBJ *Tm, int32_t StartCap, int32_t EndCap, uint32_t Join, + U_FLOAT MiterLimit, int32_t Style, int32_t DLCap, U_FLOAT DLOffset, + U_PSEUDO_OBJ *DLData, int32_t PenAlignment, U_PSEUDO_OBJ *CmpndLineData, U_PSEUDO_OBJ *CSCapData, + U_PSEUDO_OBJ *CECapData); +U_PSEUDO_OBJ *U_PMF_POINT_set(uint32_t Elements, const U_PMF_POINT *Coords); +U_PSEUDO_OBJ *U_PMF_POINTF_set(uint32_t Elements, const U_PMF_POINTF *Coords); +U_PSEUDO_OBJ *U_PMF_POINTR_set(uint32_t Elements, const U_PMF_POINTF *Coords); +U_PSEUDO_OBJ *U_PMF_RECT4_set(int16_t X, int16_t Y, int16_t Width, int16_t Height); +U_PSEUDO_OBJ *U_PMF_RECT_set(U_PMF_RECT *Rect); +U_PSEUDO_OBJ *U_PMF_RECTN_set(uint32_t Elements, U_PMF_RECT *Rects); +U_PSEUDO_OBJ *U_PMF_RECTF4_set(U_FLOAT X, U_FLOAT Y, U_FLOAT Width, U_FLOAT Height); +U_PSEUDO_OBJ *U_PMF_RECTF_set(U_PMF_RECTF *Rect); +U_PSEUDO_OBJ *U_PMF_RECTFN_set(uint32_t Elements, U_PMF_RECTF *Rects); +U_PSEUDO_OBJ *U_PMF_REGIONNODE_set(int32_t Type, const U_PSEUDO_OBJ *Rnd); +U_PSEUDO_OBJ *U_PMF_REGIONNODECHILDNODES_set(const U_PSEUDO_OBJ *Left, const U_PSEUDO_OBJ *Right); +U_PSEUDO_OBJ *U_PMF_REGIONNODEPATH_set(const U_PSEUDO_OBJ *Path); +U_PSEUDO_OBJ *U_PMF_SOLIDBRUSHDATA_set(const U_PSEUDO_OBJ *Color); +U_PSEUDO_OBJ *U_PMF_STRINGFORMATDATA_set(uint32_t TabStopCount, U_FLOAT *TabStops, const U_PSEUDO_OBJ *Ranges); +U_PSEUDO_OBJ *U_PMF_TEXTUREBRUSHDATA_set(uint32_t Flags, uint32_t WrapMode, const U_PSEUDO_OBJ *Tbod); +U_PSEUDO_OBJ *U_PMF_TEXTUREBRUSHOPTIONALDATA_set(const U_PSEUDO_OBJ *Tm, const U_PSEUDO_OBJ *Image); +U_PSEUDO_OBJ *U_PMF_TRANSFORMMATRIX_set(U_PMF_TRANSFORMMATRIX *Tm); +U_PSEUDO_OBJ *U_PMF_IE_BLUR_set(U_FLOAT Radius, uint32_t ExpandEdge); +U_PSEUDO_OBJ *U_PMF_IE_BRIGHTNESSCONTRAST_set(int32_t Brightness, int32_t Contrast); +U_PSEUDO_OBJ *U_PMF_IE_COLORBALANCE_set(int32_t CyanRed, int32_t MagentaGreen, int32_t YellowBlue); +U_PSEUDO_OBJ *U_PMF_IE_COLORCURVE_set(uint32_t Adjust, uint32_t Channel, int32_t Intensity); +U_PSEUDO_OBJ *U_PMF_IE_COLORLOOKUPTABLE_set(const uint8_t *BLUT, const uint8_t *GLUT, const uint8_t *RLUT, const uint8_t *ALUT); +U_PSEUDO_OBJ *U_PMF_IE_COLORMATRIX_set(const U_FLOAT *Matrix); +U_PSEUDO_OBJ *U_PMF_IE_HUESATURATIONLIGHTNESS_set(int32_t Hue, int32_t Saturation, int32_t Lightness); +U_PSEUDO_OBJ *U_PMF_IE_LEVELS_set(int32_t Highlight, int32_t Midtone, int32_t Shadow); +U_PSEUDO_OBJ *U_PMF_IE_REDEYECORRECTION_set(uint32_t Elements, const U_RECTL *rects); +U_PSEUDO_OBJ *U_PMF_IE_SHARPEN_set(U_FLOAT Radius, int32_t Sharpen); +U_PSEUDO_OBJ *U_PMF_IE_TINT_set(int32_t Hue, int32_t Amount); +U_PSEUDO_OBJ *U_PMR_SERIALIZABLEOBJECT_set(const U_PSEUDO_OBJ *Siepb); + +/* EMF+ prototypes (records_set) */ + +U_PSEUDO_OBJ *U_PMR_OFFSETCLIP_set(U_FLOAT dX, U_FLOAT dY); +U_PSEUDO_OBJ *U_PMR_RESETCLIP_set(void); +U_PSEUDO_OBJ *U_PMR_SETCLIPPATH_set(uint32_t PathID, uint32_t CMenum); +U_PSEUDO_OBJ *U_PMR_SETCLIPRECT_set(uint32_t CMenum, const U_PSEUDO_OBJ *Rect); +U_PSEUDO_OBJ *U_PMR_SETCLIPREGION_set(uint32_t PathID, uint32_t CMenum); +U_PSEUDO_OBJ *U_PMR_COMMENT_set(size_t cbData, const void *Data); +U_PSEUDO_OBJ *U_PMR_ENDOFFILE_set(void); +U_PSEUDO_OBJ *U_PMR_GETDC_set(void); +U_PSEUDO_OBJ *U_PMR_HEADER_set(int IsDual, int IsVideo, const U_PSEUDO_OBJ *Version, + uint32_t LogicalDpiX, uint32_t LogicalDpiY); +U_PSEUDO_OBJ *U_PMR_CLEAR_set(const U_PSEUDO_OBJ *Color); +U_PSEUDO_OBJ *U_PMR_DRAWARC_set(uint32_t PenID, U_FLOAT Start, U_FLOAT Sweep, const U_PSEUDO_OBJ *Rect); +U_PSEUDO_OBJ *U_PMR_DRAWBEZIERS_set(uint32_t PenID, const U_PSEUDO_OBJ *Points); +U_PSEUDO_OBJ *U_PMR_DRAWCLOSEDCURVE_set(uint32_t PenID, U_FLOAT Tension, const U_PSEUDO_OBJ *Points); +U_PSEUDO_OBJ *U_PMR_DRAWCURVE_set(uint32_t PenID, U_FLOAT Tension,uint32_t Offset, uint32_t NSegs, const U_PSEUDO_OBJ *Points); +U_PSEUDO_OBJ *U_PMR_DRAWDRIVERSTRING_set(uint32_t FontID, U_FLOAT Tension, const U_PSEUDO_OBJ *BrushID, + uint32_t DSOFlags, uint32_t HasMatrix, uint32_t GlyphCount, + const uint16_t *Glyphs, const U_PSEUDO_OBJ *Points, const U_PSEUDO_OBJ *Tm); +U_PSEUDO_OBJ *U_PMR_DRAWELLIPSE_set(uint32_t PenID, const U_PSEUDO_OBJ *Rect); +U_PSEUDO_OBJ *U_PMR_DRAWIMAGE_set(uint32_t ImgID, int32_t ImgAttrID, int32_t SrcUnit, const U_PSEUDO_OBJ *SrcRect, const U_PSEUDO_OBJ *DstRect); +U_PSEUDO_OBJ *U_PMR_DRAWIMAGEPOINTS_set(uint32_t ImgID, int etype, int32_t ImgAttrID, int32_t SrcUnit, const U_PSEUDO_OBJ *SrcRect, const U_PSEUDO_OBJ *Points); +U_PSEUDO_OBJ *U_PMR_DRAWLINES_set(uint32_t PenID, int dtype, const U_PSEUDO_OBJ *Points); +U_PSEUDO_OBJ *U_PMR_DRAWPATH_set(uint32_t PathID, uint32_t PenID); +U_PSEUDO_OBJ *U_PMR_DRAWPIE_set(uint32_t PenID, U_FLOAT Start, U_FLOAT Sweep, const U_PSEUDO_OBJ *Rect); +U_PSEUDO_OBJ *U_PMR_DRAWRECTS_set(uint32_t PenID, const U_PSEUDO_OBJ *Rects); +U_PSEUDO_OBJ *U_PMR_DRAWSTRING_set(uint32_t FontID, const U_PSEUDO_OBJ *BrushID, + uint32_t FormatID, uint32_t Length, const U_PSEUDO_OBJ *Rect, const uint16_t *Text); +U_PSEUDO_OBJ *U_PMR_FILLCLOSEDCURVE_set(int ftype, U_FLOAT Tension, const U_PSEUDO_OBJ * BrushID, const U_PSEUDO_OBJ *Points); +U_PSEUDO_OBJ *U_PMR_FILLELLIPSE_set(const U_PSEUDO_OBJ * BrushID, const U_PSEUDO_OBJ *Rect); +U_PSEUDO_OBJ *U_PMR_FILLPATH_set(uint32_t PathID, const U_PSEUDO_OBJ * BrushID); +U_PSEUDO_OBJ *U_PMR_FILLPIE_set(U_FLOAT Start, U_FLOAT Sweep, const U_PSEUDO_OBJ *BrushID, const U_PSEUDO_OBJ *Rect); +U_PSEUDO_OBJ *U_PMR_FILLPOLYGON_set(const U_PSEUDO_OBJ *BrushID, const U_PSEUDO_OBJ *Points); +U_PSEUDO_OBJ *U_PMR_FILLRECTS_set(const U_PSEUDO_OBJ *BrushID, const U_PSEUDO_OBJ *Rects); +U_PSEUDO_OBJ *U_PMR_FILLREGION_set(uint32_t RgnID, const U_PSEUDO_OBJ *BrushID); +U_PSEUDO_OBJ *U_PMR_OBJECT_PO_set(uint32_t ObjID, U_PSEUDO_OBJ *Po); +U_PSEUDO_OBJ *U_PMR_OBJECT_set(uint32_t ObjID, int otype, int ntype, uint32_t TSize, size_t cbData, const char *Data); +U_PSEUDO_OBJ *U_PMR_SETANTIALIASMODE_set(int SMenum, int aatype); +U_PSEUDO_OBJ *U_PMR_SETCOMPOSITINGMODE_set(int CMenum); +U_PSEUDO_OBJ *U_PMR_SETCOMPOSITINGQUALITY_set(int CQenum); +U_PSEUDO_OBJ *U_PMR_SETINTERPOLATIONMODE_set(int IMenum); +U_PSEUDO_OBJ *U_PMR_SETPIXELOFFSETMODE_set(int POMenum); +U_PSEUDO_OBJ *U_PMR_SETRENDERINGORIGIN_set(int32_t X, int32_t Y); +U_PSEUDO_OBJ *U_PMR_SETTEXTCONTRAST_set(int GC); +U_PSEUDO_OBJ *U_PMR_SETTEXTRENDERINGHINT_set(int TRHenum); +U_PSEUDO_OBJ *U_PMR_BEGINCONTAINER_set(int UTenum, U_PSEUDO_OBJ *DstRect, U_PSEUDO_OBJ *SrcRect, uint32_t StackID); +U_PSEUDO_OBJ *U_PMR_BEGINCONTAINERNOPARAMS_set(int StackID); +U_PSEUDO_OBJ *U_PMR_ENDCONTAINER_set(int StackID); +U_PSEUDO_OBJ *U_PMR_RESTORE_set(int StackID); +U_PSEUDO_OBJ *U_PMR_SAVE_set(int StackID); +U_PSEUDO_OBJ *U_PMR_SETTSCLIP_set(U_PSEUDO_OBJ *Rects); +U_PSEUDO_OBJ *U_PMR_SETTSGRAPHICS_set(int vgatype, U_PMF_SETTSGRAPHICS *Tsg, U_PSEUDO_OBJ *Palette); +U_PSEUDO_OBJ *U_PMR_MULTIPLYWORLDTRANSFORM_set(int xmtype, U_PSEUDO_OBJ *Tm); +U_PSEUDO_OBJ *U_PMR_RESETWORLDTRANSFORM_set(void); +U_PSEUDO_OBJ *U_PMR_ROTATEWORLDTRANSFORM_set(int xmtype, U_FLOAT Angle); +U_PSEUDO_OBJ *U_PMR_SCALEWORLDTRANSFORM_set(int xmtype, U_FLOAT X, U_FLOAT Y); +U_PSEUDO_OBJ *U_PMR_SETPAGETRANSFORM_set(int PUenum, U_FLOAT Sale); +U_PSEUDO_OBJ *U_PMR_SETWORLDTRANSFORM_set(U_PSEUDO_OBJ *Tm); +U_PSEUDO_OBJ *U_PMR_TRANSLATEWORLDTRANSFORM_set(int xmtype, U_FLOAT Dx, U_FLOAT Dy); +U_PSEUDO_OBJ *U_PMR_STROKEFILLPATH_set(void); + + + + +/* EMF+ prototypes (objects_get) */ + +int U_PMF_BRUSH_get(const char *contents, uint32_t *Version, uint32_t *Type, const char **Data); +int U_PMF_CUSTOMLINECAP_get(const char *contents, uint32_t *Version, uint32_t *Type, const char **Data); +int U_PMF_FONT_get(const char *contents, uint32_t *Version, U_FLOAT *EmSize, uint32_t *SizeUnit, int32_t *FSFlags, uint32_t *Length, const char **Data); +int U_PMF_IMAGE_get(const char *contents, uint32_t *Version, uint32_t *Type, const char **Data); +int U_PMF_IMAGEATTRIBUTES_get(const char *contents, uint32_t *Version, uint32_t *WrapMode, uint32_t *ClampColor, uint32_t *ObjectClamp); +int U_PMF_PATH_get(const char *contents, uint32_t *Version, uint32_t *Count, uint16_t *Flags, const char **Points, const char **Types); +int U_PMF_PEN_get(const char *contents, uint32_t *Version, uint32_t *Type, const char **PenData, const char **Brush); +int U_PMF_REGION_get(const char *contents, uint32_t *Version, uint32_t *Count, const char **Nodes); +int U_PMF_STRINGFORMAT_get(const char *contents, U_PMF_STRINGFORMAT *Sfs, const char **Data); +int U_PMF_ARGB_get(const char *contents, uint8_t *Blue, uint8_t *Green, uint8_t *Red, uint8_t *Alpha); +int U_PMF_BITMAP_get(const char *contents, U_PMF_BITMAP *Bs, const char **Data); +int U_PMF_BITMAPDATA_get(const char *contents, U_PMF_PALETTE *Ps, const char **Colors, const char **Data); +int U_PMF_BLENDCOLORS_get(const char *contents, uint32_t *Elements, U_FLOAT **Positions, const char **Colors); +int U_PMF_BLENDFACTORS_get(const char *contents, uint32_t *Elements, U_FLOAT **Positions, U_FLOAT **Factors); +int U_PMF_BOUNDARYPATHDATA_get(const char *contents, int32_t *Size, const char **Data); +int U_PMF_BOUNDARYPOINTDATA_get(const char *contents, int32_t *Elements, U_PMF_POINTF **Points); +int U_PMF_CHARACTERRANGE_get(const char *contents, int32_t *First, int32_t *Length); +int U_PMF_COMPOUNDLINEDATA_get(const char *contents, int32_t *Elements, U_FLOAT **Widths); +int U_PMF_COMPRESSEDIMAGE_get(const char *contents, const char **Data); +int U_PMF_CUSTOMENDCAPDATA_get(const char *contents, int32_t *Size, const char **Data); +int U_PMF_CUSTOMLINECAPARROWDATA_get(const char *contents, U_PMF_CUSTOMLINECAPARROWDATA *Ccad); +int U_PMF_CUSTOMLINECAPDATA_get(const char *contents, U_PMF_CUSTOMLINECAPDATA *Clcd, const char **Data); +int U_PMF_CUSTOMLINECAPOPTIONALDATA_get(const char *contents, uint32_t Flags, const char **FillData, const char **LineData); +int U_PMF_CUSTOMSTARTCAPDATA_get(const char *contents, int32_t *Size, const char **Data); +int U_PMF_DASHEDLINEDATA_get(const char *contents, int32_t *Elements, U_FLOAT **Lengths); +int U_PMF_FILLPATHOBJ_get(const char *contents, int32_t *Size, const char **Data); +int U_PMF_FOCUSSCALEDATA_get(const char *contents, uint32_t *Count, U_FLOAT *ScaleX, U_FLOAT *ScaleY); +int U_PMF_GRAPHICSVERSION_get(const char *contents, int *Signature, int *GrfVersion); +int U_PMF_HATCHBRUSHDATA_get(const char *contents, uint32_t *Style, U_PMF_ARGB *Foreground, U_PMF_ARGB *Background); +int U_PMF_INTEGER7_get(const char **contents, U_FLOAT *Value); +int U_PMF_INTEGER15_get(const char **contents, U_FLOAT *Value); +int U_PMF_LANGUAGEIDENTIFIER_get(U_PMF_LANGUAGEIDENTIFIER LId, int *SubLId, int *PriLId); +int U_PMF_LINEARGRADIENTBRUSHDATA_get(const char *contents, U_PMF_LINEARGRADIENTBRUSHDATA *Lgbd, const char **Data); +int U_PMF_LINEARGRADIENTBRUSHOPTIONALDATA_get(const char *contents, uint32_t Flags, U_PMF_TRANSFORMMATRIX *Tm, const char **Bc, const char **BfH, const char **BfV); +int U_PMF_LINEPATH_get(const char *contents, int32_t *Size, const char **Data); +int U_PMF_METAFILE_get(const char *contents, uint32_t *Type, uint32_t *Size, const char **Data); +int U_PMF_PALETTE_get(const char *contents, uint32_t *Flags, uint32_t *Elements, const char **Data); +int U_PMF_PATHGRADIENTBRUSHDATA_get(const char *contents, U_PMF_PATHGRADIENTBRUSHDATA *Pgbd, const char **Gradient, const char **Boundary, const char **Data); +int U_PMF_PATHGRADIENTBRUSHOPTIONALDATA_get(const char *contents, uint32_t Flags, U_PMF_TRANSFORMMATRIX *Matrix, const char **Pattern, const char **Data); +int U_PMF_PATHPOINTTYPE_get(const char *contents, int *Flags, int *Type); +int U_PMF_PATHPOINTTYPERLE_get(const char *contents, int *Bezier, int *RL, int *Ppt); +int U_PMF_PENDATA_get(const char *contents, uint32_t *Flags, uint32_t *Unit, U_FLOAT *Width, const char **Data); +int U_PMF_PENOPTIONALDATA_get(const char *contents, uint32_t Flags, U_PMF_TRANSFORMMATRIX *Matrix, + int32_t *StartCap, int32_t *EndCap, uint32_t *Join, U_FLOAT *MiterLimit, int32_t *Style, int32_t *DLCap, U_FLOAT *DLOffset, + const char **DLData, int32_t *Alignment, const char **CmpndLineData, const char **CSCapData, const char **CECapData); +int U_PMF_POINT_get(const char **contents, U_FLOAT *X, U_FLOAT *Y); +int U_PMF_POINTF_get(const char **contents, U_FLOAT *X, U_FLOAT *Y); +int U_PMF_POINTR_get(const char **contents, U_FLOAT *X, U_FLOAT *Y); +int U_PMF_RECT_get(const char **contents, int16_t *X, int16_t *Y, int16_t *Width, int16_t *Height); +int U_PMF_RECTF_get(const char **contents, U_FLOAT *X, U_FLOAT *Y, U_FLOAT *Width, U_FLOAT *Height); +int U_PMF_REGIONNODE_get(const char *contents, uint32_t *Type, const char **Data); +/* There is no U_PMF_REGIONNODECHILDNODES_get, see the note in upmf.c */ +int U_PMF_REGIONNODEPATH_get(const char *contents, int32_t *Size, const char **Data); +int U_PMF_SOLIDBRUSHDATA_get(const char *contents, U_PMF_ARGB *Color); +int U_PMF_STRINGFORMATDATA_get(const char *contents, uint32_t TabStopCount, uint32_t RangeCount, + const U_FLOAT **TabStops, const U_PMF_CHARACTERRANGE **CharRange); +int U_PMF_TEXTUREBRUSHDATA_get(const char *contents, uint32_t *Flags, int32_t *WrapMode, const char **Data); +int U_PMF_TEXTUREBRUSHOPTIONALDATA_get(const char *contents, int HasImage, U_PMF_TRANSFORMMATRIX *Matrix, const char **Image); +int U_PMF_TRANSFORMMATRIX_get(const char *contents, U_PMF_TRANSFORMMATRIX *Matrix); +int U_PMF_IE_BLUR_get(const char *contents, U_FLOAT *Radius, uint32_t *ExpandEdge); +int U_PMF_IE_BRIGHTNESSCONTRAST_get(const char *contents, int32_t *Brightness, int32_t *Contrast); +int U_PMF_IE_COLORBALANCE_get(const char *contents, int32_t *CyanRed, int32_t *MagentaGreen, int32_t *YellowBlue); +int U_PMF_IE_COLORCURVE_get(const char *contents, uint32_t *Adjust, uint32_t *Channel, int32_t *Intensity); +int U_PMF_IE_COLORLOOKUPTABLE_get(const char *contents, + const uint8_t **BLUT, const uint8_t **GLUT, const uint8_t **RLUT, const uint8_t **ALUT); +int U_PMF_IE_COLORMATRIX_get(const char *contents, U_PMF_IE_COLORMATRIX *Matrix); +int U_PMF_IE_HUESATURATIONLIGHTNESS_get(const char *contents, int32_t *Hue, int32_t *Saturation, int32_t *Lightness); +int U_PMF_IE_LEVELS_get(const char *contents, int32_t *Highlight, int32_t *Midtone, int32_t *Shadow); +int U_PMF_IE_REDEYECORRECTION_get(const char *contents, int32_t *Elements, U_RECTL **Rects); +int U_PMF_IE_SHARPEN_get(const char *contents, U_FLOAT *Radius, int32_t *Sharpen); +int U_PMF_IE_TINT_get(const char *contents, int32_t *Hue, int32_t *Amount); + +/* EMF+ prototypes (records_get) */ + +int U_PMR_OFFSETCLIP_get(const char *contents, U_PMF_CMN_HDR *Header, U_FLOAT *dX, U_FLOAT *dY); +int U_PMR_RESETCLIP_get(const char *contents, U_PMF_CMN_HDR *Header); +int U_PMR_SETCLIPPATH_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *PathID, int *CMenum); +int U_PMR_SETCLIPRECT_get(const char *contents, U_PMF_CMN_HDR *Header, int *CMenum, U_PMF_RECTF *Rect); +int U_PMR_SETCLIPREGION_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *PathID, int *CMenum); +int U_PMR_COMMENT_get(const char *contents, U_PMF_CMN_HDR *Header, const char **Data); +int U_PMR_ENDOFFILE_get(const char *contents, U_PMF_CMN_HDR *Header); +int U_PMR_GETDC_get(const char *contents, U_PMF_CMN_HDR *Header); +int U_PMR_HEADER_get(const char *contents, U_PMF_CMN_HDR *Header, U_PMF_GRAPHICSVERSION *Version, int *IsDual, int *IsVideo, uint32_t *LogicalDpiX, uint32_t *LogicalDpiY); +int U_PMR_CLEAR_get(const char *contents, U_PMF_CMN_HDR *Header, U_PMF_ARGB *Color); +int U_PMR_DRAWARC_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *PenID, int *ctype, U_FLOAT *Start, U_FLOAT *Sweep, U_PMF_RECTF *Rect); +int U_PMR_DRAWBEZIERS_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *PenID, int *ctype, int *RelAbs, uint32_t *Elements, U_PMF_POINTF **Points); +int U_PMR_DRAWCLOSEDCURVE_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *PenID, int *ctype, int *RelAbs, U_FLOAT *Tension, uint32_t *Elements, U_PMF_POINTF **Points); +int U_PMR_DRAWCURVE_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *PenID, int *ctype, U_FLOAT *Tension, uint32_t *Offset, uint32_t *NSegs, uint32_t *Elements, U_PMF_POINTF **Points); +int U_PMR_DRAWDRIVERSTRING_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *FontID, int *btype, U_FLOAT *Tension, uint32_t *BrushID, uint32_t *DSOFlags, uint32_t *HasMatrix, uint32_t *Elements, uint16_t **Glyphs, U_PMF_POINTF **Points, U_PMF_TRANSFORMMATRIX **Matrix); +int U_PMR_DRAWELLIPSE_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *PenID, int *ctype, U_PMF_RECTF *Rect); +int U_PMR_DRAWIMAGE_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *ImgID, int *ctype, uint32_t *ImgAttrID, int32_t *SrcUnit, U_PMF_RECTF *SrcRect, U_PMF_RECTF *DstRect); +int U_PMR_DRAWIMAGEPOINTS_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *ImgID, int *ctype, int *etype, int *RelAbs, uint32_t *ImgAttrID, int32_t *SrcUnit, U_PMF_RECTF *SrcRect, uint32_t *Elements, U_PMF_POINTF **Points); +int U_PMR_DRAWLINES_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *PenID, int *ctype, int *dtype, int *RelAbs, uint32_t *Elements, U_PMF_POINTF **Points); +int U_PMR_DRAWPATH_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *PathID, uint32_t *PenID); +int U_PMR_DRAWPIE_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *PenID, int *ctype, U_FLOAT *Start, U_FLOAT *Sweep, U_PMF_RECTF *Rect); +int U_PMR_DRAWRECTS_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *PenID, int *ctype, uint32_t *Elements, U_PMF_RECTF **Rects); +int U_PMR_DRAWSTRING_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *FontID, int *btype, uint32_t *BrushID, uint32_t *FormatID, uint32_t *Elements, U_PMF_RECTF *Rect, uint16_t **String); +int U_PMR_FILLCLOSEDCURVE_get(const char *contents, U_PMF_CMN_HDR *Header, int *btype, int *ctype, int *ftype, int *RelAbs, uint32_t *BrushID, U_FLOAT *Tension, uint32_t *Elements, U_PMF_POINTF **Points); +int U_PMR_FILLELLIPSE_get(const char *contents, U_PMF_CMN_HDR *Header, int *btype, int *ctype, uint32_t *BrushID, U_PMF_RECTF *Rect); +int U_PMR_FILLPATH_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *PathID, int *btype, uint32_t *BrushID); +int U_PMR_FILLPIE_get(const char *contents, U_PMF_CMN_HDR *Header, int *btype, int *ctype, uint32_t *BrushID, U_FLOAT *Start, U_FLOAT *Sweep, U_PMF_RECTF *Rect); +int U_PMR_FILLPOLYGON_get(const char *contents, U_PMF_CMN_HDR *Header, int *btype, int *ctype, int *RelAbs, uint32_t *BrushID, uint32_t *Elements, U_PMF_POINTF **Points); +int U_PMR_FILLRECTS_get(const char *contents, U_PMF_CMN_HDR *Header, int *btype, int *ctype, uint32_t *BrushID, uint32_t *Elements, U_PMF_RECTF **Rects); +int U_PMR_FILLREGION_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *RgnID, int *btype, int *ctype, uint32_t *BrushID); +int U_PMR_OBJECT_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *ObjID, int *otype, int *ntype, uint32_t *TSize, const char **Data); +int U_PMR_SERIALIZABLEOBJECT_get(const char *contents, U_PMF_CMN_HDR *Header, uint8_t *GUID, uint32_t *Size, const char **Data); +int U_PMR_SETANTIALIASMODE_get(const char *contents, U_PMF_CMN_HDR *Header, int *SMenum, int *aatype); +int U_PMR_SETCOMPOSITINGMODE_get(const char *contents, U_PMF_CMN_HDR *Header, int *CMenum); +int U_PMR_SETCOMPOSITINGQUALITY_get(const char *contents, U_PMF_CMN_HDR *Header, int *CQenum); +int U_PMR_SETINTERPOLATIONMODE_get(const char *contents, U_PMF_CMN_HDR *Header, int *IMenum); +int U_PMR_SETPIXELOFFSETMODE_get(const char *contents, U_PMF_CMN_HDR *Header, int *POMenum); +int U_PMR_SETRENDERINGORIGIN_get(const char *contents, U_PMF_CMN_HDR *Header, int32_t *X, int32_t *Y); +int U_PMR_SETTEXTCONTRAST_get(const char *contents, U_PMF_CMN_HDR *Header, int *TGC); +int U_PMR_SETTEXTRENDERINGHINT_get(const char *contents, U_PMF_CMN_HDR *Header, int *TRHenum); +int U_PMR_BEGINCONTAINER_get(const char *contents, U_PMF_CMN_HDR *Header, int *UTenum, U_PMF_RECTF *DstRect, U_PMF_RECTF *SrcRect, uint32_t *StackID); +int U_PMR_BEGINCONTAINERNOPARAMS_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *StackID); +int U_PMR_ENDCONTAINER_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *StackID); +int U_PMR_RESTORE_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *StackID); +int U_PMR_SAVE_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *StackID); +int U_PMR_SETTSCLIP_get(const char *contents, U_PMF_CMN_HDR *Header, int *ctype, uint32_t *Elements, U_PMF_RECTF **Rects); +int U_PMR_SETTSGRAPHICS_get(const char *contents, U_PMF_CMN_HDR *Header, int *vgatype, int *pptype, uint8_t *AntiAliasMode, uint8_t *TextRenderHint, uint8_t *CompositingMode, uint8_t *CompositingQuality, int16_t *RenderOriginX, int16_t *RenderOriginY, uint16_t *TextContrast, uint8_t *FilterType, uint8_t *PixelOffset, U_PMF_TRANSFORMMATRIX *WorldToDevice, const char **Data); +int U_PMR_MULTIPLYWORLDTRANSFORM_get(const char *contents, U_PMF_CMN_HDR *Header, int *xmtype, U_PMF_TRANSFORMMATRIX *Matrix); +int U_PMR_RESETWORLDTRANSFORM_get(const char *contents, U_PMF_CMN_HDR *Header); +int U_PMR_ROTATEWORLDTRANSFORM_get(const char *contents, U_PMF_CMN_HDR *Header, int *xmtype, U_FLOAT *Angle); +int U_PMR_SCALEWORLDTRANSFORM_get(const char *contents, U_PMF_CMN_HDR *Header, int *xmtype, U_FLOAT *Sx, U_FLOAT *Sy); +int U_PMR_SETPAGETRANSFORM_get(const char *contents, U_PMF_CMN_HDR *Header, int *PUenum, U_FLOAT *Scale); +int U_PMR_SETWORLDTRANSFORM_get(const char *contents, U_PMF_CMN_HDR *Header, U_PMF_TRANSFORMMATRIX *Matrix); +int U_PMR_TRANSLATEWORLDTRANSFORM_get(const char *contents, U_PMF_CMN_HDR *Header, int *xmtype, U_FLOAT *Dx, U_FLOAT *Dy); +int U_PMR_STROKEFILLPATH_get(const char *contents, U_PMF_CMN_HDR *Header); +int U_PMR_MULTIFORMATSTART_get(const char *contents, U_PMF_CMN_HDR *Header); +int U_PMR_MULTIFORMATSECTION_get(const char *contents, U_PMF_CMN_HDR *Header); +int U_PMR_MULTIFORMATEND_get(const char *contents, U_PMF_CMN_HDR *Header); +//! \endcond + + +#ifdef __cplusplus +} +#endif + +#endif /* _UPMF_ */ diff --git a/src/libuemf/upmf_print.c b/src/libuemf/upmf_print.c new file mode 100644 index 000000000..f446d6caf --- /dev/null +++ b/src/libuemf/upmf_print.c @@ -0,0 +1,3138 @@ +/** + @file upmf_print.c + + @brief Functions for printing EMF records +*/ + +/* +File: upmf_print.c +Version: 0.0.2 +Date: 17-OCT-2013 +Author: David Mathog, Biology Division, Caltech +email: mathog@caltech.edu +Copyright: 2013 David Mathog and California Institute of Technology (Caltech) +*/ + +/* compiler options: + +-DNOBRUSH causes brush objects to be treated as pen objects. PowerPoint 2003 and 2010 define pen objects +as brush objects, and this is one way to see their structure even though they are misidentified. +This option should only be used for tiny test files, consisting of just line objects. +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdlib.h> +#include <stdio.h> +#include <stddef.h> /* for offsetof() macro */ +#include <string.h> +#include "upmf_print.h" +#include "uemf_print.h" + + +//! \cond + +#define UNUSED(x) (void)(x) //! Please ignore - Doxygen simply insisted on including this + +/* + this function is not visible in the API. Print "data" for one of the many records that has none. +*/ +int U_PMR_NODATAREC_print(const char *contents){ + U_PMF_CMN_HDR Header; + int status = U_PMR_RESETCLIP_get(contents,&Header); /* One of many possibilities */ + if(status)status = Header.Size; + return(status); +} + +/* + this function is not visible in the API. Common routine used by many functions that draw points. +*/ +void U_PMF_VARPOINTS_print(const char **contents, int Flags, uint32_t Elements){ + unsigned int i; + U_FLOAT Xpos, Ypos; + + if( Flags & U_PPF_P){ printf(" + Points(Relative):"); } + else if(Flags & U_PPF_C){ printf(" + Points(Int16):"); } + else { printf(" + Points(Float):"); } + for(Xpos = Ypos = i = 0; i<Elements; i++){ + printf(" %d:",i); + if( Flags & U_PPF_P){ (void) U_PMF_POINTR_print(contents, &Xpos, &Ypos); } + else if(Flags & U_PPF_C){ (void) U_PMF_POINT_print(contents); } + else { (void) U_PMF_POINTF_print(contents); } + } +#if 0 +int residual; +uintptr_t holdptr = (uintptr_t) *contents; + residual = holdptr & 0x3; + if(residual){ *contents += (4-residual); } +printf("DEBUG U_PMF_VARPOINTS_print residual:%d *contents:%p\n",residual,*contents);fflush(stdout); +#endif + printf("\n"); +} + +/* + this function is not visible in the API. Common routine used by many functions that draw points. +*/ +void U_PMF_VARPOINTF_S_print(U_PMF_POINTF *Points, uint32_t Elements){ + unsigned int i; + printf(" + Points:"); + for(i=0; i<Elements; i++, Points++){ + printf(" %d:",i); + (void) U_PMF_POINTF_S_print(Points); + } + printf("\n"); +} + +/* + this function is not visible in the API. Common routine used by many functions that draw rectangles. +*/ +int U_PMF_VARRECTF_S_print(U_PMF_RECTF *Rects, uint32_t Elements){ + if(!Elements)return(0); + if(Elements == 1){ printf(" Rect(Float):"); } + else { printf(" Rects(Float):"); } + while(1){ + U_PMF_RECTF_S_print(Rects++); + Elements--; + if(!Elements)break; + printf(" "); + } + return(1); +} + +/* + this function is not visible in the API. Common routine used by many functions. +*/ +int U_PMF_VARBRUSHID_print(int btype, uint32_t BrushID){ + if(btype){ + printf(" Color:"); + (void) U_PMF_ARGB_print((char *)&(BrushID)); + } + else { + printf(" BrushID:%u",BrushID); + } + return(1); +} +//! \endcond + +/** + \brief Print any EMF+ record + \returns record length for a normal record, 0 for EMREOF or , -1 for a bad record + \param contents pointer to a buffer holding this EMF+ record + \param blimit one byte past the end of data of this EMF+ record + \param recnum EMF number of this record in contents + \param off Offset from the beginning of the EMF+ file. +*/ +int U_pmf_onerec_print(const char *contents, const char *blimit, int recnum, int off){ + int status; + static U_OBJ_ACCUM ObjCont={NULL,0,0,0,0}; /* for keeping track of object continuation. These may + be split across multiple EMF Comment records */ + U_PMF_CMN_HDR Header; + const char *contemp = contents; + if(!U_PMF_CMN_HDR_get(&contemp, &Header)){return(-1);} + + int type = Header.Type & U_PMR_TYPE_MASK; /* strip the U_PMR_RECFLAG bit, leaving the indexable part */ + if(type < U_PMR_MIN || type > U_PMR_MAX)return(-1); /* unknown EMF+ record type */ + status = U_PMF_CMN_HDR_print(Header, recnum, off); /* EMF+ part */ + + /* Buggy EMF+ can set the continue bit and then do something else. In that case, force out the pending + Object. Side effect - clears the pending object. */ + if((type != U_PMR_OBJECT) && (ObjCont.used > 0)){ + U_PMR_OBJECT_print(contents, blimit, &ObjCont, 1); + } + + switch(type){ + case (U_PMR_HEADER): U_PMR_HEADER_print(contents); break; + case (U_PMR_ENDOFFILE): U_PMR_ENDOFFILE_print(contents); + U_OA_release(&ObjCont); break; + case (U_PMR_COMMENT): U_PMR_COMMENT_print(contents); break; + case (U_PMR_GETDC): U_PMR_GETDC_print(contents); break; + case (U_PMR_MULTIFORMATSTART): U_PMR_MULTIFORMATSTART_print(contents); break; + case (U_PMR_MULTIFORMATSECTION): U_PMR_MULTIFORMATSECTION_print(contents); break; + case (U_PMR_MULTIFORMATEND): U_PMR_MULTIFORMATEND_print(contents); break; + case (U_PMR_OBJECT): U_PMR_OBJECT_print(contents,blimit,&ObjCont,0); break; + case (U_PMR_CLEAR): U_PMR_CLEAR_print(contents); break; + case (U_PMR_FILLRECTS): U_PMR_FILLRECTS_print(contents, blimit); break; + case (U_PMR_DRAWRECTS): U_PMR_DRAWRECTS_print(contents, blimit); break; + case (U_PMR_FILLPOLYGON): U_PMR_FILLPOLYGON_print(contents); break; + case (U_PMR_DRAWLINES): U_PMR_DRAWLINES_print(contents); break; + case (U_PMR_FILLELLIPSE): U_PMR_FILLELLIPSE_print(contents); break; + case (U_PMR_DRAWELLIPSE): U_PMR_DRAWELLIPSE_print(contents); break; + case (U_PMR_FILLPIE): U_PMR_FILLPIE_print(contents); break; + case (U_PMR_DRAWPIE): U_PMR_DRAWPIE_print(contents); break; + case (U_PMR_DRAWARC): U_PMR_DRAWARC_print(contents); break; + case (U_PMR_FILLREGION): U_PMR_FILLREGION_print(contents); break; + case (U_PMR_FILLPATH): U_PMR_FILLPATH_print(contents); break; + case (U_PMR_DRAWPATH): U_PMR_DRAWPATH_print(contents); break; + case (U_PMR_FILLCLOSEDCURVE): U_PMR_FILLCLOSEDCURVE_print(contents); break; + case (U_PMR_DRAWCLOSEDCURVE): U_PMR_DRAWCLOSEDCURVE_print(contents); break; + case (U_PMR_DRAWCURVE): U_PMR_DRAWCURVE_print(contents); break; + case (U_PMR_DRAWBEZIERS): U_PMR_DRAWBEZIERS_print(contents); break; + case (U_PMR_DRAWIMAGE): U_PMR_DRAWIMAGE_print(contents); break; + case (U_PMR_DRAWIMAGEPOINTS): U_PMR_DRAWIMAGEPOINTS_print(contents); break; + case (U_PMR_DRAWSTRING): U_PMR_DRAWSTRING_print(contents); break; + case (U_PMR_SETRENDERINGORIGIN): U_PMR_SETRENDERINGORIGIN_print(contents); break; + case (U_PMR_SETANTIALIASMODE): U_PMR_SETANTIALIASMODE_print(contents); break; + case (U_PMR_SETTEXTRENDERINGHINT): U_PMR_SETTEXTRENDERINGHINT_print(contents); break; + case (U_PMR_SETTEXTCONTRAST): U_PMR_SETTEXTCONTRAST_print(contents); break; + case (U_PMR_SETINTERPOLATIONMODE): U_PMR_SETINTERPOLATIONMODE_print(contents); break; + case (U_PMR_SETPIXELOFFSETMODE): U_PMR_SETPIXELOFFSETMODE_print(contents); break; + case (U_PMR_SETCOMPOSITINGMODE): U_PMR_SETCOMPOSITINGMODE_print(contents); break; + case (U_PMR_SETCOMPOSITINGQUALITY): U_PMR_SETCOMPOSITINGQUALITY_print(contents); break; + case (U_PMR_SAVE): U_PMR_SAVE_print(contents); break; + case (U_PMR_RESTORE): U_PMR_RESTORE_print(contents); break; + case (U_PMR_BEGINCONTAINER): U_PMR_BEGINCONTAINER_print(contents); break; + case (U_PMR_BEGINCONTAINERNOPARAMS): U_PMR_BEGINCONTAINERNOPARAMS_print(contents); break; + case (U_PMR_ENDCONTAINER): U_PMR_ENDCONTAINER_print(contents); break; + case (U_PMR_SETWORLDTRANSFORM): U_PMR_SETWORLDTRANSFORM_print(contents); break; + case (U_PMR_RESETWORLDTRANSFORM): U_PMR_RESETWORLDTRANSFORM_print(contents); break; + case (U_PMR_MULTIPLYWORLDTRANSFORM): U_PMR_MULTIPLYWORLDTRANSFORM_print(contents); break; + case (U_PMR_TRANSLATEWORLDTRANSFORM): U_PMR_TRANSLATEWORLDTRANSFORM_print(contents); break; + case (U_PMR_SCALEWORLDTRANSFORM): U_PMR_SCALEWORLDTRANSFORM_print(contents); break; + case (U_PMR_ROTATEWORLDTRANSFORM): U_PMR_ROTATEWORLDTRANSFORM_print(contents); break; + case (U_PMR_SETPAGETRANSFORM): U_PMR_SETPAGETRANSFORM_print(contents); break; + case (U_PMR_RESETCLIP): U_PMR_RESETCLIP_print(contents); break; + case (U_PMR_SETCLIPRECT): U_PMR_SETCLIPRECT_print(contents); break; + case (U_PMR_SETCLIPPATH): U_PMR_SETCLIPPATH_print(contents); break; + case (U_PMR_SETCLIPREGION): U_PMR_SETCLIPREGION_print(contents); break; + case (U_PMR_OFFSETCLIP): U_PMR_OFFSETCLIP_print(contents); break; + case (U_PMR_DRAWDRIVERSTRING): U_PMR_DRAWDRIVERSTRING_print(contents); break; + case (U_PMR_STROKEFILLPATH): U_PMR_STROKEFILLPATH_print(contents); break; + case (U_PMR_SERIALIZABLEOBJECT): U_PMR_SERIALIZABLEOBJECT_print(contents); break; + case (U_PMR_SETTSGRAPHICS): U_PMR_SETTSGRAPHICS_print(contents); break; + case (U_PMR_SETTSCLIP): U_PMR_SETTSCLIP_print(contents); break; + } + return(status); +} + +/** + \brief Print data from a U_PMF_CMN_HDR object + \return number of bytes in record, 0 on error + \param Header Header of the record + \param precnum EMF+ record number in file. + \param off Offset in file to the start of this EMF+ record. + common structure present at the beginning of all(*) EMF+ records +*/ +int U_PMF_CMN_HDR_print(U_PMF_CMN_HDR Header, int precnum, int off){ + printf(" %-29srec+:%5d type:%X offset:%8d rsize:%8u dsize:%8u flags:%4.4X\n", + U_pmr_names(Header.Type &U_PMR_TYPE_MASK),precnum, Header.Type,off,Header.Size,Header.DataSize,Header.Flags); + return((int) Header.Size); +} + +/** + \brief Print data from a an array of uint8_t values + \return 1 + \param Start Text to lead array data + \param Array uint8_t array of data passed as char * + \param Elements Number of elements in Array + \param End Text to follow array data +*/ +int U_PMF_UINT8_ARRAY_print(const char *Start, const uint8_t *Array, int Elements, char *End){ + if(Start)printf("%s",Start); + for(; Elements--; Array++){ printf(" %u", *Array); } + if(End)printf("%s",End); + return(1); +} + +/** + \brief Print value of an BrushType Enumeration + \returns record 1 on sucess, 0 on error + \param otype Value to print. + EMF+ manual 2.1.1.3, Microsoft name: BrushType Enumeration +*/ +int U_PMF_BRUSHTYPEENUMERATION_print(int otype){ + int status=1; + switch(otype){ + case U_BT_SolidColor: printf("SolidColor"); break; + case U_BT_HatchFill: printf("HatchFill"); break; + case U_BT_TextureFill: printf("TextureFill"); break; + case U_BT_PathGradient: printf("PathGradient"); break; + case U_BT_LinearGradient: printf("LinearGradient"); break; + default: status=0; printf("INVALID(%d)",otype); break; + } + return(status); +} + +/** + \brief Print value of an BrushType Enumeration + \returns record 1 on sucess, 0 on error + \param otype Value to print. + EMF+ manual 2.1.1.4, Microsoft name: BrushType Enumeration +*/ +int U_PMF_COMBINEMODEENUMERATION_print(int otype){ + int status=1; + switch(otype){ + case U_CM_Replace: printf("Replace" ); break; + case U_CM_Intersect: printf("Intersect" ); break; + case U_CM_Union: printf("Union" ); break; + case U_CM_XOR: printf("XOR" ); break; + case U_CM_Exclude: printf("Exclude" ); break; + case U_CM_Complement: printf("Complement"); break; + default: status=0; printf("INVALID(%d)",otype); break; + } + return(status); +} + +/** + \brief Print value of a HatchStyle Enumeration + \returns record 1 on sucess, 0 on error + \param hstype Value to print. + EMF+ manual 2.1.1.13, Microsoft name: HatchStyle Enumeration +*/ +int U_PMF_HATCHSTYLEENUMERATION_print(int hstype){ + int status=1; + switch(hstype){ + case U_HSP_Horizontal: printf("Horizontal"); break; + case U_HSP_Vertical: printf("Vertical"); break; + case U_HSP_ForwardDiagonal: printf("ForwardDiagonal"); break; + case U_HSP_BackwardDiagonal: printf("BackwardDiagonal"); break; + case U_HSP_LargeGrid: printf("LargeGrid"); break; + case U_HSP_DiagonalCross: printf("DiagonalCross"); break; + case U_HSP_05Percent: printf("05Percent"); break; + case U_HSP_10Percent: printf("10Percent"); break; + case U_HSP_20Percent: printf("20Percent"); break; + case U_HSP_25Percent: printf("25Percent"); break; + case U_HSP_30Percent: printf("30Percent"); break; + case U_HSP_40Percent: printf("40Percent"); break; + case U_HSP_50Percent: printf("50Percent"); break; + case U_HSP_60Percent: printf("60Percent"); break; + case U_HSP_70Percent: printf("70Percent"); break; + case U_HSP_75Percent: printf("75Percent"); break; + case U_HSP_80Percent: printf("80Percent"); break; + case U_HSP_90Percent: printf("90Percent"); break; + case U_HSP_LightDownwardDiagonal: printf("LightDownwardDiagonal"); break; + case U_HSP_LightUpwardDiagonal: printf("LightUpwardDiagonal"); break; + case U_HSP_DarkDownwardDiagonal: printf("DarkDownwardDiagonal"); break; + case U_HSP_DarkUpwardDiagonal: printf("DarkUpwardDiagonal"); break; + case U_HSP_WideDownwardDiagonal: printf("WideDownwardDiagonal"); break; + case U_HSP_WideUpwardDiagonal: printf("WideUpwardDiagonal"); break; + case U_HSP_LightVertical: printf("LightVertical"); break; + case U_HSP_LightHorizontal: printf("LightHorizontal"); break; + case U_HSP_NarrowVertical: printf("NarrowVertical"); break; + case U_HSP_NarrowHorizontal: printf("NarrowHorizontal"); break; + case U_HSP_DarkVertical: printf("DarkVertical"); break; + case U_HSP_DarkHorizontal: printf("DarkHorizontal"); break; + case U_HSP_DashedDownwardDiagonal: printf("DashedDownwardDiagonal"); break; + case U_HSP_DashedUpwardDiagonal: printf("DashedUpwardDiagonal"); break; + case U_HSP_DashedHorizontal: printf("DashedHorizontal"); break; + case U_HSP_DashedVertical: printf("DashedVertical"); break; + case U_HSP_SmallConfetti: printf("SmallConfetti"); break; + case U_HSP_LargeConfetti: printf("LargeConfetti"); break; + case U_HSP_ZigZag: printf("ZigZag"); break; + case U_HSP_Wave: printf("Wave"); break; + case U_HSP_DiagonalBrick: printf("DiagonalBrick"); break; + case U_HSP_HorizontalBrick: printf("HorizontalBrick"); break; + case U_HSP_Weave: printf("Weave"); break; + case U_HSP_Plaid: printf("Plaid"); break; + case U_HSP_Divot: printf("Divot"); break; + case U_HSP_DottedGrid: printf("DottedGrid"); break; + case U_HSP_DottedDiamond: printf("DottedDiamond"); break; + case U_HSP_Shingle: printf("Shingle"); break; + case U_HSP_Trellis: printf("Trellis"); break; + case U_HSP_Sphere: printf("Sphere"); break; + case U_HSP_SmallGrid: printf("SmallGrid"); break; + case U_HSP_SmallCheckerBoard: printf("SmallCheckerBoard"); break; + case U_HSP_LargeCheckerBoard: printf("LargeCheckerBoard"); break; + case U_HSP_OutlinedDiamond: printf("OutlinedDiamond"); break; + case U_HSP_SolidDiamond: printf("SolidDiamond"); break; + default: status=0; printf("INVALID(%d)",hstype); break; + } + return(status); +} + +/** + \brief Print value of an ObjectType Enumeration + \returns record 1 on sucess, 0 on error + \param otype Value to print. + EMF+ manual 2.1.1.22, Microsoft name: ObjectType Enumeration +*/ +int U_PMF_OBJECTTYPEENUMERATION_print(int otype){ + int status=1; + switch(otype){ + case U_OT_Invalid: printf("Invalid"); break; + case U_OT_Brush: printf("Brush"); break; + case U_OT_Pen: printf("Pen"); break; + case U_OT_Path: printf("Path"); break; + case U_OT_Region: printf("Region"); break; + case U_OT_Image: printf("Image"); break; + case U_OT_Font: printf("Font"); break; + case U_OT_StringFormat: printf("StringFormat"); break; + case U_OT_ImageAttributes: printf("ImageAttributes"); break; + case U_OT_CustomLineCap: printf("CustomLineCap"); break; + default: + status=0; printf("INVALID(%d)",otype); break; + } + return(status); +} + +/** + \brief Print value of a U_PMF_PATHPOINTTYPE_ENUM object + \return 1 + \param Type Value to print + EMF+ manual 2.1.1.23, Microsoft name: PathPointType Enumeration +*/ +int U_PMF_PATHPOINTTYPE_ENUM_print(int Type){ + switch(Type & U_PPT_MASK){ + case U_PPT_Start : printf("Start"); break; + case U_PPT_Line : printf("Line"); break; + case U_PPT_Bezier: printf("Bezier"); break; + default: printf("INVALID(%d)",Type); break; + } + return(1); +} + +/** + \brief Print data from a PixelFormat Enumeration value + \return 1 always + \param pfe A PixelFormat Enumeration value + EMF+ manual 2.1.1.25, Microsoft name: PixelFormat Enumeration (U_PF_*) +*/ +int U_PMF_PX_FMT_ENUM_print(int pfe){ + uint8_t idx; + printf(" + PxFmtEnum: "); + printf(" 32Bit:%c", (pfe & 1<< 9 ? 'Y' : 'N')); + printf(" 16Bit:%c", (pfe & 1<<10 ? 'Y' : 'N')); + printf(" PreAlpha:%c", (pfe & 1<<11 ? 'Y' : 'N')); + printf(" Alpha:%c", (pfe & 1<<12 ? 'Y' : 'N')); + printf(" GDI:%c", (pfe & 1<<13 ? 'Y' : 'N')); + printf(" LUT:%c", (pfe & 1<<14 ? 'Y' : 'N')); + printf(" BitsPerPx:%u", (pfe >> 16) & 0xFF); + idx = pfe >> 24; + printf(" Type:%u(",idx); + switch(idx){ + case 0: printf("undefined"); break; + case 1: printf("monochrome with LUT"); break; + case 2: printf("4 bit with LUT"); break; + case 3: printf("8 bit with LUT"); break; + case 4: printf("16 bits grey values"); break; + case 5: printf("16 bit RGB values (5,5,5,(1 ignored))"); break; + case 6: printf("16 bit RGB values (5,6,5)"); break; + case 7: printf("16 bit ARGB values (1 alpha, 5,5,5 colors)"); break; + case 8: printf("24 bit RGB values (8,8.8)"); break; + case 9: printf("32 bit RGB value (8,8,8,(8 ignored))"); break; + case 10: printf("32 bit ARGB values (8 alpha,8,8,8)"); break; + case 11: printf("32 bit PARGB values (8,8,8,8, but RGB already multiplied by A)"); break; + case 12: printf("48 bit RGB (16,16,16)"); break; + case 13: printf("64 bit ARGB (16 alpha, 16,16,16)"); break; + case 14: printf("64 bit PARGB (16,16,16,16, but RGB already multiplied by A)"); break; + default: printf("INVALID(%d)",idx); break; + } + printf(")"); + return(1); +} + +/** + \brief Print as text a RegionNodeDataType Enumeration + \return 1 + \param Type RegionNodeDataType Enumeration + EMF+ manual 2.1.1.27, Microsoft name: RegionNodeDataType Enumeration (U_RNDT_*) +*/ +int U_PMF_NODETYPE_print(int Type){ + if( Type == U_RNDT_And ){ printf("And" ); } + else if(Type == U_RNDT_Or ){ printf("Or" ); } + else if(Type == U_RNDT_Xor ){ printf("Xor" ); } + else if(Type == U_RNDT_Exclude ){ printf("Exclude" ); } + else if(Type == U_RNDT_Complement){ printf("Complement"); } + else if(Type == U_RNDT_Rect ){ printf("Rect" ); } + else if(Type == U_RNDT_Path ){ printf("Path" ); } + else if(Type == U_RNDT_Empty ){ printf("Empty" ); } + else if(Type == U_RNDT_Infinite ){ printf("Infinite" ); } + else { printf("Undefined" ); return(0); } + return(1); +} + +/** + \brief Print data from a U_PMF_BRUSH object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.1.1, Microsoft name: EmfPlusBrush Object +*/ +int U_PMF_BRUSH_print(const char *contents){ + uint32_t Version, Type; + const char *Data; + int status = U_PMF_BRUSH_get(contents, &Version, &Type, &Data); + if(status){ + printf(" + Brush:"); + (void) U_PMF_GRAPHICSVERSION_print((char *)&Version); + printf(" Type:%X(",Type); + (void) U_PMF_BRUSHTYPEENUMERATION_print(Type); + printf(")"); + switch(Type){ + case U_BT_SolidColor: + status = U_PMF_ARGB_print(Data); + break; + case U_BT_HatchFill: + printf("\n"); + status = U_PMF_HATCHBRUSHDATA_print(Data); + break; + case U_BT_TextureFill: + printf("\n"); + status = U_PMF_TEXTUREBRUSHDATA_print(Data); + break; + case U_BT_PathGradient: + printf("\n"); + status = U_PMF_PATHGRADIENTBRUSHDATA_print(Data); + break; + case U_BT_LinearGradient: + printf("\n"); + status = U_PMF_LINEARGRADIENTBRUSHDATA_print(Data); + break; + default: + status = 0; + } + printf("\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMF_CUSTOMLINECAP object + \return 1 on success, 0 on error + \param contents Record from which to print data + \param Which A string which is either "Start" or "End". + EMF+ manual 2.2.1.2, Microsoft name: EmfPlusCustomLineCap Object +*/ +int U_PMF_CUSTOMLINECAP_print(const char *contents, const char *Which){ + uint32_t Version, Type; + const char *Data; + int status = U_PMF_CUSTOMLINECAP_get(contents, &Version, &Type, &Data); + + if(status){ + printf(" + %sLineCap:",Which); + (void) U_PMF_GRAPHICSVERSION_print((char *)&Version); + printf(", Type %X\n",Type); + switch(Type){ + case U_CLCDT_Default: + status = U_PMF_CUSTOMLINECAPDATA_print(Data); + break; + case U_CLCDT_AdjustableArrow: + status = U_PMF_CUSTOMLINECAPARROWDATA_print(Data); + break; + default: + status = 0; + } + } + return(status); +} + +/** + \brief Print data from a U_PMF_FONT object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.1.3, Microsoft name: EmfPlusFont Object +*/ +int U_PMF_FONT_print(const char *contents){ + uint32_t Version, SizeUnit, Length; + U_FLOAT EmSize; + int32_t FSFlags; + const char *Data; + char *string; + int status = U_PMF_FONT_get(contents, &Version, &EmSize, &SizeUnit, &FSFlags, &Length, &Data); + if(status){ + printf(" + Font:"); + (void) U_PMF_GRAPHICSVERSION_print((char *)&Version); + printf(" EmSize:%f ", EmSize ); + printf(" SizeUnit:%d ",SizeUnit); + printf(" FSFlags:%d ", FSFlags ); + printf(" Length:%d", Length ); + string = U_Utf16leToUtf8((uint16_t *)Data, Length, NULL); + if(string){ + printf(" Family:<%s>\n",string); + free(string); + } + else { + printf(" Family:<>\n"); + } + } + return(status); +} + + +/** + \brief Print data from a U_PMF_IMAGE object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.1.4, Microsoft name: EmfPlusImage Object +*/ +int U_PMF_IMAGE_print(const char *contents){ + uint32_t Version, Type; + const char *Data; + int status = U_PMF_IMAGE_get(contents, &Version, &Type, &Data); + if(status){ + printf(" + Image:"); + (void) U_PMF_GRAPHICSVERSION_print((char *)&Version); + printf(" Type:%X\n",Type); + switch(Type){ + case U_IDT_Unknown: + printf(" + Unknown Image Type\n"); + break; + case U_IDT_Bitmap: + status = U_PMF_BITMAP_print(Data); + break; + case U_IDT_Metafile: + status = U_PMF_METAFILE_print(Data); + break; + default: + status = 0; + } + } + return(status); +} + + +/** + \brief Print data from a U_PMF_IMAGEATTRIBUTES object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.1.5, Microsoft name: EmfPlusImageAttributes Object +*/ +int U_PMF_IMAGEATTRIBUTES_print(const char *contents){ + uint32_t Version, WrapMode, ClampColor, ObjectClamp; + int status = U_PMF_IMAGEATTRIBUTES_get(contents, &Version, &WrapMode, &ClampColor, &ObjectClamp); + + if(status){ + printf(" + Image Attributes: "); + (void) U_PMF_GRAPHICSVERSION_print((char *)&Version); + printf(" WrapMode:%X", WrapMode); + printf(" ClampColor:%X", ClampColor); + printf(" ObjectClamp:%X\n", ObjectClamp); + } + return(status); +} + + + +/** + \brief Print data from a U_PMF_PATH object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.1.6, Microsoft name: EmfPlusPath Object +*/ +int U_PMF_PATH_print(const char *contents){ + unsigned int i, pos; + uint32_t Version, Count; + uint16_t Flags; + const char *Points; + const char *Types; + int status = U_PMF_PATH_get(contents, &Version, &Count, &Flags, &Points, &Types); + if(status){ + printf(" + Path: Version:%X Count:%d Flags:%X\n",Version, Count, Flags); + + /* Points part */ + U_PMF_VARPOINTS_print(&Points, Flags, Count); + + /* Types part */ + printf(" + Types:"); + pos = 0; + for(i=0; i<Count; i++){ + /* EMF+ manual says that the first of these two cases can actually contain either type + of PATHPOINT, but it does not say how the program is supposed to figure out which record + is which type. */ + if(Flags & U_PPF_R){ + printf(" %u:",pos); + pos += U_PMF_PATHPOINTTYPERLE_print(Types); + Types+=2; + } + else { + printf(" %d:",i); + (void) U_PMF_PATHPOINTTYPE_print(Types); + Types++; + } + } + printf("\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMF_PEN object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.1.7, Microsoft name: EmfPlusPen Object +*/ +int U_PMF_PEN_print(const char *contents){ + uint32_t Version, Type; + const char *PenData; + const char *Brush; + int status = U_PMF_PEN_get(contents, &Version, &Type, &PenData, &Brush); + if(status){ + printf(" + Pen: Version:%X Type:%d\n",Version,Type); + (void) U_PMF_PENDATA_print(PenData); + (void) U_PMF_BRUSH_print(Brush); + } + return(status); +} + +/** + \brief Print data from a U_PMF_REGION object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.1.8, Microsoft name: EmfPlusRegion Object +*/ +int U_PMF_REGION_print(const char *contents){ + uint32_t Version, Count; + const char *Nodes; + int status = U_PMF_REGION_get(contents, &Version, &Count, &Nodes); + if(status){ + printf(" + "); + (void) U_PMF_GRAPHICSVERSION_print((char *) &Version); + printf(" ChildNodes:%d",Count); + (void) U_PMF_REGIONNODE_print(Nodes, 1); /* 1 == top level*/ + } + return(status); +} + +/** + \brief Print data from a U_PMF_STRINGFORMAT object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.1.9, Microsoft name: EmfPlusStringFormat Object +*/ +int U_PMF_STRINGFORMAT_print(const char *contents){ + U_PMF_STRINGFORMAT Sfs; + const char *Data; + int status = U_PMF_STRINGFORMAT_get(contents, &Sfs, &Data); + if(status){ + printf(" + StringFormat: "); + printf(" Version:%X", Sfs.Version ); + printf(" Flags:%X", Sfs.Flags ); + printf(" Language"); (void) U_PMF_LANGUAGEIDENTIFIER_print(Sfs.Language); + printf(" StringAlignment:%X", Sfs.StringAlignment ); + printf(" LineAlign:%X", Sfs.LineAlign ); + printf(" DigitSubstitution:%X",Sfs.DigitSubstitution); + printf(" DigitLanguage"); (void) U_PMF_LANGUAGEIDENTIFIER_print(Sfs.DigitLanguage); + printf(" FirstTabOffset:%f", Sfs.FirstTabOffset ); + printf(" HotkeyPrefix:%d", Sfs.HotkeyPrefix ); + printf(" LeadingMargin:%f", Sfs.LeadingMargin ); + printf(" TrailingMargin:%f", Sfs.TrailingMargin ); + printf(" Tracking:%f", Sfs.Tracking ); + printf(" Trimming:%X", Sfs.Trimming ); + printf(" TabStopCount:%u", Sfs.TabStopCount ); + printf(" RangeCount:%u", Sfs.RangeCount ); + (void) U_PMF_STRINGFORMATDATA_print(Data, Sfs.TabStopCount, Sfs.RangeCount); + } + return(status); +} + +/** + \brief Print data from a U_PMF_ARGB object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.1, Microsoft name: EmfPlusARGB Object +*/ +int U_PMF_ARGB_print(const char *contents){ + uint8_t Blue, Green, Red, Alpha; + int status = U_PMF_ARGB_get(contents, &Blue, &Green, &Red, &Alpha); + if(status){ + printf(" RGBA{%2.2X,%2.2X,%2.2X,%2.2X}", Red, Green, Blue, Alpha); + } + return(status); +} + + +/** + \brief Print data from a U_PMF_BITMAP object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.2, Microsoft name: EmfPlusBitmap Object +*/ +int U_PMF_BITMAP_print(const char *contents){ + U_PMF_BITMAP Bs; + const char *Data; + int status = U_PMF_BITMAP_get(contents, &Bs, &Data); + if(status){ + printf(" + Bitmap: Width:%d Height:%d Stride:%d\n",Bs.Width, Bs.Height, Bs.Stride); + U_PMF_PX_FMT_ENUM_print(Bs.PxFormat); + switch(Bs.Type){ + case 0: printf(" Type:MSBitmap\n"); break; + case 1: printf(" Type:(PNG|JPG|GIF|EXIF|TIFF)\n"); break; + default: printf(" Type:INVALID(%d)\n",Bs.Type); break; + } + /* Pixel data is never shown - it could easily swamp the output for even a smallish picture */ + } + return(status); +} + + +/** + \brief Print data from a U_PMF_BITMAPDATA object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.3, Microsoft name: EmfPlusBitmapData Object +*/ +int U_PMF_BITMAPDATA_print(const char *contents){ + unsigned int i; + U_PMF_PALETTE Ps; + const char *Colors; + const char *Data; + int status = U_PMF_BITMAPDATA_get(contents, &Ps, &Colors, &Data); + if(status){ + status = 0; + printf(" BMData: Flags:%X, Elements:%u Colors:", Ps.Flags, Ps.Elements); + for(i=0; i<Ps.Elements; i++, Colors+=sizeof(U_PMF_ARGB)){ + (void) U_PMF_ARGB_print(Colors); + } + } + return(status); +} + +/** + \brief Print data from a U_PMF_BLENDCOLORS object + \return size in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.4, Microsoft name: EmfPlusBlendColors Object +*/ +int U_PMF_BLENDCOLORS_print(const char *contents){ + unsigned int i; + uint32_t Elements; + U_FLOAT *Positions; + const char *Colors; + int status = U_PMF_BLENDCOLORS_get(contents, &Elements, &Positions, &Colors); + if(status){ + status = 0; + printf(" + BlendColors: Entries:%d (entry,pos,color): ", Elements); + for(i=0; i<Elements; i++){ + printf(" (%d,%f,", i, Positions[i]); + (void) U_PMF_ARGB_print(Colors); + Colors += sizeof(U_PMF_ARGB); + printf(")"); + } + status = sizeof(uint32_t) + Elements*sizeof(U_FLOAT) + Elements*sizeof(U_PMF_ARGB); + free(Positions); + } + return(status); +} + +/** + \brief Print data from a U_PMF_BLENDFACTORS object + \return size on success, 0 on error + \param type Type of BlendFactors, usually H or V + \param contents Record from which to print data + EMF+ manual 2.2.2.5, Microsoft name: EmfPlusBlendFactors Object +*/ +int U_PMF_BLENDFACTORS_print(const char *contents, const char *type){ + unsigned int i; + uint32_t Elements; + U_FLOAT *Positions; + U_FLOAT *Factors; + int status = U_PMF_BLENDFACTORS_get(contents, &Elements, &Positions, &Factors); + if(status){ + printf(" + BlendFactors%s: Entries:%d (entry,pos,factor): ",type, Elements); + for(i=0; i<Elements; i++){ + printf(" (%d,%f,%f)", i, Positions[i],Factors[i]); + } + status = sizeof(uint32_t) + Elements*2*sizeof(U_FLOAT); + free(Positions); + free(Factors); + } + return(status); +} + +/** + \brief Print data from a U_PMF_BOUNDARYPATHDATA object + \return size on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.6, Microsoft name: EmfPlusBoundaryPathData Object +*/ +int U_PMF_BOUNDARYPATHDATA_print(const char *contents){ + int32_t Size; + const char *Data; + int status = U_PMF_BOUNDARYPATHDATA_get(contents, &Size, &Data); + if(status){ + printf(" + BoundaryPathData: Size:%d\n",Size); + (void) U_PMF_PATH_print(Data); + } + return(status); +} + + +/** + \brief Print data from a U_PMF_BOUNDARYPOINTDATA object + \return size on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.7, Microsoft name: EmfPlusBoundaryPointData Object +*/ +int U_PMF_BOUNDARYPOINTDATA_print(const char *contents){ + int32_t Elements; + U_PMF_POINTF *Points; + int status = U_PMF_BOUNDARYPOINTDATA_get(contents, &Elements, &Points); + if(status){ + printf(" + BoundaryPointData: Elements:%u\n",Elements); + U_PMF_VARPOINTF_S_print(Points, Elements); + free(Points); + } + return(status); +} + +/** + \brief Print data from a U_PMF_CHARACTERRANGE object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.8, Microsoft name: EmfPlusCharacterRange Object +*/ +int U_PMF_CHARACTERRANGE_print(const char *contents){ + int32_t First, Length; + int status = U_PMF_CHARACTERRANGE_get(contents, &First, &Length); + if(status){ + printf(" {%d,%d}",First,Length); + } + return(status); +} + +/** + \brief Print data from a U_PMF_DASHEDLINEDATA object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.9, Microsoft name: EmfPlusCompoundLineData Object +*/ +int U_PMF_COMPOUNDLINEDATA_print(const char *contents){ + int32_t Elements; + U_FLOAT *Widths; + U_FLOAT *hold; + int status = U_PMF_COMPOUNDLINEDATA_get(contents, &Elements, &Widths); + if(status){ + printf(" + CompoundLineData: Elements:%u {",Elements); + Elements--; + for(hold=Widths; Elements; Elements--,Widths++){ printf("%f, ",*Widths); } + printf("%f}",*Widths); + free(hold); + printf("\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMF_COMPRESSEDIMAGE object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.10, Microsoft name: EmfPlusCompressedImage Object + + This function does not do anything useful, but it is included so that all objects have a corresponding _get(). +*/ +int U_PMF_COMPRESSEDIMAGE_print(const char *contents){ + const char *Data; + int status = U_PMF_COMPRESSEDIMAGE_get(contents, &Data); + if(status){ + printf("CompressedImage:\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMF_CUSTOMENDCAPDATA object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.11, Microsoft name: EmfPlusCustomEndCapData Object +*/ +int U_PMF_CUSTOMENDCAPDATA_print(const char *contents){ + int32_t Size; + const char *Data; + int status = U_PMF_CUSTOMENDCAPDATA_get(contents, &Size, &Data); + if(status){ + printf(" + CustomEndCap: Size:%d\n",Size); + (void) U_PMF_CUSTOMLINECAP_print(Data, "End"); + } + return(status); +} + +/** + \brief Print data from a U_PMF_CUSTOMLINECAPARROWDATA object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.12, Microsoft name: EmfPlusCustomLineCapArrowData Object +*/ +int U_PMF_CUSTOMLINECAPARROWDATA_print(const char *contents){ + U_PMF_CUSTOMLINECAPARROWDATA Ccad; + int status = U_PMF_CUSTOMLINECAPARROWDATA_get(contents, &Ccad); + if(status){ + printf("CustomLineCapArrowData: "); + printf(" Width:%f", Ccad.Width ); + printf(" Height:%f", Ccad.Height ); + printf(" MiddleInset:%f", Ccad.MiddleInset ); + printf(" FillState:%u", Ccad.FillState ); + printf(" StartCap:%X", Ccad.StartCap ); + printf(" EndCap:%X", Ccad.EndCap ); + printf(" Join:%X", Ccad.Join ); + printf(" MiterLimit:%f", Ccad.MiterLimit ); + printf(" WidthScale:%f", Ccad.WidthScale ); + printf(" FillHotSpot:{%f,%f}",Ccad.FillHotSpot[0],Ccad.FillHotSpot[1]); + printf(" LineHotSpot:{%f,%f}",Ccad.LineHotSpot[0],Ccad.LineHotSpot[1]); + printf("\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMF_CUSTOMLINECAPDATA object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.13, Microsoft name: EmfPlusCustomLineCapData Object +*/ +int U_PMF_CUSTOMLINECAPDATA_print(const char *contents){ + U_PMF_CUSTOMLINECAPDATA Clcd; + const char *Data; + int status = U_PMF_CUSTOMLINECAPDATA_get(contents, &Clcd, &Data); + if(status){ + printf(" + CustomLineCapData: "); + printf(" Flags:%X", Clcd.Flags ); + printf(" Cap:%X", Clcd.Cap ); + printf(" Inset:%f", Clcd.Inset ); + printf(" StartCap:%X", Clcd.StartCap ); + printf(" EndCap:%X", Clcd.EndCap ); + printf(" Join:%X", Clcd.Join ); + printf(" MiterLimit:%f", Clcd.MiterLimit ); + printf(" WidthScale:%f", Clcd.WidthScale ); + printf(" FillHotSpot:{%f,%f}",Clcd.FillHotSpot[0],Clcd.FillHotSpot[1]); + printf(" LineHotSpot:{%f,%f}\n",Clcd.LineHotSpot[0],Clcd.LineHotSpot[1]); + (void) U_PMF_CUSTOMLINECAPOPTIONALDATA_print(Data, Clcd.Flags); + /* preceding line always emits an EOL */ + } + return(status); +} + + +/** + \brief Print data from a U_PMF_CUSTOMLINECAPOPTIONALDATA object + \return 1 on success, 0 on error + \param contents Record from which to print data + \param Flags CustomLineCapData Flags + + EMF+ manual 2.2.2.14, Microsoft name: EmfPlusCustomLineCapOptionalData Object +*/ +int U_PMF_CUSTOMLINECAPOPTIONALDATA_print(const char *contents, uint32_t Flags){ + const char *FillData; + const char *LineData; + int status = U_PMF_CUSTOMLINECAPOPTIONALDATA_get(contents, Flags, &FillData, &LineData); + if(status){ /* True even if there is nothing in it! */ + printf(" + CustomLineCapOptionalData:"); + if(FillData || LineData){ + if(FillData){ (void) U_PMF_FILLPATHOBJ_print(FillData); } + if(LineData){ (void) U_PMF_LINEPATH_print(LineData); } + } + else { + printf("None"); + } + } + if(status<=1){ printf("\n"); } + return(status); +} + +/** + \brief Print data from a U_PMF_CUSTOMSTARTCAPDATA object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.15, Microsoft name: EmfPlusCustomStartCapData Object +*/ +int U_PMF_CUSTOMSTARTCAPDATA_print(const char *contents){ + int32_t Size; + const char *Data; + int status = U_PMF_CUSTOMSTARTCAPDATA_get(contents, &Size, &Data); + if(status){ + printf(" + CustomStartCap: Size:%d ",Size); + (void) U_PMF_CUSTOMLINECAP_print(Data, "Start"); + } + return(status); +} + +/** + \brief Print data from a U_PMF_DASHEDLINEDATA object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.16, Microsoft name: EmfPlusDashedLineData Object +*/ +int U_PMF_DASHEDLINEDATA_print(const char *contents){ + int32_t Elements; + U_FLOAT *Lengths; + U_FLOAT *hold; + int status = U_PMF_DASHEDLINEDATA_get(contents, &Elements, &Lengths); + if(status){ + printf(" DashedLineData: Elements:%u {",Elements); + Elements--; + for(hold=Lengths; Elements; Elements--, Lengths++){ printf("%f, ", *Lengths); } + printf("%f}", *Lengths); + free(hold); + } + return(status); +} + +/** + \brief Print data from a U_PMF_FILLPATHOBJ object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.17, Microsoft name: EmfPlusFillPath Object +*/ +int U_PMF_FILLPATHOBJ_print(const char *contents){ + int32_t Size; + const char *Data; + int status = U_PMF_FILLPATHOBJ_get(contents, &Size, &Data); + if(status){ + printf(" FillPathObj: Size:%d\n",Size); + if(Size){ (void) U_PMF_PATH_print(Data); } + } + return(status); +} + +/** + \brief Print data from a U_PMF_FOCUSSCALEDATA object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.18, Microsoft name: EmfPlusFocusScaleData Object +*/ +int U_PMF_FOCUSSCALEDATA_print(const char *contents){ + uint32_t Count; + U_FLOAT ScaleX, ScaleY; + int status = U_PMF_FOCUSSCALEDATA_get(contents, &Count, &ScaleX, &ScaleY); + if(status){ + printf(" FocusScaleData: Count:%d ScaleX:%f ScaleY:%f ",Count,ScaleX,ScaleY); + } + return(status); +} + +/** + \brief Print data from a U_PMF_GRAPHICSVERSION_print object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.19, Microsoft name: EmfPlusGraphicsVersion Object +*/ +int U_PMF_GRAPHICSVERSION_print(const char *contents){ + int Signature,GrfVersion; + int status = U_PMF_GRAPHICSVERSION_get(contents, &Signature, &GrfVersion); + if(status){ + printf(" MetaFileSig:%X",Signature ); + printf(" GraphicsVersion:%X", GrfVersion); + } + return(status); +} + + +/** + \brief Print data from a U_PMF_HATCHBRUSHDATA_print object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.20, Microsoft name: EmfPlusHatchBrushData Object +*/ +int U_PMF_HATCHBRUSHDATA_print(const char *contents){ + uint32_t Style; + U_PMF_ARGB Foreground, Background; + int status = U_PMF_HATCHBRUSHDATA_get(contents, &Style, &Foreground, &Background); + if(status){ + printf(" + HBdata: Style:%u(",Style); + U_PMF_HATCHSTYLEENUMERATION_print(Style); + printf(") FG:{"); + (void) U_PMF_ARGB_print((char *)&Foreground); + printf("} BG:{"); + (void) U_PMF_ARGB_print((char *)&Background); + printf("}"); + } + return(status); +} + +/** + \brief Print data from a U_PMF_LANGUAGEIDENTIFIER object + \return 1 on success, 0 on error + \param LId Record from which to print data + EMF+ manual 2.2.2.23, Microsoft name: EmfPlusLanguageIdentifier Object +*/ +int U_PMF_LANGUAGEIDENTIFIER_print(U_PMF_LANGUAGEIDENTIFIER LId){ + int SubLId, PriLId; + int status = U_PMF_LANGUAGEIDENTIFIER_get(LId, &SubLId, &PriLId); + if(status){ /* do it the hard way just to verify that the preceding call works, OK to just print LId directly */ + printf("{%4.4X}",U_PMF_LANGUAGEIDENTIFIEROBJ_set(SubLId, PriLId)); + } + return(status); +} + + + +/** + \brief Print data from a U_PMF_LINEARGRADIENTBRUSHDATA object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.24, Microsoft name: EmfPlusLinearGradientBrushData Object +*/ +int U_PMF_LINEARGRADIENTBRUSHDATA_print(const char *contents){ + U_PMF_LINEARGRADIENTBRUSHDATA Lgbd; + const char *Data; + int status = U_PMF_LINEARGRADIENTBRUSHDATA_get(contents, &Lgbd, &Data); + if(status){ + printf(" + LinearGradientBrushData: Flags:%X WrapMode:%d Rect:",Lgbd.Flags, Lgbd.WrapMode); + (void) U_PMF_RECTF_S_print(&(Lgbd.RectF)); + printf(" StartColor:"); + (void) U_PMF_ARGB_print((char *)&(Lgbd.StartColor)); + printf(" EndColor:"); + (void) U_PMF_ARGB_print((char *)&(Lgbd.EndColor)); + /* Technically these are to be ignored, in practice they must be colors with the same value as the preceding 2*/ + printf(" Reserved1:"); + (void) U_PMF_ARGB_print((char *)&(Lgbd.Reserved1)); + printf(" Reserved2:"); + (void) U_PMF_ARGB_print((char *)&(Lgbd.Reserved2)); + printf("\n"); + (void) U_PMF_LINEARGRADIENTBRUSHOPTIONALDATA_print(Data, Lgbd.Flags); + } + return(status); +} + + + +/** + \brief Print data from a U_PMF_LINEARGRADIENTBRUSHOPTIONALDATA object + \return 1 on success, 0 on error + \param contents Record from which to print data + \param BDFlag Describes optional values in contents + EMF+ manual 2.2.2.25, Microsoft name: EmfPlusLinearGradientBrushOptionalData Object +*/ +int U_PMF_LINEARGRADIENTBRUSHOPTIONALDATA_print(const char *contents, int BDFlag){ + U_PMF_TRANSFORMMATRIX Tm; + const char *Bc; + const char *BfH; + const char *BfV; + int None=1; + printf(" + LinearGradientBrushOptionalData: "); + int status = U_PMF_LINEARGRADIENTBRUSHOPTIONALDATA_get(contents, BDFlag, &Tm, &Bc, &BfH, &BfV); + if(status){ + if(BDFlag & U_BD_Transform){ + U_PMF_TRANSFORMMATRIX2_print(&Tm); + None=0; + } + if(Bc){ + printf("\n"); + (void) U_PMF_BLENDCOLORS_print(Bc); + None=0; + } + if(BfH){ + printf("\n"); + (void) U_PMF_BLENDFACTORS_print(BfH,"H"); + None=0; + } + if(BfV){ + printf("\n"); + (void) U_PMF_BLENDFACTORS_print(BfV,"V"); + None=0; + } + if(None){ + printf("(none)"); + } + } + return(status); +} + +/** + \brief Print data from a U_PMF_LINEPATH object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.26, Microsoft name: EmfPlusLinePath Object +*/ +int U_PMF_LINEPATH_print(const char *contents){ + int32_t Size; + const char *Data; + int status = U_PMF_LINEPATH_get(contents, &Size, &Data); + if(status){ + printf(" LinePath: Size:%d\n", Size); + (void) U_PMF_PATH_print(Data); + } + return(status); +} + +/** + \brief Print data from a U_PMF_METAFILE object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.27, Microsoft name: EmfPlusMetafile Object +*/ +int U_PMF_METAFILE_print(const char *contents){ + uint32_t Type; + uint32_t Size; + const char *Data; + int status = U_PMF_METAFILE_get(contents, &Type, &Size, &Data); + if(status){ + printf(" MetaFile: Type:%X Size:%d",Type, Size); + /* embedded metafiles are not handled beyond this*/ + } + return(status); +} + +/** + \brief Print data from a U_PMF_PALETTE object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.28, Microsoft name: EmfPlusPalette Object +*/ +int U_PMF_PALETTE_print(const char *contents){ + unsigned int i; + uint32_t Flags; + uint32_t Elements; + const char *Data; + int status = U_PMF_PALETTE_get(contents, &Flags, &Elements, &Data); + if(status){ + printf(" Palette: Flags:%X Elements:%u Colors:",Flags, Elements); + for(i=0; i<Elements; i++){ + (void) U_PMF_ARGB_print(Data); + Data += sizeof(U_PMF_ARGB); + } + printf("\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMF_PATHGRADIENTBRUSHDATA object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.29, Microsoft name: EmfPlusPathGradientBrushData Object +*/ +int U_PMF_PATHGRADIENTBRUSHDATA_print(const char *contents){ + U_PMF_PATHGRADIENTBRUSHDATA Pgbd; + const char *Gradient; + const char *Boundary; + const char *Data=NULL; + unsigned int i; + int status = U_PMF_PATHGRADIENTBRUSHDATA_get(contents, &Pgbd, &Gradient, &Boundary, &Data); + if(status){ + printf(" + PathGradientBrushData: Flags:%X WrapMode:%d, CenterColor:",Pgbd.Flags, Pgbd.WrapMode); + (void) U_PMF_ARGB_print((char *)&(Pgbd.CenterColor)); + printf(" Center:"); + (void) U_PMF_POINTF_S_print(&(Pgbd.Center)); + printf(" Elements:%u\n",Pgbd.Elements); + if(Pgbd.Elements){ + printf(" + SurroundingColor: "); + for(i=Pgbd.Elements; i; i--, Gradient+=4){ + (void) U_PMF_ARGB_print(Gradient); + } + printf("\n"); + } + if(Pgbd.Flags & U_BD_Path){ + (void) U_PMF_BOUNDARYPATHDATA_print(Boundary); + } + else { + (void) U_PMF_BOUNDARYPOINTDATA_print(Boundary); + } + (void) U_PMF_PATHGRADIENTBRUSHOPTIONALDATA_print(Data, Pgbd.Flags); + } + return(status); +} + +/** + \brief Print data from a U_PMF_PATHGRADIENTBRUSHOPTIONALDATA object + \return 1 on success, 0 on error + \param contents Record from which to print data + \param BDFlag Describes optional values in contents + EMF+ manual 2.2.2.30, Microsoft name: EmfPlusPathGradientBrushOptionalData Object +*/ +int U_PMF_PATHGRADIENTBRUSHOPTIONALDATA_print(const char *contents, int BDFlag){ + if(BDFlag & (U_BD_Transform | U_BD_PresetColors | U_BD_BlendFactorsH | U_BD_FocusScales)){ + printf(" + PathGradientBrushOptionalData: "); + } + if(BDFlag & U_BD_Transform){ + U_PMF_TRANSFORMMATRIX_print(contents); + contents += sizeof(U_PMF_TRANSFORMMATRIX); + } + if(BDFlag & U_BD_PresetColors){ /* If this is present, BlendFactorsH will not be */ + contents += U_PMF_BLENDCOLORS_print(contents); + } + if(BDFlag & U_BD_BlendFactorsH){/* If this is present, U_BD_PresetColors will not be */ + contents += U_PMF_BLENDFACTORS_print(contents,""); + } + if(BDFlag & U_BD_FocusScales){ + contents += U_PMF_BLENDFACTORS_print(contents,""); + U_PMF_FOCUSSCALEDATA_print(contents); + } + return(1); +} + +/** + \brief Print data from a U_PMF_PATHPOINTTYPE object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.31, Microsoft name: EmfPlusPathPointType Object +*/ +int U_PMF_PATHPOINTTYPE_print(const char *contents){ + int Flags, Type; + int status = U_PMF_PATHPOINTTYPE_get(contents, &Flags, &Type); + if(status){ + printf("{Flags:%X Type:",Flags); + (void) U_PMF_PATHPOINTTYPE_ENUM_print(Type); + printf("}"); + } + return(status); +} + +/** + \brief Print data from a U_PMF_PATHPOINTTYPERLE object + \return Number of elements in the run, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.32, Microsoft name: EmfPlusPathPointTypeRLE Object +*/ +int U_PMF_PATHPOINTTYPERLE_print(const char *contents){ + int Bezier, Elements, Type; + int status = U_PMF_PATHPOINTTYPERLE_get(contents, &Bezier, &Elements, &Type); + if(status){ + status = Elements; + printf(" PathPointTypeRLE: Bezier:%c Elements:%u, Type: ",(Bezier ? 'Y' : 'N'), Elements); + (void) U_PMF_PATHPOINTTYPE_ENUM_print(Type); + printf("\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMF_PATHPOINTTYPERLE object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.33, Microsoft name: EmfPlusPenData Object +*/ +int U_PMF_PENDATA_print(const char *contents){ + uint32_t Flags, Unit; + U_FLOAT Width; + const char *Data; + int status = U_PMF_PENDATA_get(contents, &Flags, &Unit, &Width, &Data); + if(status){ + printf(" + Pendata: Flags:%X Unit:%X Width:%f",Flags, Unit, Width); + (void) U_PMF_PENOPTIONALDATA_print(Data, Flags); /* prints a new line at end */ + } + return(status); +} + + + +/** + \brief Print data from a U_PMF_PENOPTIONALDATA object + \return 1 on success, 0 on error + \param contents Record from which to print data + \param Flags PenData Flags that determine which optionaldata fields are present in the record. + + EMF+ manual 2.2.2.34, Microsoft name: EmfPlusPenOptionalData Object +*/ +int U_PMF_PENOPTIONALDATA_print(const char *contents, int Flags){ + U_PMF_TRANSFORMMATRIX Matrix; + int32_t StartCap; + int32_t EndCap; + uint32_t Join; + U_FLOAT MiterLimit; + int32_t Style; + int32_t DLCap; + U_FLOAT DLOffset; + const char *DLData; + int32_t Alignment; + const char *CmpndLineData; + const char *CSCapData; + const char *CECapData; + int status = U_PMF_PENOPTIONALDATA_get( + contents, + Flags, // determines which fields are filled + &Matrix, + &StartCap, + &EndCap, + &Join, + &MiterLimit, + &Style, + &DLCap, + &DLOffset, + &DLData, + &Alignment, + &CmpndLineData, + &CSCapData, + &CECapData); + if(status){ + if(Flags & U_PD_Transform){ (void) U_PMF_TRANSFORMMATRIX2_print(&Matrix);} + if(Flags & U_PD_StartCap){ printf(" StartCap:%d", StartCap );} + if(Flags & U_PD_EndCap){ printf(" EndCap:%d", EndCap );} + if(Flags & U_PD_Join){ printf(" Join:%X", Join );} + if(Flags & U_PD_MiterLimit){ printf(" MiterLimit:%f", MiterLimit );} + if(Flags & U_PD_LineStyle){ printf(" Style:%X", Style );} + if(Flags & U_PD_DLCap){ printf(" DLCap:%X", DLCap );} + if(Flags & U_PD_DLOffset){ printf(" DLOffset:%f", DLOffset );} + if(Flags & U_PD_DLData){ (void) U_PMF_DASHEDLINEDATA_print(DLData );} + if(Flags & U_PD_NonCenter){ printf(" Alignment:%d", Alignment );} + if(Flags & (U_PD_Transform | U_PD_StartCap | U_PD_EndCap | + U_PD_Join | U_PD_MiterLimit | U_PD_LineStyle | + U_PD_DLCap | U_PD_DLOffset |U_PD_DLData |U_PD_NonCenter)){ printf("\n"); } + if(Flags & U_PD_CLData){ (void) U_PMF_COMPOUNDLINEDATA_print(CmpndLineData); } + if(Flags & U_PD_CustomStartCap){ (void) U_PMF_CUSTOMSTARTCAPDATA_print(CSCapData); } + if(Flags & U_PD_CustomEndCap){ (void) U_PMF_CUSTOMENDCAPDATA_print(CECapData); } + } + return(status); +} +/** + \brief Print data from a U_PMF_POINT object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.35, Microsoft name: EmfPlusPoint Object +*/ +int U_PMF_POINT_print(const char **contents){ + U_FLOAT X, Y; + int status = U_PMF_POINT_get(contents, &X, &Y); + if(status){ + printf("{%f,%f}", X, Y); + } + return(status); +} + +/** + \brief Print data from a U_PMF_POINT Structure + \return 1 on success, 0 on error + \param Point U_PMF_POINT Structure to print + EMF+ manual 2.2.2.35, Microsoft name: EmfPlusPoint Object +*/ +int U_PMF_POINT_S_print(U_PMF_POINT *Point){\ + if(!Point){ return(0); } + printf("{%d,%d}", Point->X, Point->Y); + return(1); +} + +/** + \brief Print data from a U_PMF_POINTF object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.36, Microsoft name: EmfPlusPointF Object +*/ +int U_PMF_POINTF_print(const char **contents){ + U_FLOAT X, Y; + int status = U_PMF_POINTF_get(contents, &X, &Y); + if(status){ + printf("{%f,%f}", X, Y); + } + return(status); +} + +/** + \brief Print data from a U_PMF_POINTF Structure + \return 1 on success, 0 on error + \param Point U_PMF_POINTF Structure to print + EMF+ manual 2.2.2.36, Microsoft name: EmfPlusPointF Object +*/ +int U_PMF_POINTF_S_print(U_PMF_POINTF *Point){ + if(!Point){ return(0); } + printf("{%f,%f}", Point->X, Point->Y); + return(1); +} + +/** + \brief Print data from a U_PMF_POINTR object + \return bytes traversed on success, 0 on error + \param contents Pointer to next data to print + \param Xpos X coordinate for current point + \param Ypos Y coordinate for current point + + On each call the next relative offset is extracted, the current + coordinates are modified with that offset, and the pointer is + advanced to the next data point. + + EMF+ manual 2.2.2.37, Microsoft name: EmfPlusPointR Object +*/ +int U_PMF_POINTR_print(const char **contents, U_FLOAT *Xpos, U_FLOAT *Ypos){ + U_FLOAT X, Y; + int status = U_PMF_POINTR_get(contents, &X, &Y); + *Xpos += X; + *Ypos += Y; + if(status){ + printf("{%f,%f(%f,%f)}", *Xpos, *Ypos, X, Y); + } + return(status); +} + +/** + \brief Print data from a U_PMF_RECT object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.38, Microsoft name: EmfPlusRect Object +*/ +int U_PMF_RECT_print(const char **contents){ + int16_t X, Y, Width, Height; + int status = U_PMF_RECT_get(contents, &X, &Y, &Width, &Height); + if(status){ + printf("{UL{%d,%d},WH{%d,%d}}", X, Y, Width, Height); + } + return(status); +} + +/** + \brief Print data from a U_PMF_RECT Structure + \return 1 on success, 0 on error + \param Rect U_PMF_RECT structure + EMF+ manual 2.2.2.39, Microsoft name: EmfPlusRectF Object +*/ +int U_PMF_RECT_S_print(U_PMF_RECT *Rect){ + printf("{UL{%d,%d},WH{%d,%d}}", Rect->X, Rect->Y, Rect->Width, Rect->Height); + return(1); +} + +/** + \brief Print data from a U_PMF_RECTF object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.39, Microsoft name: EmfPlusRectF Object +*/ +int U_PMF_RECTF_print(const char **contents){ + U_FLOAT X, Y, Width, Height; + int status = U_PMF_RECTF_get(contents, &X, &Y, &Width, &Height); + if(status){ + printf("{UL{%f,%f},WH{%f,%f}}", X, Y, Width, Height); + } + return(status); +} + +/** + \brief Print data from a U_PMF_RECTF Structure + \return 1 on success, 0 on error + \param Rect U_PMF_RECTF Structure + EMF+ manual 2.2.2.39, Microsoft name: EmfPlusRectF Object +*/ +int U_PMF_RECTF_S_print(U_PMF_RECTF *Rect){ + printf("{UL{%f,%f},WH{%f,%f}}", Rect->X, Rect->Y, Rect->Width, Rect->Height); + return(1); +} + +/** + \brief Print data from a U_PMF_REGIONNODE object + \return size on success, 0 on error + \param contents Record from which to print data + \param Level Tree level. This routine is recursive and could go down many levels. 1 is the top, >1 are child nodes. + EMF+ manual 2.2.2.40, Microsoft name: EmfPlusRegionNode Object +*/ +int U_PMF_REGIONNODE_print(const char *contents, int Level){ + int len=4; /* Type will always be present */ + uint32_t Type; + const char *Data; + int status = U_PMF_REGIONNODE_get(contents, &Type, &Data); + if(status){ + printf("\n + RegionNode(Level:%d) { Type:%X(",Level,Type); + U_PMF_NODETYPE_print(Type); + printf(")"); + if(Type >= U_RNDT_And && Type <= U_RNDT_Complement){ + len += U_PMF_REGIONNODECHILDNODES_print(Data, Level+1); + } + else if(Type == U_RNDT_Rect){ + len += sizeof(U_PMF_RECTF); + (void) U_PMF_RECTF_print(&Data); + printf("\n"); + } + else if(Type == U_RNDT_Path){ + len += U_PMF_REGIONNODEPATH_print(Data); + } + /* U_RNDT_Empty and U_RNDT_Infinite do not change the length */ + else if(Type == U_RNDT_Empty ){ printf(" Empty" ); } + else if(Type == U_RNDT_Infinite ){ printf(" Infinite" ); } + printf(" + RegionNode(Level:%d) }",Level); + status = len; /* length of data + length of type */ + } + printf("\n"); + return(status); +} + +/** + \brief Print data from a U_PMF_REGIONNODECHILDNODES object + \return size on success, 0 on error + \param contents Record from which to print data + \param Level Tree level. This routine is recursive and could go down many levels. 1 is the top, >1 are child nodes. + EMF+ manual 2.2.2.41, Microsoft name: EmfPlusRegionNodeChildNodes Object +*/ +int U_PMF_REGIONNODECHILDNODES_print(const char *contents, int Level){ + uint32_t size,rsize; + printf(" RegionNodeChildNodes:\n"); + printf(" + RNCN__Left(Level:%d) {", Level); + size = U_PMF_REGIONNODE_print(contents, Level); + printf(" + RNCN__Left(Level:%d) },\n", Level); + if(size){ + contents += size; + printf(" + RNCN_Right(Level:%d) {", Level); + rsize = U_PMF_REGIONNODE_print(contents, Level); + size += rsize; + printf(" + RNCN_Right(Level:%d) },\n",Level); + } + return(size); +} + +/** + \brief Print data from a U_PMF_REGIONNODEPATH object + \return Size of data on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.42, Microsoft name: EmfPlusRegionNodePath Object +*/ +int U_PMF_REGIONNODEPATH_print(const char *contents){ + int32_t Size; + const char *Data; + int status = U_PMF_REGIONNODEPATH_get(contents, &Size, &Data); + if(status){ + printf(" RegionNodePath: \n"); + (void) U_PMF_PATH_print(Data); + status = Size + 4; /* data sizee + the 4 bytes encoding the size */ + } + return(status); +} + + +/** + \brief Print data from a U_PMF_SOLIDBRUSHDATA object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.43, Microsoft name: EmfPlusSolidBrushData Object +*/ +int U_PMF_SOLIDBRUSHDATA_print(const char *contents){ + U_PMF_ARGB Color; + int status = U_PMF_SOLIDBRUSHDATA_get(contents, &Color); + if(status){ + printf(" SolidBrushData: "); + (void) U_PMF_ARGB_print((char *) &Color); + } + return(status); +} + +/** + \brief Print data from a U_PMF_STRINGFORMATDATA object + \return 1 on success, 0 on error + \param contents Record from which to print data + \param TabStopCount Entries in TabStop array + \param RangeCount Entries in CharRange array + EMF+ manual 2.2.2.44, Microsoft name: EmfPlusStringFormatData Object +*/ +int U_PMF_STRINGFORMATDATA_print(const char *contents, uint32_t TabStopCount, uint32_t RangeCount){ + const U_FLOAT *TabStops; + const U_PMF_CHARACTERRANGE *CharRange; + int status = U_PMF_STRINGFORMATDATA_get(contents, TabStopCount, RangeCount, &TabStops, &CharRange); + if(status){ + printf(" SFdata: TabStopCount:%u RangeCount:%u\n", TabStopCount, RangeCount); + + printf(" Tabstops:"); + for(; TabStopCount; TabStopCount--,TabStops++){ printf(" %f",*TabStops); } + printf("\n"); + + printf(" CharRange:"); + for(; RangeCount; RangeCount--,CharRange++){ printf(" {%d,%d}",CharRange->First,CharRange->Length); } + printf("\n"); + + } + return(status); +} + +/** + \brief Print data from a U_PMF_TEXTUREBRUSHDATA object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.45, Microsoft name: EmfPlusTextureBrushData Object +*/ +int U_PMF_TEXTUREBRUSHDATA_print(const char *contents){ + uint32_t Flags; + int32_t WrapMode; + const char *Data; + int status = U_PMF_TEXTUREBRUSHDATA_get(contents, &Flags, &WrapMode, &Data); + if(status){ + printf(" + TBdata: Flags:%X WrapMode:%d", Flags, WrapMode); + } + return(status); +} + +/** + \brief Print data from a U_PMF_TEXTUREBRUSHOPTIONALDATA object + \return 1 on success, 0 on error + \param contents Record from which to print data + \param HasImage True if the record contains an image. + + EMF+ manual 2.2.2.46, Microsoft name: EmfPlusTextureBrushOptionalData Object +*/ +int U_PMF_TEXTUREBRUSHOPTIONALDATA_print(const char *contents, int HasImage){ + U_PMF_TRANSFORMMATRIX Matrix; + const char *Image; + int status = U_PMF_TEXTUREBRUSHOPTIONALDATA_get(contents, HasImage, &Matrix, &Image); + if(status){ + printf(" + TBOptdata: Image:%c", (HasImage ? 'Y' : 'N')); + (void) U_PMF_TRANSFORMMATRIX2_print(&Matrix); + (void) U_PMF_IMAGE_print(Image); + } + return(status); +} + +/** + \brief Print data from a U_PMF_TRANSFORMMATRIX object stored in file byte order. + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.47, Microsoft name: EmfPlusTransformMatrix Object +*/ +int U_PMF_TRANSFORMMATRIX_print(const char *contents){ + U_PMF_TRANSFORMMATRIX Tm; + int status = U_PMF_TRANSFORMMATRIX_get(contents, &Tm); + if(status){ + U_PMF_TRANSFORMMATRIX2_print(&Tm); + } + return(status); +} + +/** + \brief Print data from a U_PMF_TRANSFORMMATRIX structure + \return 1 on success, 0 on error + \param Tm U_PMF_TRANSFORMMATRIX structure + EMF+ manual 2.2.2.47, Microsoft name: EmfPlusTransformMatrix Object +*/ +int U_PMF_TRANSFORMMATRIX2_print(U_PMF_TRANSFORMMATRIX *Tm){ + printf(" Matrix:{%f,%f,%f,%f,%f,%f}", Tm->m11, Tm->m12, Tm->m21, Tm->m22, Tm->dX, Tm->dY); + return(1); +} + +/** + \brief Print data from a U_PMF_ROTMATRIX object + \return 1 on success, 0 on error + \param Rm U_PMF_ROTMATRIX object + NOT DOCUMENTED, like EMF+ manual 2.2.2.47, Microsoft name: EmfPlusTransformMatrix Object, but missing offset values +*/ +int U_PMF_ROTMATRIX2_print(U_PMF_ROTMATRIX *Rm){ + printf(" Matrix:{%f,%f,%f,%f}", Rm->m11, Rm->m12, Rm->m21, Rm->m22); + return(1); +} + +/** + \brief Print data from a U_PMF_IE_BLUR object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.3.1, Microsoft name: BlurEffect Object +*/ +int U_PMF_IE_BLUR_print(const char *contents){ + U_FLOAT Radius; + uint32_t ExpandEdge; + int status = U_PMF_IE_BLUR_get(contents, &Radius, &ExpandEdge); + if(status){ + printf("BlurEffect Radius:%f ExpandEdge:%u\n", Radius, ExpandEdge); + } + return(status); +} + +/** + \brief Print data from a U_PMF_IE_BRIGHTNESSCONTRAST object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.3.2, Microsoft name: BrightnessContrastEffect Object +*/ +int U_PMF_IE_BRIGHTNESSCONTRAST_print(const char *contents){ + int32_t Brightness, Contrast; + int status = U_PMF_IE_BRIGHTNESSCONTRAST_get(contents, &Brightness, &Contrast); + if(status){ + printf("BrightnessContrastEffect Brightness:%d Contrast:%d\n", Brightness, Contrast); + } + return(status); +} + +/** + \brief Print data from a U_PMF_IE_COLORBALANCE object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.3.3, Microsoft name: ColorBalanceEffect Object +*/ +int U_PMF_IE_COLORBALANCE_print(const char *contents){ + int32_t CyanRed, MagentaGreen, YellowBlue; + int status = U_PMF_IE_COLORBALANCE_get(contents, &CyanRed, &MagentaGreen, &YellowBlue); + if(status){ + printf("ColorBalanceEffect CyanRed:%d MagentaGreen:%d YellowBlue:%d\n", CyanRed, MagentaGreen, YellowBlue); + } + return(status); +} + +/** + \brief Print data from a U_PMF_IE_COLORCURVE object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.3.4, Microsoft name: ColorCurveEffect Object +*/ +int U_PMF_IE_COLORCURVE_print(const char *contents){ + uint32_t Adjust, Channel; + int32_t Intensity; + int status = U_PMF_IE_COLORCURVE_get(contents, &Adjust, &Channel, &Intensity); + if(status){ + printf("ColorBalanceEffect Adjust:%u Channel:%u Intensity:%d\n", Adjust, Channel, Intensity); + } + return(status); +} + +/** + \brief Print data from a U_PMF_IE_COLORLOOKUPTABLE object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.3.5, Microsoft name: ColorLookupTableEffect Object +*/ +int U_PMF_IE_COLORLOOKUPTABLE_print(const char *contents){ + const uint8_t *BLUT, *GLUT, *RLUT, *ALUT; + int status = U_PMF_IE_COLORLOOKUPTABLE_get(contents, &BLUT, &GLUT, &RLUT, &ALUT); + if(status){ + printf("ColorLookupTableEffect \n"); + U_PMF_UINT8_ARRAY_print(" BLUT:", BLUT, 256, "\n"); + U_PMF_UINT8_ARRAY_print(" GLUT:", GLUT, 256, "\n"); + U_PMF_UINT8_ARRAY_print(" RLUT:", RLUT, 256, "\n"); + U_PMF_UINT8_ARRAY_print(" ALUT:", ALUT, 256, "\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMF_IE_COLORMATRIX object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.3.6, Microsoft name: ColorMatrixEffect Object +*/ +int U_PMF_IE_COLORMATRIX_print(const char *contents){ + U_PMF_IE_COLORMATRIX Matrix; + int i,j; + int status = U_PMF_IE_COLORMATRIX_get(contents, &Matrix); + if(status){ + printf("ColorMatrixEffect\n"); + for(i=0;i<5;i++){ + printf(" {"); + for(j=0;j<4;i++){ printf("%f,",Matrix.M[i][j]); } + printf("%f}",Matrix.M[i][j]); + } + printf("\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMF_IE_HUESATURATIONLIGHTNESS object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.3.7, Microsoft name: HueSaturationLightnessEffect Object +*/ +int U_PMF_IE_HUESATURATIONLIGHTNESS_print(const char *contents){ + int32_t Hue, Saturation, Lightness; + int status = U_PMF_IE_HUESATURATIONLIGHTNESS_get(contents, &Hue, &Saturation, &Lightness); + if(status){ + printf("HueSaturationLightnessEffect Hue:%d Saturation:%d Lightness:%d\n", Hue, Saturation, Lightness); + } + return(status); +} + +/** + \brief Print data from a U_PMF_IE_LEVELS object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.3.8, Microsoft name: LevelsEffect Object +*/ +int U_PMF_IE_LEVELS_print(const char *contents){ + int32_t Highlight, Midtone, Shadow; + int status = U_PMF_IE_LEVELS_get(contents, &Highlight, &Midtone, &Shadow); + if(status){ + printf("LevelEffect Highlight:%d Midtone:%d Shadow:%d\n", Highlight, Midtone, Shadow); + } + return(status); +} + +/** + \brief Print data from a U_PMF_IE_REDEYECORRECTION object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.3.9, Microsoft name: RedEyeCorrectionEffect Object +*/ +int U_PMF_IE_REDEYECORRECTION_print(const char *contents){ + int32_t Elements; + U_RECTL *Rects; + int status = U_PMF_IE_REDEYECORRECTION_get(contents, &Elements, &Rects); + if(status){ + printf("RedEyeCorrectionEffect Elements:%u", Elements); + for(; Elements; Elements--, Rects++){ + printf(" "); + rectl_print(*Rects); + } + printf("\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMF_IE_SHARPEN object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.3.10, Microsoft name: SharpenEffect Object +*/ +int U_PMF_IE_SHARPEN_print(const char *contents){ + U_FLOAT Radius; + int32_t Sharpen; + int status = U_PMF_IE_SHARPEN_get(contents, &Radius, &Sharpen); + if(status){ + printf("SharpenEffect Radius:%f Sharpen:%u\n", Radius, Sharpen); + } + return(status); +} + +/** + \brief Print data from a U_PMF_IE_TINT object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.3.11, Microsoft name: TintEffect Object +*/ +int U_PMF_IE_TINT_print(const char *contents){ + int32_t Hue, Amount; + int status = U_PMF_IE_TINT_get(contents, &Hue, &Amount); + if(status){ + printf("TintEffect Hue:%d Amount:%d\n", Hue, Amount); + } + return(status); +} + +/* ***************************************************************************************** */ +/* EMF+ records, the EMF+ record header is printed separately, these print the contents only */ +/* ***************************************************************************************** */ + + +/** + \brief Print data from a U_PMR_OFFSETCLIP record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.1.1, Microsoft name: EmfPlusOffsetClip Record, Index 0x35 +*/ +int U_PMR_OFFSETCLIP_print(const char *contents){ + U_PMF_CMN_HDR Header; + U_FLOAT dX,dY; + int status = U_PMR_OFFSETCLIP_get(contents, &Header, &dX, &dY); + if(status){ + printf(" + dx:%f dy:%f\n",dX,dY); + } + return(status); +} + +/** + \brief Print data from a U_PMR_OFFSETCLIP record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.1.2, Microsoft name: EmfPlusResetClip Record, Index 0x31 +*/ +int U_PMR_RESETCLIP_print(const char *contents){ + return(U_PMR_NODATAREC_print(contents)); +} + +/** + \brief Print data from a U_PMR_SETCLIPPATH record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.1.3, Microsoft name: EmfPlusSetClipPath Record, Index 0x33 +*/ +int U_PMR_SETCLIPPATH_print(const char *contents){ + int CMenum; + uint32_t PathID; + int status = U_PMR_SETCLIPPATH_get(contents, NULL, &PathID, &CMenum); + if(status){ + printf(" + PathID:%u CMenum:%d\n",PathID,CMenum); + } + return(status); +} + +/** + \brief Print data from a U_PMR_SETCLIPRECT record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.1.4, Microsoft name: EmfPlusSetClipRect Record, Index 0x32 +*/ +int U_PMR_SETCLIPRECT_print(const char *contents){ + int CMenum; + U_PMF_RECTF Rect; + int status = U_PMR_SETCLIPRECT_get(contents, NULL, &CMenum, &Rect); + if(status){ + printf(" + CMenum:%d(", CMenum); + U_PMF_COMBINEMODEENUMERATION_print(CMenum); + printf(") Rect:"); + U_PMF_RECTF_S_print(&Rect); + printf("\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMR_SETCLIPREGION record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.1.5, Microsoft name: EmfPlusSetClipRegion Record, Index 0x34 +*/ +int U_PMR_SETCLIPREGION_print(const char *contents){ + int CMenum; + uint32_t PathID; + int status = U_PMR_SETCLIPREGION_get(contents, NULL, &PathID, &CMenum); + if(status){ + printf(" + PathID:%u CMenum:%d(",PathID, CMenum); + U_PMF_COMBINEMODEENUMERATION_print(CMenum); + printf(")\n"); + } + return(status); +} + + +/** + \brief Print data from a U_PMR_COMMENT record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.2.1, Microsoft name: EmfPlusComment Record, Index 0x03 +*/ +int U_PMR_COMMENT_print(const char *contents){ + U_PMF_CMN_HDR Header; + const char *Data; + unsigned int i=0; + int status = U_PMR_COMMENT_get(contents, &Header, &Data); + if(status){ + /* try to print it, but only ASCII, bail on anything that is not ASCII */ + printf(" + Data:"); + for(i=0; i< Header.DataSize; i++,Data++){ + if(!*Data)break; + if(*(unsigned const char *)Data <128){ printf("%c",*Data); } + else { break; } + } + printf("\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMR_ENDOFFILE record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.3.1, Microsoft name: EmfPlusEndOfFile Record, Index 0x02 +*/ +int U_PMR_ENDOFFILE_print(const char *contents){ + return(U_PMR_NODATAREC_print(contents)); +} + +/** + \brief Print data from a U_PMR_ENDOFFILE record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.3.2, Microsoft name: EmfPlusGetDC Record, Index 0x04 +*/ +int U_PMR_GETDC_print(const char *contents){ + return(U_PMR_NODATAREC_print(contents)); +} + +/** + \brief Print data from a U_PMR_HEADER record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.3.3, Microsoft name: EmfPlusHeader Record, Index 0x01 +*/ +int U_PMR_HEADER_print(const char *contents){ + U_PMF_GRAPHICSVERSION Version; + int IsDual, IsVideo; + uint32_t LogicalDpiX, LogicalDpiY; + int status = U_PMR_HEADER_get(contents, NULL, &Version, &IsDual, &IsVideo, &LogicalDpiX, &LogicalDpiY); + if(status){ + /* try to print it, but only ASCII, bail on anything that is not ASCII */ + printf(" + "); + (void) U_PMF_GRAPHICSVERSION_print((char *) &Version); + printf(" IsDual:%c IsVideo:%d LogicalDpiX,y:{%u,%u}\n",(IsDual ? 'Y' : 'N'),IsVideo,LogicalDpiX, LogicalDpiY); + } + return(status); +} + +/** + \brief Print data from a U_PMR_CLEAR record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.4.1, Microsoft name: EmfPlusClear Record, Index 0x09 +*/ +int U_PMR_CLEAR_print(const char *contents){ + U_PMF_ARGB Color; + int status = U_PMR_CLEAR_get(contents, NULL, &Color); + if(status){ + /* try to print it, but only ASCII, bail on anything that is not ASCII */ + printf(" + Color:"); + (void) U_PMF_ARGB_print((char *) &Color); + } + return(status); +} + +/** + \brief Print data from a U_PMR_DRAWARC record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.4.2, Microsoft name: EmfPlusDrawArc Record, Index 0x12 +*/ +int U_PMR_DRAWARC_print(const char *contents){ + uint32_t PenID; + int ctype; + U_FLOAT Start, Sweep; + U_PMF_RECTF Rect; + int status = U_PMR_DRAWARC_get(contents, NULL, &PenID, &ctype, &Start, &Sweep, &Rect); + if(status){ + printf(" + PenID:%u ctype:%d Start:%f Sweep:%f Rect:", PenID,ctype,Start,Sweep); + (void) U_PMF_VARRECTF_S_print(&Rect, 1); + printf("\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMR_DRAWBEZIERS record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.4.3, Microsoft name: EmfPlusDrawBeziers Record, Index 0x19 +*/ +int U_PMR_DRAWBEZIERS_print(const char *contents){ + uint32_t PenID; + int ctype, RelAbs; + uint32_t Elements; + U_PMF_POINTF *Points; + int status = U_PMR_DRAWBEZIERS_get(contents, NULL, &PenID, &ctype, &RelAbs, &Elements, &Points); + if(status){ + printf(" + PenIdx:%u ctype:%d RelAbs:%d Elements:%u\n", PenID, ctype, RelAbs, Elements); + U_PMF_VARPOINTF_S_print(Points, Elements); + free(Points); + } + return(status); +} + +/** + \brief Print data from a U_PMR_DRAWCLOSEDCURVE record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + + Curve is a cardinal spline. + References sent by MS support: + http://alvyray.com/Memos/CG/Pixar/spline77.pdf + http://msdn.microsoft.com/en-us/library/4cf6we5y(v=vs.110).aspx + + EMF+ manual 2.3.4.4, Microsoft name: EmfPlusDrawClosedCurve Record, Index 0x17 +*/ +int U_PMR_DRAWCLOSEDCURVE_print(const char *contents){ + uint32_t PenID; + int ctype, RelAbs; + U_FLOAT Tension; + uint32_t Elements; + U_PMF_POINTF *Points; + int status = U_PMR_DRAWCLOSEDCURVE_get(contents, NULL, &PenID, &ctype, &RelAbs, &Tension, &Elements, &Points); + if(status){ + printf(" + PenID:%u ctype:%d RelAbs:%d Tension:%f\n", PenID, ctype, RelAbs, Tension); + U_PMF_VARPOINTF_S_print(Points, Elements); + free(Points); + } + return(status); +} + +/** + \brief Print data from a U_PMR_DRAWCURVE record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + + Curve is a cardinal spline, using doubled terminator points to generate curves for the terminal segments. + References sent by MS support: + http://alvyray.com/Memos/CG/Pixar/spline77.pdf + http://msdn.microsoft.com/en-us/library/4cf6we5y(v=vs.110).aspx + + EMF+ manual 2.3.4.5, Microsoft name: EmfPlusDrawCurve Record, Index 0x18 +*/ +int U_PMR_DRAWCURVE_print(const char *contents){ + uint32_t PenID; + int ctype; + U_FLOAT Tension; + uint32_t Offset, NSegs, Elements; + U_PMF_POINTF *Points; + int status = U_PMR_DRAWCURVE_get(contents, NULL, &PenID, &ctype, &Tension, &Offset, &NSegs, &Elements, &Points); + if(status){ + printf(" + PenID:%u ctype:%d Tension:%f Offset:%u NSegs:%u Elements:%u\n", PenID, ctype, Tension, Offset, NSegs, Elements); + U_PMF_VARPOINTF_S_print(Points, Elements); + free(Points); + } + return(status); +} + +/** + \brief Print data from a U_PMR_DRAWDRIVERSTRING record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.4.6, Microsoft name: EmfPlusDrawDriverString Record, Index 0x36 +*/ +int U_PMR_DRAWDRIVERSTRING_print(const char *contents){ + unsigned int i; + uint32_t FontID; + int btype; + U_FLOAT Tension; + uint32_t BrushID, DSOFlags, HasMatrix, Elements; + uint16_t *Glyphs; + U_PMF_POINTF *Points; + U_PMF_TRANSFORMMATRIX *Matrix; + int status = U_PMR_DRAWDRIVERSTRING_get(contents, NULL, &FontID, &btype, + &Tension, &BrushID, &DSOFlags, &HasMatrix, &Elements,&Glyphs, &Points, &Matrix); + if(status){ + printf(" + FontID:%u btype:%d Tension:%f BrushID:%u DSOFlags:%X Elements:%u\n", FontID,btype,Tension, BrushID, DSOFlags, Elements); + + printf(" + Glyphs:"); + if(*Glyphs){ + for(i=0; i<Elements;i++, Glyphs++){ printf(" %u",*Glyphs); } + free(Glyphs); + } + else { + printf("(none)"); + } + printf("\n"); + + printf(" + Positions:\n"); + if(Points){ + U_PMF_VARPOINTF_S_print(Points, Elements); + free(Points); + } + else { + printf("(none)\n"); + } + + if(Matrix){ + printf(" + "); + U_PMF_TRANSFORMMATRIX2_print(Matrix); + free(Matrix); + printf("\n"); + } + + } + return(status); +} + +/** + \brief Print data from a U_PMR_DRAWELLIPSE record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.4.7, Microsoft name: EmfPlusDrawEllipse Record, Index 0x0F +*/ +int U_PMR_DRAWELLIPSE_print(const char *contents){ + uint32_t PenID; + int ctype; + U_PMF_RECTF Rect; + int status = U_PMR_DRAWELLIPSE_get(contents, NULL, &PenID, &ctype, &Rect); + if(status){ + printf(" + PenID:%u ctype:%d", PenID,ctype); + (void) U_PMF_VARRECTF_S_print(&Rect, 1); + printf("\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMR_DRAWIMAGE record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.4.8, Microsoft name: EmfPlusDrawImage Record, Index 0x1A +*/ +int U_PMR_DRAWIMAGE_print(const char *contents){ + uint32_t ImgID, ImgAttrID; + int ctype; + int32_t SrcUnit; + U_PMF_RECTF SrcRect; + U_PMF_RECTF DstRect; + int status = U_PMR_DRAWIMAGE_get(contents, NULL, &ImgID, &ctype, &ImgAttrID, &SrcUnit, &SrcRect, &DstRect); + if(status){ + printf(" + ImgID:%u ctype:%d ImgAttrID:%u SrcUnit:%d SrcRect:", ImgID, ctype, ImgAttrID, SrcUnit); + (void) U_PMF_RECTF_S_print(&SrcRect); + printf(" DstRect:"); + (void) U_PMF_RECTF_S_print(&DstRect); + printf("\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMR_DRAWIMAGEPOINTS record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.4.9, Microsoft name: EmfPlusDrawImagePoints Record, Index 0x1B +*/ +int U_PMR_DRAWIMAGEPOINTS_print(const char *contents){ + uint32_t ImgID, ImgAttrID; + int ctype, etype, RelAbs; + int32_t SrcUnit; + U_PMF_RECTF SrcRect; + uint32_t Elements; + U_PMF_POINTF *Points; + int status = U_PMR_DRAWIMAGEPOINTS_get(contents, NULL, &ImgID, &ctype, &etype, &RelAbs, + &ImgAttrID, &SrcUnit, &SrcRect, &Elements, &Points); + if(status){ + printf(" + ImgID:%u ctype:%d etype:%d ImgAttrID:%u SrcUnit:%d Elements:%u SrcRect:", + ImgID, ctype, etype, ImgAttrID, SrcUnit, Elements); + (void) U_PMF_RECTF_S_print(&SrcRect); + printf("\n"); + U_PMF_VARPOINTF_S_print(Points, Elements); + free(Points); + } + return(status); +} + + +/** + \brief Print data from a U_PMR_DRAWLINES record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.4.10, Microsoft name: EmfPlusDrawLines Record, Index 0x0D +*/ +int U_PMR_DRAWLINES_print(const char *contents){ + uint32_t PenIdx; + int ctype, dtype, RelAbs; + uint32_t Elements; + U_PMF_POINTF *Points; + int status = U_PMR_DRAWLINES_get(contents, NULL, &PenIdx, &ctype, &dtype, &RelAbs, &Elements, &Points); + if(status){ + printf(" + PenIdx:%d ctype:%d dtype:%d RelAbs:%d\n", PenIdx,ctype,dtype,RelAbs); + U_PMF_VARPOINTF_S_print(Points, Elements); + free(Points); + } + return(status); +} + +/** + \brief Print data from a U_PMR_DRAWPATH record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.4.11, Microsoft name: EmfPlusDrawPath Record, Index 0x15 +*/ +int U_PMR_DRAWPATH_print(const char *contents){ + uint32_t PathIdx, PenIdx; + int status = U_PMR_DRAWPATH_get(contents, NULL, &PathIdx, &PenIdx); + if(status){ + printf(" + PathIdx:%d PenIdx:%d\n", PathIdx, PenIdx); + } + return(status); +} + +/** + \brief Print data from a U_PMR_DRAWPIE record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.4.12, Microsoft name: EmfPlusDrawPie Record, Index 0x0D +*/ +int U_PMR_DRAWPIE_print(const char *contents){ + uint32_t PenID; + int ctype; + U_FLOAT Start, Sweep; + U_PMF_RECTF Rect; + int status = U_PMR_DRAWPIE_get(contents, NULL, &PenID, &ctype, &Start, &Sweep, &Rect); + if(status){ + printf(" + PenID:%u ctype:%d Start:%f Sweep:%f Rect:", PenID,ctype,Start,Sweep); + (void) U_PMF_VARRECTF_S_print(&Rect, 1); + printf("\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMR_DRAWRECTS record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + \param blimit One byte past the last record in memory. + EMF+ manual 2.3.4.13, Microsoft name: EmfPlusDrawRects Record, Index 0x0B +*/ +int U_PMR_DRAWRECTS_print(const char *contents, const char *blimit){ + uint32_t PenID; + int ctype; + uint32_t Elements; + U_PMF_RECTF *Rects=NULL; + U_PMF_CMN_HDR hdr; + int status = U_PMR_DRAWRECTS_get(contents, &hdr, &PenID, &ctype, &Elements, &Rects); + if(status){ + if(contents + hdr.Size >= blimit)return(0); + printf(" + PenID:%u ctype:%d Elements:%u Rect:", PenID,ctype,Elements); + (void) U_PMF_VARRECTF_S_print(Rects, Elements); + printf("\n"); + } + if(Rects)free(Rects); + return(status); +} + +/** + \brief Print data from a U_PMR_DRAWSTRING record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.4.14, Microsoft name: EmfPlusDrawString Record, Index 0x1C +*/ +int U_PMR_DRAWSTRING_print(const char *contents){ + char *String8=NULL; + uint32_t FontID, BrushID, FormatID, Length; + int btype; + U_PMF_RECTF Rect; + uint16_t *String16; + int status = U_PMR_DRAWSTRING_get(contents, NULL, &FontID, &btype, + &BrushID, &FormatID, &Length, &Rect, &String16); + if(status){ + printf(" + FontID:%u StringFormatID:%u btype:%d Length:%u Rect:", FontID, FormatID, btype, Length); + (void) U_PMF_RECTF_S_print(&Rect); + (void) U_PMF_VARBRUSHID_print(btype, BrushID); + if(String16){ + String8 = U_Utf16leToUtf8(String16, Length, NULL); + free(String16); + if(String8){ + printf(" String(as_UTF8):<%s>\n",String8); + free(String8); + } + } + else { + printf(" String(as_UTF8):(none)\n"); + } + } + return(status); +} + +/** + \brief Print data from a U_PMR_FILLCLOSEDCURVE record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.4.15, Microsoft name: EmfPlusFillClosedCurve Record, Index 0x16 +*/ +int U_PMR_FILLCLOSEDCURVE_print(const char *contents){ + uint32_t BrushID; + int btype, ctype, ftype, RelAbs; + U_FLOAT Tension; + uint32_t Elements; + U_PMF_POINTF *Points; + int status = U_PMR_FILLCLOSEDCURVE_get(contents, NULL, &btype, &ctype, &ftype, &RelAbs, + &BrushID, &Tension, &Elements, &Points); + if(status){ + printf(" + btype:%d ctype:%d ftype:%d RelAbs:%d Elements:%u", + btype, ctype, ftype, RelAbs, Elements); + (void) U_PMF_VARBRUSHID_print(btype, BrushID); + printf("\n"); + U_PMF_VARPOINTF_S_print(Points, Elements); + free(Points); + } + return(status); +} + + +/** + \brief Print data from a U_PMR_FILLELLIPSE record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.4.16, Microsoft name: EmfPlusFillEllipse Record, Index 0x0E +*/ +int U_PMR_FILLELLIPSE_print(const char *contents){ + int btype, ctype; + uint32_t BrushID; + U_PMF_RECTF Rect; + int status = U_PMR_FILLELLIPSE_get(contents, NULL, &btype, &ctype, &BrushID, &Rect); + if(status){ + printf(" + btype:%d ctype:%d",btype,ctype); + (void) U_PMF_VARBRUSHID_print(btype, BrushID); + (void) U_PMF_VARRECTF_S_print(&Rect, 1); + printf("\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMR_FILLPATH record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.4.17, Microsoft name: EmfPlusFillPath Record, Index 0x14 +*/ +int U_PMR_FILLPATH_print(const char *contents){ + int btype; + uint32_t PathID, BrushID; + int status = U_PMR_FILLPATH_get(contents, NULL, &PathID, &btype, &BrushID); + if(status){ + printf(" + PathID:%u btype:%d",PathID, btype); + (void) U_PMF_VARBRUSHID_print(btype, BrushID); + printf("\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMR_FILLPIE record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.4.18, Microsoft name: EmfPlusFillPie Record, Index 0x10 +*/ +int U_PMR_FILLPIE_print(const char *contents){ + int btype, ctype; + U_FLOAT Start, Sweep; + uint32_t BrushID; + U_PMF_RECTF Rect; + int status = U_PMR_FILLPIE_get(contents, NULL, &btype, &ctype, &BrushID, &Start, &Sweep, &Rect); + if(status){ + printf(" + btype:%d ctype:%d",btype,ctype); + (void) U_PMF_VARBRUSHID_print(btype, BrushID); + (void) U_PMF_VARRECTF_S_print(&Rect, 1); + printf("\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMR_FILLPOLYGON record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.4.19, Microsoft name: EmfPlusFillPolygon Record, Index 0x0C +*/ +int U_PMR_FILLPOLYGON_print(const char *contents){ + int btype, ctype, RelAbs; + uint32_t BrushID, Elements; + U_PMF_POINTF *Points; + int status = U_PMR_FILLPOLYGON_get(contents, NULL, &btype, &ctype, &RelAbs, &BrushID, &Elements, &Points); + if(status){ + printf(" + btype:%d ctype:%d RelAbs:%d Elements:%u",btype,ctype,RelAbs,Elements); + (void) U_PMF_VARBRUSHID_print(btype, BrushID); + printf("\n"); + U_PMF_VARPOINTF_S_print(Points, Elements); + free(Points); + } + return(status); +} + +/** + \brief Print data from a U_PMR_FILLRECTS record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + \param blimit One byte past the last record in memory. + EMF+ manual 2.3.4.20, Microsoft name: EmfPlusFillRects Record, Index 0x0A +*/ +int U_PMR_FILLRECTS_print(const char *contents, const char *blimit){ + int btype, ctype; + uint32_t BrushID, Elements; + U_PMF_RECTF *Rects; + U_PMF_CMN_HDR hdr; + int status = U_PMR_FILLRECTS_get(contents, &hdr, &btype,&ctype, &BrushID, &Elements, &Rects); + if(status){ + if(contents + hdr.Size >= blimit)return(0); + printf(" + btype:%d ctype:%d Elements:%u",btype,ctype,Elements); + (void) U_PMF_VARBRUSHID_print(btype, BrushID); + (void) U_PMF_VARRECTF_S_print(Rects, Elements); + free(Rects); + printf("\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMR_FILLREGION record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.4.21, Microsoft name: EmfPlusFillRegion Record, Index 0x13 +*/ +int U_PMR_FILLREGION_print(const char *contents){ + uint32_t RgnID, BrushID; + int btype, ctype; + int status = U_PMR_FILLREGION_get(contents, NULL, &RgnID, &btype, &ctype, &BrushID); + if(status){ + printf(" + RgnID:%u btype:%d ctype:%d", RgnID, btype, ctype); + (void) U_PMF_VARBRUSHID_print(btype, BrushID); + printf("\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMR_OBJECT record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + \param blimit One byte past the last record in memory. + \param ObjCont Structure that holds accumulated object. + \param term Flag used when an abnormal termination of a series of continuation records is encountered. + EMF+ manual 2.3.5.1, Microsoft name: EmfPlusObject Record, Index 0x13 +*/ +int U_PMR_OBJECT_print(const char *contents, const char *blimit, U_OBJ_ACCUM *ObjCont, int term){ + U_PMF_CMN_HDR Header; + uint32_t ObjID; + int otype, ntype; + uint32_t TSize; + const char *Data; + int ttype,status; + +//int k; const char *cptr; for(cptr=contents, k=0; k<608;k++,cptr++){ printf("%3.3d %2.2X\n",k,*(uint8_t*)cptr); }; fflush(stdout); + + /* Continued records are a pain. Each contains the total size of the continued object in the first 4 bytes + of data. When the total hits that then then the record is complete, even though the continuation bit will + still be set on that last record. Check for this and then print the terminated continued series. + */ + + if(term){ /* mode for handling unexpected end of accumulated object */ + if(ObjCont->used == 0)return(0); /* no continued object pending */ + printf(" + START Forced Termination of Accumulating object Bytes:%u ObjID:%u DeclaredType:%d(", + ObjCont->used, ObjCont->Id, ObjCont->Type); + U_PMF_OBJECTTYPEENUMERATION_print(ObjCont->Type); + ttype = ObjCont->Type & 0x3F; + printf(")\n"); + status = 1; + } + else { + status = U_PMR_OBJECT_get(contents, &Header, &ObjID, &otype, &ntype, &TSize, &Data); + /* In a corrupt EMF+ file we might hit a new type of record before all the continuation records + expected have been found. If that happens terminate whatever we have accumulated so far, and then go on + to emit the new (unexpected) record. */ + if(contents + Header.Size >= blimit)return(0); + if(!status)return(status); + if((ObjCont->used > 0) && (U_OA_append(ObjCont, NULL, 0, otype, ObjID) < 0)){ + U_PMR_OBJECT_print(contents, blimit, ObjCont, 1); + } + printf(" + ObjID:%u ObjType:%d(", ObjID, otype); + U_PMF_OBJECTTYPEENUMERATION_print(otype); + printf(") ntype:%d", ntype); + printf(" ContinueD:%c",( ObjCont->used ? 'Y' : 'N')); + printf(" ContinueB:%c",( ntype ? 'Y' : 'N')); + if(ntype){ + U_OA_append(ObjCont, Data, Header.DataSize - 4, otype, ObjID); // The total byte count is not added to the object + printf(" TotalSize:%u",TSize); + printf(" Accumulated:%u",ObjCont->used); + } + else { + U_OA_append(ObjCont, Data, Header.DataSize, otype, ObjID); // The total byte count is not added to the object + } + printf("\n"); + if(ntype && ObjCont->used < TSize)return(status); + /* preceding terminates any continued series for >= accumulated bytes */ + ttype = otype; + } + if(status){ + switch(ttype){ + case U_OT_Brush: (void) U_PMF_BRUSH_print(ObjCont->accum); break; + case U_OT_Pen: (void) U_PMF_PEN_print(ObjCont->accum); break; + case U_OT_Path: (void) U_PMF_PATH_print(ObjCont->accum); break; + case U_OT_Region: (void) U_PMF_REGION_print(ObjCont->accum); break; + case U_OT_Image: (void) U_PMF_IMAGE_print(ObjCont->accum); break; + case U_OT_Font: (void) U_PMF_FONT_print(ObjCont->accum); break; + case U_OT_StringFormat: (void) U_PMF_STRINGFORMAT_print(ObjCont->accum); break; + case U_OT_ImageAttributes: (void) U_PMF_IMAGEATTRIBUTES_print(ObjCont->accum); break; + case U_OT_CustomLineCap: (void) U_PMF_CUSTOMLINECAP_print(ObjCont->accum,""); break; + case U_OT_Invalid: + default: + printf("INVALID OBJECT TYPE!!!!\n"); + break; + } + U_OA_clear(ObjCont); + } + if(term)printf(" + END Forced Termination of Accumulating object\n"); + return(status); +} + +/** + \brief Print data from a U_PMR_SERIALIZABLEOBJECT record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.5.2, Microsoft name: EmfPlusSerializableObject Record, Index 0x38 +*/ +int U_PMR_SERIALIZABLEOBJECT_print(const char *contents){ + uint8_t GUID[16]; + uint32_t Size; + const char *Data; + char *string=NULL; + int iee; + int status = U_PMR_SERIALIZABLEOBJECT_get(contents, NULL, &GUID[0], &Size, &Data); + if(status){ + string = U_PMF_CURLYGUID_set(&GUID[0]); + if(string){ + printf(" + GUID:%s Size:%u",string,Size); + iee = U_PMF_KNOWNCURLYGUID_set(string); /* overwrites string with short text form */ + printf("\n + Effect:"); + free(string); + switch(iee){ + case U_IEE_Unknown: printf("(undefined)\n"); break; + case U_IEE_BlurEffectGuid: U_PMF_IE_BLUR_print(Data); break; + case U_IEE_BrightnessContrastEffectGuid: U_PMF_IE_BRIGHTNESSCONTRAST_print(Data); break; + case U_IEE_ColorBalanceEffectGuid: U_PMF_IE_COLORBALANCE_print(Data); break; + case U_IEE_ColorCurveEffectGuid: U_PMF_IE_COLORCURVE_print(Data); break; + case U_IEE_ColorLookupTableEffectGuid: U_PMF_IE_COLORLOOKUPTABLE_print(Data); break; + case U_IEE_ColorMatrixEffectGuid: U_PMF_IE_COLORMATRIX_print(Data); break; + case U_IEE_HueSaturationLightnessEffectGuid: U_PMF_IE_HUESATURATIONLIGHTNESS_print(Data); break; + case U_IEE_LevelsEffectGuid: U_PMF_IE_LEVELS_print(Data); break; + case U_IEE_RedEyeCorrectionEffectGuid: U_PMF_IE_REDEYECORRECTION_print(Data); break; + case U_IEE_SharpenEffectGuid: U_PMF_IE_SHARPEN_print(Data); break; + case U_IEE_TintEffectGuid: U_PMF_IE_TINT_print(Data); break; + } + } + else { + printf(" + GUID:ERROR Size:%u\n",Size); + } + } + return(status); +} + +/** + \brief Print data from a U_PMR_SETANTIALIASMODE record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.6.1, Microsoft name: EmfPlusSetAntiAliasMode Record, Index 0x1E +*/ +int U_PMR_SETANTIALIASMODE_print(const char *contents){ + int SMenum, aatype; + int status = U_PMR_SETANTIALIASMODE_get(contents, NULL, &SMenum, &aatype); + if(status){ + printf(" + SMenum:%d AntiAlias:%c\n",SMenum,(aatype ? 'Y' : 'N')); + } + return(status); +} + +/** + \brief Print data from a U_PMR_SETCOMPOSITINGMODE record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.6.2, Microsoft name: EmfPlusSetCompositingMode Record, Index 0x23 +*/ +int U_PMR_SETCOMPOSITINGMODE_print(const char *contents){ + int CMenum; + int status = U_PMR_SETCOMPOSITINGMODE_get(contents, NULL, &CMenum); + if(status){ + printf(" + CMenum:%d\n",CMenum); + } + return(status); +} + +/** + \brief Print data from a U_PMR_SETCOMPOSITINGQUALITY record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.6.3, Microsoft name: EmfPlusSetCompositingQuality Record, Index 0x24 +*/ +int U_PMR_SETCOMPOSITINGQUALITY_print(const char *contents){ + int CQenum; + int status = U_PMR_SETCOMPOSITINGQUALITY_get(contents, NULL, &CQenum); + if(status){ + printf(" + CQenum:%d\n",CQenum); + } + return(status); +} + +/** + \brief Print data from a U_PMR_SETINTERPOLATIONMODE record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.6.4, Microsoft name: EmfPlusSetInterpolationMode Record, Index 0x21 +*/ +int U_PMR_SETINTERPOLATIONMODE_print(const char *contents){ + int IMenum; + int status = U_PMR_SETINTERPOLATIONMODE_get(contents, NULL, &IMenum); + if(status){ + printf(" + IMenum:%d\n",IMenum); + } + return(status); +} + +/** + \brief Print data from a U_PMR_SETPIXELOFFSETMODE record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.6.5, Microsoft name: EmfPlusSetPixelOffsetMode Record, Index 0x22 +*/ +int U_PMR_SETPIXELOFFSETMODE_print(const char *contents){ + int POMenum; + int status = U_PMR_SETPIXELOFFSETMODE_get(contents, NULL, &POMenum); + if(status){ + printf(" + POMenum:%d\n",POMenum); + } + return(status); +} + +/** + \brief Print data from a U_PMR_SETRENDERINGORIGIN record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.6.6, Microsoft name: EmfPlusSetRenderingOrigin Record, Index 0x1D +*/ +int U_PMR_SETRENDERINGORIGIN_print(const char *contents){ + int32_t X, Y; + int status = U_PMR_SETRENDERINGORIGIN_get(contents, NULL, &X, &Y); + if(status){ + printf(" + X:%d Y:%d\n", X, Y); + } + return(status); +} + +/** + \brief Print data from a U_PMR_SETTEXTCONTRAST record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.6.7, Microsoft name: EmfPlusSetTextContrast Record, Index 0x20 +*/ +int U_PMR_SETTEXTCONTRAST_print(const char *contents){ + int GC; + int status = U_PMR_SETTEXTCONTRAST_get(contents, NULL, &GC); + if(status){ + printf(" + GC:%d\n", GC); + } + return(status); +} + +/** + \brief Print data from a U_PMR_SETTEXTRENDERINGHINT record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.6.8, Microsoft name: EmfPlusSetTextRenderingHint Record, Index 0x1F +*/ +int U_PMR_SETTEXTRENDERINGHINT_print(const char *contents){ + int TRHenum; + int status = U_PMR_SETTEXTRENDERINGHINT_get(contents, NULL, &TRHenum); + if(status){ + printf(" + TRHenum:%d\n",TRHenum); + } + return(status); +} + +/** + \brief Print data from a U_PMR_BEGINCONTAINER record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.7.1, Microsoft name: EmfPlusBeginContainer Record, Index 0x27 +*/ +int U_PMR_BEGINCONTAINER_print(const char *contents){ + int UTenum; + U_PMF_RECTF DstRect, SrcRect; + uint32_t StackID; + int status = U_PMR_BEGINCONTAINER_get(contents, NULL, &UTenum, &DstRect, &SrcRect, &StackID); + if(status){ + printf(" + UTenum:%d",UTenum); + printf(" DstRect:"); (void) U_PMF_RECTF_S_print(&DstRect); + printf(" SrcRect:"); (void) U_PMF_RECTF_S_print(&SrcRect); + printf(" StackID:%u\n", StackID); + } + return(status); +} + +/** + \brief Print data from a U_PMR_BEGINCONTAINERNOPARAMS record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.7.2, Microsoft name: EmfPlusBeginContainerNoParams Record, Index 0x28 +*/ +int U_PMR_BEGINCONTAINERNOPARAMS_print(const char *contents){ + uint32_t StackID; + int status = U_PMR_BEGINCONTAINERNOPARAMS_get(contents, NULL, &StackID); + if(status){ + printf(" + StackID:%u\n", StackID); + } + return(status); +} + +/** + \brief Print data from a U_PMR_ENDCONTAINER record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.7.3, Microsoft name: EmfPlusEndContainer Record, Index 0x29 +*/ +int U_PMR_ENDCONTAINER_print(const char *contents){ + uint32_t StackID; + int status = U_PMR_ENDCONTAINER_get(contents, NULL, &StackID); + if(status){ + printf(" + StackID:%u\n", StackID); + } + return(status); +} + +/** + \brief Print data from a U_PMR_RESTORE record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.7.4, Microsoft name: EmfPlusRestore Record, Index 0x26 +*/ +int U_PMR_RESTORE_print(const char *contents){ + uint32_t StackID; + int status = U_PMR_RESTORE_get(contents, NULL, &StackID); + if(status){ + printf(" + StackID:%u\n", StackID); + } + return(status); +} + +/** + \brief Print data from a U_PMR_SAVE record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.7.5, Microsoft name: EmfPlusSave Record, Index 0x25 +*/ +int U_PMR_SAVE_print(const char *contents){ + uint32_t StackID; + int status = U_PMR_SAVE_get(contents, NULL, &StackID); + if(status){ + printf(" + StackID:%u\n", StackID); + } + return(status); +} + +/** + \brief Print data from a U_PMR_SETTSCLIP record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.8.1, Microsoft name: EmfPlusSetTSClip Record, Index 0x3A +*/ +int U_PMR_SETTSCLIP_print(const char *contents){ + int ctype; + uint32_t Elements; + U_PMF_RECTF *Rects; + int status = U_PMR_SETTSCLIP_get(contents, NULL, &ctype, &Elements, &Rects); + if(status){ + printf(" + ctype:%d Elements:%u",ctype,Elements); + (void) U_PMF_VARRECTF_S_print(Rects, Elements); + free(Rects); + printf("\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMR_SETTSGRAPHICS record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.8.2, Microsoft name: EmfPlusSetTSGraphics Record, Index 0x39 +*/ +int U_PMR_SETTSGRAPHICS_print(const char *contents){ + int vgatype, pptype; + uint8_t AntiAliasMode, TextRenderHint, CompositingMode, CompositingQuality, FilterType, PixelOffset; + int16_t RenderOriginX, RenderOriginY; + uint16_t TextContrast; + U_PMF_TRANSFORMMATRIX WorldToDevice; + const char *Data; + int status = U_PMR_SETTSGRAPHICS_get(contents, NULL, + &vgatype, &pptype, + &AntiAliasMode, &TextRenderHint, &CompositingMode, &CompositingQuality, + &RenderOriginX, &RenderOriginY, &TextContrast, &FilterType, + &PixelOffset, &WorldToDevice, &Data); + if(status){ + printf(" + vgatype:%d pptype:%u",vgatype,pptype); + printf(" AntiAliasMode:%u TextRenderHint:%u CompositingMode:%u CompositingQuality:%u", + AntiAliasMode, TextRenderHint, CompositingMode, CompositingQuality); + printf(" RenderOriginX:%d RenderOriginY:%d",RenderOriginX, RenderOriginY); + printf(" TextContrast:%u",TextContrast); + printf(" WorldToDevice:"); + U_PMF_TRANSFORMMATRIX2_print(&WorldToDevice); + if(pptype){ (void) U_PMF_PALETTE_print(Data); } + printf("\n"); + } + return(status); +} + + +/** + \brief Print data from a U_PMR_MULTIPLYWORLDTRANSFORM record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.9.1, Microsoft name: EmfPlusMultiplyWorldTransform Record, Index 0x2C +*/ +int U_PMR_MULTIPLYWORLDTRANSFORM_print(const char *contents){ + int xmtype; + U_PMF_TRANSFORMMATRIX Matrix; + int status = U_PMR_MULTIPLYWORLDTRANSFORM_get(contents, NULL, &xmtype, &Matrix); + if(status){ + printf(" + xmtype:%d Multiply:%s",xmtype,(xmtype ? "Post" : "Pre")); + U_PMF_TRANSFORMMATRIX2_print(&Matrix); + printf("\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMR_RESETWORLDTRANSFORM record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.9.2, Microsoft name: EmfPlusResetWorldTransform Record, Index 0x2B +*/ +int U_PMR_RESETWORLDTRANSFORM_print(const char *contents){ + return(U_PMR_NODATAREC_print(contents)); +} + +/** + \brief Print data from a U_PMR_ROTATEWORLDTRANSFORM record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.9.3, Microsoft name: EmfPlusRotateWorldTransform Record, Index 0x2F +*/ +int U_PMR_ROTATEWORLDTRANSFORM_print(const char *contents){ + int xmtype; + U_FLOAT Angle; + int status = U_PMR_ROTATEWORLDTRANSFORM_get(contents, NULL, &xmtype, &Angle); + if(status){ + printf(" + xmtype:%d Multiply:%s Angle:%f\n",xmtype,(xmtype ? "Post" : "Pre"), Angle); + } + return(status); +} + +/** + \brief Print data from a U_PMR_SCALEWORLDTRANSFORM record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.9.4, Microsoft name: EmfPlusScaleWorldTransform Record, Index 0x2E +*/ +int U_PMR_SCALEWORLDTRANSFORM_print(const char *contents){ + int xmtype; + U_FLOAT Sx, Sy; + int status = U_PMR_SCALEWORLDTRANSFORM_get(contents, NULL, &xmtype, &Sx, &Sy); + if(status){ + printf(" + xmtype:%d Multiply:%s ScaleX:%f ScaleY:%f\n",xmtype,(xmtype ? "Post" : "Pre"), Sx, Sy); + } + return(status); +} + +/** + \brief Print data from a U_PMR_SETPAGETRANSFORM record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.9.5, Microsoft name: EmfPlusSetPageTransform Record, Index 0x30 +*/ +int U_PMR_SETPAGETRANSFORM_print(const char *contents){ + int UTenum; + U_FLOAT Scale; + int status = U_PMR_SETPAGETRANSFORM_get(contents, NULL, &UTenum, &Scale); + if(status){ + printf(" + UTenum:%d Scale:%f\n",UTenum, Scale); + } + return(status); +} + +/** + \brief Print data from a U_PMR_SETWORLDTRANSFORM record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.9.6, Microsoft name: EmfPlusSetWorldTransform Record, Index 0x2A +*/ +int U_PMR_SETWORLDTRANSFORM_print(const char *contents){ + U_PMF_TRANSFORMMATRIX Matrix; + int status = U_PMR_SETWORLDTRANSFORM_get(contents, NULL, &Matrix); + if(status){ + printf(" + "); + U_PMF_TRANSFORMMATRIX2_print(&Matrix); + printf("\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMR_TRANSLATEWORLDTRANSFORM record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.9.7, Microsoft name: EmfPlusTranslateWorldTransform Record, Index 0x2D +*/ +int U_PMR_TRANSLATEWORLDTRANSFORM_print(const char *contents){ + int xmtype; + U_FLOAT Dx, Dy; + int status = U_PMR_TRANSLATEWORLDTRANSFORM_get(contents, NULL, &xmtype, &Dx, &Dy); + if(status){ + printf(" + xmtype:%d Multiply:%s TranslateX:%f TranlateY:%f\n",xmtype,(xmtype ? "Post" : "Pre"), Dx, Dy); + } + return(status); +} + + +/** + \brief Print data from a U_PMR_STROKEFILLPATH record + \return 1 on success, 0 on error + \param contents Record from which to print data +*/ +int U_PMR_STROKEFILLPATH_print(const char *contents){ + return(U_PMR_NODATAREC_print(contents)); +} + +/** + \brief Print data from a U_PMR_MULTIFORMATSTART record + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual mentioned in 2.1.1.1, reserved, not otherwise documented, Microsoft name: EmfPlusMultiFormatStart Record, Index 0x05 +*/ +int U_PMR_MULTIFORMATSTART_print(const char *contents){ + return(U_PMR_NODATAREC_print(contents)); +} + +/** + \brief Print data from a U_PMR_MULTIFORMATSECTION record + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual mentioned in 2.1.1.1, reserved, not otherwise documented, Microsoft name: EmfPlusMultiFormatSection Record, Index 0x06 +*/ +int U_PMR_MULTIFORMATSECTION_print(const char *contents){ + return(U_PMR_NODATAREC_print(contents)); +} + +/** + \brief Print data from a U_PMR_MULTIFORMATEND record + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual mentioned in 2.1.1.1, reserved, not otherwise documented, Microsoft name: EmfPlusMultiFormatEnd Record, Index 0x06 +*/ +int U_PMR_MULTIFORMATEND_print(const char *contents){ + return(U_PMR_NODATAREC_print(contents)); +} + + + +#ifdef __cplusplus +} +#endif diff --git a/src/libuemf/upmf_print.h b/src/libuemf/upmf_print.h new file mode 100644 index 000000000..3ba6694eb --- /dev/null +++ b/src/libuemf/upmf_print.h @@ -0,0 +1,180 @@ +/** + @file upmf_print.h + + @brief Prototypes for functions for printing records from EMF files. +*/ + +/* +File: upmf_print.h +Version: 0.0.2 +Date: 17-OCT-2013 +Author: David Mathog, Biology Division, Caltech +email: mathog@caltech.edu +Copyright: 2013 David Mathog and California Institute of Technology (Caltech) +*/ + +#ifndef _UPMF_PRINT_ +#define _UPMF_PRINT_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "upmf.h" /* includes uemf.h */ + +/* prototypes for simple types and enums used in PMR records */ +int U_PMF_CMN_HDR_print(U_PMF_CMN_HDR Header, int precnum, int off); +int U_PMF_UINT8_ARRAY_print(const char *Start, const uint8_t *Array, int Elements, char *End); +int U_PMF_BRUSHTYPEENUMERATION_print(int otype); +int U_PMF_HATCHSTYLEENUMERATION_print(int hstype); +int U_PMF_OBJECTTYPEENUMERATION_print(int otype); +int U_PMF_PATHPOINTTYPE_ENUM_print(int Type); +int U_PMF_PX_FMT_ENUM_print(int pfe); +int U_PMF_NODETYPE_print(int Type); + +/* prototypes for objects used in PMR records */ +int U_PMF_BRUSH_print(const char *contents); +int U_PMF_CUSTOMLINECAP_print(const char *contents, const char *Which); +int U_PMF_FONT_print(const char *contents); +int U_PMF_IMAGE_print(const char *contents); +int U_PMF_IMAGEATTRIBUTES_print(const char *contents); +int U_PMF_PATH_print(const char *contents); +int U_PMF_PEN_print(const char *contents); +int U_PMF_REGION_print(const char *contents); +int U_PMF_STRINGFORMAT_print(const char *contents); +int U_PMF_ARGB_print(const char *contents); +int U_PMF_BITMAP_print(const char *contents); +int U_PMF_BITMAPDATA_print(const char *contents); +int U_PMF_BLENDCOLORS_print(const char *contents); +int U_PMF_BLENDFACTORS_print(const char *contents, const char *type); +int U_PMF_BOUNDARYPATHDATA_print(const char *contents); +int U_PMF_BOUNDARYPOINTDATA_print(const char *contents); +int U_PMF_CHARACTERRANGE_print(const char *contents); +int U_PMF_COMPOUNDLINEDATA_print(const char *contents); +int U_PMF_COMPRESSEDIMAGE_print(const char *contents); +int U_PMF_CUSTOMENDCAPDATA_print(const char *contents); +int U_PMF_CUSTOMLINECAPARROWDATA_print(const char *contents); +int U_PMF_CUSTOMLINECAPDATA_print(const char *contents); +int U_PMF_CUSTOMLINECAPOPTIONALDATA_print(const char *contents, uint32_t Flags); +int U_PMF_CUSTOMSTARTCAPDATA_print(const char *contents); +int U_PMF_DASHEDLINEDATA_print(const char *contents); +int U_PMF_FILLPATHOBJ_print(const char *contents); +int U_PMF_FOCUSSCALEDATA_print(const char *contents); +int U_PMF_GRAPHICSVERSION_print(const char *contents); +int U_PMF_HATCHBRUSHDATA_print(const char *contents); +int U_PMF_LANGUAGEIDENTIFIER_print(U_PMF_LANGUAGEIDENTIFIER LId); +int U_PMF_LINEARGRADIENTBRUSHDATA_print(const char *contents); +int U_PMF_LINEARGRADIENTBRUSHOPTIONALDATA_print(const char *contents, int BDFlag); +int U_PMF_LINEPATH_print(const char *contents); +int U_PMF_METAFILE_print(const char *contents); +int U_PMF_PALETTE_print(const char *contents); +int U_PMF_PATHGRADIENTBRUSHDATA_print(const char *contents); +int U_PMF_PATHGRADIENTBRUSHOPTIONALDATA_print(const char *contents, int BDFlag); +int U_PMF_PATHPOINTTYPE_print(const char *contents); +int U_PMF_PATHPOINTTYPERLE_print(const char *contents); +int U_PMF_PENDATA_print(const char *contents); +int U_PMF_PENOPTIONALDATA_print(const char *contents, int Flags); +int U_PMF_POINT_print(const char **contents); +int U_PMF_POINTF_print(const char **contents); +int U_PMF_POINTR_print(const char **contents, U_FLOAT *Xpos, U_FLOAT *Ypos); +int U_PMF_POINT_S_print(U_PMF_POINT *Point); +int U_PMF_POINTF_S_print(U_PMF_POINTF *Point); +int U_PMF_RECT_print(const char **contents); +int U_PMF_RECTF_print(const char **contents); +int U_PMF_RECT_S_print(U_PMF_RECT *Rect); +int U_PMF_RECTF_S_print(U_PMF_RECTF *Rect); +int U_PMF_REGIONNODE_print(const char *contents, int Level); +int U_PMF_REGIONNODECHILDNODES_print(const char *contents, int Level); +int U_PMF_REGIONNODEPATH_print(const char *contents); +int U_PMF_SOLIDBRUSHDATA_print(const char *contents); +int U_PMF_STRINGFORMATDATA_print(const char *contents, uint32_t TabStopCount, uint32_t RangeCount); +int U_PMF_TEXTUREBRUSHDATA_print(const char *contents); +int U_PMF_TEXTUREBRUSHOPTIONALDATA_print(const char *contents, int HasImage); +int U_PMF_TRANSFORMMATRIX_print(const char *contents); +int U_PMF_TRANSFORMMATRIX2_print(U_PMF_TRANSFORMMATRIX *Matrix); +int U_PMF_ROTMATRIX2_print(U_PMF_ROTMATRIX *Matrix); +int U_PMF_IE_BLUR_print(const char *contents); +int U_PMF_IE_BRIGHTNESSCONTRAST_print(const char *contents); +int U_PMF_IE_COLORBALANCE_print(const char *contents); +int U_PMF_IE_COLORCURVE_print(const char *contents); +int U_PMF_IE_COLORLOOKUPTABLE_print(const char *contents); +int U_PMF_IE_COLORMATRIX_print(const char *contents); +int U_PMF_IE_HUESATURATIONLIGHTNESS_print(const char *contents); +int U_PMF_IE_LEVELS_print(const char *contents); +int U_PMF_IE_REDEYECORRECTION_print(const char *contents); +int U_PMF_IE_SHARPEN_print(const char *contents); +int U_PMF_IE_TINT_print(const char *contents); + +/* prototypes for PMR records */ +int U_PMR_OFFSETCLIP_print(const char *contents); +int U_PMR_RESETCLIP_print(const char *contents); +int U_PMR_SETCLIPPATH_print(const char *contents); +int U_PMR_SETCLIPRECT_print(const char *contents); +int U_PMR_SETCLIPREGION_print(const char *contents); +int U_PMR_COMMENT_print(const char *contents); +int U_PMR_ENDOFFILE_print(const char *contents); +int U_PMR_GETDC_print(const char *contents); +int U_PMR_HEADER_print(const char *contents); +int U_PMR_CLEAR_print(const char *contents); +int U_PMR_DRAWARC_print(const char *contents); +int U_PMR_DRAWBEZIERS_print(const char *contents); +int U_PMR_DRAWCLOSEDCURVE_print(const char *contents); +int U_PMR_DRAWCURVE_print(const char *contents); +int U_PMR_DRAWDRIVERSTRING_print(const char *contents); +int U_PMR_DRAWELLIPSE_print(const char *contents); +int U_PMR_DRAWIMAGE_print(const char *contents); +int U_PMR_DRAWIMAGEPOINTS_print(const char *contents); +int U_PMR_DRAWLINES_print(const char *contents); +int U_PMR_DRAWPATH_print(const char *contents); +int U_PMR_DRAWPIE_print(const char *contents); +int U_PMR_DRAWRECTS_print(const char *contents, const char *blimit); +int U_PMR_DRAWSTRING_print(const char *contents); +int U_PMR_FILLCLOSEDCURVE_print(const char *contents); +int U_PMR_FILLELLIPSE_print(const char *contents); +int U_PMR_FILLPATH_print(const char *contents); +int U_PMR_FILLPIE_print(const char *contents); +int U_PMR_FILLPOLYGON_print(const char *contents); +int U_PMR_FILLRECTS_print(const char *contents, const char *blimit); +int U_PMR_FILLREGION_print(const char *contents); +int U_PMR_OBJECT_print(const char *contents, const char *blimit, U_OBJ_ACCUM *ObjCont, int term); +int U_PMR_SERIALIZABLEOBJECT_print(const char *contents); +int U_PMR_SETANTIALIASMODE_print(const char *contents); +int U_PMR_SETCOMPOSITINGMODE_print(const char *contents); +int U_PMR_SETCOMPOSITINGQUALITY_print(const char *contents); +int U_PMR_SETINTERPOLATIONMODE_print(const char *contents); +int U_PMR_SETPIXELOFFSETMODE_print(const char *contents); +int U_PMR_SETRENDERINGORIGIN_print(const char *contents); +int U_PMR_SETTEXTCONTRAST_print(const char *contents); +int U_PMR_SETTEXTRENDERINGHINT_print(const char *contents); +int U_PMR_BEGINCONTAINER_print(const char *contents); +int U_PMR_BEGINCONTAINERNOPARAMS_print(const char *contents); +int U_PMR_ENDCONTAINER_print(const char *contents); +int U_PMR_RESTORE_print(const char *contents); +int U_PMR_SAVE_print(const char *contents); +int U_PMR_SETTSCLIP_print(const char *contents); +int U_PMR_SETTSGRAPHICS_print(const char *contents); +int U_PMR_MULTIPLYWORLDTRANSFORM_print(const char *contents); +int U_PMR_RESETWORLDTRANSFORM_print(const char *contents); +int U_PMR_ROTATEWORLDTRANSFORM_print(const char *contents); +int U_PMR_SCALEWORLDTRANSFORM_print(const char *contents); +int U_PMR_SETPAGETRANSFORM_print(const char *contents); +int U_PMR_SETWORLDTRANSFORM_print(const char *contents); +int U_PMR_TRANSLATEWORLDTRANSFORM_print(const char *contents); +int U_PMR_STROKEFILLPATH_print(const char *contents); /* not documented */ +int U_PMR_MULTIFORMATSTART_print(const char *contents); /* last of reserved but not used */ +int U_PMR_MULTIFORMATSECTION_print(const char *contents); /* last of reserved but not used */ +int U_PMR_MULTIFORMATEND_print(const char *contents); /* last of reserved but not used */ + +int U_pmf_onerec_print(const char *contents, const char *blimit, int recnum, int off); + + + + + + + +#ifdef __cplusplus +} +#endif + +#endif /* _UPMF_PRINT_ */ diff --git a/src/libuemf/uwmf.c b/src/libuemf/uwmf.c index 9d916ecee..a6ac963cb 100644 --- a/src/libuemf/uwmf.c +++ b/src/libuemf/uwmf.c @@ -1,5 +1,7 @@ /** - @file uwmf.c Functions for manipulating WMF files and structures. + @file uwmf.c + + @brief Functions for manipulating WMF files and structures. [U_WMR*]_set all take data and return a pointer to memory holding the constructed record. If something goes wrong a NULL pointer is returned. @@ -17,8 +19,8 @@ /* File: uwmf.c -Version: 0.0.11 -Date: 19-MAR-2013 +Version: 0.0.12 +Date: 25-NOV-2013 Author: David Mathog, Biology Division, Caltech email: mathog@caltech.edu Copyright: 2013 David Mathog and California Institute of Technology (Caltech) @@ -665,17 +667,19 @@ char *U_wmr_escnames(int idx){ return(name); } +//! \cond /* one prototype from uwmf_endian. Put it here because end user should never need to see it, so not in uemf.h or uwmf_endian.h */ void U_swap2(void *ul, unsigned int count); +//! \endcond /** \brief Derive from bounding box and start and end arc, for WMF arc, chord, or pie records, the center, start, and end points, and the bounding rectangle. \return 0 on success, other values on errors. - \param rclBox Bounding box of Arc - \param ArcStart Coordinates for Start of Arc - \param ArcEnd Coordinates for End of Arc + \param rclBox16 Bounding box of Arc + \param ArcStart16 Coordinates for Start of Arc + \param ArcEnd16 Coordinates for End of Arc \param f1 1 if rotation angle >= 180, else 0 \param f2 Rotation direction, 1 if counter clockwise, else 0 \param center Center coordinates @@ -689,10 +693,10 @@ int wmr_arc_points( U_POINT16 ArcEnd16, int *f1, int f2, - PU_PAIRF center, - PU_PAIRF start, - PU_PAIRF end, - PU_PAIRF size + U_PAIRF *center, + U_PAIRF *start, + U_PAIRF *end, + U_PAIRF *size ){ U_RECTL rclBox; U_POINTL ArcStart,ArcEnd; @@ -737,6 +741,7 @@ uint32_t U_wmr_size(const U_METARECORD *record){ return(2*Size16); } +//! \cond should never be called directly #define SET_CB_FROM_PXBMI(A,B,C,D,E,F) /* A=Px, B=Bmi, C=cbImage, D=cbImage4, E=cbBmi, F=cbPx */ \ if(A){\ if(!B)return(NULL); /* size is derived from U_BITMAPINFO, but NOT from its size field, go figure*/ \ @@ -745,7 +750,7 @@ uint32_t U_wmr_size(const U_METARECORD *record){ E = U_SIZE_BITMAPINFOHEADER + 4 * get_real_color_count((char *)&(B->bmiHeader)); /* bmiheader + colortable*/ \ }\ else { C = 0; D = 0; E=0; } - +//! \endcond /** \brief Create and return a U_FONT structure. @@ -765,7 +770,7 @@ uint32_t U_wmr_size(const U_METARECORD *record){ \param PitchAndFamily LF_PitchAndFamily Enumeration \param FaceName Name of font. ANSI Latin1, null terminated. */ -PU_FONT U_FONT_set( +U_FONT *U_FONT_set( int16_t Height, //!< Height in Logical units int16_t Width, //!< Average Width in Logical units int16_t Escapement, //!< Angle in 0.1 degrees betweem escapement vector and X axis @@ -781,10 +786,10 @@ PU_FONT U_FONT_set( uint8_t PitchAndFamily, //!< LF_PitchAndFamily Enumeration char *FaceName //!< Name of font. ANSI Latin1, null terminated. ){ - PU_FONT font; + U_FONT *font; int slen = 1 + strlen(FaceName); /* include terminator */ if(slen & 1)slen++; /* storage length even */ - font = (PU_FONT) calloc(1,slen + U_SIZE_FONT_CORE); /* use calloc to auto fill in terminating '\0'*/ + font = (U_FONT *) calloc(1,slen + U_SIZE_FONT_CORE); /* use calloc to auto fill in terminating '\0'*/ if(font){ font->Height = Height; font->Width = Width; @@ -825,12 +830,12 @@ U_PLTNTRY U_PLTNTRY_set(U_COLORREF Color){ \param NumEntries Number of U_LOGPLTNTRY objects \param PalEntries Pointer to array of PaletteEntry Objects */ -PU_PALETTE U_PLTENTRY_set( +U_PALETTE *U_PLTENTRY_set( uint16_t Start, //!< Either 0x0300 or an offset into the Palette table uint16_t NumEntries, //!< Number of U_LOGPLTNTRY objects - PU_PLTNTRY PalEntries //!< Pointer to array of PaletteEntry Objects + U_PLTNTRY *PalEntries //!< Pointer to array of PaletteEntry Objects ){ - PU_PALETTE Palette = NULL; + U_PALETTE *Palette = NULL; if(NumEntries){ Palette = malloc(4 + 4*NumEntries); if(Palette){ @@ -892,7 +897,7 @@ U_RECT16 U_RECT16_set( \param BitsPixel number of adjacent color bits on each plane (R bits + G bits + B bits ????) \param Bits bitmap pixel data. Bytes contained = (((Width * BitsPixel + 15) >> 4) << 1) * Height */ -PU_BITMAP16 U_BITMAP16_set( +U_BITMAP16 *U_BITMAP16_set( const int16_t Type, const int16_t Width, const int16_t Height, @@ -900,11 +905,11 @@ PU_BITMAP16 U_BITMAP16_set( const uint8_t BitsPixel, const char *Bits ){ - PU_BITMAP16 bm16; - uint32_t irecsize; - int cbBits,iHeight; - int usedbytes; - int16_t WidthBytes; // total bytes per scan line (used and padding). + U_BITMAP16 *bm16; + uint32_t irecsize; + int cbBits,iHeight; + int usedbytes; + int16_t WidthBytes; // total bytes per scan line (used and padding). usedbytes = (Width * BitsPixel + 7)/8; // width of line in fully and partially occupied bytes WidthBytes = (LineN * ((usedbytes + (LineN - 1) ) / LineN)); // Account for padding required by line alignment in the pixel array @@ -913,7 +918,7 @@ PU_BITMAP16 U_BITMAP16_set( cbBits = WidthBytes * iHeight; if(!Bits || cbBits<=0)return(NULL); irecsize = U_SIZE_BITMAP16 + cbBits; - bm16 = (PU_BITMAP16) malloc(irecsize); + bm16 = (U_BITMAP16 *) malloc(irecsize); if(bm16){ bm16->Type = Type; bm16->Width = Width; @@ -934,13 +939,13 @@ PU_BITMAP16 U_BITMAP16_set( \param bottom Y coordinate of the bottom scanline \param ScanLines Array of 16 bit left/right pairs, array has 2*count entries */ -PU_SCAN U_SCAN_set( +U_SCAN *U_SCAN_set( uint16_t count, //!< Number of entries in the ScanLines array uint16_t top, //!< Y coordinate of the top scanline uint16_t bottom, //!< Y coordinate of the bottom scanline uint16_t *ScanLines //!< Array of 16 bit left/right pairs, array has 2*count entries ){ - PU_SCAN scan=NULL; + U_SCAN *scan=NULL; int size = 6 + count*4; scan = malloc(size); if(scan){ @@ -961,19 +966,19 @@ PU_SCAN U_SCAN_set( \param sRect bounding rectangle \param aScans series of U_SCAN objects to append. This is also an array of uint16_t, but should be handled as a bunch of U_SCAN objects tightly packed into the buffer. */ -PU_REGION U_REGION_set( +U_REGION *U_REGION_set( int16_t Size, //!< aScans in bytes + regions size in bytes (size of this header plus all U_SCAN objects?) int16_t sCount, //!< number of scan objects in region (docs say scanlines, but then no way to add sizes) int16_t sMax, //!< largest number of points in any scan U_RECT16 sRect, //!< bounding rectangle uint16_t *aScans //!< series of U_SCAN objects to append. This is also an array of uint16_t, but should be handled as a bunch of U_SCAN objects tightly packed into the buffer. ){ - PU_REGION region=NULL; + U_REGION *region=NULL; char *psc; int scansize,i,off; psc = (char *)aScans; for(scansize=i=0; i<sCount; i++){ - off = 6 + 4*(((PU_SCAN)psc)->count); + off = 6 + 4*(((U_SCAN *)psc)->count); scansize += off; psc += off; } @@ -1021,11 +1026,11 @@ U_WLOGBRUSH U_WLOGBRUSH_set( \param x x value \param y y value */ -PU_PAIRF U_PAIRF_set( +U_PAIRF *U_PAIRF_set( float x, //!< x value float y //!< y value ){ - PU_PAIRF pf=malloc(U_SIZE_PAIRF); + U_PAIRF *pf=malloc(U_SIZE_PAIRF); if(pf){ pf->x = x; pf->y = y; @@ -1496,7 +1501,7 @@ int wmf_finish( // Set the header fields which were unknown up until this point - if(((PU_WMRPLACEABLE) wt->buf)->Key == 0x9AC6CDD7){ off = U_SIZE_WMRPLACEABLE; } + if(((U_WMRPLACEABLE *) wt->buf)->Key == 0x9AC6CDD7){ off = U_SIZE_WMRPLACEABLE; } else { off = 0; } record = (wt->buf + off); @@ -1617,14 +1622,14 @@ int wmf_append( \param freerec If true, free rec after append */ int wmf_header_append( - PU_METARECORD rec, + U_METARECORD *rec, WMFTRACK *wt, int freerec ){ size_t deficit; unsigned int hsize; - hsize = (((PU_WMRPLACEABLE) rec)->Key == 0x9AC6CDD7 ? U_SIZE_WMRHEADER + U_SIZE_WMRPLACEABLE: U_SIZE_WMRHEADER); + hsize = (((U_WMRPLACEABLE *) rec)->Key == 0x9AC6CDD7 ? U_SIZE_WMRHEADER + U_SIZE_WMRPLACEABLE: U_SIZE_WMRHEADER); #ifdef U_VALGRIND printf("\nbefore \n"); @@ -1764,7 +1769,7 @@ These functions create standard structures used in the WMR records. *********************************************************************************************** */ // hide these from Doxygen -//! @cond +//! \cond /* ********************************************************************************************** These functions contain shared code used by various U_WMR*_print functions. These should NEVER be called by end user code and to further that end prototypes are NOT provided and they are hidden from Doxygen. @@ -1789,8 +1794,8 @@ void U_WMRCORE_SETRECHEAD(char *record, uint32_t irecsize, int iType){ uint32_t Size16; Size16 = irecsize/2; memcpy(record,&Size16,4); /*Size16_4 is at offset 0 in the record */ - ((PU_METARECORD) record)->iType = iType; - ((PU_METARECORD) record)->xb = U_WMR_XB_FROM_TYPE(iType); + ((U_METARECORD *) record)->iType = iType; + ((U_METARECORD *) record)->xb = U_WMR_XB_FROM_TYPE(iType); } /* records that have no arguments */ @@ -1832,7 +1837,7 @@ char *U_WMRCORE_1U16_CRF_2U16_set( return(record); } -/* records that have a single uint16_t argument like PU_WMRSETMAPMODE +/* records that have a single uint16_t argument like U_WMRSETMAPMODE May also be used with int16_t with appropriate casts */ char *U_WMRCORE_1U16_set( int iType, @@ -2016,7 +2021,7 @@ char *U_WMRCORE_2U16_N16_set( May also be used with int16_t with appropriate casts */ char *U_WMRCORE_PALETTE_set( int iType, - PU_PALETTE Palette + const U_PALETTE *Palette ){ char *record=NULL; uint32_t irecsize, off, nPE; @@ -2034,7 +2039,7 @@ char *U_WMRCORE_PALETTE_set( return(record); } -//! @endcond +//! \endcond /* ********************************************************************************************** These functions are simpler or more convenient ways to generate the specified types of WMR records. @@ -2141,7 +2146,7 @@ char *wcreatedibpatternbrush_srcdib_set( uint32_t *ihBrush, WMFHANDLES *wht, const uint32_t iUsage, - PU_BITMAPINFO Bmi, + const U_BITMAPINFO *Bmi, const uint32_t cbPx, const char *Px @@ -2164,7 +2169,7 @@ char *wcreatedibpatternbrush_srcbm16_set( uint32_t *ihBrush, WMFHANDLES *wht, const uint32_t iUsage, - PU_BITMAP16 Bm16 + const U_BITMAP16 *Bm16 ){ if(wmf_htable_insert(ihBrush, wht))return(NULL); *ihBrush -= 1; /* 1->N+1 --> 0->N */ @@ -2184,7 +2189,7 @@ char *wcreatedibpatternbrush_srcbm16_set( char *wcreatepatternbrush_set( uint32_t *ihBrush, WMFHANDLES *wht, - PU_BITMAP16 Bm16, + U_BITMAP16 *Bm16, char *Pattern ){ if(wmf_htable_insert(ihBrush, wht))return(NULL); @@ -2199,12 +2204,12 @@ char *wcreatepatternbrush_set( \return pointer to the U_WMRCREATEFONTINDIRECT record, or NULL on error. \param ihFont Font handle, will be created and returned \param wht Pointer to structure holding all WMF handles - \param uf Pointer to Font parameters as PU_FONT + \param uf Pointer to Font parameters as U_FONT * */ char *wcreatefontindirect_set( uint32_t *ihFont, WMFHANDLES *wht, - PU_FONT uf + U_FONT *uf ){ if(wmf_htable_insert(ihFont, wht))return(NULL); *ihFont -= 1; /* 1->N+1 --> 0->N */ @@ -2223,7 +2228,7 @@ char *wcreatefontindirect_set( char *wcreatepalette_set( uint32_t *ihPal, WMFHANDLES *wht, - PU_PALETTE up + U_PALETTE *up ){ if(wmf_htable_insert(ihPal, wht))return(NULL); *ihPal -= 1; /* 1->N+1 --> 0->N */ @@ -2242,7 +2247,7 @@ char *wcreatepalette_set( char *wsetpaletteentries_set( uint32_t *ihPal, WMFHANDLES *wht, - const PU_PALETTE Palettes + const U_PALETTE *Palettes ){ if(wmf_htable_insert(ihPal, wht))return(NULL); *ihPal -= 1; /* 1->N+1 --> 0->N */ @@ -2261,7 +2266,7 @@ char *wsetpaletteentries_set( char *wcreateregion_set( uint32_t *ihReg, WMFHANDLES *wht, - const PU_REGION Region + const U_REGION *Region ){ if(wmf_htable_insert(ihReg, wht))return(NULL); *ihReg -= 1; /* 1->N+1 --> 0->N */ @@ -2349,7 +2354,7 @@ They are listed in order by the corresponding U_WMR_* index number. \param dpi Logical units/inch. If 0 defaults to 1440. */ char *U_WMRHEADER_set( - PU_PAIRF size, + U_PAIRF *size, unsigned int dpi ){ char *record=NULL; @@ -2370,20 +2375,20 @@ char *U_WMRHEADER_set( } xm16 = xmax; ym16 = ymax; - ((PU_WMRPLACEABLE) record)->Key = 0x9AC6CDD7; - ((PU_WMRPLACEABLE) record)->HWmf = 0; /* Manual says number of 16 bit words in record, but all WMF examples had it as 0 */ - ((PU_WMRPLACEABLE) record)->Dst.left = 0; - ((PU_WMRPLACEABLE) record)->Dst.top = 0; - ((PU_WMRPLACEABLE) record)->Dst.right = xm16; - ((PU_WMRPLACEABLE) record)->Dst.bottom = ym16; - ((PU_WMRPLACEABLE) record)->Inch = dpi; - ((PU_WMRPLACEABLE) record)->Reserved = 0; - ((PU_WMRPLACEABLE) record)->Checksum = U_16_checksum((int16_t *)record,10); + ((U_WMRPLACEABLE *) record)->Key = 0x9AC6CDD7; + ((U_WMRPLACEABLE *) record)->HWmf = 0; /* Manual says number of 16 bit words in record, but all WMF examples had it as 0 */ + ((U_WMRPLACEABLE *) record)->Dst.left = 0; + ((U_WMRPLACEABLE *) record)->Dst.top = 0; + ((U_WMRPLACEABLE *) record)->Dst.right = xm16; + ((U_WMRPLACEABLE *) record)->Dst.bottom = ym16; + ((U_WMRPLACEABLE *) record)->Inch = dpi; + ((U_WMRPLACEABLE *) record)->Reserved = 0; + ((U_WMRPLACEABLE *) record)->Checksum = U_16_checksum((int16_t *)record,10); off = U_SIZE_WMRPLACEABLE; } - ((PU_WMRHEADER) (record + off))->iType = 1; - ((PU_WMRHEADER) (record + off))->version = U_METAVERSION300; - ((PU_WMRHEADER) (record + off))->Size16w = U_SIZE_WMRHEADER/2; + ((U_WMRHEADER *) (record + off))->iType = 1; + ((U_WMRHEADER *) (record + off))->version = U_METAVERSION300; + ((U_WMRHEADER *) (record + off))->Size16w = U_SIZE_WMRHEADER/2; } return(record); } @@ -2731,13 +2736,13 @@ char *U_WMRPATBLT_set( ){ char *record=NULL; uint32_t irecsize; - PU_WMRPATBLT pmr; + U_WMRPATBLT *pmr; irecsize = U_SIZE_WMRPATBLT; record = malloc(irecsize); if(record){ U_WMRCORE_SETRECHEAD(record,irecsize,U_WMR_PATBLT); - pmr = (PU_WMRPATBLT) record; + pmr = (U_WMRPATBLT *) record; memcpy(pmr->rop3w, &dwRop3, 4); pmr->Height = cwh.y; pmr->Width = cwh.x; @@ -2755,16 +2760,27 @@ char *U_WMRSAVEDC_set(void){ return U_WMRCORE_NOARGS_set(U_WMR_SAVEDC); } -char *U_WMRSETPIXEL_set(U_COLORREF Color, U_POINT16 coord){ +/** + \brief Allocate and construct a U_WMRSETPIXEL record + \return pointer to the U_WMRSETPIXEL record, or NULL on error. + \param Color U_COLORREF color of the pixel + \param Coord U_POINT16 coordinates of the pixel +*/ +char *U_WMRSETPIXEL_set(U_COLORREF Color, U_POINT16 Coord){ return U_WMRCORE_1U16_CRF_2U16_set( U_WMR_SETPIXEL, NULL, Color, - U_P16(coord.y), - U_P16(coord.x) + U_P16(Coord.y), + U_P16(Coord.x) ); } +/** + \brief Allocate and construct a U_WMROFFSETCLIPRGN record + \return pointer to the U_WMROFFSETCLIPRGN record, or NULL on error. + \param offset U_POINT16 x,y offset to apply to the clipping region. +*/ char *U_WMROFFSETCLIPRGN_set(U_POINT16 offset){ return U_WMRCORE_2U16_set(U_WMR_OFFSETCLIPRGN, U_U16(offset.y), U_U16(offset.x)); } @@ -2815,13 +2831,13 @@ char *U_WMRBITBLT_set( U_POINT16 cwh, U_POINT16 Src, uint32_t dwRop3, - const PU_BITMAP16 Bm16 + const U_BITMAP16 *Bm16 ){ char *record=NULL; uint32_t irecsize; int cbBm16,cbBm164,off; - PU_WMRBITBLT_PX pmr_px; - PU_WMRBITBLT_NOPX pmr_nopx; + U_WMRBITBLT_PX *pmr_px; + U_WMRBITBLT_NOPX *pmr_nopx; if(Bm16){ cbBm16 = U_SIZE_BITMAP16 + (((Bm16->Width * Bm16->BitsPixel + 15) >> 4) << 1) * Bm16->Height; @@ -2830,7 +2846,7 @@ char *U_WMRBITBLT_set( record = malloc(irecsize); if(record){ U_WMRCORE_SETRECHEAD(record,irecsize,U_WMR_BITBLT); - pmr_px = (PU_WMRBITBLT_PX) record; + pmr_px = (U_WMRBITBLT_PX *) record; memcpy(pmr_px->rop3w, &dwRop3, 4); pmr_px->ySrc = Src.y; pmr_px->xSrc = Src.x; @@ -2848,7 +2864,7 @@ char *U_WMRBITBLT_set( record = malloc(irecsize); if(record){ U_WMRCORE_SETRECHEAD(record,irecsize,U_WMR_BITBLT); - pmr_nopx = (PU_WMRBITBLT_NOPX) record; + pmr_nopx = (U_WMRBITBLT_NOPX *) record; memcpy(pmr_nopx->rop3w, &dwRop3, 4); pmr_nopx->ySrc = Src.y; pmr_nopx->xSrc = Src.x; @@ -2878,13 +2894,13 @@ char *U_WMRSTRETCHBLT_set( U_POINT16 Src, U_POINT16 cSrc, uint32_t dwRop3, - const PU_BITMAP16 Bm16 + const U_BITMAP16 *Bm16 ){ char *record=NULL; uint32_t irecsize; int cbBm16,cbBm164,off; - PU_WMRSTRETCHBLT_PX pmr_px; - PU_WMRSTRETCHBLT_NOPX pmr_nopx; + U_WMRSTRETCHBLT_PX *pmr_px; + U_WMRSTRETCHBLT_NOPX *pmr_nopx; if(Bm16){ cbBm16 = U_SIZE_BITMAP16 + (((Bm16->Width * Bm16->BitsPixel + 15) >> 4) << 1) * Bm16->Height; @@ -2893,7 +2909,7 @@ char *U_WMRSTRETCHBLT_set( record = malloc(irecsize); if(record){ U_WMRCORE_SETRECHEAD(record,irecsize,U_WMR_STRETCHBLT); - pmr_px = (PU_WMRSTRETCHBLT_PX) record; + pmr_px = (U_WMRSTRETCHBLT_PX *) record; memcpy(pmr_px->rop3w, &dwRop3, 4); pmr_px->hSrc = cSrc.y; pmr_px->wSrc = cSrc.x; @@ -2913,7 +2929,7 @@ char *U_WMRSTRETCHBLT_set( record = malloc(irecsize); if(record){ U_WMRCORE_SETRECHEAD(record,irecsize,U_WMR_STRETCHBLT); - pmr_nopx = (PU_WMRSTRETCHBLT_NOPX) record; + pmr_nopx = (U_WMRSTRETCHBLT_NOPX *) record; memcpy(pmr_nopx->rop3w, &dwRop3, 4); pmr_nopx->hSrc = cSrc.y; pmr_nopx->wSrc = cSrc.x; @@ -2935,7 +2951,7 @@ char *U_WMRSTRETCHBLT_set( \param Length Number of points in the Polygon \param Data Array of Length points */ -char *U_WMRPOLYGON_set(uint16_t Length, const PU_POINT16 Data){ +char *U_WMRPOLYGON_set(uint16_t Length, const U_POINT16 *Data){ return U_WMRCORE_2U16_N16_set(U_WMR_POLYGON, NULL, &Length, 2*Length, Data); } @@ -2945,7 +2961,7 @@ char *U_WMRPOLYGON_set(uint16_t Length, const PU_POINT16 Data){ \param Length Number of points in the Polyline \param Data Array of Length points */ -char *U_WMRPOLYLINE_set(uint16_t Length, const PU_POINT16 Data){ +char *U_WMRPOLYLINE_set(uint16_t Length, const U_POINT16 *Data){ return U_WMRCORE_2U16_N16_set(U_WMR_POLYLINE, NULL, &Length, 2*Length, Data); } @@ -3042,8 +3058,9 @@ char *U_WMRSETTEXTALIGN_set(uint16_t Mode){ return U_WMRCORE_2U16_set(U_WMR_SETTEXTALIGN, Mode, 0); } -/* in Wine, not in WMF PDF. */ - char *U_WMRDRAWTEXT_set(void){ /* in Wine, not in WMF PDF. */ +/** in GDI and Wine, not in WMF manual.. +*/ + char *U_WMRDRAWTEXT_set(void){ return U_WMRCORENONE_set("U_WMRDRAWTEXT"); } @@ -3155,7 +3172,7 @@ char *U_WMRREALIZEPALETTE_set(void){ \return pointer to the U_WMRSETPALENTRIES record, or NULL on error. \param Palette Redefines a set of RGB values for the current active Palette. */ -char *U_WMRANIMATEPALETTE_set(PU_PALETTE Palette){ +char *U_WMRANIMATEPALETTE_set(U_PALETTE *Palette){ return U_WMRCORE_PALETTE_set(U_WMR_ANIMATEPALETTE, Palette); } @@ -3164,7 +3181,7 @@ char *U_WMRANIMATEPALETTE_set(PU_PALETTE Palette){ \return pointer to the U_WMRSETPALENTRIES record, or NULL on error. \param Palette Defines a set of RGB values for the current active Palette. */ -char *U_WMRSETPALENTRIES_set(PU_PALETTE Palette){ +char *U_WMRSETPALENTRIES_set(const U_PALETTE *Palette){ return U_WMRCORE_PALETTE_set(U_WMR_SETPALENTRIES, Palette); } @@ -3178,7 +3195,7 @@ char *U_WMRSETPALENTRIES_set(PU_PALETTE Palette){ char *U_WMRPOLYPOLYGON_set( const uint16_t nPolys, const uint16_t *aPolyCounts, - const PU_POINT16 Points + const U_POINT16 *Points ){ char *record; uint32_t irecsize; @@ -3210,6 +3227,7 @@ char *U_WMRRESIZEPALETTE_set(uint16_t Palette){ return U_WMRCORE_1U16_set(U_WMR_RESIZEPALETTE, Palette); } +//! \cond char *U_WMR3A_set(void){ return U_WMRCORENONE_set("U_WMR3A"); } @@ -3233,6 +3251,7 @@ char *U_WMR3E_set(void){ char *U_WMR3F_set(void){ return U_WMRCORENONE_set("U_WMR3F"); } +//! \endcond // U_WMRDIBBITBLT_set /** @@ -3251,15 +3270,15 @@ char *U_WMRDIBBITBLT_set( U_POINT16 cwh, U_POINT16 Src, uint32_t dwRop3, - const PU_BITMAPINFO Bmi, + const U_BITMAPINFO *Bmi, uint32_t cbPx, const char *Px ){ char *record=NULL; uint32_t irecsize; int cbImage,cbImage4,cbBmi,off; - PU_WMRDIBBITBLT_PX pmr_px; - PU_WMRDIBBITBLT_NOPX pmr_nopx; + U_WMRDIBBITBLT_PX *pmr_px; + U_WMRDIBBITBLT_NOPX *pmr_nopx; if(Px && Bmi){ @@ -3268,7 +3287,7 @@ char *U_WMRDIBBITBLT_set( record = malloc(irecsize); if(record){ U_WMRCORE_SETRECHEAD(record,irecsize,U_WMR_DIBBITBLT); - pmr_px = (PU_WMRDIBBITBLT_PX) record; + pmr_px = (U_WMRDIBBITBLT_PX *) record; memcpy(pmr_px->rop3w, &dwRop3, 4); pmr_px->ySrc = Src.y; pmr_px->xSrc = Src.x; @@ -3287,7 +3306,7 @@ char *U_WMRDIBBITBLT_set( record = malloc(irecsize); if(record){ U_WMRCORE_SETRECHEAD(record,irecsize,U_WMR_DIBBITBLT); - pmr_nopx = (PU_WMRDIBBITBLT_NOPX) record; + pmr_nopx = (U_WMRDIBBITBLT_NOPX *) record; memcpy(pmr_nopx->rop3w, &dwRop3, 4); pmr_nopx->ySrc = Src.y; pmr_nopx->xSrc = Src.x; @@ -3319,22 +3338,22 @@ char *U_WMRDIBSTRETCHBLT_set( U_POINT16 Src, U_POINT16 cSrc, uint32_t dwRop3, - const PU_BITMAPINFO Bmi, + const U_BITMAPINFO *Bmi, uint32_t cbPx, const char *Px ){ char *record=NULL; uint32_t irecsize; int cbImage,cbImage4,cbBmi,off; - PU_WMRDIBSTRETCHBLT_PX pmr_px; - PU_WMRDIBSTRETCHBLT_NOPX pmr_nopx; + U_WMRDIBSTRETCHBLT_PX *pmr_px; + U_WMRDIBSTRETCHBLT_NOPX *pmr_nopx; if(Px && Bmi){ SET_CB_FROM_PXBMI(Px,Bmi,cbImage,cbImage4,cbBmi,cbPx); irecsize = U_SIZE_WMRDIBSTRETCHBLT_PX + cbBmi + cbImage4; record = malloc(irecsize); if(record){ U_WMRCORE_SETRECHEAD(record,irecsize,U_WMR_DIBSTRETCHBLT); - pmr_px = (PU_WMRDIBSTRETCHBLT_PX) record; + pmr_px = (U_WMRDIBSTRETCHBLT_PX *) record; memcpy(pmr_px->rop3w, &dwRop3, 4); pmr_px->hSrc = cSrc.y; pmr_px->wSrc = cSrc.x; @@ -3355,7 +3374,7 @@ char *U_WMRDIBSTRETCHBLT_set( record = malloc(irecsize); if(record){ U_WMRCORE_SETRECHEAD(record,irecsize,U_WMR_DIBSTRETCHBLT); - pmr_nopx = (PU_WMRDIBSTRETCHBLT_NOPX) record; + pmr_nopx = (U_WMRDIBSTRETCHBLT_NOPX *) record; memcpy(pmr_nopx->rop3w, &dwRop3, 4); pmr_nopx->hSrc = cSrc.y; pmr_nopx->wSrc = cSrc.x; @@ -3385,10 +3404,10 @@ char *U_WMRDIBSTRETCHBLT_set( char *U_WMRDIBCREATEPATTERNBRUSH_set( const uint16_t Style, const uint16_t iUsage, - PU_BITMAPINFO Bmi, + const U_BITMAPINFO *Bmi, const uint32_t cbPx, const char *Px, - PU_BITMAP16 Bm16 + const U_BITMAP16 *Bm16 ){ char *record=NULL; uint32_t irecsize; @@ -3445,14 +3464,14 @@ char *U_WMRSTRETCHDIB_set( U_POINT16 cSrc, uint16_t cUsage, uint32_t dwRop3, - const PU_BITMAPINFO Bmi, + const U_BITMAPINFO *Bmi, uint32_t cbPx, const char *Px ){ char *record; uint32_t irecsize; int cbImage,cbImage4,cbBmi,off; - PU_WMRSTRETCHDIB pmr; + U_WMRSTRETCHDIB *pmr; SET_CB_FROM_PXBMI(Px,Bmi,cbImage,cbImage4,cbBmi,cbPx); @@ -3460,7 +3479,7 @@ char *U_WMRSTRETCHDIB_set( record = malloc(irecsize); if(record){ U_WMRCORE_SETRECHEAD(record,irecsize,U_WMR_STRETCHDIB); - pmr = (PU_WMRSTRETCHDIB) record; + pmr = (U_WMRSTRETCHDIB *) record; memcpy(pmr->rop3w, &dwRop3, 4); pmr->cUsage = cUsage; pmr->hSrc = cSrc.y; @@ -3481,6 +3500,7 @@ char *U_WMRSTRETCHDIB_set( return(record); } +//! \cond char *U_WMR44_set(void){ return U_WMRCORENONE_set("U_WMR44"); } @@ -3496,6 +3516,7 @@ char *U_WMR46_set(void){ char *U_WMR47_set(void){ return U_WMRCORENONE_set("U_WMR47"); } +//! \endcond /** \brief Create and return a U_WMREXTFLOODFILL record @@ -3514,6 +3535,7 @@ char *U_WMREXTFLOODFILL_set(uint16_t Mode, U_COLORREF Color, U_POINT16 coord){ ); } +//! \cond char *U_WMR49_set(void){ return U_WMRCORENONE_set("U_WMR49"); } @@ -4181,6 +4203,7 @@ char *U_WMREE_set(void){ char *U_WMREF_set(void){ return U_WMRCORENONE_set("U_WMREF"); } +//! \endcond /** \brief Create and return a U_WMRDELETEOBJECT record @@ -4191,6 +4214,7 @@ char *U_WMRDELETEOBJECT_set(uint16_t object){ return U_WMRCORE_1U16_set(U_WMR_DELETEOBJECT, object); } +//! \cond char *U_WMRF1_set(void){ return U_WMRCORENONE_set("U_WMRF1"); } @@ -4214,19 +4238,22 @@ char *U_WMRF5_set(void){ char *U_WMRF6_set(void){ return U_WMRCORENONE_set("U_WMRF6"); } +//! \endcond /** \brief Create and return a U_WMRCREATEPALETTE record \return pointer to the U_WMRCREATEPALETTE record, or NULL on error \param Palette Create a Palette object. */ -char *U_WMRCREATEPALETTE_set(PU_PALETTE Palette){ +char *U_WMRCREATEPALETTE_set(U_PALETTE *Palette){ return U_WMRCORE_PALETTE_set(U_WMR_CREATEPALETTE, Palette); } +//! \cond char *U_WMRF8_set(void){ return U_WMRCORENONE_set("U_WMRF8"); } +//! \endcond /** \brief Allocate and construct a U_WMRCREATEPATTERNBRUSH record. @@ -4236,7 +4263,7 @@ char *U_WMRF8_set(void){ \param Pattern byte array pattern, described by Bm16, for brush */ char *U_WMRCREATEPATTERNBRUSH_set( - PU_BITMAP16 Bm16, + U_BITMAP16 *Bm16, char *Pattern ){ char *record; @@ -4271,7 +4298,7 @@ char *U_WMRCREATEPENINDIRECT_set(U_PEN pen){ \return pointer to the U_WMRCREATEFONTINDIRECT record, or NULL on error. \param font Parameters of the font object to create. */ -char *U_WMRCREATEFONTINDIRECT_set(PU_FONT font){ +char *U_WMRCREATEFONTINDIRECT_set(U_FONT *font){ char *record=NULL; uint32_t irecsize,off,flen; flen = 1 + strlen((char *)font->FaceName); /* include the null terminator in the count */ @@ -4295,12 +4322,14 @@ char *U_WMRCREATEBRUSHINDIRECT_set(U_WLOGBRUSH brush){ return U_WMRCORE_2U16_N16_set(U_WMR_CREATEBRUSHINDIRECT, NULL, NULL, U_SIZE_WLOGBRUSH/2, &brush); } - /* in Wine, not in WMF PDF */ - char *U_WMRCREATEBITMAPINDIRECT_set(void){ +/** in GDI and Wine, not in WMF manual. +*/ +char *U_WMRCREATEBITMAPINDIRECT_set(void){ return U_WMRCORENONE_set("U_WMRCREATEBITMAPINDIRECT"); } - /* in Wine, not in WMF PDF */ +/** in GDI and Wine, not in WMF manual. +*/ char *U_WMRCREATEBITMAP_set(void){ return U_WMRCORENONE_set("U_WMRCREATEBITMAP"); } @@ -4310,7 +4339,7 @@ char *U_WMRCREATEBRUSHINDIRECT_set(U_WLOGBRUSH brush){ \return pointer to the U_WMRCREATEREGION record, or NULL on error. \param region Parameters of the region object to create. */ -char *U_WMRCREATEREGION_set(PU_REGION region){ +char *U_WMRCREATEREGION_set(const U_REGION *region){ char *record=NULL; uint32_t irecsize,off; irecsize = U_SIZE_METARECORD + region->Size; @@ -4391,7 +4420,7 @@ These functions create standard structures used in the WMR records. *********************************************************************************************** */ // hide these from Doxygen -//! @cond +//! \cond /* ********************************************************************************************** These functions contain shared code used by various U_WMR*_get functions. These should NEVER be called by end user code and to further that end prototypes are NOT provided and they are hidden from Doxygen. @@ -4424,7 +4453,7 @@ int U_WMRCORE_1U16_CRF_2U16_get( const char *contents, int minsize, uint16_t *arg1, - PU_COLORREF Color, + U_COLORREF *Color, uint16_t *arg2, uint16_t *arg3 ){ @@ -4442,7 +4471,7 @@ int U_WMRCORE_1U16_CRF_2U16_get( return(size); } -/* records that have a single uint16_t argument like PU_WMRSETMAPMODE +/* records that have a single uint16_t argument like U_WMRSETMAPMODE May also be used with int16_t with appropriate casts */ int U_WMRCORE_1U16_get( const char *contents, @@ -4596,7 +4625,7 @@ int U_WMRCORE_2U16_N16_get( int U_WMRCORE_PALETTE_get( const char *contents, int minsize, - PU_PALETTE Palette, + U_PALETTE *Palette, const char **PalEntries ){ int size = U_WMRCORE_RECSAFE_get(contents, minsize); @@ -4608,14 +4637,14 @@ int U_WMRCORE_PALETTE_get( return(size); } -//! @endcond +//! \endcond /** \brief Return parameters from a bitmapcoreheader. All are returned as 32 bit integers, regardless of their internal representation. \param BmiCh char * pointer to a U_BITMAPCOREHEADER. Note, data may not be properly aligned. - \param Size_4 size of the coreheader in bytes + \param Size size of the coreheader in bytes \param Width; Width of pixel array \param Height; Height of pixel array \param BitCount Pixel Format (BitCount Enumeration) @@ -4731,7 +4760,7 @@ int wget_DIB_params( if(bic == U_BI_RGB){ *numCt = get_real_color_count(dib); if(*numCt){ - *ct = (PU_RGBQUAD) (dib + U_SIZE_BITMAPINFOHEADER); + *ct = (U_RGBQUAD *) (dib + U_SIZE_BITMAPINFOHEADER); *px += U_SIZE_COLORREF * (*numCt); } else { *ct = NULL; } @@ -4767,8 +4796,8 @@ They are listed in order by the corresponding U_WMR_* index number. int wmfheader_get( const char *contents, const char *blimit, - PU_WMRPLACEABLE Placeable, - PU_WMRHEADER Header + U_WMRPLACEABLE *Placeable, + U_WMRHEADER *Header ){ uint32_t Key; int size=0; @@ -4810,7 +4839,7 @@ int U_WMREOF_get( */ int U_WMRSETBKCOLOR_get( const char *contents, - PU_COLORREF Color + U_COLORREF *Color ){ int size = U_WMRCORE_RECSAFE_get(contents, (U_SIZE_WMRSETBKCOLOR)); if(!size)return(0); @@ -4915,7 +4944,7 @@ int U_WMRSETTEXTCHAREXTRA_get( */ int U_WMRSETTEXTCOLOR_get( const char *contents, - PU_COLORREF Color + U_COLORREF *Color ){ int size = U_WMRCORE_RECSAFE_get(contents, (U_SIZE_WMRSETTEXTCOLOR)); if(!size)return(0); @@ -4946,7 +4975,7 @@ int U_WMRSETTEXTJUSTIFICATION_get( */ int U_WMRSETWINDOWORG_get( const char *contents, - PU_POINT16 coord + U_POINT16 * coord ){ return(U_WMRCORE_2U16_get(contents, (U_SIZE_WMRSETWINDOWORG), U_P16(coord->y), U_P16(coord->x))); } @@ -4959,7 +4988,7 @@ int U_WMRSETWINDOWORG_get( */ int U_WMRSETWINDOWEXT_get( const char *contents, - PU_POINT16 extent + U_POINT16 * extent ){ return(U_WMRCORE_2U16_get(contents, (U_SIZE_WMRSETWINDOWEXT), U_P16(extent->y), U_P16(extent->x))); } @@ -4972,7 +5001,7 @@ int U_WMRSETWINDOWEXT_get( */ int U_WMRSETVIEWPORTORG_get( const char *contents, - PU_POINT16 coord + U_POINT16 * coord ){ return(U_WMRCORE_2U16_get(contents, (U_SIZE_WMRSETVIEWPORTORG), U_P16(coord->y), U_P16(coord->x))); @@ -4986,7 +5015,7 @@ int U_WMRSETVIEWPORTORG_get( */ int U_WMRSETVIEWPORTEXT_get( const char *contents, - PU_POINT16 extent + U_POINT16 * extent ){ return(U_WMRCORE_2U16_get(contents, (U_SIZE_WMRSETVIEWPORTEXT), U_P16(extent->y), U_P16(extent->x))); } @@ -4999,7 +5028,7 @@ int U_WMRSETVIEWPORTEXT_get( */ int U_WMROFFSETWINDOWORG_get( const char *contents, - PU_POINT16 offset + U_POINT16 * offset ){ return(U_WMRCORE_2U16_get(contents, (U_SIZE_WMROFFSETWINDOWORG), U_P16(offset->y), U_P16(offset->x))); } @@ -5013,8 +5042,8 @@ int U_WMROFFSETWINDOWORG_get( */ int U_WMRSCALEWINDOWEXT_get( const char *contents, - PU_POINT16 Denom, - PU_POINT16 Num + U_POINT16 * Denom, + U_POINT16 * Num ){ return(U_WMRCORE_4U16_get(contents, (U_SIZE_WMRSCALEWINDOWEXT), U_P16(Denom->y), U_P16(Denom->x), U_P16(Num->y), U_P16(Num->x))); } @@ -5027,7 +5056,7 @@ int U_WMRSCALEWINDOWEXT_get( */ int U_WMROFFSETVIEWPORTORG_get( const char *contents, - PU_POINT16 offset + U_POINT16 * offset ){ return(U_WMRCORE_2U16_get(contents, (U_SIZE_WMROFFSETVIEWPORTORG), U_P16(offset->y), U_P16(offset->x))); } @@ -5041,8 +5070,8 @@ int U_WMROFFSETVIEWPORTORG_get( */ int U_WMRSCALEVIEWPORTEXT_get( const char *contents, - PU_POINT16 Denom, - PU_POINT16 Num + U_POINT16 * Denom, + U_POINT16 * Num ){ return(U_WMRCORE_4U16_get(contents, (U_SIZE_WMRSCALEVIEWPORTEXT), U_P16(Denom->y), U_P16(Denom->x), U_P16(Num->y), U_P16(Num->x))); } @@ -5055,7 +5084,7 @@ int U_WMRSCALEVIEWPORTEXT_get( */ int U_WMRLINETO_get( const char *contents, - PU_POINT16 coord + U_POINT16 * coord ){ return(U_WMRCORE_2U16_get(contents, (U_SIZE_WMRLINETO), U_P16(coord->y), U_P16(coord->x))); } @@ -5068,7 +5097,7 @@ int U_WMRLINETO_get( */ int U_WMRMOVETO_get( const char *contents, - PU_POINT16 coord + U_POINT16 * coord ){ return(U_WMRCORE_2U16_get(contents, (U_SIZE_WMRMOVETO), U_P16(coord->y), U_P16(coord->x))); } @@ -5081,7 +5110,7 @@ int U_WMRMOVETO_get( */ int U_WMREXCLUDECLIPRECT_get( const char *contents, - PU_RECT16 rect + U_RECT16 *rect ){ return(U_WMRCORE_4U16_get(contents, (U_SIZE_WMREXCLUDECLIPRECT), U_P16(rect->bottom), U_P16(rect->right), U_P16(rect->top), U_P16(rect->left))); } @@ -5094,7 +5123,7 @@ int U_WMREXCLUDECLIPRECT_get( */ int U_WMRINTERSECTCLIPRECT_get( const char *contents, - PU_RECT16 rect + U_RECT16 *rect ){ return(U_WMRCORE_4U16_get(contents, (U_SIZE_WMRINTERSECTCLIPRECT), U_P16(rect->bottom), U_P16(rect->right), U_P16(rect->top), U_P16(rect->left))); } @@ -5109,9 +5138,9 @@ int U_WMRINTERSECTCLIPRECT_get( */ int U_WMRARC_get( const char *contents, - PU_POINT16 StartArc, - PU_POINT16 EndArc, - PU_RECT16 rect + U_POINT16 *StartArc, + U_POINT16 *EndArc, + U_RECT16 *rect ){ return U_WMRCORE_8U16_get( contents, @@ -5135,7 +5164,7 @@ int U_WMRARC_get( */ int U_WMRELLIPSE_get( const char *contents, - PU_RECT16 rect + U_RECT16 *rect ){ return U_WMRCORE_4U16_get( contents, @@ -5158,8 +5187,8 @@ int U_WMRELLIPSE_get( int U_WMRFLOODFILL_get( const char *contents, uint16_t *Mode, - PU_COLORREF Color, - PU_POINT16 coord + U_COLORREF *Color, + U_POINT16 *coord ){ return U_WMRCORE_1U16_CRF_2U16_get( contents, @@ -5181,9 +5210,9 @@ int U_WMRFLOODFILL_get( */ int U_WMRPIE_get( const char *contents, - PU_POINT16 Radial1, - PU_POINT16 Radial2, - PU_RECT16 rect + U_POINT16 *Radial1, + U_POINT16 *Radial2, + U_RECT16 *rect ){ return U_WMRCORE_8U16_get( contents, @@ -5207,7 +5236,7 @@ int U_WMRPIE_get( */ int U_WMRRECTANGLE_get( const char *contents, - PU_RECT16 rect + U_RECT16 *rect ){ return U_WMRCORE_4U16_get( contents, @@ -5231,7 +5260,7 @@ int U_WMRROUNDRECT_get( const char *contents, int16_t *Width, int16_t *Height, - PU_RECT16 rect + U_RECT16 *rect ){ return U_WMRCORE_6U16_get( contents, @@ -5255,8 +5284,8 @@ int U_WMRROUNDRECT_get( */ int U_WMRPATBLT_get( const char *contents, - PU_POINT16 Dst, - PU_POINT16 cwh, + U_POINT16 * Dst, + U_POINT16 * cwh, uint32_t *dwRop3 ){ int size = U_WMRCORE_RECSAFE_get(contents, (U_SIZE_WMRPATBLT)); @@ -5280,23 +5309,36 @@ int U_WMRSAVEDC_get( return(U_WMRCORE_RECSAFE_get(contents, (U_SIZE_WMRSAVEDC))); } +/** + \brief Get data from a U_WMRSETPIXEL record + \return length of the U_WMRSETPIXEL record in bytes, or 0 on error + \param contents record to extract data from + \param Color pointer to a U_COLORREF variable where the color will be stored. + \param Coord pointer to a U_POINT16 variable where the coordinates will be stored. +*/ int U_WMRSETPIXEL_get( const char *contents, - PU_COLORREF Color, - PU_POINT16 coord){ + U_COLORREF *Color, + U_POINT16 *Coord){ return U_WMRCORE_1U16_CRF_2U16_get( contents, (U_SIZE_WMRSETPIXEL), NULL, Color, - U_P16(coord->y), - U_P16(coord->x) + U_P16(Coord->y), + U_P16(Coord->x) ); } +/** + \brief Get data from a U_WMROFFSETCLIPRGN record + \return length of the U_WMROFFSETCLIPRGN record in bytes, or 0 on error + \param contents record to extract data from + \param offset pointer to a U_POINT16 variable where the x,y offsets will be stored. +*/ int U_WMROFFSETCLIPRGN_get( const char *contents, - PU_POINT16 offset + U_POINT16 *offset ){ return U_WMRCORE_2U16_get(contents, (U_SIZE_WMROFFSETCLIPRGN), U_P16(offset->y), U_P16(offset->x)); } @@ -5311,7 +5353,7 @@ int U_WMROFFSETCLIPRGN_get( */ int U_WMRTEXTOUT_get( const char *contents, - PU_POINT16 Dst, + U_POINT16 * Dst, int16_t *Length, const char **string ){ @@ -5344,11 +5386,11 @@ int U_WMRTEXTOUT_get( */ int U_WMRBITBLT_get( const char *contents, - PU_POINT16 Dst, - PU_POINT16 cwh, - PU_POINT16 Src, + U_POINT16 * Dst, + U_POINT16 * cwh, + U_POINT16 * Src, uint32_t *dwRop3, - PU_BITMAP16 Bm16, + U_BITMAP16 *Bm16, const char **px ){ uint8_t xb; @@ -5394,12 +5436,12 @@ int U_WMRBITBLT_get( */ int U_WMRSTRETCHBLT_get( const char *contents, - PU_POINT16 Dst, - PU_POINT16 cDst, - PU_POINT16 Src, - PU_POINT16 cSrc, + U_POINT16 * Dst, + U_POINT16 * cDst, + U_POINT16 * Src, + U_POINT16 * cSrc, uint32_t *dwRop3, - PU_BITMAP16 Bm16, + U_BITMAP16 *Bm16, const char **px ){ uint8_t xb; @@ -5601,7 +5643,8 @@ int U_WMRSETTEXTALIGN_get( return U_WMRCORE_1U16_get(contents, (U_SIZE_WMRSETTEXTALIGN), Mode); } -/* in Wine, not in WMF PDF. */ +/** in GDI and Wine, not in WMF manual. +*/ int U_WMRDRAWTEXT_get(void){ /* in Wine, not in WMF PDF. */ return U_WMRCORENONE_get("U_WMRDRAWTEXT"); } @@ -5616,9 +5659,9 @@ int U_WMRDRAWTEXT_get(void){ /* in Wine, not in WMF PDF. */ */ int U_WMRCHORD_get( const char *contents, - PU_POINT16 Radial1, - PU_POINT16 Radial2, - PU_RECT16 rect + U_POINT16 *Radial1, + U_POINT16 *Radial2, + U_RECT16 *rect ){ return U_WMRCORE_8U16_get( contents, @@ -5663,12 +5706,12 @@ int U_WMRSETMAPPERFLAGS_get( */ int U_WMREXTTEXTOUT_get( const char *contents, - PU_POINT16 Dst, + U_POINT16 * Dst, int16_t *Length, uint16_t *Opts, const char **string, const int16_t **dx, - PU_RECT16 rect + U_RECT16 *rect ){ int size = U_WMRCORE_RECSAFE_get(contents, (U_SIZE_WMREXTTEXTOUT)); int off = U_SIZE_METARECORD; @@ -5701,9 +5744,9 @@ int U_WMREXTTEXTOUT_get( */ int U_WMRSETDIBTODEV_get( const char *contents, - PU_POINT16 Dst, - PU_POINT16 cwh, - PU_POINT16 Src, + U_POINT16 * Dst, + U_POINT16 * cwh, + U_POINT16 * Src, uint16_t *cUsage, uint16_t *ScanCount, uint16_t *StartScan, @@ -5757,7 +5800,7 @@ int U_WMRREALIZEPALETTE_get( */ int U_WMRANIMATEPALETTE_get( const char *contents, - PU_PALETTE Palette, + U_PALETTE *Palette, const char **PalEntries ){ return U_WMRCORE_PALETTE_get(contents, (U_SIZE_WMRANIMATEPALETTE), Palette, PalEntries); @@ -5772,7 +5815,7 @@ int U_WMRANIMATEPALETTE_get( */ int U_WMRSETPALENTRIES_get( const char *contents, - PU_PALETTE Palette, + U_PALETTE *Palette, const char **PalEntries ){ return U_WMRCORE_PALETTE_get(contents, (U_SIZE_WMRSETPALENTRIES), Palette, PalEntries); @@ -5814,6 +5857,7 @@ int U_WMRRESIZEPALETTE_get( return U_WMRCORE_1U16_get(contents, (U_SIZE_WMRRESIZEPALETTE), Palette); } +//! \cond int U_WMR3A_get(void){ return U_WMRCORENONE_get("U_WMR3A"); } @@ -5837,6 +5881,7 @@ int U_WMR3E_get(void){ int U_WMR3F_get(void){ return U_WMRCORENONE_get("U_WMR3F"); } +//! \endcond // U_WMRDIBBITBLT_get /** @@ -5851,9 +5896,9 @@ int U_WMR3F_get(void){ */ int U_WMRDIBBITBLT_get( const char *contents, - PU_POINT16 Dst, - PU_POINT16 cwh, - PU_POINT16 Src, + U_POINT16 * Dst, + U_POINT16 * cwh, + U_POINT16 * Src, uint32_t *dwRop3, const char **dib ){ @@ -5897,10 +5942,10 @@ int U_WMRDIBBITBLT_get( */ int U_WMRDIBSTRETCHBLT_get( const char *contents, - PU_POINT16 Dst, - PU_POINT16 cDst, - PU_POINT16 Src, - PU_POINT16 cSrc, + U_POINT16 * Dst, + U_POINT16 * cDst, + U_POINT16 * Src, + U_POINT16 * cSrc, uint32_t *dwRop3, const char **dib ){ @@ -5993,10 +6038,10 @@ int U_WMRDIBCREATEPATTERNBRUSH_get( */ int U_WMRSTRETCHDIB_get( const char *contents, - PU_POINT16 Dst, - PU_POINT16 cDst, - PU_POINT16 Src, - PU_POINT16 cSrc, + U_POINT16 * Dst, + U_POINT16 * cDst, + U_POINT16 * Src, + U_POINT16 * cSrc, uint16_t *cUsage, uint32_t *dwRop3, const char **dib @@ -6018,6 +6063,7 @@ int U_WMRSTRETCHDIB_get( return(size); } +//! \cond int U_WMR44_get(void){ return U_WMRCORENONE_get("U_WMR44"); } @@ -6033,6 +6079,7 @@ int U_WMR46_get(void){ int U_WMR47_get(void){ return U_WMRCORENONE_get("U_WMR47"); } +//! \endcond /** \brief Retrieve values from a U_WMREXTFLOODFILL record @@ -6045,8 +6092,8 @@ int U_WMR47_get(void){ int U_WMREXTFLOODFILL_get( const char *contents, uint16_t *Mode, - PU_COLORREF Color, - PU_POINT16 coord + U_COLORREF *Color, + U_POINT16 * coord ){ return U_WMRCORE_1U16_CRF_2U16_get( contents, @@ -6058,6 +6105,7 @@ int U_WMREXTFLOODFILL_get( ); } +//! \cond int U_WMR49_get(void){ return U_WMRCORENONE_get("U_WMR49"); } @@ -6725,6 +6773,7 @@ int U_WMREE_get(void){ int U_WMREF_get(void){ return U_WMRCORENONE_get("U_WMREF"); } +//! \endcond /** \brief Get data from a U_WMRDELETEOBJECT record. @@ -6739,6 +6788,7 @@ int U_WMRDELETEOBJECT_get( return U_WMRCORE_1U16_get(contents, (U_SIZE_WMRDELETEOBJECT), Object); } +//! \cond int U_WMRF1_get(void){ return U_WMRCORENONE_get("U_WMRF1"); } @@ -6762,6 +6812,7 @@ int U_WMRF5_get(void){ int U_WMRF6_get(void){ return U_WMRCORENONE_get("U_WMRF6"); } +//! \endcond /** \brief Retrieve values from a U_WMRCREATEPALETTE record @@ -6772,15 +6823,17 @@ int U_WMRF6_get(void){ */ int U_WMRCREATEPALETTE_get( const char *contents, - PU_PALETTE Palette, + U_PALETTE *Palette, const char **PalEntries ){ return U_WMRCORE_PALETTE_get(contents, (U_SIZE_WMRCREATEPALETTE), Palette, PalEntries); } +//! \cond int U_WMRF8_get(void){ return U_WMRCORENONE_get("U_WMRF8"); } +//! \endcond /** \brief Get data from a U_WMRCREATEPATTERNBRUSH record. @@ -6793,7 +6846,7 @@ int U_WMRF8_get(void){ */ int U_WMRCREATEPATTERNBRUSH_get( const char *contents, - PU_BITMAP16 Bm16, + U_BITMAP16 *Bm16, int *pasize, const char **Pattern ){ @@ -6816,7 +6869,7 @@ int U_WMRCREATEPATTERNBRUSH_get( */ int U_WMRCREATEPENINDIRECT_get( const char *contents, - PU_PEN pen + U_PEN *pen ){ int size = U_WMRCORE_RECSAFE_get(contents, (U_SIZE_WMRCREATEPENINDIRECT)); if(!size)return(0); @@ -6850,12 +6903,14 @@ int U_WMRCREATEBRUSHINDIRECT_get( return U_WMRCORE_2U16_N16_get(contents, (U_SIZE_WMRCREATEBRUSHINDIRECT), NULL, NULL, brush); } - /* in Wine, not in WMF PDF */ +/** in GDI and Wine, not in WMF manual. +*/ int U_WMRCREATEBITMAPINDIRECT_get(void){ return U_WMRCORENONE_get("U_WMRCREATEBITMAPINDIRECT"); } - /* in Wine, not in WMF PDF */ +/** in GDI and Wine, not in WMF manual. +*/ int U_WMRCREATEBITMAP_get(void){ return U_WMRCORENONE_get("U_WMRCREATEBITMAP"); } diff --git a/src/libuemf/uwmf.h b/src/libuemf/uwmf.h index a97648eb1..65424cad1 100644 --- a/src/libuemf/uwmf.h +++ b/src/libuemf/uwmf.h @@ -1,10 +1,12 @@ /** - @file uwmf.h Structures and functions prototypes for WMF files. + @file uwmf.h + + @brief Structures, definitions, and function prototypes for WMF files. WMF file Record structure information has been derived from Mingw and Wine header files, and from Microsoft's WMF Information pdf, release date July 5,2012, link from here: - http://msdn2.microsoft.com/en-us/library/250370.aspx + http://msdn2.microsoft.com/en-us/library/cc250370.aspx If the direct link fails the document may be found by searching for: "[MS-WMF]: Windows Metafile Format" @@ -62,11 +64,11 @@ extern "C" { // *********************************************************************************** -// Value enumerations and other predefined constants, alphabetical order by group +// Value Enumerations and other predefined constants, alphabetical order by group -/** RecordType Enumeration WMF PDF 2.1.1.1 - \defgroup U_WMR_RecordTypes WMR Record types - @{ +/* RecordType Enumeration WMF manual 2.1.1.1 */ +/** WMF manual 2.1.1.1 + \brief WMR Record types */ enum U_WMR_TYPES{ U_WMR_EOF, //!< 0x0000 U_WMREOF record @@ -326,20 +328,19 @@ enum U_WMR_TYPES{ U_WMR_CREATEBITMAP, //!< 0x06FE U_WMRCREATEBITMAP record U_WMR_CREATEREGION, //!< 0x06FF U_WMRCREATEREGION record }; -/** @} */ #define U_WMR_MIN 0 //!< Minimum U_WMR_ value. #define U_WMR_MAX 255 //!< Maximum U_WMR_ value. #define U_WMR_MASK 0xFF //!< Mask for enumerator (lower) byte -#define U_WMR_INVALID 0xFFFFFFFF //!< Not any valid U_EMF_ valuee +#define U_WMR_INVALID 0xFFFFFFFF //!< Indicates "Not a valid U_WMR_* value" -/** BinaryRasterOperation Enumeration WMF PDF 2.1.1.2 +/** BinaryRasterOperation Enumeration WMF manual 2.1.1.2 - Same as U_EMRSETROP2 in uemf.h + Same as U_EMF_EMRSETROP2 in uemf.h */ -/** BitCount Enumeration WMF PDF 2.1.1.3 - \defgroup AltBitCount_Qualifiers Alternate names for the values under U_BITMAPINFOHEADER_biBitCount_Qualifiers in uemf.h +/** BitCount Enumeration WMF manual 2.1.1.3 + \defgroup U_WMF_AltBitCount_Qualifiers WMF Alternate names for the values under EMF Bitcount Enumeration in uemf.h @{ */ #define BI_BITCOUNT_0 U_BCBM_EXPLICIT //!< Derived from JPG or PNG compressed image or ? @@ -351,26 +352,27 @@ enum U_WMR_TYPES{ #define BI_BITCOUNT_6 U_BCBM_COLOR32 //!< 2^32 colors. bmiColors is not used. Pixels are U_RGBQUAD. /** @} */ -/** BrushStyle Enumeration WMF PDF 2.1.1.4 - Same as "LB_Style Enumeration" in uemf.h +/* BrushStyle Enumeration WMF manual 2.1.1.4 + Same as "EMF LB_Style Enumeration" in uemf.h */ -/** CharacterSet Enumeration WMF PDF 2.1.1.5 - Same as "LF_CharSet Enumeration" in uemf.h +/* CharacterSet Enumeration WMF manual 2.1.1.5 + Same as "EMF LF_CharSet Enumeration" in uemf.h */ -/** ColorUsage Enumeration WMF PDF 2.1.1.6 - Same as "DIBColors Enumeration" in uemf.h, with one addition - \defgroup Extra_iUsageSrc_Qualifiers Extra DIBColors Enumeration +/** ColorUsage Enumeration WMF manual 2.1.1.6 For cUsage fields in various DIB related records. + \defgroup U_WMF_Extra_iUsageSrc_Qualifiers WMF Extra DIBColors Enumeration + WMF is the same as "EMF DIBColors Enumeration" in uemf.h, except it also supports + this one extra value. @{ */ #define U_DIB_PAL_INDICES 2 //!< No color table, pixels are logical palette indices. /** @} */ -/** Compression Enumeration WMF PDF 2.1.1.7 - Same as "BI_Compression Enumeration" in uemf.h with these additions - \defgroup ExtraU_BITMAPINFOHEADER_biCompression_Qualifiers Extra BI_Compression Enumeration, none are implemented +/** Compression Enumeration WMF manual 2.1.1.7 + Same as "EMF BI_Compression Enumeration" in uemf.h with these additions + \defgroup U_WMF_EXTRA_BITMAPINFOHEADER_biCompression_Qualifiers WMF Extra BI_Compression Enumerations, none are implemented @{ */ #define U_BI_CMYK 0x000B //!< CMYK uncompressed @@ -378,49 +380,51 @@ enum U_WMR_TYPES{ #define U_BI_CMYKRLE4 = 0x000D //!< CMYK RLE4 compression /** @} */ -/** FamilyFont enumeration WMF PDF 2.1.1.8 +/* FamilyFont Enumeration WMF manual 2.1.1.8 Only used in a PitchAndFamily object, defined there */ -/** Floodfill enumeration WMF PDF 2.1.1.9 - Same as "FloodFill Enumeration" in uemf.h +/* FloodFill Enumeration WMF manual 2.1.1.9 + Same as "EMF FloodFill Enumeration" in uemf.h */ -/** FontQuality enumeration WMF PDF 2.1.1.10 - Same as "LF_Quality Enumeration" in uemf.h +/* FontQuality Enumeration WMF manual 2.1.1.10 + Same as "EMF LF_Quality Enumeration" in uemf.h */ -/** GamutMappingIntent enumeration WMF PDF 2.1.1.11 - Same as "LCS_Intent Enumeration" in uemf.h +/* GamutMappingIntent Enumeration WMF manual 2.1.1.11 + Same as "EMF LCS_Intent Enumeration" in uemf.h */ -/** HatchStyle enumeration WMF PDF 2.1.1.12 - Same as "HatchStyle Enumeration" in uemf.h +/* HatchStyle Enumeration WMF manual 2.1.1.12 + Same as "EMF HatchStyle Enumeration" in uemf.h */ -/** Layout enumeration WMF PDF 2.1.1.13 - Same as "Mirroring Enumeration" in uemf.h +/* Layout Enumeration WMF manual 2.1.1.13 + Same as "EMF Mirroring Enumeration" in uemf.h */ -/** LogicalColorSpace Enumeration WMF PDF 2.1.1.14 +/** LogicalColorSpace Enumeration WMF manual 2.1.1.14 Not used presently, applies in BitmapV4Header @{ */ -//!< #define U_LCS_CALIBRATED_RGB 0x00000000 calibrated RGB -#define U_LCS_sRGB 0x73524742 //!< ASCII for "sRGB" -#define U_LCS_WINDOWS_COLOR_SPACE 0x57696E20 //!< ASCII for "Win " +/* U_LCS_CALIBRATED_RGB is defined in uemf.h under LCS_CSType Enumeration, WMF manual also defines it, but do not replicate define. +#define U_LCS_CALIBRATED_RGB 0x00000000 //!< calibrated RGB +*/ +#define U_LCS_sRGB 0x73524742 //!< ASCII for "sRGB" +#define U_LCS_WINDOWS_COLOR_SPACE 0x57696E20 //!< ASCII for "Win " /** @} */ -/** LogicalColorSpaceV5 Enumeration WMF PDF 2.1.1.15 - Same as "Profile Enumeration" in uemf.h +/* LogicalColorSpaceV5 Enumeration WMF manual 2.1.1.15 + Same as "EMF Profile Enumeration" in uemf.h */ -/** MapMode Enumeration WMF PDF 2.1.1.16 - Same as "MapMode Enumeration" in uemf.h +/* MapMode Enumeration WMF manual 2.1.1.16 + Same as "EMF MapMode Enumeration" in uemf.h */ -/** MetaFilesEscape Enumeration WMF PDF 2.1.1.17 - \defgroup MFEscape_Qualifiers Metafile Escape record types +/** MetaFilesEscape Enumeration WMF manual 2.1.1.17 + \defgroup U_WMF_MFEscape_Qualifiers WMF Metafile Escape record types For U_WMRESCAPE eFunc field @{ */ @@ -486,14 +490,14 @@ enum U_WMR_TYPES{ #define U_MFE_SPCLPASSTHROUGH2 0x11D8 //!< SPCLPASSTHROUGH2 escape type /** @} */ -/** MetafileType Enumeration WMF PDF 2.1.1.18 +/** MetafileType Enumeration WMF manual 2.1.1.18 @{ */ #define U_MEMORYMETAFILE 0x0001 //!< memory metafile (never used by libUWMF) #define U_DISKMETAFILE 0x0002 //!< disk metafile (always used by libUWMF) /** @} */ -/** MetafileVersion Enumeration WMF PDF 2.1.1.19 +/** MetafileVersion Enumeration WMF manual 2.1.1.19 @{ */ @@ -501,15 +505,15 @@ enum U_WMR_TYPES{ #define U_METAVERSION300 0x0300 //!< DIBs allowed /** @} */ -/** MixMode Enumeration WMF PDF 2.1.1.20 - Same as "BackgroundMode Enumeration" in uemf.h +/* MixMode Enumeration WMF manual 2.1.1.20 + Same as "EMF BackgroundMode Enumeration" in uemf.h */ -/** OutPrecision Enumeration WMF PDF 2.1.1.21 - Same as "LF_OutPrecision Enumeration" in uemf.h +/* OutPrecision Enumeration WMF manual 2.1.1.21 + Same as "EMF LF_OutPrecision Enumeration" in uemf.h */ -/** PaletteEntryFlag Enumeration WMF PDF 2.1.1.22 +/** PaletteEntryFlag Enumeration WMF manual 2.1.1.22 @{ */ #define U_PC_RESERVED 0x01 //!< used for animation @@ -517,8 +521,8 @@ enum U_WMR_TYPES{ #define U_PC_NOCOLLAPSE 0x04 //!< store as new color in palette, do not match to existing color /** @} */ -/** PenStyle Enumeration WMF PDF 2.1.1.23 - Same as "PenStyle Enumeration" in uemf.h +/** PenStyle Enumeration WMF manual 2.1.1.23 + Same as "EMF PenStyle Enumeration" in uemf.h, EXCEPT no values >0xFFFF are used, in particular there is no U_PS_GEOMETRIC (ie, all are U_PS_COSMETIC). Apparently because there is no U_PS_GEOMETRIC, U_PS_JOIN* and U_PS_ENDCAP* are also ignored by XP SP3 Preview (which defaults to a rounded cap) and PowerPoint 2003 (which defaults to square cap). The behavior @@ -526,16 +530,16 @@ enum U_WMR_TYPES{ to be very hit and miss from application to application. */ -/** PitchFont Enumeration WMF PDF 2.1.1.24 +/* PitchFont Enumeration WMF manual 2.1.1.24 These are only used in PitchAndFamily object, defined there. */ -/** PolyFillMode Enumeration WMF PDF 2.1.1.25 - These are the first twp emtries in "PolygonFillMode Enumeration" in uemf.h +/* PolyFillMode Enumeration WMF manual 2.1.1.25 + These are the first two emtries in "EMF PolygonFillMode Enumeration" in uemf.h */ -/** PostScriptCap Enumeration WMF PDF 2.1.1.26 +/** PostScriptCap Enumeration WMF manual 2.1.1.26 These are used in Escape Cap @{ */ @@ -545,13 +549,13 @@ enum U_WMR_TYPES{ #define U_WPS_CAP_SQUARE 2 /** @} */ -/** PostScriptClipping Enumeration WMF PDF 2.1.1.27 - PostFeatureSetting Enumeration WMF PDF 2.1.1.28 +/* PostScriptClipping Enumeration WMF manual 2.1.1.27 + PostFeatureSetting Enumeration WMF manual 2.1.1.28 These are used by postscript drivers, not supported by libUWEMF. */ -/** PostScrioptJoin Enumeration WMF PDF 2.1.1.29 +/** PostScrioptJoin Enumeration WMF manual 2.1.1.29 These are used in Escape Cap @{ */ @@ -561,170 +565,182 @@ enum U_WMR_TYPES{ #define U_WPS_JOIN_BEVEL 2 /** @} */ -/** StretchMode Enumeration WMF PDF 2.1.1.30 - Same as "StretchMode Enumeration" in uemf.h +/* StretchMode Enumeration WMF manual 2.1.1.30 + Same as "EMF StretchMode Enumeration" in uemf.h */ -/** TernaryRasterOperation Enumeration WMF PDF 2.1.1.31 - Same as "Ternary Raster Operation Enumeration" in uemf.h +/* TernaryRasterOperation Enumeration WMF manual 2.1.1.31 + Same as "EMF Ternary Raster Operation Enumeration" in uemf.h Only partially supported in libUWMF.h */ -/** ClipPrecision Flags WMF PDF 2.1.2.1 - Same as "LF_ClipPrecision Enumeration" in uemf.h +/* ClipPrecision Flags WMF manual 2.1.2.1 + Same as "EMF LF_ClipPrecision Enumeration" in uemf.h */ -/** ExtTextOutOptions Flags WMF PDF 2.1.2.2 - These are a subset of "ExtTextOutOptions Enumeration" in uemf.h +/* ExtTextOutOptions Flags WMF manual 2.1.2.2 + These are a subset of "EMF ExtTextOutOptions Enumeration" in uemf.h + Not defined for WMF: U_ETO_NONE, U_ETO_GRAYED, U_ETO_NORECT, U_ETO_SMALL_CHARS,U_ETO_IGNORELANGUAGE,U_ETO_REVERSE_INDEX_MAP + Defined for WMF: U_ETO_OPAQUE, U_ETO_CLIPPED, U_ETO_GLYPH_INDEX, U_ETO_RTLREADING,_ETO_NUMERICSLOCAL,U_ETO_NUMERICSLATIN, U_ETO_PDY */ -/** TextAlignment Enumeration WMF PDF 2.1.2.3 - VertialTextAlignment Enumeration WMF PDF 2.1.2.4 - These are both in "TextAlignment Enumeration" in uemf.h +/* TextAlignment Enumeration WMF manual 2.1.2.3 + VertialTextAlignment Enumeration WMF manual 2.1.2.4 + These are both in "EMF TextAlignment Enumeration" in uemf.h */ // *************************************************************************** // Miscellaneous Values -/** TextAlignmentMode Flags WMF PDF 2.1.2.3 - VerticalTextAlignmentMode Flags WMF PDF 2.1.2.4 - Same as "TextAlignment Enumeration" in uemf.h +/* TextAlignmentMode Flags WMF manual 2.1.2.3 + VerticalTextAlignmentMode Flags WMF manual 2.1.2.4 + Same as "EMF TextAlignment Enumeration" in uemf.h */ -/** \defgroup MinimumRecord_sizes Size in bytes of core record of each type. - These are USUALLY not the same - as the corresponding struct, so in general it is unsafe to use sizeof() with this code. +/** \defgroup U_WMF_MinimumRecord_sizes WMF Size in bytes of core record types. + + The size of the object/record is USUALLY not the same + as the sizeof() of the corresponding struct, so in general it is unsafe to use sizeof() with this code. + Always use the U_SIZE_x instead!!!! - Note that some records may actually be much, much longer than their minimum as they include strings, + + Note that some records may actually be much, much longer than their minimum size as they include strings, bitmaps, and such. + + Documentation for each value is: + + = same as struct size + or + X = different from struct size + followed by + Number (sizeof(struct) == size of the struct in bytes.) + @{ */ -/* Record sizeof (+ same, X differs) */ -#define U_SIZE_PAIRF 8 /* + 8 this might be different on 64 bit platform */ -#define U_SIZE_COLORREF 4 /* + 4 */ -#define U_SIZE_BRUSH 8 /* + 8 */ -#define U_SIZE_FONT 19 /* + 20 */ -#define U_SIZE_FONT_CORE 18 /* Minus the FaceName part */ -#define U_SIZE_PLTNTRY 4 /* + 4 */ -#define U_SIZE_PALETTE 8 /* + 8 */ -#define U_SIZE_PEN 10 /* + 10 */ -#define U_SIZE_POINT16 4 /* + 4 */ -#define U_SIZE_RECT16 8 /* + 8 */ -#define U_SIZE_REGION 20 /* X 22 20 is minums the variable part */ -#define U_SIZE_BITMAP16 10 /* + 10 */ -#define U_SIZE_BITMAPCOREHEADER 12 /* + 12 */ -#define U_SIZE_BITMAPINFOHEADER 40 /* + 40 */ -#define U_SIZE_BITMAPV4HEADER 108 /* ? 108 not tested */ -#define U_SIZE_BITMAPV5HEADER 124 /* ? 124 not tested */ -#define U_SIZE_WLOGBRUSH 8 /* + 8 */ -#define U_SIZE_POLYPOLYGON 4 /* + 4 */ -#define U_SIZE_SCAN 8 /* + 8 */ -#define U_SIZE_METARECORD 6 /* X 8 */ -#define U_SIZE_WMRPLACEABLE 22 /* X 24 */ -#define U_SIZE_WMRHEADER 18 /* X 20 */ -#define U_SIZE_WMREOF 6 /* X 8 */ -#define U_SIZE_WMRSETRELABS 6 /* X 8 */ -#define U_SIZE_WMRSAVEDC 6 /* X 8 */ -#define U_SIZE_WMRRESTOREDC 8 /* * 8 */ -#define U_SIZE_WMRREALIZEPALETTE 6 /* X 8 */ -#define U_SIZE_WMRSETBKCOLOR 10 /* X 12 */ -#define U_SIZE_WMRSETTEXTCOLOR 10 /* X 12 */ -#define U_SIZE_WMRSETBKMODE 8 /* X 12 last 2 bytes are optional */ -#define U_SIZE_WMRSETROP2 8 /* X 12 last 2 bytes are optional */ -#define U_SIZE_WMRSETPOLYFILLMODE 8 /* X 12 last 2 bytes are optional */ -#define U_SIZE_WMRSETSTRETCHBLTMODE 8 /* X 12 last 2 bytes are optional */ -#define U_SIZE_WMRSETTEXTALIGN 8 /* X 12 last 2 bytes are optional */ -#define U_SIZE_WMRSETMAPMODE 8 /* + 8 */ -#define U_SIZE_WMRSETTEXTCHAREXTRA 8 /* + 8 */ -#define U_SIZE_WMRSETTEXTJUSTIFICATION 10 /* X 12 */ -#define U_SIZE_WMRSETWINDOWORG 10 /* X 12 */ -#define U_SIZE_WMRSETWINDOWEXT 10 /* X 12 */ -#define U_SIZE_WMRSETVIEWPORTORG 10 /* X 12 */ -#define U_SIZE_WMRSETVIEWPORTEXT 10 /* X 12 */ -#define U_SIZE_WMROFFSETWINDOWORG 10 /* X 12 */ -#define U_SIZE_WMROFFSETVIEWPORTORG 10 /* X 12 */ -#define U_SIZE_WMRLINETO 10 /* X 12 */ -#define U_SIZE_WMRMOVETO 10 /* X 12 */ -#define U_SIZE_WMROFFSETCLIPRGN 10 /* X 12 */ -#define U_SIZE_WMRSCALEWINDOWEXT 14 /* X 16 */ -#define U_SIZE_WMRSCALEVIEWPORTEXT 14 /* X 16 */ -#define U_SIZE_WMREXCLUDECLIPRECT 14 /* X 16 */ -#define U_SIZE_WMRINTERSECTCLIPRECT 14 /* X 16 */ -#define U_SIZE_WMRARC 22 /* X 24 */ -#define U_SIZE_WMRELLIPSE 14 /* X 16 */ -#define U_SIZE_WMRRECTANGLE 14 /* X 16 */ -#define U_SIZE_WMRFLOODFILL 16 /* + 16 */ -#define U_SIZE_WMREXTFLOODFILL 16 /* + 16 */ -#define U_SIZE_WMRSETPIXEL 14 /* X 16 */ -#define U_SIZE_WMRPIE 22 /* X 24 */ -#define U_SIZE_WMRCHORD 22 /* X 24 */ -#define U_SIZE_WMRROUNDRECT 18 /* X 20 */ -#define U_SIZE_WMRPATBLT 18 /* X 20 */ -#define U_SIZE_WMRTEXTOUT 8 /* X 12 (not including String,y,x) */ -#define U_SIZE_WMRBITBLT_NOPX 24 /* + 24 */ -#define U_SIZE_WMRBITBLT_PX 22 /* X 32 */ -#define U_SIZE_WMRSTRETCHBLT_NOPX 28 /* + 28 */ -#define U_SIZE_WMRSTRETCHBLT_PX 26 /* X 36 */ -#define U_SIZE_WMRPOLYGON 10 /* X 12 */ -#define U_SIZE_WMRPOLYLINE 10 /* X 12 */ -#define U_SIZE_WMRESCAPE 10 /* X 12 Data field could be completely absent */ -#define U_SIZE_WMRFILLREGION 10 /* X 12 */ -#define U_SIZE_WMRFRAMEREGION 14 /* X 16 */ -#define U_SIZE_WMRINVERTREGION 8 /* + 8 */ -#define U_SIZE_WMRPAINTREGION 8 /* + 8 */ -#define U_SIZE_WMRSELECTCLIPREGION 8 /* + 8 */ -#define U_SIZE_WMRSELECTOBJECT 8 /* + 8 */ -#define U_SIZE_WMRSELECTPALETTE 8 /* + 8 */ -#define U_SIZE_WMRRESIZEPALETTE 8 /* + 8 */ -#define U_SIZE_WMRDELETEOBJECT 8 /* + 8 */ -#define U_SIZE_WMRDRAWTEXT 6 /* X 8 */ -#define U_SIZE_WMRCREATEBITMAPINDIRECT 6 /* X 8 */ -#define U_SIZE_WMRCREATEBITMAP 6 /* X 8 */ -#define U_SIZE_WMRSETMAPPERFLAGS 10 /* X 12 */ -#define U_SIZE_WMREXTTEXTOUT 14 /* X 16 */ -#define U_SIZE_WMRSETDIBTODEV 22 /* X 28 */ -#define U_SIZE_WMRANIMATEPALETTE 14 /* X 16 */ -#define U_SIZE_WMRSETPALENTRIES 14 /* X 16 */ -#define U_SIZE_WMRCREATEPALETTE 14 /* X 16 */ -#define U_SIZE_WMRPOLYPOLYGON 10 /* X 12 */ -#define U_SIZE_WMRDIBBITBLT_NOPX 24 /* + 24 */ -#define U_SIZE_WMRDIBBITBLT_PX 22 /* X 24 */ -#define U_SIZE_WMRDIBSTRETCHBLT_NOPX 28 /* + 28 */ -#define U_SIZE_WMRDIBSTRETCHBLT_PX 26 /* X 28 */ -#define U_SIZE_WMRDIBCREATEPATTERNBRUSH 10 /* X 12 */ -#define U_SIZE_WMRSTRETCHDIB 28 /* X 32 */ -#define U_SIZE_WMRCREATEPATTERNBRUSH 6 /* X 8 */ -#define U_SIZE_WMRCREATEPENINDIRECT 16 /* + 16 */ -#define U_SIZE_WMRCREATEFONTINDIRECT 26 /* X 28 */ -#define U_SIZE_WMRCREATEBRUSHINDIRECT 14 /* X 16 */ -#define U_SIZE_WMRCREATEREGION 26 /* X 28 */ +#define U_SIZE_PAIRF 8 /**< + 8 this might be different on 64 bit platform */ +#define U_SIZE_COLORREF 4 /**< + 4 */ +#define U_SIZE_BRUSH 8 /**< + 8 */ +#define U_SIZE_FONT 19 /**< X 20 */ +#define U_SIZE_FONT_CORE 18 /**< X 20 Like U_FONT, but minus the FaceName part */ +#define U_SIZE_PLTNTRY 4 /**< + 4 */ +#define U_SIZE_PALETTE 8 /**< + 8 */ +#define U_SIZE_PEN 10 /**< + 10 */ +#define U_SIZE_POINT16 4 /**< + 4 */ +#define U_SIZE_RECT16 8 /**< + 8 */ +#define U_SIZE_REGION 20 /**< X 22 20 is minums the variable part */ +#define U_SIZE_BITMAP16 10 /**< + 10 */ +#define U_SIZE_BITMAPCOREHEADER 12 /**< + 12 */ +#define U_SIZE_BITMAPINFOHEADER 40 /**< + 40 */ +#define U_SIZE_BITMAPV4HEADER 108 /**< ? 108 not tested */ +#define U_SIZE_BITMAPV5HEADER 124 /**< ? 124 not tested */ +#define U_SIZE_WLOGBRUSH 8 /**< + 8 */ +#define U_SIZE_POLYPOLYGON 4 /**< + 4 */ +#define U_SIZE_SCAN 8 /**< + 8 */ +#define U_SIZE_METARECORD 6 /**< X 8 */ +#define U_SIZE_WMRPLACEABLE 22 /**< X 24 */ +#define U_SIZE_WMRHEADER 18 /**< X 20 */ +#define U_SIZE_WMREOF 6 /**< X 8 */ +#define U_SIZE_WMRSETRELABS 6 /**< X 8 */ +#define U_SIZE_WMRSAVEDC 6 /**< X 8 */ +#define U_SIZE_WMRRESTOREDC 8 /**< * 8 */ +#define U_SIZE_WMRREALIZEPALETTE 6 /**< X 8 */ +#define U_SIZE_WMRSETBKCOLOR 10 /**< X 12 */ +#define U_SIZE_WMRSETTEXTCOLOR 10 /**< X 12 */ +#define U_SIZE_WMRSETBKMODE 8 /**< X 12 last 2 bytes are optional */ +#define U_SIZE_WMRSETROP2 8 /**< X 12 last 2 bytes are optional */ +#define U_SIZE_WMRSETPOLYFILLMODE 8 /**< X 12 last 2 bytes are optional */ +#define U_SIZE_WMRSETSTRETCHBLTMODE 8 /**< X 12 last 2 bytes are optional */ +#define U_SIZE_WMRSETTEXTALIGN 8 /**< X 12 last 2 bytes are optional */ +#define U_SIZE_WMRSETMAPMODE 8 /**< + 8 */ +#define U_SIZE_WMRSETTEXTCHAREXTRA 8 /**< + 8 */ +#define U_SIZE_WMRSETTEXTJUSTIFICATION 10 /**< X 12 */ +#define U_SIZE_WMRSETWINDOWORG 10 /**< X 12 */ +#define U_SIZE_WMRSETWINDOWEXT 10 /**< X 12 */ +#define U_SIZE_WMRSETVIEWPORTORG 10 /**< X 12 */ +#define U_SIZE_WMRSETVIEWPORTEXT 10 /**< X 12 */ +#define U_SIZE_WMROFFSETWINDOWORG 10 /**< X 12 */ +#define U_SIZE_WMROFFSETVIEWPORTORG 10 /**< X 12 */ +#define U_SIZE_WMRLINETO 10 /**< X 12 */ +#define U_SIZE_WMRMOVETO 10 /**< X 12 */ +#define U_SIZE_WMROFFSETCLIPRGN 10 /**< X 12 */ +#define U_SIZE_WMRSCALEWINDOWEXT 14 /**< X 16 */ +#define U_SIZE_WMRSCALEVIEWPORTEXT 14 /**< X 16 */ +#define U_SIZE_WMREXCLUDECLIPRECT 14 /**< X 16 */ +#define U_SIZE_WMRINTERSECTCLIPRECT 14 /**< X 16 */ +#define U_SIZE_WMRARC 22 /**< X 24 */ +#define U_SIZE_WMRELLIPSE 14 /**< X 16 */ +#define U_SIZE_WMRRECTANGLE 14 /**< X 16 */ +#define U_SIZE_WMRFLOODFILL 16 /**< + 16 */ +#define U_SIZE_WMREXTFLOODFILL 16 /**< + 16 */ +#define U_SIZE_WMRSETPIXEL 14 /**< X 16 */ +#define U_SIZE_WMRPIE 22 /**< X 24 */ +#define U_SIZE_WMRCHORD 22 /**< X 24 */ +#define U_SIZE_WMRROUNDRECT 18 /**< X 20 */ +#define U_SIZE_WMRPATBLT 18 /**< X 20 */ +#define U_SIZE_WMRTEXTOUT 8 /**< X 12 (not including String,y,x) */ +#define U_SIZE_WMRBITBLT_NOPX 24 /**< + 24 */ +#define U_SIZE_WMRBITBLT_PX 22 /**< X 32 */ +#define U_SIZE_WMRSTRETCHBLT_NOPX 28 /**< + 28 */ +#define U_SIZE_WMRSTRETCHBLT_PX 26 /**< X 36 */ +#define U_SIZE_WMRPOLYGON 10 /**< X 12 */ +#define U_SIZE_WMRPOLYLINE 10 /**< X 12 */ +#define U_SIZE_WMRESCAPE 10 /**< X 12 Data field could be completely absent */ +#define U_SIZE_WMRFILLREGION 10 /**< X 12 */ +#define U_SIZE_WMRFRAMEREGION 14 /**< X 16 */ +#define U_SIZE_WMRINVERTREGION 8 /**< + 8 */ +#define U_SIZE_WMRPAINTREGION 8 /**< + 8 */ +#define U_SIZE_WMRSELECTCLIPREGION 8 /**< + 8 */ +#define U_SIZE_WMRSELECTOBJECT 8 /**< + 8 */ +#define U_SIZE_WMRSELECTPALETTE 8 /**< + 8 */ +#define U_SIZE_WMRRESIZEPALETTE 8 /**< + 8 */ +#define U_SIZE_WMRDELETEOBJECT 8 /**< + 8 */ +#define U_SIZE_WMRDRAWTEXT 6 /**< X 8 */ +#define U_SIZE_WMRCREATEBITMAPINDIRECT 6 /**< X 8 */ +#define U_SIZE_WMRCREATEBITMAP 6 /**< X 8 */ +#define U_SIZE_WMRSETMAPPERFLAGS 10 /**< X 12 */ +#define U_SIZE_WMREXTTEXTOUT 14 /**< X 16 */ +#define U_SIZE_WMRSETDIBTODEV 22 /**< X 28 */ +#define U_SIZE_WMRANIMATEPALETTE 14 /**< X 16 */ +#define U_SIZE_WMRSETPALENTRIES 14 /**< X 16 */ +#define U_SIZE_WMRCREATEPALETTE 14 /**< X 16 */ +#define U_SIZE_WMRPOLYPOLYGON 10 /**< X 12 */ +#define U_SIZE_WMRDIBBITBLT_NOPX 24 /**< + 24 */ +#define U_SIZE_WMRDIBBITBLT_PX 22 /**< X 24 */ +#define U_SIZE_WMRDIBSTRETCHBLT_NOPX 28 /**< + 28 */ +#define U_SIZE_WMRDIBSTRETCHBLT_PX 26 /**< X 28 */ +#define U_SIZE_WMRDIBCREATEPATTERNBRUSH 10 /**< X 12 */ +#define U_SIZE_WMRSTRETCHDIB 28 /**< X 32 */ +#define U_SIZE_WMRCREATEPATTERNBRUSH 6 /**< X 8 */ +#define U_SIZE_WMRCREATEPENINDIRECT 16 /**< + 16 */ +#define U_SIZE_WMRCREATEFONTINDIRECT 26 /**< X 28 */ +#define U_SIZE_WMRCREATEBRUSHINDIRECT 14 /**< X 16 */ +#define U_SIZE_WMRCREATEREGION 26 /**< X 28 */ /** @} */ // *************************************************************************** // Macros -/** \defgroup Common_macros Common Macros +/** \defgroup U_WMF_Common_macros WMF Common Macros +Because Size16_4 may not be aligned no tests should dereference it directly from a pointer. +in NOPX tests cast causes uint8_t to promote to uint32_t, without it c++ compiler complains about +comparison of int with unsigned int @{ */ -/* Because Size16_4 may not be aligned no tests should dereference it directly from a pointer. -in NOPX tests cast causes uint8_t to promote to uint32_t, without it c++ compiler complains about -comparison of int with unsigned int */ -#define U_TEST_NOPX2(A,B) (A == (uint32_t) (B + 3)) /* A is Size16_4 (extracted and aligned), B = xb true if no bitmap associated with the structure, used with some BLT records*/ -#define U_TEST_NOPXB(A,B) (A/2 == (uint32_t) (B + 3)) /* A is Size16_4(extracted and aligned)*2, B - xb, true if no bitmap associated with the structure, used with some BLT records*/ -#define U_WMRTYPE(A) (((PU_METARECORD)A)->iType) //!< Get iType from U_WMR* record -#define U_WMRXB(A) (((PU_METARECORD)A)->xb) //!< Get xb from U_WMR* record -#define U_WMR_XB_FROM_TYPE(A) ((uint8_t) (U_wmr_values(A)>>8)) //!< Get xb from type value -#define U_U16(A) (*(uint16_t *)&A) /* interpret a 16 bit type as uint16_t */ -#define U_P16(A) ( (uint16_t *)&A) /* pass any 16 bit type as a pointer to a uint16_t */ -#define U_PP16(A) ( (uint16_t *) A) /* pass any pointer to a 16 bit type as a pointer to a uint16_t */ +#define U_TEST_NOPX2(A,B) (A == (uint32_t) (B + 3)) //!< A is Size16_4 (extracted and aligned), B = xb true if no bitmap associated with the structure, used with some BLT records. +#define U_TEST_NOPXB(A,B) (A/2 == (uint32_t) (B + 3)) //!< A is Size16_4 (extracted and aligned)*2, B = xb, true if no bitmap associated with the structure, used with some BLT records. +#define U_WMRTYPE(A) (((U_METARECORD *)A)->iType) //!< Get iType from U_WMR* record. +#define U_WMRXB(A) (((U_METARECORD *)A)->xb) //!< Get xb from U_WMR* record. +#define U_WMR_XB_FROM_TYPE(A) ((uint8_t) (U_wmr_values(A)>>8)) //!< Get xb from type value. +#define U_U16(A) (*(uint16_t *)&A) //!< interpret a 16 bit type as uint16_t. +#define U_P16(A) ( (uint16_t *)&A) //!< pass any 16 bit type as a pointer to a uint16_t. +#define U_PP16(A) ( (uint16_t *) A) //!< pass any pointer to a 16 bit type as a pointer to a uint16_t. /** @} */ @@ -732,28 +748,27 @@ comparison of int with unsigned int */ WMF structures OTHER than those corresponding to complete U_WMR_* records ************************************************************ */ -/** Brush Object WMF PDF 2.2.1.1 +/** Brush Object WMF manual 2.2.1.1 Documentation is muddy, bColor and bHatch fields have different meanings depending on the value of bStyle. Unclear if bHatch bytes are present in some cases from the documentation. - style Color Data - U_BS_SOLID ColorRef Object Not used (bytes present???) - U_BS_NULL ignored ignored (bytes present???). - U_BS_PATTERN ignored Bitmap16 object holding patern - U_BS_DIBPATTERNPT ColorUsage Enum DIB object - U_BS_HATCHED ColorRef Object HatchStyle Enumeration + style Color Data + U_BS_SOLID ColorRef Object Not used (bytes present???) + U_BS_NULL ignored ignored (bytes present???). + U_BS_PATTERN ignored Bitmap16 object holding patern + U_BS_DIBPATTERNPT ColorUsage Enum DIB object + U_BS_HATCHED ColorRef Object HatchStyle Enumeration */ - typedef struct { - uint16_t Style; //!< BrushStyle enumeration + uint16_t Style; //!< BrushStyle Enumeration U_COLORREF Color; //!< Brush Color value, 32 bit value is not aligned. uint8_t Data[1]; //!< Brush pattern information, variable size and format -} U_BRUSH, *PU_BRUSH; +} U_BRUSH; -/** Font Object WMF PDF 2.2.1.2 +/** Font Object WMF manual 2.2.1.2 Warning, only pass by pointer, passing by value will will truncate in Facename! */ typedef struct { @@ -771,9 +786,9 @@ typedef struct { uint8_t Quality; //!< LF_Quality Enumeration uint8_t PitchAndFamily; //!< LF_PitchAndFamily Enumeration uint8_t FaceName[1]; //!< Name of font. ANSI Latin1, null terminated. -} U_FONT, *PU_FONT; +} U_FONT; -/** PaletteEntry Object WMF PDF 2.2.2.13 +/** PaletteEntry Object WMF manual 2.2.2.13 Note, NOT compatiable with U_LOGPLTNTRY Out of PDF order because needed for next struture. */ @@ -782,10 +797,10 @@ typedef struct { uint8_t Blue; //!< Palette entry Blue Intensity uint8_t Green; //!< Palette entry Green Intensity uint8_t Red; //!< Palette entry Red Intensity -} U_PLTNTRY, *PU_PLTNTRY; +} U_PLTNTRY; -/** Palette Object WMF PDF 2.2.1.3 - NOT same as "LogPalette Object" in uemf.h because Palette Entries have reversed colors. +/** Palette Object WMF manual 2.2.1.3 + NOT Same as "EMF LogPalette Object" in uemf.h because Palette Entries have reversed colors. Values for palVersion are expanded Start must be 0x0300 (as for EMF) with U_WMRCREATEPALETTE but is an offset @@ -795,17 +810,17 @@ typedef struct { uint16_t Start; //!< Either 0x0300 or an offset into the Palette table uint16_t NumEntries; //!< Number of U_LOGPLTNTRY objects U_PLTNTRY PalEntries[1]; //!< Array of PaletteEntry Objects -} U_PALETTE, *PU_PALETTE; +} U_PALETTE; -/** Pen Object WMF PDF 2.2.1.4 +/** Pen Object WMF manual 2.2.1.4 */ typedef struct { uint16_t Style; //!< PenStyle Enumeration uint16_t Widthw[2]; //!< reassemble/store the Pen Width in object dimensions using Widthw, the 32 bit value is not aligned U_COLORREF Color; //!< Pen Color, the 32 bit value is not aligned. -} U_PEN, *PU_PEN; +} U_PEN; -/** Rect Object WMF PDF 2.2.2.18 +/** Rect Object WMF manual 2.2.2.18 \brief Coordinates of the upper left, lower right corner. Note that the coordinate system is 0,0 in the upper left corner of the screen an N,M in the lower right corner. @@ -818,11 +833,11 @@ typedef struct { int16_t top; //!< top coordinate int16_t right; //!< right coordinate int16_t bottom; //!< bottom coordinate -} U_RECT16, *PU_RECT16; +} U_RECT16; #define U_RCL16_DEF (U_RECT16){0,0,-1,-1} //!< Use this when no bounds are needed. -/** Region Object WMF PDF 2.2.1.5 +/** Region Object WMF manual 2.2.1.5 */ typedef struct { uint16_t ignore1; //!< unused value @@ -833,13 +848,13 @@ typedef struct { int16_t sMax; //!< largest number of points in any scan U_RECT16 sRect; //!< bounding rectangle uint16_t aScans[1]; //!< series of appended U_SCAN objects -} U_REGION, *PU_REGION; +} U_REGION; -/** Bitmap16 Object WMF PDF 2.2.2.1 +/** Bitmap16 Object WMF manual 2.2.2.1 - The U_BITMAP16 core is always followed by - uint8_t Bits[1]; //!< bitmap pixel data. Bytes contained = (((Width * BitsPixel + 15) >> 4) << 1) * Height - Note that in U_WMRCREATEPATTERNBRUSH Bits is always [4]. + The U_BITMAP16 core is always followed by + uint8_t Bits[1]; //!< bitmap pixel data. Bytes contained = (((Width * BitsPixel + 15) >> 4) << 1) * Height + Note that in U_WMRCREATEPATTERNBRUSH Bits is always [4]. */ typedef struct { @@ -849,9 +864,9 @@ typedef struct { int16_t WidthBytes; //!< bytes per scan line. uint8_t Planes; //!< must be 1. uint8_t BitsPixel; //!< number of adjacent color bits on each plane (R bits + G bits + B bits ????) -} U_BITMAP16, *PU_BITMAP16; +} U_BITMAP16; -/** BitmapCoreHeader Object WMF PDF 2.2.2.2 +/** BitmapCoreHeader Object WMF manual 2.2.2.2 */ typedef struct { uint16_t Size_4[2]; //!< size of U_BITMAPCOREHEADER in bytes. @@ -859,15 +874,16 @@ typedef struct { uint16_t Height; //!< DIB height in pixels. uint16_t Planes; //!< must be 1 uint16_t BitCount; //!< Pixel Format (BitCount Enumeration) -} U_BITMAPCOREHEADER, *PU_BITMAPCOREHEADER; +} U_BITMAPCOREHEADER; -/** BitmapInfoHeader Object WMF PDF 2.2.2.3 - same as "BITMAPINFOHEADER Object" in uemf.h +/** BitmapInfoHeader Object WMF manual 2.2.2.3 + Same as "EMF BITMAPINFOHEADER Object" in uemf.h use U_BITMAPINFOHEADER */ -/** BitmapV4Header Object WMF PDF 2.2.2.4 +//! \cond +/** BitmapV4Header Object WMF manual 2.2.2.4 */ typedef struct { uint32_t bV4Size; @@ -890,10 +906,10 @@ typedef struct { uint32_t bV4GammaRed; uint32_t bV4GammaGreen; uint32_t bV4GammaBlue; -} U_BITMAPV4HEADER, *PU_BITMAPV4HEADER; //!< For ? +} U_BITMAPV4HEADER; //!< For ? -/** BitmapV5Header Object WMF PDF 2.2.2.5 +/** BitmapV5Header Object WMF manual 2.2.2.5 */ typedef struct { uint32_t bV5Size; @@ -920,129 +936,138 @@ typedef struct { uint32_t bV5ProfileData; uint32_t bV5ProfileSize; uint32_t bV5Reserved; -} U_BITMAPV5HEADER, *PU_BITMAPV5HEADER; //!< For ? +} U_BITMAPV5HEADER; //!< For ? +//! \endcond -/** CIEXYZ Object WMF PDF 2.2.2.6 - Same as "CIEXYZ Object" in uemf.h +/** CIEXYZ Object WMF manual 2.2.2.6 + Same as "EMF CIEXYZ Object" in uemf.h */ -/** CIEXYZTriple Object WMF PDF 2.2.2.7 - Same as "CIEXYZTRIPLE Object" in uemf.h +/** CIEXYZTriple Object WMF manual 2.2.2.7 + Same as "EMF CIEXYZTRIPLE Object" in uemf.h */ -/** ColorRef Object WMF PDF 2.2.2.8 - Same as "COLORREF Object" in uemf.h +/** ColorRef Object WMF manual 2.2.2.8 + Same as "EMF COLORREF Object" in uemf.h */ -/** DeviceIndependentBitmap Object WMF PDF 2.2.2.9 +/** DeviceIndependentBitmap Object WMF manual 2.2.2.9 This "object" has an organization, but not one that can be easily expressed with a C struct. It consists of three parts, all of which have variable size: - DIBHeaderInfo BitmapCoreHeader or BitmapInfoHeader Object - Colors Array of RGBQuad Objects or uint16_t that make a color table, as determined from the DIBHeaderInfo field. - BitMapBuffer Array of bytes containing the image. + DIBHeaderInfo BitmapCoreHeader or BitmapInfoHeader Object + Colors Array of RGBQuad Objects or uint16_t that make a color table, as determined from the DIBHeaderInfo field. + BitMapBuffer Array of bytes containing the image. */ -/** WLogBrush Object WMF PDF 2.2.2.10 +/** WLogBrush Object WMF manual 2.2.2.10 Not compatible with EMF LogBrush object! - style Color Hatch - U_BS_SOLID ColorRef Object Not used (bytes present???) - U_BS_NULL ignored ignored (bytes present???). - U_BS_PATTERN ignored not used (Action is not strictly defined) - U_BS_DIBPATTERN ignored not used (Action is not strictly defined) - U_BS_DIBPATTERNPT ignored not used (Action is not strictly defined) - U_BS_HATCHED ColorRef Object HatchStyle Enumeration + style Color Hatch + U_BS_SOLID ColorRef Object Not used (bytes present???) + U_BS_NULL ignored ignored (bytes present???). + U_BS_PATTERN ignored not used (Action is not strictly defined) + U_BS_DIBPATTERN ignored not used (Action is not strictly defined) + U_BS_DIBPATTERNPT ignored not used (Action is not strictly defined) + U_BS_HATCHED ColorRef Object HatchStyle Enumeration */ typedef struct { uint16_t Style; //!< BrushStyle Enumeration U_COLORREF Color; //!< Brush Color value, 32 bit value is not aligned. uint16_t Hatch; //!< HatchStyle Enumeration -} U_WLOGBRUSH, *PU_WLOGBRUSH; +} U_WLOGBRUSH; -/** LogColorSpace Object WMF PDF 2.2.2.11 - Same as "LOGCOLORSPACEA Object" in uemf.h +/* LogColorSpace Object WMF manual 2.2.2.11 + Same as "EMF LOGCOLORSPACEA Object" in uemf.h use U_LOGCOLORSPACEA */ -/** LogColorSpaceW Object WMF PDF 2.2.2.12 - Same as "LOGCOLORSPACEW Object" in uemf.h +/* LogColorSpaceW Object WMF manual 2.2.2.12 + Same as "EMF LOGCOLORSPACEW Object" in uemf.h use U_LOGCOLORSPACEW */ -/** PaletteEntry Object WMF PDF 2.2.2.13 +/* PaletteEntry Object WMF manual 2.2.2.13 moved up before Palette Object */ -/** PitchAndFamily Enumerations WMF PDF 2.2.2.14 - Same as "LF_PitchAndFamily Enumeration" in uemf.h +/* PitchAndFamily Enumerations WMF manual 2.2.2.14 + Same as "EMF LF_PitchAndFamily Enumeration" in uemf.h */ -/** PointL Object WMF PDF 2.2.2.15 - Same as "Point Object" in uemf.h +/* PointL Object WMF manual 2.2.2.15 + Same as "EMF Point Object" in uemf.h */ -/** PointS Object WMF PDF 2.2.2.16 - Same as "POINTS Object" in uemf.h +/* PointS Object WMF manual 2.2.2.16 + Same as "EMF POINTS Object" in uemf.h */ -/** PolyPolygon Object WMF PDF 2.2.2.17 +/* PolyPolygon Object WMF manual 2.2.2.17 */ +/** WMF manual 2.2.2.17 + There is an array "aPoints" of uint16_t after aPolyCounts that holds the coordinates. + Presumably it is in order [x1,y1],[x2,y2],etc. The documentation does not say, it might have y then x. + aPoints starts at aPolyCounts[nPolys] */ typedef struct { uint16_t nPolys; //!< Number of polygons uint16_t aPolyCounts[1]; //!< Number of points in each polygon (sequential) -} U_POLYPOLYGON, *PU_POLYPOLYGON; +} U_POLYPOLYGON; -/** Rect Object WMF PDF 2.2.2.18 +/* Rect Object WMF manual 2.2.2.18 This one is out of order, had to be created much earlier than this */ -/** RectL Object WMF PDF 2.2.2.19 - Same as "RECT Object" in uemf.h +/* RectL Object WMF manual 2.2.2.19 + Same as "EMF RECT Object" in uemf.h */ -/** RGBQuad Object WMF PDF 2.2.2.20 - Same as "RGBQUAD Object" in uemf.h +/* RGBQuad Object WMF manual 2.2.2.20 + Same as "EMF RGBQUAD Object" in uemf.h */ -/** Scan Object WMF PDF 2.2.2.21 - Field "count2" must follow ScanLines, but it cannot be placed into the struct. It is - an uint16_t value which must be the same as count. +/** Scan Object WMF manual 2.2.2.21 */ +/** WMF manual 2.2.2.21 + + Mandatory field "count2" must follow ScanLines, but it cannot be placed into the struct because + ScanLines has variable size. "count2" is + an uint16_t value which must have the same value as count. */ typedef struct { uint16_t count; //!< Number of entries in the ScanLines array uint16_t top; //!< Y coordinate of the top scanline uint16_t bottom; //!< Y coordinate of the bottom scanline uint16_t ScanLines[1]; //!< Array of 16 bit left/right pairs -} U_SCAN, *PU_SCAN; +} U_SCAN; -/** SizeL Object WMF PDF 2.2.2.22 - Same as "SIZEL Object" in uemf.h +/** SizeL Object WMF manual 2.2.2.22 + Same as "EMF SIZEL Object" in uemf.h */ /** First three fields of MOST WMF records (not WMR_HEADER and WMR_PLACEABLE!) - Should only used for accessing size and type fields. - NOT used as a prefix like U_EMR in uemf.h because it may cause alignment issues. + + This Sshould only used for accessing size and type fields. + It is NOT used as a prefix like U_EMR in uemf.h because it may cause alignment issues. Microsoft name: WMF Object */ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type -} U_METARECORD, *PU_METARECORD; +} U_METARECORD; -/** WMF PDF 2.3.2.3 META_PLACEABLE - If present this must immediately precede the header. - It is not enumerated as an WMR record type. - This only ever occurs at the start of a WMF file, so the two uint32_t values will always be aligned. +/** WMF manual 2.3.2.3 META_PLACEABLE + If present this must immediately precede the header. + It is not enumerated as an WMR record type. + This only ever occurs at the start of a WMF file, so the two uint32_t values will always be aligned. */ typedef struct { uint32_t Key; //!< MUST be 0x9AC6CDD7 @@ -1051,146 +1076,172 @@ typedef struct { uint16_t Inch; //!< Logical units/inch (convention if not specified: 1440 logical units/inch) uint32_t Reserved; //!< must be 0 uint16_t Checksum; //!< Checksum of preceding 10 16 bit values -} U_WMRPLACEABLE, *PU_WMRPLACEABLE; +} U_WMRPLACEABLE; -/** WMF PDF 2.3.2.2 META_HEADER +/** WMF manual 2.3.2.2 META_HEADER */ typedef struct { - uint8_t iType; //!< RecordType enumeration, must be 1 + uint8_t iType; //!< RecordType Enumeration, must be 1 uint8_t xb; //!< Extra high order byte associated with record type uint16_t Size16w; //!< Total number of 16bit words in record - uint16_t version; //!< Metafile version enumeration + uint16_t version; //!< Metafile version Enumeration uint16_t Sizew[2]; //!< reassemble/store the Size (16 bit words in entire file) using Sizew, the 32 bit value is not aligned uint16_t nObjects; //!< Total number of brushes, pens, and other graphics objects defined in this file uint32_t maxSize; //!< Largest record in file, in number of 16bit words (This uint32_t is aligned) uint16_t nMembers; //!< Unused, should be 0 -} U_WMRHEADER, *PU_WMRHEADER; +} U_WMRHEADER; // *********************************************************************************** // The following structures correspond to U_WMR_# records -/* Index 00 U_WMREOF WMF PDF 2.3.2.1 META_EOF */ +/* Index 00 U_WMREOF WMF manual 2.3.2.1 META_EOF */ +/** WMF manual 2.3.2.1 META_EOF +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type -} U_WMREOF, *PU_WMREOF, - U_WMRSETRELABS, *PU_WMRSETRELABS, - U_WMRSAVEDC, *PU_WMRSAVEDC, - U_WMRREALIZEPALETTE, *PU_WMRREALIZEPALETTE; +} U_WMREOF, + U_WMRSETRELABS, //!< WMF manual 2.3.5.21 + U_WMRSAVEDC, //!< WMF manual 2.3.5.11 + U_WMRREALIZEPALETTE; //!< WMF manual 2.3.5.8 -/* Index 01 U_WMRSETBKCOLOR WMF PDF 2.3.5.14 */ +/* Index 01 U_WMRSETBKCOLOR WMF manual 2.3.5.14 */ +/** WMF manual 2.3.5.14 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type U_COLORREF Color; //!< Color value, the 32 bit value is not aligned. -} U_WMRSETBKCOLOR, *PU_WMRSETBKCOLOR, - U_WMRSETTEXTCOLOR, *PU_WMRSETTEXTCOLOR; +} U_WMRSETBKCOLOR, + U_WMRSETTEXTCOLOR; //!< WMF manual 2.3.5.26 -/* Index 02 U_WMRSETBKMODE WMF PDF 2.3.5.15 */ +/* Index 02 U_WMRSETBKMODE WMF manual 2.3.5.15 */ +/** WMF manual 2.3.5.15 +mode = MixMode Enumeration. +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type uint16_t Mode; //!< Various Enumeraton. uint16_t Reserved; //!< Ignore (ALSO OPTIONAL - FIELD MAY NOT BE PRESENT!!!!) -} U_WMRSETBKMODE, *PU_WMRSETBKMODE, //!< MixMode Enumeration. - U_WMRSETROP2, *PU_WMRSETROP2, //!< Binary Raster Operation Enumeration. - U_WMRSETPOLYFILLMODE, *PU_WMRSETPOLYFILLMODE, //!< PolyFillMode Enumeration. - U_WMRSETSTRETCHBLTMODE, *PU_WMRSETSTRETCHBLTMODE, //!< StretchMode Enumeration - U_WMRSETTEXTALIGN, *PU_WMRSETTEXTALIGN; //!< TextAlignment Enumeration. +} U_WMRSETBKMODE, + U_WMRSETPOLYFILLMODE, //!< WMF manual 2.3.5.20 Mode = PolyFillMode Enumeration. + U_WMRSETROP2, //!< WMF manual 2.3.5.22 Binary Raster Operation Enumeration. + U_WMRSETSTRETCHBLTMODE, //!< WMF manual 2.3.5.23 Mode = StretchMode Enumeration + U_WMRSETTEXTALIGN; //!< WMF manual 2.3.5.24 Mode = TextAlignment Enumeration. -/* Index 03 U_WMRSETMAPMODE WMF PDF 2.3.5.17 */ +/* Index 03 U_WMRSETMAPMODE WMF manual 2.3.5.17 */ +/** WMF manual 2.3.5.17 +Mode = MapMode Enumeration. +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type uint16_t Mode; //!< Various Enumeraton and other -} U_WMRSETMAPMODE, *PU_WMRSETMAPMODE, //!< MapMode Enumeration. - U_WMRSETTEXTCHAREXTRA, *PU_WMRSETTEXTCHAREXTRA; //!< Extra space in logical units to add to each character +} U_WMRSETMAPMODE, + U_WMRSETTEXTCHAREXTRA; //!< WMF manual 2.3.5.25, Mode = Extra space in logical units to add to each character -/* Index 04 U_WMRSETROP2 WMF PDF 2.3.5.22 See Index 02 */ +/* Index 04 U_WMRSETROP2 WMF manual 2.3.5.22 See Index 02 */ -/* Index 05 U_WMRSETRELABS WMF PDF 2.3.5.21 See Index 00*/ +/* Index 05 U_WMRSETRELABS WMF manual 2.3.5.21 See Index 00*/ -/* Index 06 U_WMRSETPOLYFILLMODE WMF PDF 2.3.5.20 See Index 02 - Index 07 U_WMRSETSTRETCHBLTMODE WMF PDF 2.3.5.23 */ +/* Index 06 U_WMRSETPOLYFILLMODE WMF manual 2.3.5.20 See Index 02 + Index 07 U_WMRSETSTRETCHBLTMODE WMF manual 2.3.5.23 */ -/* Index 08 U_WMRSETTEXTCHAREXTRA WMF PDF 2.3.5.25 See Index 03*/ +/* Index 08 U_WMRSETTEXTCHAREXTRA WMF manual 2.3.5.25 See Index 03*/ -/* Index 09 U_WMRSETTEXTCOLOR WMF PDF 2.3.5.26 see Index 01 */ +/* Index 09 U_WMRSETTEXTCOLOR WMF manual 2.3.5.26 see Index 01 */ -/* Index 0A U_WMRSETTEXTJUSTIFICATION WMF PDF 2.3.5.27 */ +/* Index 0A U_WMRSETTEXTJUSTIFICATION WMF manual 2.3.5.27 */ +/** WMF manual 2.3.5.27 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type uint16_t Count; //!< Number of space characters in the line uint16_t Extra; //!< Number of extra space characters to add to the line -} U_WMRSETTEXTJUSTIFICATION, *PU_WMRSETTEXTJUSTIFICATION; +} U_WMRSETTEXTJUSTIFICATION; -/* Index 0B U_WMRSETWINDOWORG WMF PDF 2.3.5.31 - Index 0C U_WMRSETWINDOWEXT WMF PDF 2.3.5.30 - Index 0D U_WMRSETVIEWPORTORG WMF PDF 2.3.5.29 - Index 0E U_WMRSETVIEWPORTEXT WMF PDF 2.3.5.28 - Index 0F U_WMROFFSETWINDOWORG WMF PDF 2.3.5.7 - Index 13 U_WMRLINETO WMF PDF 2.3.3.10 - Index 14 U_WMRMOVETO WMF PDF 2.3.3.4 +/* Index 0B U_WMRSETWINDOWORG WMF manual 2.3.5.31 + Index 0C U_WMRSETWINDOWEXT WMF manual 2.3.5.30 + Index 0D U_WMRSETVIEWPORTORG WMF manual 2.3.5.29 + Index 0E U_WMRSETVIEWPORTEXT WMF manual 2.3.5.28 + Index 0F U_WMROFFSETWINDOWORG WMF manual 2.3.5.7 + Index 0F U_WMROFFSETVIEWPORTORG WMF manual 2.3.5.6 + Index 13 U_WMRLINETO WMF manual 2.3.3.10 + Index 14 U_WMRMOVETO WMF manual 2.3.3.4 + Index 20 U_WMROFFSETCLIPRGN WMF manual 2.3.5.5 +*/ +/** WMF manual 2.3.5.31 +Window X,Y origin */ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type int16_t y; //!< Y value (note order!) int16_t x; //!< X value -} U_WMRSETWINDOWORG, *PU_WMRSETWINDOWORG, //!< Window X,Y origin - U_WMRSETWINDOWEXT, *PU_WMRSETWINDOWEXT, //!< Window X,Y extent - U_WMRSETVIEWPORTORG, *PU_WMRSETVIEWPORTORG, //!< Viewport X,Y origin - U_WMRSETVIEWPORTEXT, *PU_WMRSETVIEWPORTEXT, //!< Viewport X,Y extent - U_WMROFFSETWINDOWORG, *PU_WMROFFSETWINDOWORG, //!< Window X,Y offset in device units - U_WMROFFSETVIEWPORTORG, *PU_WMROFFSETVIEWPORTORG, //!< Viewport X,Y offset in device units - U_WMRLINETO, *PU_WMRLINETO, //!< Endpoint X,Y in logical units - U_WMRMOVETO, *PU_WMRMOVETO, //!< Destination X,Y in logical units - U_WMROFFSETCLIPRGN, *PU_WMROFFSETCLIPRGN; //!< ClipRegion X,Y offset in logical units - -/* Index 10 U_WMRSCALEWINDOWEXT WMF PDF 2.3.5.13 */ +} U_WMRSETWINDOWORG, + U_WMRSETWINDOWEXT, //!< WMF manual 2.3.5.30, Window X,Y extent + U_WMRSETVIEWPORTORG, //!< WMF manual 2.3.5.29, Viewport X,Y origin + U_WMRSETVIEWPORTEXT, //!< WMF manual 2.3.5.28, Viewport X,Y extent + U_WMROFFSETWINDOWORG, //!< WMF manual 2.3.5.7, Window X,Y offset in device units + U_WMROFFSETVIEWPORTORG, //!< WMF manual 2.3.5.6, Viewport X,Y offset in device units + U_WMRLINETO, //!< WMF manual 2.3.3.10, Endpoint X,Y in logical units + U_WMRMOVETO, //!< WMF manual 2.3.3.4, Destination X,Y in logical units + U_WMROFFSETCLIPRGN; //!< WMF manual 2.3.5.5, Y offset in logical units + +/* Index 10 U_WMRSCALEWINDOWEXT WMF manual 2.3.5.13 + Index 12 U_WMRSCALEVIEWPORTEXT WMF manual 2.3.5.12 +*/ +/** WMF manual 2.3.5.13 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type int16_t yDenom; //!< Y denominator int16_t yNum; //!< Y numerator int16_t xDenom; //!< X denominator int16_t xNum; //!< X numerator -} U_WMRSCALEWINDOWEXT, *PU_WMRSCALEWINDOWEXT, - U_WMRSCALEVIEWPORTEXT, *PU_WMRSCALEVIEWPORTEXT; +} U_WMRSCALEWINDOWEXT, + U_WMRSCALEVIEWPORTEXT; //!< WMF manual 2.3.5.12 -/* Index 11 U_WMROFFSETVIEWPORTORG WMF PDF 2.3.5.6 see Index 0B */ +/* Index 11 U_WMROFFSETVIEWPORTORG WMF manual 2.3.5.6 see Index 0B */ -/* Index 12 U_WMRSCALEVIEWPORTEXT WMF PDF 2.3.5.12 see Index 10 */ +/* Index 12 U_WMRSCALEVIEWPORTEXT WMF manual 2.3.5.12 see Index 10 */ -/* Index 13 U_WMRLINETO WMF PDF 2.3.3.10 see index 0B - Index 14 U_WMRMOVETO WMF PDF 2.3.5.4 */ +/* Index 13 U_WMRLINETO WMF manual 2.3.3.10 see index 0B + Index 14 U_WMRMOVETO WMF manual 2.3.5.4 */ -/* Index 15 U_WMREXCLUDECLIPRECT WMF PDF 2.3.5.2 - Index 16 U_WMRINTERSECTCLIPRECT WMF PDF 2.3.5.3 */ +/* Index 15 U_WMREXCLUDECLIPRECT WMF manual 2.3.5.2 + Index 16 U_WMRINTERSECTCLIPRECT WMF manual 2.3.5.3 +*/ +/** WMF manual 2.3.5.2 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type int16_t Bottom; //!< Coordinates in logical units int16_t Right; //!< Coordinates in logical units int16_t Top; //!< Coordinates in logical units int16_t Left; //!< Coordinates in logical units -} U_WMREXCLUDECLIPRECT, *PU_WMREXCLUDECLIPRECT, - U_WMRINTERSECTCLIPRECT, *PU_WMRINTERSECTCLIPRECT; +} U_WMREXCLUDECLIPRECT, + U_WMRINTERSECTCLIPRECT; //!< WMF manual 2.3.5.3 -/* Index 17 U_WMRARC WMF PDF 2.3.3.1 */ +/* Index 17 U_WMRARC WMF manual 2.3.3.1 */ +/** WMF manual 2.3.3.1 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type int16_t yEndArc; //!< Coordinates in logical units int16_t xEndArc; //!< Coordinates in logical units @@ -1200,36 +1251,48 @@ typedef struct { int16_t Right; //!< Coordinates in logical units int16_t Top; //!< Coordinates in logical units int16_t Left; //!< Coordinates in logical units -} U_WMRARC, *PU_WMRARC; +} U_WMRARC; -/* Index 18 U_WMRELLIPSE WMF PDF 2.3.3.3 */ +/* Index 18 U_WMRELLIPSE WMF manual 2.3.3.3 + Index 1B U_WMRRECTANGLE WMF manual 2.3.3.17 +*/ +/** WMF manual 2.3.3.3 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type int16_t Bottom; //!< Coordinates in logical units int16_t Right; //!< Coordinates in logical units int16_t Top; //!< Coordinates in logical units int16_t Left; //!< Coordinates in logical units -} U_WMRELLIPSE, *PU_WMRELLIPSE, - U_WMRRECTANGLE, *PU_WMRRECTANGLE; +} U_WMRELLIPSE, + U_WMRRECTANGLE; //!< WMF manual 2.3.3.17 -/* Index 19 U_WMRFLOODFILL WMF PDF 2.3.3.7 */ +/* Index 19 U_WMRFLOODFILL WMF manual 2.3.3.7 + Index 48 U_WMREXTFLOODFILL WMF manual 2.3.3.4 +*/ +/** WMF manual 2.3.3.7 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type int16_t Mode; //!< FloodFill Enumeration U_COLORREF Color; //!< Color int16_t y; //!< Y int16_t x; //!< X -} U_WMRFLOODFILL, *PU_WMRFLOODFILL, - U_WMREXTFLOODFILL, *PU_WMREXTFLOODFILL; +} U_WMRFLOODFILL, + U_WMREXTFLOODFILL; //!< WMF manual 2.3.3.7 -/* Index 1A U_WMRPIE WMF PDF 2.3.3.13 */ +/* Index 1A U_WMRPIE WMF manual 2.3.3.13 + Index 30 U_WMRCHORD WMF manual 2.3.3.2 +*/ +/** WMF manual 2.3.3.13 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type int16_t yRadial2; //!< in logical units int16_t xRadial2; //!< in logical units @@ -1239,15 +1302,17 @@ typedef struct { int16_t Right; //!< in logical units int16_t Top; //!< in logical units int16_t Left; //!< in logical units -} U_WMRPIE, *PU_WMRPIE, - U_WMRCHORD, *PU_WMRCHORD; +} U_WMRPIE, + U_WMRCHORD; //!< WMF manual 2.3.3.2 -/* Index 1B U_WMRRECTANGLE WMF PDF 2.3.3.17 See Index 18 */ +/* Index 1B U_WMRRECTANGLE WMF manual 2.3.3.17 See Index 18 */ -/* Index 1C U_WMRROUNDRECT WMF PDF 2.3.3.18 */ +/* Index 1C U_WMRROUNDRECT WMF manual 2.3.3.18 */ +/** WMF manual 2.3.3.18 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type int16_t Height; //!< in logical units (rounded corner) int16_t Width; //!< in logical units (rounded corner) @@ -1255,50 +1320,61 @@ typedef struct { int16_t Right; //!< in logical units int16_t Top; //!< in logical units int16_t Left; //!< in logical units -} U_WMRROUNDRECT, *PU_WMRROUNDRECT; +} U_WMRROUNDRECT; -/* Index 1D U_WMRPATBLT WMF PDF 2.3.3.12 +/* Index 1D U_WMRPATBLT WMF manual 2.3.3.12 +*/ +/** WMF manual 2.3.3.12 */ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type uint16_t rop3w[2]; //!< reassemble/store the rop3 Ternary raster operation using rop3w, as the 32 bit value is not aligned int16_t Height; //!< in logical units (of Rect to Fill) int16_t Width; //!< in logical units (of Rect to Fill) int16_t yDst; //!< in logical units (UL corner to fill) int16_t xDst; //!< in logical units (UL corner to fill) -} U_WMRPATBLT, *PU_WMRPATBLT; +} U_WMRPATBLT; -/* Index 1E U_WMRSAVEDC WMF PDF 2.3.5.11 See Index 00*/ +/* Index 1E U_WMRSAVEDC WMF manual 2.3.5.11 See Index 00*/ -/* Index 1F U_WMRSETPIXEL WMF PDF 2.3.3.19 */ +/* Index 1F U_WMRSETPIXEL WMF manual 2.3.3.19 */ +/** WMF manual 2.3.3.19 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type U_COLORREF Color; //!< Color int16_t y; //!< Y int16_t x; //!< X -} U_WMRSETPIXEL, *PU_WMRSETPIXEL; +} U_WMRSETPIXEL; -/* Index 20 U_WMROFFSETCLIPRGN WMF PDF 2.3.5.5 See Index 0B*/ +/* Index 20 U_WMROFFSETCLIPRGN WMF manual 2.3.5.5 See Index 0B*/ -/* Index 21 U_WMRTEXTOUT WMF PDF 2.3.3.20 - Also part of the record, but at variable positions - int16_t y; start position - int16_t x; start position +/* Index 21 U_WMRTEXTOUT WMF manual 2.3.3.20 +*/ +/** WMF manual 2.3.3.20 +Also part of the record, following String, and so at variable positions: + +int16_t y; start position + +int16_t x; start position */ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type int16_t Length; //!< Stringlength in bytes uint8_t String; //!< String to write, storage area must be 2n bytes. -} U_WMRTEXTOUT, *PU_WMRTEXTOUT; +} U_WMRTEXTOUT; + +/* Index 22 U_WMRBITBLT WMF manual 2.3.1.1 +*/ +/** WMF manual 2.3.1.1 -/* Index 22 U_WMRBITBLT WMF PDF 2.3.1.1 - This is a variable structure the core, invariant part extends to xSrc. + This is a variable structure the core/invariant part extends to xSrc. if RecordSize == ((xb) + 3) then there is no bitmap and use the _NOPX form, otherwise use the _PX form Use Macro U_TEST_NOPX2 @@ -1306,7 +1382,7 @@ typedef struct { */ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type uint16_t rop3w[2]; //!< reassemble/store the Ternary raster operation rop3 value using rop3w, the 32 bit value is not aligned. int16_t ySrc; //!< in logical units (UL corner of Src rect) @@ -1316,11 +1392,19 @@ typedef struct { int16_t Width; //!< in logical units (of Src and Dst rects) int16_t yDst; //!< in logical units (UL corner of Dst rect) int16_t xDst; //!< in logical units (UL corner of Dst rect) -} U_WMRBITBLT_NOPX, *PU_WMRBITBLT_NOPX; +} U_WMRBITBLT_NOPX; + +/** WMF manual 2.3.1.1 + This is a variable structure the core/invariant part extends to xSrc. + + if RecordSize == ((xb) + 3) then there is no bitmap and use the _NOPX form, otherwise use the _PX form + Use Macro U_TEST_NOPX2 + +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type uint16_t rop3w[2]; //!< reassemble/store the Ternary raster operation rop3 value using rop3w, the 32 bit value is not aligned. int16_t ySrc; //!< in logical units (UL corner of Src rect) @@ -1330,18 +1414,21 @@ typedef struct { int16_t yDst; //!< in logical units (UL corner of Dst rect) int16_t xDst; //!< in logical units (UL corner of Dst rect) U_BITMAP16 bitmap; //!< Src bitmap -} U_WMRBITBLT_PX, *PU_WMRBITBLT_PX; +} U_WMRBITBLT_PX; + +/* Index 23 U_WMRSTRETCHBLT WMF manual 2.3.1.5 */ +/** WMF manual 2.3.1.5 -/* Index 23 U_WMRSTRETCHBLT WMF PDF 2.3.1.5 - This is a variable structure the core, invariant part extends to xSrc. + This is a variable structure the core/invariant part extends to xSrc. if RecordSize == ((xb) + 3) then there is no bitmap and use the _NOPX form, otherwise use the _PX form Use Macro U_TEST_NOPX2. */ + typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type uint16_t rop3w[2]; //!< reassemble/store the Ternary raster operation rop3 value using rop3w, the 32 bit value is not aligned. int16_t hSrc; //!< Height in logical units of Src rect @@ -1353,11 +1440,20 @@ typedef struct { int16_t wDst; //!< Wdith in logical units of Dst rect int16_t yDst; //!< in logical units (UL corner of Dst rect) int16_t xDst; //!< in logical units (UL corner of Dst rect) -} U_WMRSTRETCHBLT_NOPX, *PU_WMRSTRETCHBLT_NOPX; +} U_WMRSTRETCHBLT_NOPX; + + +/* Index 23 U_WMRSTRETCHBLT WMF manual 2.3.1.5 */ +/** WMF manual 2.3.1.5 + This is a variable structure the core/invariant part extends to xSrc. + + if RecordSize == ((xb) + 3) then there is no bitmap and use the _NOPX form, otherwise use the _PX form + Use Macro U_TEST_NOPX2. +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type uint16_t rop3w[2]; //!< reassemble/store the Ternary raster operation rop3 value using rop3w, the 32 bit value is not aligned. int16_t hSrc; //!< Height in logical units of Src rect @@ -1369,124 +1465,153 @@ typedef struct { int16_t yDst; //!< in logical units (UL corner of Dst rect) int16_t xDst; //!< in logical units (UL corner of Dst rect) U_BITMAP16 bitmap; //!< Src bitmap -} U_WMRSTRETCHBLT_PX, *PU_WMRSTRETCHBLT_PX; +} U_WMRSTRETCHBLT_PX; -/* Index 24 U_WMRPOLYGON WMF PDF 2.3.3.15 - Index 25 U_WMRPOLYLINE WMF PDF 2.3.3.14 */ +/* Index 24 U_WMRPOLYGON WMF manual 2.3.3.15 + Index 25 U_WMRPOLYLINE WMF manual 2.3.3.14 +*/ +/** WMF manual 2.3.3.15 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type int16_t nPoints; //!< Number of points in aPoints U_POINT16 aPoints[1]; //!< Array of points -} U_WMRPOLYGON, *PU_WMRPOLYGON, - U_WMRPOLYLINE, *PU_WMRPOLYLINE; +} U_WMRPOLYGON, + U_WMRPOLYLINE; //!< WMF manual 2.3.3.14 -/* Index 26 U_WMRESCAPE WMF PDF 2.3.6.1 */ +/* Index 26 U_WMRESCAPE WMF manual 2.3.6.1 */ +/** WMF manual 2.3.6.1 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type uint16_t eFunc; //!< Escape function uint16_t nBytes; //!< bytes in the data array uint8_t Data[1]; //!< data array -} U_WMRESCAPE, *PU_WMRESCAPE; +} U_WMRESCAPE; -/* Index 27 U_WMRRESTOREDC WMF PDF 2.3.5.10*/ +/* Index 27 U_WMRRESTOREDC WMF manual 2.3.5.10 */ +/** WMF manual 2.3.5.10 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type int16_t DC; //!< DC to restore (negative is relative to current, positive is absolute) -} U_WMRRESTOREDC, *PU_WMRRESTOREDC; +} U_WMRRESTOREDC; -/* Index 28 U_WMRFILLREGION WMF PDF 2.3.3.6 */ +/* Index 28 U_WMRFILLREGION WMF manual 2.3.3.6 */ +/** WMF manual 2.3.3.6 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type uint16_t Region; //!< Index of region to fill in object table uint16_t Brush; //!< Index of brush to use in object table -} U_WMRFILLREGION, *PU_WMRFILLREGION; +} U_WMRFILLREGION; -/* Index 29 U_WMRFRAMEREGION WMF PDF 2.3.3.8 */ +/* Index 29 U_WMRFRAMEREGION WMF manual 2.3.3.8 */ +/** WMF manual 2.3.3.8 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type uint16_t Region; //!< Index of region to frame in object table uint16_t Brush; //!< Index of brush to use in frame in object table int16_t Height; //!< in logical units (of frame) int16_t Width; //!< in logical units (of frame) -} U_WMRFRAMEREGION, *PU_WMRFRAMEREGION; +} U_WMRFRAMEREGION; -/* Index 2A U_WMRINVERTREGION WMF PDF 2.3.3.9 - Index 2B U_WMRPAINTREGION WMF PDF 2.3.3.11 - Index 2C U_WMRSELECTCLIPREGION WMF PDF 2.3.4.9 - Index 2D U_WMRSELECTOBJECT WMF PDF 2.3.4.10 */ +/* Index 2A U_WMRINVERTREGION WMF manual 2.3.3.9 + Index 2B U_WMRPAINTREGION WMF manual 2.3.3.11 + Index 2C U_WMRSELECTCLIPREGION WMF manual 2.3.4.9 + Index 2D U_WMRSELECTOBJECT WMF manual 2.3.4.10 + Index 34 U_WMRSELECTPALETTE WMF manual 2.3.4.11 + Index 39 U_WMRRESIZEPALETTE WMF manual 2.3.5.9 + Index F0 U_WMRDELETEOBJECT WMF manual 2.3.4.7 +*/ +/** WMF manual 2.3.3.9 +invert region +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type uint16_t index; //!< (usually) index of region/object in object table -} U_WMRINVERTREGION, *PU_WMRINVERTREGION, //!< invert region - U_WMRPAINTREGION, *PU_WMRPAINTREGION, //!< paint region - U_WMRSELECTCLIPREGION, *PU_WMRSELECTCLIPREGION, //!< select as clip region - U_WMRSELECTOBJECT, *PU_WMRSELECTOBJECT, //!< select object - U_WMRSELECTPALETTE, *PU_WMRSELECTPALETTE, //!< select palette object - U_WMRRESIZEPALETTE, *PU_WMRRESIZEPALETTE, //!< resize the system palette to "index" - U_WMRDELETEOBJECT, *PU_WMRDELETEOBJECT; //!< delete object - -/* Index 2E U_WMRSETTEXTALIGN WMF PDF 2.3.5.24 See Index 02 */ - -/* Index 2F U_WMRDRAWTEXT in Wine, not in WMF PDF. - no documentation found, this part must be correct */ +} U_WMRINVERTREGION, + U_WMRPAINTREGION, //!< WMF manual 2.3.3.11, paint region + U_WMRSELECTCLIPREGION, //!< WMF manual 2.3.4.9, select as clip region + U_WMRSELECTOBJECT, //!< WMF manual 2.3.4.10, select object + U_WMRSELECTPALETTE, //!< WMF manual 2.3.4.11, select palette object + U_WMRRESIZEPALETTE, //!< WMF manual 2.3.5.9, resize the system palette to "index" + U_WMRDELETEOBJECT; //!< WMF manual 2.3.4.7, delete object + +/* Index 2E U_WMRSETTEXTALIGN WMF manual 2.3.5.24 See Index 02 */ + +/* Index 2F U_WMRDRAWTEXT in GDI and Wine, not documented in WMF manual. + Index FE U_WMRCREATEBITMAP in GDI and Wine, not documented in WMF manual. + Index FD U_WMRCREATEBITMAPINDIRECT in GDI and Wine, not documented in WMF manual. + + no documentation found, this part of these records, at least, must be correct */ +/** in GDI and Wine, not documented in WMF manual. +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type -} U_WMRDRAWTEXT, *PU_WMRDRAWTEXT, - U_WMRCREATEBITMAPINDIRECT, *PU_WMRCREATEBITMAPINDIRECT, - U_WMRCREATEBITMAP, *PU_WMRCREATEBITMAP; +} U_WMRDRAWTEXT, + U_WMRCREATEBITMAPINDIRECT, //!< in GDI and Wine, not documented in WMF manual. + U_WMRCREATEBITMAP; //!< in GDI and Wine, not documented in WMF manual. -/* Index 30 U_WMRCHORD WMF PDF 2.3.3.2 See Index 1A */ +/* Index 30 U_WMRCHORD WMF manual 2.3.3.2 See Index 1A */ -/* Index 31 U_WMRSETMAPPERFLAGS WMF PDF 2.3.5.18 */ +/* Index 31 U_WMRSETMAPPERFLAGS WMF manual 2.3.5.18 */ +/** WMF manual 2.3.5.18 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type uint16_t valuew[2]; //!< if 1 bit set font mapper selects only matching aspect fonts. reassemble/store the value using valuew, the 32 bit value is not aligned. -} U_WMRSETMAPPERFLAGS, *PU_WMRSETMAPPERFLAGS; +} U_WMRSETMAPPERFLAGS; -/* Index 32 U_WMREXTTEXTOUT WMF PDF 2.3.3.5 - Variable size structure. Common part is shown. +/* Index 32 U_WMREXTTEXTOUT WMF manual 2.3.3.5 +*/ +/** WMF manual 2.3.3.5 + + Variable size record. Optional fields which follow the struct fields are: - U_RECT16 Rect; Only present when U_ETO_OPAQUE or U_ETO_CLIPPED bits are set in Opts - uint8_t String; String to write, storage area must be 2n bytes. - int16_t Dx; Kerning information. Must have same number of entries as Length. - Dx is present when - 2*Size16_4[2] -14 - 2*((Length + 1)/2)) - 8*(Opts & (U_ETO_OPAQUE | U_ETO_CLIPPED)) == 2*Length + U_RECT16 Rect; Only present when U_ETO_OPAQUE or U_ETO_CLIPPED bits are set in Opts + uint8_t String; String to write, storage area must be 2n bytes. + int16_t Dx; Kerning information. Must have same number of entries as Length. + Dx is present when + 2*Size16_4[2] -14 - 2*((Length + 1)/2)) - 8*(Opts & (U_ETO_OPAQUE | U_ETO_CLIPPED)) == 2*Length */ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type int16_t y; //!< in logical units (draw point) int16_t x; //!< in logical units (draw point) int16_t Length; //!< Stringlength in bytes uint16_t Opts; //!< ExtTextOutOptions Flags -} U_WMREXTTEXTOUT, *PU_WMREXTTEXTOUT; +} U_WMREXTTEXTOUT; + +/* Index 33 U_WMRSETDIBTODEV WMF manual 2.3.1.4 */ +/** WMF manual 2.3.1.4 -/* Index 33 U_WMRSETDIBTODEV WMF PDF 2.3.1.4 - Constant part of record is showon. It is followed by a - DeviceIndependentBitmap Object + Constant part of record is shown. It is followed by a DeviceIndependentBitmap Object */ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type - uint16_t cUsage; //!< ColorUsage enumeration + uint16_t cUsage; //!< ColorUsage Enumeration uint16_t ScanCount; //!< Number of scan lines in Src uint16_t StartScan; //!< First Scan line in Src int16_t ySrc; //!< in logical units (UL corner of Src rect) @@ -1496,35 +1621,44 @@ typedef struct { int16_t yDst; //!< in logical units (UL corner of Dst rect) int16_t xDst; //!< in logical units (UL corner of Dst rect) uint8_t dib[1]; //!< DeviceIndependentBitmap object -} U_WMRSETDIBTODEV, *PU_WMRSETDIBTODEV; +} U_WMRSETDIBTODEV; -/* Index 34 U_WMRSELECTPALETTE WMF PDF 2.3.4.11 See Index 2A */ +/* Index 34 U_WMRSELECTPALETTE WMF manual 2.3.4.11 See Index 2A */ -/* Index 35 U_WMRREALIZEPALETTE WMF PDF 2.3.5.8 See Index 00 */ +/* Index 35 U_WMRREALIZEPALETTE WMF manual 2.3.5.8 See Index 00 */ -/* Index 36 U_WMRANIMATEPALETTE WMF PDF 2.3.5.1 - Index 37 U_WMRSETPALENTRIES WMF PDF 2.3.5.19 */ +/* Index 36 U_WMRANIMATEPALETTE WMF manual 2.3.5.1 + Index 37 U_WMRSETPALENTRIES WMF manual 2.3.5.19 + Index F7 U_WMRCREATEPALETTE WMF manual 2.3.4.3 +*/ +/** WMF manual 2.3.5.1 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type U_PALETTE Palette; //!< Palette object -} U_WMRANIMATEPALETTE, *PU_WMRANIMATEPALETTE, - U_WMRSETPALENTRIES, *PU_WMRSETPALENTRIES, - U_WMRCREATEPALETTE, *PU_WMRCREATEPALETTE; +} U_WMRANIMATEPALETTE, + U_WMRSETPALENTRIES, //!< WMF manual 2.3.5.19 + U_WMRCREATEPALETTE; //!< WMF manual 2.3.4.3 -/* Index 38 U_WMRPOLYPOLYGON WMF PDF 2.3.3.16 */ +/* Index 38 U_WMRPOLYPOLYGON WMF manual 2.3.3.16 */ +/** WMF manual 2.3.3.16 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type U_POLYPOLYGON PPolygon; //!< PolyPolygon object (size is variable!) -} U_WMRPOLYPOLYGON, *PU_WMRPOLYPOLYGON; +} U_WMRPOLYPOLYGON; -/* Index 39 U_WMRRESIZEPALETTE WMF PDF 2.3.5.9 See Index 2A */ +/* Index 39 U_WMRRESIZEPALETTE WMF manual 2.3.5.9 See Index 2A */ -/* Index 40 U_WMRDIBBITBLT WMF PDF 2.3.1.2 - The PX form is a variable structure the core, invariant part extends to xDst, and that is +/* Index 40 U_WMRDIBBITBLT WMF manual 2.3.1.2 +*/ +/** WMF manual 2.3.1.2 + + The PX form is a variable structure the core/invariant part extends to xDst, and that is followed by a DeviceInvariantBitmap object which starts at "dib". The NOPX form is a constant structure. @@ -1533,7 +1667,7 @@ typedef struct { */ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type uint16_t rop3w[2]; //!< reassemble/store the Ternary raster operation rop3 value using rop3w, the 32 bit value is not aligned. int16_t ySrc; //!< in logical units (UL corner of Src rect) @@ -1543,11 +1677,20 @@ typedef struct { int16_t Width; //!< in logical units (of Src and Dst) int16_t yDst; //!< in logical units (UL corner of Dst rect) int16_t xDst; //!< in logical units (UL corner of Dst rect) -} U_WMRDIBBITBLT_NOPX, *PU_WMRDIBBITBLT_NOPX; +} U_WMRDIBBITBLT_NOPX; + +/** WMF manual 2.3.1.2 + The PX form is a variable structure the core/invariant part extends to xDst, and that is + followed by a DeviceInvariantBitmap object which starts at "dib". + The NOPX form is a constant structure. + + if RecordSize == ((xb) + 3) then there is no bitmap and use the _NOPX form, otherwise use the _PX form + Use Macro U_TEST_NOPX2. +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type uint16_t rop3w[2]; //!< reassemble/store the Ternary raster operation rop3 value using rop3w, the 32 bit value is not aligned. int16_t ySrc; //!< in logical units (UL corner of Src rect) @@ -1557,10 +1700,12 @@ typedef struct { int16_t yDst; //!< in logical units (UL corner of Dst rect) int16_t xDst; //!< in logical units (UL corner of Dst rect) uint8_t dib[1]; //!< DeviceIndependentBitmap object -} U_WMRDIBBITBLT_PX, *PU_WMRDIBBITBLT_PX; +} U_WMRDIBBITBLT_PX; + +/* Index 41 U_WMRDIBSTRETCHBLT WMF manual 2.3.1.3 */ +/** WMF manual 2.3.1.3 -/* Index 41 U_WMRDIBSTRETCHBLT WMF PDF 2.3.1.3 - The PX form is a variable structure the core, invariant part extends to xDst, and that is + The PX form is a variable structure the core/invariant part extends to xDst, and that is followed by a DeviceInvariantBitmap object which starts at "dib". The NOPX form is a constant structure. @@ -1569,7 +1714,7 @@ typedef struct { */ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type uint16_t rop3w[2]; //!< reassemble/store the Ternary raster operation rop3 value using rop3w, the 32 bit value is not aligned. int16_t hSrc; //!< in logical units (of Src) @@ -1581,11 +1726,20 @@ typedef struct { int16_t wDst; //!< in logical units (of Dst) int16_t yDst; //!< in logical units (UL corner of Dst rect) int16_t xDst; //!< in logical units (UL corner of Dst rect) -} U_WMRDIBSTRETCHBLT_NOPX, *PU_WMRDIBSTRETCHBLT_NOPX; +} U_WMRDIBSTRETCHBLT_NOPX; +/** WMF manual 2.3.1.3 + + The PX form is a variable structure the core/invariant part extends to xDst, and that is + followed by a DeviceInvariantBitmap object which starts at "dib". + The NOPX form is a constant structure. + + if RecordSize == ((xb) + 3) then there is no bitmap and use the _NOPX form, otherwise use the _PX form + Use Macro U_TEST_NOPX2. +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type uint16_t rop3w[2]; //!< reassemble/store the Ternary raster operation rop3 value using rop3w, the 32 bit value is not aligned. int16_t hSrc; //!< in logical units (of Src) @@ -1597,34 +1751,38 @@ typedef struct { int16_t yDst; //!< in logical units (UL corner of Dst rect) int16_t xDst; //!< in logical units (UL corner of Dst rect) uint8_t dib[1]; //!< DeviceIndependentBitmap object -} U_WMRDIBSTRETCHBLT_PX, *PU_WMRDIBSTRETCHBLT_PX; +} U_WMRDIBSTRETCHBLT_PX; -/* Index 42 U_WMRDIBCREATEPATTERNBRUSH WMF PDF 2.3.4.8 +/* Index 42 U_WMRDIBCREATEPATTERNBRUSH WMF manual 2.3.4.8 +*/ +/** WMF manual 2.3.4.8 - style cUsage Brush created - U_BS_SOLID like U_BS_DIBPATTERNPT - U_BS_NULL like U_BS_DIBPATTERNPT - U_BS_HATCHED like U_BS_DIBPATTERNPT - U_BS_DIBPATTERNPT ColorUsage enumer. U_BS_DIBPATTERNPT brush from DIB in Src - U_BS_PATTERN ColorUsage enumer. U_BS_PATTERN brush from Bitmap16 object in Src + style cUsage Brush created + U_BS_SOLID like U_BS_DIBPATTERNPT + U_BS_NULL like U_BS_DIBPATTERNPT + U_BS_HATCHED like U_BS_DIBPATTERNPT + U_BS_DIBPATTERNPT ColorUsage enumer. U_BS_DIBPATTERNPT brush from DIB in Src + U_BS_PATTERN ColorUsage enumer. U_BS_PATTERN brush from Bitmap16 object in Src */ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type uint16_t Style; //!< BrushStyle Enumeration uint16_t cUsage; //!< See table above uint8_t Src[1]; //!< DeviceIndependentBitmap or Bitmap16 object -} U_WMRDIBCREATEPATTERNBRUSH, *PU_WMRDIBCREATEPATTERNBRUSH; +} U_WMRDIBCREATEPATTERNBRUSH; -/* Index 43 U_WMRSTRETCHDIB WMF PDF 2.3.1.6 */ +/* Index 43 U_WMRSTRETCHDIB WMF manual 2.3.1.6 */ +/** WMF manual 2.3.1.6 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type uint16_t rop3w[2]; //!< reassemble/store the Ternary raster operation rop3 value using rop3w, the 32 bit value is not aligned. - uint16_t cUsage; //!< ColorUsage enumeration + uint16_t cUsage; //!< ColorUsage Enumeration int16_t hSrc; //!< in logical units (of Src) int16_t wSrc; //!< in logical units (of Src) int16_t ySrc; //!< in logical units (UL corner of Src rect) @@ -1634,9 +1792,9 @@ typedef struct { int16_t yDst; //!< in logical units (UL corner of Dst rect) int16_t xDst; //!< in logical units (UL corner of Dst rect) uint8_t dib[1]; //!< DeviceIndependentBitmap object -} U_WMRSTRETCHDIB, *PU_WMRSTRETCHDIB; +} U_WMRSTRETCHDIB; -/* Index 48 U_WMREXTFLOODFILL WMF PDF 2.3.3.4 See Index 19*/ +/* Index 48 U_WMREXTFLOODFILL WMF manual 2.3.3.4 See Index 19*/ /* Index 4C U_WMR4C */ /* Index 4D U_WMR4D */ /* Index 4F U_WMR4F */ @@ -1788,78 +1946,90 @@ typedef struct { /* Index ED U_WMRED */ /* Index EE U_WMREE */ /* Index EF U_WMREF */ -/* Index F0 U_WMRDELETEOBJECT WMF PDF 2.3.4.7 See Index 2A */ +/* Index F0 U_WMRDELETEOBJECT WMF manual 2.3.4.7 See Index 2A */ /* Index F1 U_WMRF1 */ /* Index F2 U_WMRF2 */ /* Index F3 U_WMRF3 */ /* Index F4 U_WMRF4 */ /* Index F5 U_WMRF5 */ -/* Index F7 U_WMRCREATEPALETTE WMF PDF 2.3.4.3 See Index 36*/ +/* Index F7 U_WMRCREATEPALETTE WMF manual 2.3.4.3 See Index 36*/ /* Index F8 U_WMRF8 */ -/* Index F9 U_WMRCREATEPATTERNBRUSH WMF PDF 2.3.4.4 +/* Index F9 U_WMRCREATEPATTERNBRUSH WMF manual 2.3.4.4 */ +/** WMF manual 2.3.4.4 - This one is peculiar... + This record is peculiar... After the core structure there is: - 1. A truncated U_BITMAP16. Only the first 14 bytes are present, and the last 4 bytes (bits section) are ignored.\ - 2. 18 zero bytes (reserved) - 3. A pattern. The pattern is a byte array whose size is set by the fields in the U_BITMAP16 structure as follows: + A truncated U_BITMAP16. Only the first 14 bytes are present, and the last 4 bytes (bits section) are ignored. + 18 zero bytes (reserved) + A pattern. The pattern is a byte array whose size is set by the fields in the U_BITMAP16 structure as follows: - (((Width * BitsPixel + 15) >> 4) << 1) * Height - - brush created is BS_PATTERN + (((Width * BitsPixel + 15) >> 4) << 1) * Height + + brush created has style U_BS_PATTERN. -*/ +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type -} U_WMRCREATEPATTERNBRUSH, *PU_WMRCREATEPATTERNBRUSH; +} U_WMRCREATEPATTERNBRUSH; -/* Index FA U_WMRCREATEPENINDIRECT WMF PDF 2.3.4.5 */ +/* Index FA U_WMRCREATEPENINDIRECT WMF manual 2.3.4.5 */ +/** WMF manual 2.3.4.5 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type U_PEN pen; //!< Pen Object -} U_WMRCREATEPENINDIRECT, *PU_WMRCREATEPENINDIRECT; +} U_WMRCREATEPENINDIRECT; -/* Index FB U_WMRCREATEFONTINDIRECT WMF PDF 2.3.4.2 */ +/* Index FB U_WMRCREATEFONTINDIRECT WMF manual 2.3.4.2 */ +/** WMF manual 2.3.4.2 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type U_FONT font; //!< Font Object -} U_WMRCREATEFONTINDIRECT, *PU_WMRCREATEFONTINDIRECT; +} U_WMRCREATEFONTINDIRECT; -/* Index FC U_WMRCREATEBRUSHINDIRECT WMF PDF 2.3.4.1 */ +/* Index FC U_WMRCREATEBRUSHINDIRECT WMF manual 2.3.4.1 */ +/** WMF manual 2.3.4.1 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type U_WLOGBRUSH brush; //!< WLogBrush Object -} U_WMRCREATEBRUSHINDIRECT, *PU_WMRCREATEBRUSHINDIRECT; +} U_WMRCREATEBRUSHINDIRECT; -/* Index FD U_WMRCREATEBITMAPINDIRECT in Wine, not in WMF PDF see index 2F */ +/* Index FD U_WMRCREATEBITMAPINDIRECT in GDI and Wine, not in WMF manual, see index 2F */ -/* Index FE U_WMRCREATEBITMAP in Wine, not in WMF PDF see index 2F */ +/* Index FE U_WMRCREATEBITMAP in GDI and Wine, not in WMF manual, see index 2F */ -/* Index FF U_WMRCREATEREGION WMF PDF 2.3.4.6 */ +/* Index FF U_WMRCREATEREGION WMF manual 2.3.4.6 */ +/** WMF manual 2.3.4.6 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type U_REGION region; //!< Region Object -} U_WMRCREATEREGION, *PU_WMRCREATEREGION; +} U_WMRCREATEREGION; // ************************************************************************************************ // Utility function structures +/** + Storage for keeping track of properties of the growing WMF file as records are added. +*/ typedef struct { FILE *fp; //!< Open file size_t allocated; //!< Size of the buffer @@ -1891,14 +2061,15 @@ typedef struct { uint32_t peak; //!< Highest table slot occupied (ever) } WMFHANDLES; +//! \cond // ************************************************************************************************ // Prototypes (_set first, then _get) char *wmr_dup(const char *wmr); int wmf_start(const char *name, uint32_t initsize, uint32_t chunksize, WMFTRACK **wt); int wmf_free(WMFTRACK **wt); int wmf_finish(WMFTRACK *wt); -int wmf_append(PU_METARECORD rec, WMFTRACK *wt, int freerec); -int wmf_header_append(PU_METARECORD rec,WMFTRACK *et, int freerec); +int wmf_append(U_METARECORD *rec, WMFTRACK *wt, int freerec); +int wmf_header_append(U_METARECORD *rec,WMFTRACK *et, int freerec); int wmf_readdata(const char *filename, char **contents, size_t*length); #define wmf_fopen emf_fopen int wmf_htable_create(uint32_t initsize, uint32_t chunksize, WMFHANDLES **wht); @@ -1917,34 +2088,34 @@ char *U_wmr_escnames(int idx); void U_sanerect16(U_RECT16 rc, double *left, double *top, double *right, double *bottom); -PU_FONT U_FONT_set(int16_t Height, int16_t Width, int16_t Escapement, int16_t Orientation, +U_FONT *U_FONT_set(int16_t Height, int16_t Width, int16_t Escapement, int16_t Orientation, int16_t Weight, uint8_t Italic, uint8_t Underline, uint8_t StrikeOut, uint8_t CharSet, uint8_t OutPrecision, uint8_t ClipPrecision, uint8_t Quality, uint8_t PitchAndFamily, char *FaceName); U_PLTNTRY U_PLTNTRY_set(U_COLORREF Color); -PU_PALETTE U_PLTENTRY_set(uint16_t Start, uint16_t NumEntries, PU_PLTNTRY Entries); +U_PALETTE *U_PLTENTRY_set(uint16_t Start, uint16_t NumEntries, U_PLTNTRY *Entries); U_PEN U_PEN_set(uint16_t Style, uint16_t Width, U_COLORREF Color); U_RECT16 U_RECT16_set(U_POINT16 ul,U_POINT16 lr); -PU_BITMAP16 U_BITMAP16_set(const int16_t Type, const int16_t Width, const int16_t Height, +U_BITMAP16 *U_BITMAP16_set(const int16_t Type, const int16_t Width, const int16_t Height, const int16_t LineN, const uint8_t BitsPixel, const char *Bits); -PU_SCAN U_SCAN_set(uint16_t count, uint16_t top, uint16_t bottom, uint16_t *ScanLines); -PU_REGION U_REGION_set(int16_t Size, int16_t sCount, int16_t sMax, U_RECT16 sRect, uint16_t *aScans); +U_SCAN *U_SCAN_set(uint16_t count, uint16_t top, uint16_t bottom, uint16_t *ScanLines); +U_REGION *U_REGION_set(int16_t Size, int16_t sCount, int16_t sMax, U_RECT16 sRect, uint16_t *aScans); U_WLOGBRUSH U_WLOGBRUSH_set(uint16_t Style, U_COLORREF Color, uint16_t Hatch); -PU_PAIRF U_PAIRF_set(float x, float y); +U_PAIRF *U_PAIRF_set(float x, float y); char *wdeleteobject_set(uint32_t *ihObject, WMFHANDLES *wht); char *wselectobject_set(uint32_t ihObject, WMFHANDLES *wht ); char *wcreatepenindirect_set(uint32_t *ihPen, WMFHANDLES *wht, U_PEN pen); char *wcreatebrushindirect_set(uint32_t *ihBrush, WMFHANDLES *wht, U_WLOGBRUSH lb); char *wcreatedibpatternbrush_srcdib_set(uint32_t *ihBrush, WMFHANDLES *wht, - uint32_t iUsage, const PU_BITMAPINFO Bmi, uint32_t cbPx, const char *Px); + uint32_t iUsage, const U_BITMAPINFO *Bmi, uint32_t cbPx, const char *Px); char *wcreatedibpatternbrush_srcbm16_set(uint32_t *ihBrush, WMFHANDLES *wht, - uint32_t iUsage, const PU_BITMAP16 Bm16); -char *wcreatepatternbrush_set(uint32_t *ihBrush, WMFHANDLES *wht, PU_BITMAP16 Bm16, char *Pattern); -char *wcreatefontindirect_set(uint32_t *ihFont, WMFHANDLES *wht, PU_FONT uf); -char *wcreatepalette_set(uint32_t *ihPal, WMFHANDLES *wht, PU_PALETTE up); -char *wsetpaletteentries_set(uint32_t *ihPal, WMFHANDLES *wht, const PU_PALETTE Palletes); -char *wcreateregion_set(uint32_t *ihReg, WMFHANDLES *wht, const PU_REGION Region); + uint32_t iUsage, const U_BITMAP16 *Bm16); +char *wcreatepatternbrush_set(uint32_t *ihBrush, WMFHANDLES *wht, U_BITMAP16 *Bm16, char *Pattern); +char *wcreatefontindirect_set(uint32_t *ihFont, WMFHANDLES *wht, U_FONT *uf); +char *wcreatepalette_set(uint32_t *ihPal, WMFHANDLES *wht, U_PALETTE *up); +char *wsetpaletteentries_set(uint32_t *ihPal, WMFHANDLES *wht, const U_PALETTE *Palletes); +char *wcreateregion_set(uint32_t *ihReg, WMFHANDLES *wht, const U_REGION *Region); char *wbegin_path_set(void); char *wend_path_set(void); char *wlinecap_set(int32_t Type); @@ -1952,7 +2123,7 @@ char *wlinejoin_set(int32_t Type); char *wmiterlimit_set(int32_t limit); -char *U_WMRHEADER_set(PU_PAIRF size,unsigned int dpi); +char *U_WMRHEADER_set(U_PAIRF *size,unsigned int dpi); char *U_WMREOF_set(void); char *U_WMRSETBKCOLOR_set(U_COLORREF Color); char *U_WMRSETBKMODE_set(uint16_t Mode); @@ -1988,11 +2159,11 @@ char *U_WMRSETPIXEL_set(U_COLORREF Color, U_POINT16 coord); char *U_WMROFFSETCLIPRGN_set(U_POINT16 offset); char *U_WMRTEXTOUT_set(U_POINT16 Dst, char *string); char *U_WMRBITBLT_set(U_POINT16 Dst, U_POINT16 cwh, U_POINT16 Src, - uint32_t dwRop3, const PU_BITMAP16 Bm16); + uint32_t dwRop3, const U_BITMAP16 *Bm16); char *U_WMRSTRETCHBLT_set(U_POINT16 Dst, U_POINT16 cDst, U_POINT16 Src, - U_POINT16 cSrc, uint32_t dwRop3, const PU_BITMAP16 Bm16); -char *U_WMRPOLYGON_set(uint16_t Length, const PU_POINT16 Data); -char *U_WMRPOLYLINE_set(uint16_t Length, const PU_POINT16 Data); + U_POINT16 cSrc, uint32_t dwRop3, const U_BITMAP16 *Bm16); +char *U_WMRPOLYGON_set(uint16_t Length, const U_POINT16 * Data); +char *U_WMRPOLYLINE_set(uint16_t Length, const U_POINT16 * Data); char *U_WMRESCAPE_set(uint16_t Escape, uint16_t Length, const void *Data); char *U_WMRRESTOREDC_set(int16_t DC); char *U_WMRFILLREGION_set(uint16_t Region, uint16_t Brush); @@ -2002,16 +2173,16 @@ char *U_WMRPAINTREGION_set(uint16_t Region); char *U_WMRSELECTCLIPREGION_set(uint16_t Region); char *U_WMRSELECTOBJECT_set(uint16_t object); char *U_WMRSETTEXTALIGN_set(uint16_t Mode); -char *U_WMRDRAWTEXT_set(void); /* in Wine, not in WMF PDF. */ +char *U_WMRDRAWTEXT_set(void); /* in GDI and Wine, not in WMF manual. */ char *U_WMRCHORD_set(U_POINT16 Radial1, U_POINT16 Radial2, U_RECT16 rect); char *U_WMRSETMAPPERFLAGS_set(uint32_t Mode); char *U_WMREXTTEXTOUT_set(U_POINT16 Dst, int16_t Length, uint16_t Opts, const char *string, int16_t *dx, U_RECT16 rect); char *U_WMRSETDIBTODEV_set(void); char *U_WMRSELECTPALETTE_set(uint16_t Palette); char *U_WMRREALIZEPALETTE_set(void); -char *U_WMRANIMATEPALETTE_set(PU_PALETTE Palette); -char *U_WMRSETPALENTRIES_set(PU_PALETTE Palette); -char *U_WMRPOLYPOLYGON_set(const uint16_t, const uint16_t *aPolyCounts, const PU_POINT16 points); +char *U_WMRANIMATEPALETTE_set(U_PALETTE *Palette); +char *U_WMRSETPALENTRIES_set(const U_PALETTE *Palette); +char *U_WMRPOLYPOLYGON_set(const uint16_t, const uint16_t *aPolyCounts, const U_POINT16 * points); char *U_WMRRESIZEPALETTE_set(uint16_t Palette); char *U_WMR3A_set(void); char *U_WMR3B_set(void); @@ -2020,13 +2191,13 @@ char *U_WMR3D_set(void); char *U_WMR3E_set(void); char *U_WMR3F_set(void); char *U_WMRDIBBITBLT_set(U_POINT16 Dst, U_POINT16 cwh, U_POINT16 Src, - uint32_t dwRop3, const PU_BITMAPINFO Bmi, uint32_t cbPx, const char *Px); + uint32_t dwRop3, const U_BITMAPINFO * Bmi, uint32_t cbPx, const char *Px); char *U_WMRDIBSTRETCHBLT_set(U_POINT16 Dst, U_POINT16 cDst, U_POINT16 Src, - U_POINT16 cSrc, uint32_t dwRop3, const PU_BITMAPINFO Bmi, uint32_t cbPx, const char *Px); + U_POINT16 cSrc, uint32_t dwRop3, const U_BITMAPINFO *Bmi, uint32_t cbPx, const char *Px); char *U_WMRDIBCREATEPATTERNBRUSH_set(const uint16_t Style, const uint16_t iUsage, - PU_BITMAPINFO Bmi, uint32_t cbPx, const char *Px, PU_BITMAP16 Bm16); + const U_BITMAPINFO *Bmi, uint32_t cbPx, const char *Px, const U_BITMAP16 *Bm16); char *U_WMRSTRETCHDIB_set(U_POINT16 Dest, U_POINT16 cDest, U_POINT16 Src, U_POINT16 cSrc, - const uint16_t cUsage, uint32_t dwRop3, const PU_BITMAPINFO Bmi, uint32_t cbPx, const char *Px); + const uint16_t cUsage, uint32_t dwRop3, const U_BITMAPINFO *Bmi, uint32_t cbPx, const char *Px); char *U_WMR44_set(void); char *U_WMR45_set(void); char *U_WMR46_set(void); @@ -2206,21 +2377,21 @@ char *U_WMRF3_set(void); char *U_WMRF4_set(void); char *U_WMRF5_set(void); char *U_WMRF6_set(void); -char *U_WMRCREATEPALETTE_set(PU_PALETTE Palette); +char *U_WMRCREATEPALETTE_set(U_PALETTE *Palette); char *U_WMRF8_set(void); -char *U_WMRCREATEPATTERNBRUSH_set(PU_BITMAP16 Bm16, char *Pattern); +char *U_WMRCREATEPATTERNBRUSH_set(U_BITMAP16 *Bm16, char *Pattern); char *U_WMRCREATEPENINDIRECT_set(U_PEN pen); -char *U_WMRCREATEFONTINDIRECT_set(PU_FONT font); +char *U_WMRCREATEFONTINDIRECT_set(U_FONT *font); char *U_WMRCREATEBRUSHINDIRECT_set(U_WLOGBRUSH brush); -char *U_WMRCREATEBITMAPINDIRECT_set(void); /* in Wine, not in WMF PDF*/ -char *U_WMRCREATEBITMAP_set(void); /* in Wine, not in WMF PDF */ -char *U_WMRCREATEREGION_set(PU_REGION region); +char *U_WMRCREATEBITMAPINDIRECT_set(void); /* in GDI and Wine, not in WMF manual. */ +char *U_WMRCREATEBITMAP_set(void); /* in GDI and Wine, not in WMF manual. */ +char *U_WMRCREATEREGION_set(const U_REGION *region); int16_t *dx16_get( int32_t height, uint32_t weight, uint32_t members); size_t U_WMRRECSAFE_get(const char *contents, const char *blimit); -int wmfheader_get(const char *contents, const char *blimit, PU_WMRPLACEABLE Placeable, PU_WMRHEADER Header); +int wmfheader_get(const char *contents, const char *blimit, U_WMRPLACEABLE *Placeable, U_WMRHEADER *Header); int wmr_arc_points(U_RECT16 rclBox, U_POINT16 ArcStart, U_POINT16 ArcEnd, - int *f1, int f2, PU_PAIRF center, PU_PAIRF start, PU_PAIRF end, PU_PAIRF size ); + int *f1, int f2, U_PAIRF *center, U_PAIRF *start, U_PAIRF *end, U_PAIRF *size ); void U_BITMAPINFOHEADER_get(const char *Bmih, uint32_t *Size, int32_t *Width, int32_t *Height, uint32_t *Planes, uint32_t *BitCount, uint32_t *Compression, uint32_t *SizeImage, int32_t *XPelsPerMeter, int32_t *YPelsPerMeter, uint32_t *ClrUsed, uint32_t *ClrImportant); @@ -2228,7 +2399,7 @@ void U_BITMAPCOREHEADER_get(const char *BmiCh, int32_t *Size, int32_t *W int wget_DIB_params(const char *dib, const char **px, const U_RGBQUAD **ct, int32_t *numCt, int32_t *width, int32_t *height, int32_t *colortype, int32_t *invert); int U_WMREOF_get(const char *contents); -int U_WMRSETBKCOLOR_get(const char *contents, PU_COLORREF Color); +int U_WMRSETBKCOLOR_get(const char *contents, U_COLORREF *Color); int U_WMRSETBKMODE_get(const char *contents, uint16_t *Mode); int U_WMRSETMAPMODE_get(const char *contents, uint16_t *Mode); int U_WMRSETROP2_get(const char *contents, uint16_t *Mode); @@ -2236,33 +2407,33 @@ int U_WMRSETRELABS_get(const char *contents); int U_WMRSETPOLYFILLMODE_get(const char *contents, uint16_t *Mode); int U_WMRSETSTRETCHBLTMODE_get(const char *contents, uint16_t *Mode); int U_WMRSETTEXTCHAREXTRA_get(const char *contents, uint16_t *Mode); -int U_WMRSETTEXTCOLOR_get(const char *contents, PU_COLORREF Color); +int U_WMRSETTEXTCOLOR_get(const char *contents, U_COLORREF *Color); int U_WMRSETTEXTJUSTIFICATION_get(const char *contents, uint16_t *Count, uint16_t *Extra); -int U_WMRSETWINDOWORG_get(const char *contents, PU_POINT16 coord); -int U_WMRSETWINDOWEXT_get(const char *contents, PU_POINT16 extent); -int U_WMRSETVIEWPORTORG_get(const char *contents, PU_POINT16 coord); -int U_WMRSETVIEWPORTEXT_get(const char *contents, PU_POINT16 extent); -int U_WMROFFSETWINDOWORG_get(const char *contents, PU_POINT16 offset); -int U_WMRSCALEWINDOWEXT_get(const char *contents, PU_POINT16 Denom, PU_POINT16 Num); -int U_WMROFFSETVIEWPORTORG_get(const char *contents, PU_POINT16 offset); -int U_WMRSCALEVIEWPORTEXT_get(const char *contents, PU_POINT16 Denom, PU_POINT16 Num); -int U_WMRLINETO_get(const char *contents, PU_POINT16 coord); -int U_WMRMOVETO_get(const char *contents, PU_POINT16 coord); -int U_WMREXCLUDECLIPRECT_get(const char *contents, PU_RECT16 rect); -int U_WMRINTERSECTCLIPRECT_get(const char *contents, PU_RECT16 rect); -int U_WMRARC_get(const char *contents, PU_POINT16 StartArc, PU_POINT16 EndArc, PU_RECT16 rect); -int U_WMRELLIPSE_get(const char *contents, PU_RECT16 rect); -int U_WMRFLOODFILL_get(const char *contents, uint16_t *Mode, PU_COLORREF Color, PU_POINT16 coord); -int U_WMRPIE_get(const char *contents, PU_POINT16 Radial1, PU_POINT16 Radial2, PU_RECT16 rect); -int U_WMRRECTANGLE_get(const char *contents, PU_RECT16 rect); -int U_WMRROUNDRECT_get(const char *contents, int16_t *Width, int16_t *Height, PU_RECT16 rect); -int U_WMRPATBLT_get(const char *contents, PU_POINT16 Dst, PU_POINT16 cwh, uint32_t *dwRop3); +int U_WMRSETWINDOWORG_get(const char *contents, U_POINT16 * coord); +int U_WMRSETWINDOWEXT_get(const char *contents, U_POINT16 * extent); +int U_WMRSETVIEWPORTORG_get(const char *contents, U_POINT16 * coord); +int U_WMRSETVIEWPORTEXT_get(const char *contents, U_POINT16 * extent); +int U_WMROFFSETWINDOWORG_get(const char *contents, U_POINT16 * offset); +int U_WMRSCALEWINDOWEXT_get(const char *contents, U_POINT16 * Denom, U_POINT16 * Num); +int U_WMROFFSETVIEWPORTORG_get(const char *contents, U_POINT16 * offset); +int U_WMRSCALEVIEWPORTEXT_get(const char *contents, U_POINT16 * Denom, U_POINT16 * Num); +int U_WMRLINETO_get(const char *contents, U_POINT16 * coord); +int U_WMRMOVETO_get(const char *contents, U_POINT16 * coord); +int U_WMREXCLUDECLIPRECT_get(const char *contents, U_RECT16 * rect); +int U_WMRINTERSECTCLIPRECT_get(const char *contents, U_RECT16 * rect); +int U_WMRARC_get(const char *contents, U_POINT16 * StartArc, U_POINT16 * EndArc, U_RECT16 * rect); +int U_WMRELLIPSE_get(const char *contents, U_RECT16 * rect); +int U_WMRFLOODFILL_get(const char *contents, uint16_t *Mode, U_COLORREF *Color, U_POINT16 * coord); +int U_WMRPIE_get(const char *contents, U_POINT16 * Radial1, U_POINT16 * Radial2, U_RECT16 * rect); +int U_WMRRECTANGLE_get(const char *contents, U_RECT16 * rect); +int U_WMRROUNDRECT_get(const char *contents, int16_t *Width, int16_t *Height, U_RECT16 * rect); +int U_WMRPATBLT_get(const char *contents, U_POINT16 * Dst, U_POINT16 * cwh, uint32_t *dwRop3); int U_WMRSAVEDC_get(const char *contents); -int U_WMRSETPIXEL_get(const char *contents, PU_COLORREF Color, PU_POINT16 coord); -int U_WMROFFSETCLIPRGN_get(const char *contents, PU_POINT16 offset); -int U_WMRTEXTOUT_get(const char *contents, PU_POINT16 Dst, int16_t *Length, const char **string); -int U_WMRBITBLT_get(const char *contents, PU_POINT16 Dst, PU_POINT16 cwh, PU_POINT16 Src, uint32_t *dwRop3, PU_BITMAP16 Bm16, const char **px); -int U_WMRSTRETCHBLT_get(const char *contents, PU_POINT16 Dst, PU_POINT16 cDst, PU_POINT16 Src, PU_POINT16 cSrc, uint32_t *dwRop3, PU_BITMAP16 Bm16, const char **px); +int U_WMRSETPIXEL_get(const char *contents, U_COLORREF *Color, U_POINT16 * coord); +int U_WMROFFSETCLIPRGN_get(const char *contents, U_POINT16 * offset); +int U_WMRTEXTOUT_get(const char *contents, U_POINT16 * Dst, int16_t *Length, const char **string); +int U_WMRBITBLT_get(const char *contents, U_POINT16 * Dst, U_POINT16 * cwh, U_POINT16 * Src, uint32_t *dwRop3, U_BITMAP16 *Bm16, const char **px); +int U_WMRSTRETCHBLT_get(const char *contents, U_POINT16 * Dst, U_POINT16 * cDst, U_POINT16 * Src, U_POINT16 * cSrc, uint32_t *dwRop3, U_BITMAP16 *Bm16, const char **px); int U_WMRPOLYGON_get(const char *contents, uint16_t *Length, const char **Data); int U_WMRPOLYLINE_get(const char *contents, uint16_t *Length, const char **Data); int U_WMRESCAPE_get(const char *contents, uint16_t *Escape, uint16_t *Length, const char **Data); @@ -2274,15 +2445,15 @@ int U_WMRPAINTREGION_get(const char *contents, uint16_t *Region); int U_WMRSELECTCLIPREGION_get(const char *contents, uint16_t *Region); int U_WMRSELECTOBJECT_get(const char *contents, uint16_t *Object); int U_WMRSETTEXTALIGN_get(const char *contents, uint16_t *Mode); -int U_WMRDRAWTEXT_get(void); /* in Wine, not in WMF PDF. */ -int U_WMRCHORD_get(const char *contents, PU_POINT16 Radial1, PU_POINT16 Radial2, PU_RECT16 rect); +int U_WMRDRAWTEXT_get(void); /* in GDI and Wine, not in WMF manual. */ +int U_WMRCHORD_get(const char *contents, U_POINT16 * Radial1, U_POINT16 * Radial2, U_RECT16 * rect); int U_WMRSETMAPPERFLAGS_get(const char *contents, uint32_t *Mode); -int U_WMREXTTEXTOUT_get(const char *contents, PU_POINT16 Dst, int16_t *Length, uint16_t *Opts, const char **string, const int16_t **dx, PU_RECT16 rect); -int U_WMRSETDIBTODEV_get(const char *contents, PU_POINT16 Dst, PU_POINT16 cwh, PU_POINT16 Src, uint16_t *cUsage, uint16_t *ScanCount, uint16_t *StartScan, const char **dib); +int U_WMREXTTEXTOUT_get(const char *contents, U_POINT16 * Dst, int16_t *Length, uint16_t *Opts, const char **string, const int16_t **dx, U_RECT16 * rect); +int U_WMRSETDIBTODEV_get(const char *contents, U_POINT16 * Dst, U_POINT16 * cwh, U_POINT16 * Src, uint16_t *cUsage, uint16_t *ScanCount, uint16_t *StartScan, const char **dib); int U_WMRSELECTPALETTE_get(const char *contents, uint16_t *Palette); int U_WMRREALIZEPALETTE_get(const char *contents); -int U_WMRANIMATEPALETTE_get(const char *contents, PU_PALETTE Palette, const char **PalEntries); -int U_WMRSETPALENTRIES_get(const char *contents, PU_PALETTE Palette, const char **PalEntries); +int U_WMRANIMATEPALETTE_get(const char *contents, U_PALETTE *Palette, const char **PalEntries); +int U_WMRSETPALENTRIES_get(const char *contents, U_PALETTE *Palette, const char **PalEntries); int U_WMRPOLYPOLYGON_get(const char *contents, uint16_t *nPolys, const uint16_t **aPolyCounts, const char **Points); int U_WMRRESIZEPALETTE_get(const char *contents, uint16_t *Palette); int U_WMR3A_get(void); @@ -2291,15 +2462,15 @@ int U_WMR3C_get(void); int U_WMR3D_get(void); int U_WMR3E_get(void); int U_WMR3F_get(void); -int U_WMRDIBBITBLT_get(const char *contents, PU_POINT16 Dst, PU_POINT16 cwh, PU_POINT16 Src, uint32_t *dwRop3, const char **dib); -int U_WMRDIBSTRETCHBLT_get(const char *contents, PU_POINT16 Dst, PU_POINT16 cDst, PU_POINT16 Src, PU_POINT16 cSrc, uint32_t *dwRop3, const char **dib); +int U_WMRDIBBITBLT_get(const char *contents, U_POINT16 * Dst, U_POINT16 * cwh, U_POINT16 * Src, uint32_t *dwRop3, const char **dib); +int U_WMRDIBSTRETCHBLT_get(const char *contents, U_POINT16 * Dst, U_POINT16 * cDst, U_POINT16 * Src, U_POINT16 * cSrc, uint32_t *dwRop3, const char **dib); int U_WMRDIBCREATEPATTERNBRUSH_get(const char *contents, uint16_t *Style, uint16_t *cUsage, const char **Bm16, const char **dib); -int U_WMRSTRETCHDIB_get(const char *contents, PU_POINT16 Dst, PU_POINT16 cDst, PU_POINT16 Src, PU_POINT16 cSrc, uint16_t *cUsage, uint32_t *dwRop3, const char **dib); +int U_WMRSTRETCHDIB_get(const char *contents, U_POINT16 * Dst, U_POINT16 * cDst, U_POINT16 * Src, U_POINT16 * cSrc, uint16_t *cUsage, uint32_t *dwRop3, const char **dib); int U_WMR44_get(void); int U_WMR45_get(void); int U_WMR46_get(void); int U_WMR47_get(void); -int U_WMREXTFLOODFILL_get(const char *contents, uint16_t *Mode, PU_COLORREF Color, PU_POINT16 coord); +int U_WMREXTFLOODFILL_get(const char *contents, uint16_t *Mode, U_COLORREF *Color, U_POINT16 * coord); int U_WMR49_get(void); int U_WMR4A_get(void); int U_WMR4B_get(void); @@ -2474,15 +2645,16 @@ int U_WMRF3_get(void); int U_WMRF4_get(void); int U_WMRF5_get(void); int U_WMRF6_get(void); -int U_WMRCREATEPALETTE_get(const char *contents, PU_PALETTE Palette, const char **PalEntries); +int U_WMRCREATEPALETTE_get(const char *contents, U_PALETTE *Palette, const char **PalEntries); int U_WMRF8_get(void); -int U_WMRCREATEPATTERNBRUSH_get(const char *contents, PU_BITMAP16 Bm16, int *pasize, const char **Pattern); -int U_WMRCREATEPENINDIRECT_get(const char *contents, PU_PEN pen); +int U_WMRCREATEPATTERNBRUSH_get(const char *contents, U_BITMAP16 *Bm16, int *pasize, const char **Pattern); +int U_WMRCREATEPENINDIRECT_get(const char *contents, U_PEN *pen); int U_WMRCREATEFONTINDIRECT_get(const char *contents, const char **font); int U_WMRCREATEBRUSHINDIRECT_get(const char *contents, const char **brush); int U_WMRCREATEBITMAPINDIRECT_get(void); int U_WMRCREATEBITMAP_get(void); int U_WMRCREATEREGION_get(const char *contents, const char **Region); +//! \endcond #ifdef __cplusplus diff --git a/src/libuemf/uwmf_endian.c b/src/libuemf/uwmf_endian.c index e14c7aa77..6caa24d8f 100644 --- a/src/libuemf/uwmf_endian.c +++ b/src/libuemf/uwmf_endian.c @@ -1,5 +1,7 @@ /** - @file uwmf_endian.c Functions for Swaping WMF records + @file uwmf_endian.c + + @brief Functions for converting WMF records between Big Endian and Little Endian byte orders. */ /* @@ -23,7 +25,7 @@ extern "C" { #include "uwmf_endian.h" // hide almost everything in this file from Doxygen -//! @cond +//! \cond /* Prototypes for functions used here and defined in uemf_endian.c, but which are not supposed to be used in end user code. */ @@ -273,8 +275,6 @@ int wmfheader_swap( -// hide these from Doxygen -//! @cond /* ********************************************************************************************** These functions contain shared code used by various U_WMR*_Swap functions. These should NEVER be called by end user code and to further that end prototypes are NOT provided and they are hidden from Doxygen. @@ -327,9 +327,6 @@ void U_WMRCORE_U16_CR_2U16_swap(char *record, int torev){ U_swap2(record+off, 2); } - -//! @endcond - /* ********************************************************************************************** These are the core WMR functions, each creates a particular type of record. All return these records via a char* pointer, which is NULL if the call failed. @@ -1465,7 +1462,7 @@ void U_WMRCREATEREGION_swap(char *record, int torev){ U_WMRCORE_SIZE16_swap(record, torev); region_swap(record + offsetof(U_WMRCREATEREGION,region), torev); } -//! @endcond +//! \endcond /** \brief Convert an entire WMF in memory from Big Endian to Little Endian (or vice versa). diff --git a/src/libuemf/uwmf_endian.h b/src/libuemf/uwmf_endian.h index dc01c0d07..57fd4ae44 100644 --- a/src/libuemf/uwmf_endian.h +++ b/src/libuemf/uwmf_endian.h @@ -1,11 +1,13 @@ /** - @file uemf_endian.h Prototype for function for converting EMF records between Big Endian and Little Endian + @file uwmf_endian.h + + @brief Prototypes for functions for converting WMF records between Big Endian and Little Endian */ /* File: uwmf_endian.h -Version: 0.0.1 -Date: 10-JAN-2013 +Version: 0.0.2 +Date: 26-NOV-2013 Author: David Mathog, Biology Division, Caltech email: mathog@caltech.edu Copyright: 2013 David Mathog and California Institute of Technology (Caltech) @@ -20,17 +22,10 @@ extern "C" { #include "uemf_endian.h" -/* There is no way for the preprocessor, in general, to figure out endianness. So the command line must define - WORDS_BIGENDIAN for a big endian machine. Otherwise we assume is is little endian. If it is something - else this code won't work in any case. */ -#ifdef WORDS_BIGENDIAN -#define U_BYTE_SWAP 1 -#else -#define U_BYTE_SWAP 0 -#endif - +//! \cond // prototypes int U_wmf_endian(char *contents, size_t length, int torev); +//! \endcond #ifdef __cplusplus } diff --git a/src/libuemf/uwmf_print.c b/src/libuemf/uwmf_print.c index d044cf9b6..d120a2da0 100644 --- a/src/libuemf/uwmf_print.c +++ b/src/libuemf/uwmf_print.c @@ -1,11 +1,13 @@ /** - @file uwmf_print.c Functions for printing WMF records + @file uwmf_print.c + + @brief Functions for printing WMF records */ /* File: uwmf_print.c -Version: 0.0.2 -Date: 18-FEB-2013 +Version: 0.0.3 +Date: 17-OCT-2013 Author: David Mathog, Biology Division, Caltech email: mathog@caltech.edu Copyright: 2012 David Mathog and California Institute of Technology (Caltech) @@ -21,6 +23,10 @@ extern "C" { #include <string.h> #include "uwmf_print.h" +//! \cond + +#define UNUSED(x) (void)(x) + /* ********************************************************************************************** These functions print standard objects used in the WMR records. The low level ones do not append EOL. @@ -112,7 +118,7 @@ void pltntry_print( \param PalEntries Array of Palette Entries */ void palette_print( - const PU_PALETTE p, + const U_PALETTE *p, const char *PalEntries ){ int i; @@ -374,8 +380,6 @@ int wmfheader_print( -// hide these from Doxygen -//! @cond /* ********************************************************************************************** These functions contain shared code used by various U_WMR*_print functions. These should NEVER be called by end user code and to further that end prototypes are NOT provided and they are hidden from Doxygen. @@ -395,8 +399,6 @@ void wcore_points_print(uint16_t nPoints, const char *aPoints){ -//! @endcond - /* ********************************************************************************************** These are the core WMR functions, each creates a particular type of record. All return these records via a char* pointer, which is NULL if the call failed. @@ -408,12 +410,12 @@ They are listed in order by the corresponding U_WMR_* index number. \param contents pointer to a buffer holding a WMR record */ void U_WMRNOTIMPLEMENTED_print(const char *contents){ - (void) contents; + UNUSED(contents); printf(" Not Implemented!\n"); } void U_WMREOF_print(const char *contents){ - (void) contents; + UNUSED(contents); } void U_WMRSETBKCOLOR_print(const char *contents){ @@ -449,7 +451,7 @@ void U_WMRSETROP2_print(const char *contents){ } void U_WMRSETRELABS_print(const char *contents){ - (void) contents; + UNUSED(contents); /* This record type has only the common 6 bytes, so nothing (else) to print */ } @@ -685,7 +687,7 @@ void U_WMRPATBLT_print(const char *contents){ } void U_WMRSAVEDC_print(const char *contents){ - (void) contents; + UNUSED(contents); /* This record type has only the common 6 bytes, so nothing (else) to print */ } @@ -790,7 +792,7 @@ void U_WMRESCAPE_print(const char *contents){ } void U_WMRRESTOREDC_print(const char *contents){ - (void) contents; + UNUSED(contents); /* This record type has only the common 6 bytes, so nothing (else) to print */ } @@ -933,7 +935,7 @@ void U_WMRSELECTPALETTE_print(const char *contents){ } void U_WMRREALIZEPALETTE_print(const char *contents){ - (void) contents; + UNUSED(contents); /* This record type has only the common 6 bytes, so nothing (else) to print */ } @@ -1324,6 +1326,8 @@ void U_WMRCREATEREGION_print(const char *contents){ } } +//! \endcond + /** \brief Print any record in a wmf \returns record length for a normal record, 0 for WMREOF, -1 for a bad record @@ -1347,11 +1351,11 @@ int U_wmf_onerec_print(const char *contents, const char *blimit, int recnum, siz iType = *(uint8_t *)(contents + offsetof(U_METARECORD, iType ) ); -#if 1 /* show record checksums, this is NOT portable, result changes with endian type, useful for debugging */ - printf("%-30srecord:%5d type:%3u offset:%8d size:%8u\n", +#if 1 + printf("%-30srecord:%5d type:%-4u offset:%8d rsize:%8u\n", U_wmr_names(iType), recnum, iType, (int) off, (int) size); -#else - printf("%-30srecord:%5d type:%3u offset:%8d size:%8u recchecksum:%u\n", +#else /* show record checksums, this is NOT portable, result changes with endian type, useful for debugging */ + printf("%-30srecord:%5d type:%-4u offset:%8d size:%8u recchecksum:%u\n", U_wmr_names(iType), recnum, iType, (int) off, (int) size, U_16_checksum((int16_t *)contents, size)); #endif diff --git a/src/libuemf/uwmf_print.h b/src/libuemf/uwmf_print.h index 31a8df5dc..8daee0feb 100644 --- a/src/libuemf/uwmf_print.h +++ b/src/libuemf/uwmf_print.h @@ -1,5 +1,7 @@ /** - @file uwmf_print.h Functions for printing records from WMF files. + @file uwmf_print.h + + @brief Prototypes for functions for printing records from WMF files. */ /* @@ -20,11 +22,12 @@ extern "C" { #include "uwmf.h" #include "uemf_print.h" +//! \cond /* prototypes for objects used in WMR records (other than those defined in uemf_print.h) */ void brush_print(U_BRUSH b); void font_print(const char *font); void pltntry_print(U_PLTNTRY pny); -void palette_print(const PU_PALETTE p, const char *PalEntries); +void palette_print(const U_PALETTE *p, const char *PalEntries); void pen_print(U_PEN p); void rect16_ltrb_print(U_RECT16 rect); void rect16_brtl_print(U_RECT16 rect); @@ -40,6 +43,7 @@ void dibheader_print(const void *dh); int wmfheader_print(const char *contents, const char *blimit); void U_WMRNOTIMPLEMENTED_print(const char *contents); int U_wmf_onerec_print(const char *contents, const char *blimit, int recnum, size_t off); +//! \endcond #ifdef __cplusplus } diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 29da403e8..5f584f92d 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -491,11 +491,13 @@ Effect::addHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) { } /** - * Return a vector of PathVectors which contain all helperpaths that should be drawn by the effect. - * This is the function called by external code like SPLPEItem. + * Return a vector of PathVectors which contain all canvas indicators for this effect. + * This is the function called by external code to get all canvas indicators (effect and its parameters) + * lpeitem = the item onto which this effect is applied + * @todo change return type to one pathvector, add all paths to one pathvector instead of maintaining a vector of pathvectors */ std::vector<Geom::PathVector> -Effect::getHelperPaths(SPLPEItem const* lpeitem) +Effect::getCanvasIndicators(SPLPEItem const* lpeitem) { std::vector<Geom::PathVector> hp_vec; @@ -504,18 +506,10 @@ Effect::getHelperPaths(SPLPEItem const* lpeitem) return hp_vec; } - // TODO: we can probably optimize this by using a lot more references - // rather than copying PathVectors all over the place - if (show_orig_path) { - // add original path to helperpaths - SPCurve* curve = SP_SHAPE(lpeitem)->getCurve (); - hp_vec.push_back(curve->get_pathvector()); - } - - // add other helperpaths provided by the effect itself + // add indicators provided by the effect itself addCanvasIndicators(lpeitem, hp_vec); - // add helperpaths provided by the effect's parameters + // add indicators provided by the effect's parameters for (std::vector<Parameter *>::iterator p = param_vector.begin(); p != param_vector.end(); ++p) { (*p)->addCanvasIndicators(lpeitem, hp_vec); } diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h index b9d86628f..1da9b4cc9 100644 --- a/src/live_effects/effect.h +++ b/src/live_effects/effect.h @@ -90,7 +90,7 @@ public: // (but spiro lpe still needs it!) virtual LPEPathFlashType pathFlashType() const { return DEFAULT; } void addHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); - std::vector<Geom::PathVector> getHelperPaths(SPLPEItem const* lpeitem); + std::vector<Geom::PathVector> getCanvasIndicators(SPLPEItem const* lpeitem); inline bool providesOwnFlashPaths() const { return provides_own_flash_paths || show_orig_path; diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index 8fec69958..e91677e18 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -161,14 +161,14 @@ CrossingPoints::CrossingPoints(std::vector<Geom::Path> const &paths) : std::vect for( unsigned j=i; j<paths.size(); j++){ for( unsigned jj=(i==j?ii:0); jj < size_nondegenerate(paths[j]); jj++){ std::vector<std::pair<double,double> > times; - if ( i==j && ii==jj){ + if ( (i==j) && (ii==jj) ) { // std::cout<<"--(self int)\n"; // std::cout << paths[i][ii].toSBasis()[Geom::X] <<"\n"; // std::cout << paths[i][ii].toSBasis()[Geom::Y] <<"\n"; find_self_intersections( times, paths[i][ii].toSBasis() ); - }else{ + } else { // std::cout<<"--(pair int)\n"; // std::cout << paths[i][ii].toSBasis()[Geom::X] <<"\n"; // std::cout << paths[i][ii].toSBasis()[Geom::Y] <<"\n"; @@ -180,15 +180,17 @@ CrossingPoints::CrossingPoints(std::vector<Geom::Path> const &paths) : std::vect } for (unsigned k=0; k<times.size(); k++){ //std::cout<<"intersection "<<i<<"["<<ii<<"]("<<times[k].first<<")= "<<j<<"["<<jj<<"]("<<times[k].second<<")\n"; - if (times[k].first == times[k].first && times[k].second == times[k].second ){//is this the way to test NaN? + if ( !IS_NAN(times[k].first) && !IS_NAN(times[k].second) ){ double zero = 1e-4; - if ( i==j && fabs(times[k].first+ii - times[k].second-jj)<=zero ){//this is just end=start of successive curves in a path. + if ( (i==j) && (fabs(times[k].first+ii - times[k].second-jj) <= zero) ) + { //this is just end=start of successive curves in a path. continue; } - if ( i==j && ii == 0 && jj == size_nondegenerate(paths[i])-1 && - paths[i].closed() && - fabs(times[k].first) <= zero && - fabs(times[k].second - 1) <= zero ){//this is just end=start of a closed path. + if ( (i==j) && (ii == 0) && (jj == size_nondegenerate(paths[i])-1) + && paths[i].closed() + && (fabs(times[k].first) <= zero) + && (fabs(times[k].second - 1) <= zero) ) + {//this is just end=start of a closed path. continue; } CrossingPoint cp; @@ -218,7 +220,7 @@ CrossingPoints::CrossingPoints(std::vector<Geom::Path> const &paths) : std::vect } unsigned count = 0; for ( std::map < double, unsigned >::iterator m=cuts.begin(); m!=cuts.end(); ++m ){ - if ( (*this)[m->second].i == i && (*this)[m->second].ti == m->first ){ + if ( ((*this)[m->second].i == i) && ((*this)[m->second].ti == m->first) ){ (*this)[m->second].ni = count; }else{ (*this)[m->second].nj = count; @@ -230,7 +232,7 @@ CrossingPoints::CrossingPoints(std::vector<Geom::Path> const &paths) : std::vect CrossingPoints::CrossingPoints(std::vector<double> const &input) : std::vector<CrossingPoint>() { - if (input.size()>0 && input.size()%9 ==0){ + if ( (input.size() > 0) && (input.size()%9 == 0) ){ using namespace Geom; for( unsigned n=0; n<input.size(); ){ CrossingPoint cp; @@ -273,10 +275,11 @@ CrossingPoint CrossingPoints::get(unsigned const i, unsigned const ni) { for (unsigned k=0; k<size(); k++){ - if ( - ((*this)[k].i==i && (*this)[k].ni==ni) || - ((*this)[k].j==i && (*this)[k].nj==ni) - ) return (*this)[k]; + if ( ( ((*this)[k].i==i) && ((*this)[k].ni==ni) ) + || ( ((*this)[k].j==i) && ((*this)[k].nj==ni) ) ) + { + return (*this)[k]; + } } g_warning("LPEKnotNS::CrossingPoints::get error. %uth crossing along string %u not found.",ni,i); assert(false);//debug purpose... @@ -290,7 +293,7 @@ idx_of_nearest(CrossingPoints const &cpts, Geom::Point const &p) unsigned result = cpts.size(); for (unsigned k=0; k<cpts.size(); k++){ double dist_k = Geom::L2(p-cpts[k].pt); - if (dist<0 || dist>dist_k){ + if ( (dist < 0) || (dist > dist_k) ) { result = k; dist = dist_k; } @@ -304,28 +307,28 @@ void CrossingPoints::inherit_signs(CrossingPoints const &other, int default_value) { bool topo_changed = false; - for (unsigned n=0; n<size(); n++){ - if ( n<other.size() && - other[n].i == (*this)[n].i && - other[n].j == (*this)[n].j && - other[n].ni == (*this)[n].ni && - other[n].nj == (*this)[n].nj ) + for (unsigned n=0; n < size(); n++){ + if ( (n < other.size()) + && (other[n].i == (*this)[n].i) + && (other[n].j == (*this)[n].j) + && (other[n].ni == (*this)[n].ni) + && (other[n].nj == (*this)[n].nj) ) { (*this)[n].sign = other[n].sign; - }else{ + } else { topo_changed = true; break; } } - if (topo_changed){ + if (topo_changed) { //TODO: Find a way to warn the user!! // std::cout<<"knot topolgy changed!\n"; - for (unsigned n=0; n<size(); n++){ + for (unsigned n=0; n < size(); n++){ Geom::Point p = (*this)[n].pt; unsigned idx = idx_of_nearest(other,p); - if (idx<other.size()){ + if (idx < other.size()) { (*this)[n].sign = other[idx].sign; - }else{ + } else { (*this)[n].sign = default_value; } } @@ -412,7 +415,7 @@ LPEKnot::doEffect_path (std::vector<Geom::Path> const &path_in) std::vector<Interval> dom; dom.push_back(Interval(0., size_nondegenerate(gpaths[i0]))); for (unsigned p = 0; p < crossing_points.size(); p++){ - if (crossing_points[p].i == i0 || crossing_points[p].j == i0){ + if ( (crossing_points[p].i == i0) || (crossing_points[p].j == i0) ) { unsigned i = crossing_points[p].i; unsigned j = crossing_points[p].j; double ti = crossing_points[p].ti; @@ -475,14 +478,14 @@ LPEKnot::doEffect_path (std::vector<Geom::Path> const &path_in) //If the current path is closed and the last/first point is still there, glue first and last piece. unsigned beg_comp = 0, end_comp = dom.size(); - if ( gpaths[i0].closed() && dom.front().min() == 0 && dom.back().max() == size_nondegenerate(gpaths[i0]) ){ + if ( gpaths[i0].closed() && (dom.front().min() == 0) && (dom.back().max() == size_nondegenerate(gpaths[i0])) ) { if ( dom.size() == 1){ path_out.push_back(gpaths[i0]); continue; }else{ // std::cout<<"fusing first and last component\n"; - beg_comp++; - end_comp--; + ++beg_comp; + --end_comp; Path first = gpaths[i0].portion(dom.back()); //FIXME: STITCH_DISCONTINUOUS should not be necessary (?!?) first.append(gpaths[i0].portion(dom.front()), Path::STITCH_DISCONTINUOUS); @@ -594,19 +597,19 @@ LPEKnot::addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector<Geom::Pat double r = switcher_size*.1; char const * svgd; //TODO: use a nice path! - if (selectedCrossing >= crossing_points.size()||crossing_points[selectedCrossing].sign > 0){ + if ( (selectedCrossing >= crossing_points.size()) || (crossing_points[selectedCrossing].sign > 0) ) { //svgd = "M -10,0 A 10 10 0 1 0 0,-10 l 5,-1 -1,2"; svgd = "m -7.07,7.07 c 3.9,3.91 10.24,3.91 14.14,0 3.91,-3.9 3.91,-10.24 0,-14.14 -3.9,-3.91 -10.24,-3.91 -14.14,0 l 2.83,-4.24 0.7,2.12"; - }else if (crossing_points[selectedCrossing].sign < 0){ + } else if (crossing_points[selectedCrossing].sign < 0) { //svgd = "M 10,0 A 10 10 0 1 1 0,-10 l -5,-1 1,2"; svgd = "m 7.07,7.07 c -3.9,3.91 -10.24,3.91 -14.14,0 -3.91,-3.9 -3.91,-10.24 0,-14.14 3.9,-3.91 10.24,-3.91 14.14,0 l -2.83,-4.24 -0.7,2.12"; - }else{ + } else { //svgd = "M 10,0 A 10 10 0 1 0 -10,0 A 10 10 0 1 0 10,0 "; svgd = "M 10,0 C 10,5.52 5.52,10 0,10 -5.52,10 -10,5.52 -10,0 c 0,-5.52 4.48,-10 10,-10 5.52,0 10,4.48 10,10 z"; } PathVector pathv = sp_svg_read_pathv(svgd); pathv *= Affine(r,0,0,r,0,0); - pathv+=switcher; + pathv += switcher; hp_vec.push_back(pathv); } diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index 0533c1ed6..acf8ab6a5 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -24,7 +24,7 @@ #include <2geom/bezier-utils.h> #include <2geom/svg-elliptical-arc.h> #include <2geom/sbasis-to-bezier.h> -#include <2geom/svg-path.h> +#include <2geom/path-sink.h> #include <2geom/path-intersection.h> #include <2geom/crossing.h> #include <2geom/ellipse.h> @@ -537,7 +537,7 @@ static Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise<Geom::D2<Geom:: prev_i = i; } - pb.finish(); + pb.flush(); return pb.peek().front(); } diff --git a/src/rubberband.cpp b/src/rubberband.cpp index 08492837a..6ec4b3e45 100644 --- a/src/rubberband.cpp +++ b/src/rubberband.cpp @@ -99,6 +99,7 @@ void Inkscape::Rubberband::move(Geom::Point const &p) if (_mode == RUBBERBAND_MODE_RECT) { if (_rect == NULL) { _rect = static_cast<CtrlRect *>(sp_canvas_item_new(sp_desktop_controls(_desktop), SP_TYPE_CTRLRECT, NULL)); + _rect->setShadow(1, 0xffffffff); } _rect->setRectangle(Geom::Rect(_start, _end)); diff --git a/src/selcue.cpp b/src/selcue.cpp index 3f8a93e21..805629636 100644 --- a/src/selcue.cpp +++ b/src/selcue.cpp @@ -177,6 +177,7 @@ void Inkscape::SelCue::_newItemBboxes() SP_CTRLRECT(box)->setRectangle(*b); SP_CTRLRECT(box)->setColor(0x000000a0, 0, 0); SP_CTRLRECT(box)->setDashed(true); + SP_CTRLRECT(box)->setShadow(1, 0xffffffff); sp_canvas_item_move_to_z(box, 0); } diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp index 697b80608..25e4c07d7 100644 --- a/src/sp-ellipse.cpp +++ b/src/sp-ellipse.cpp @@ -29,7 +29,7 @@ #include <2geom/ellipse.h> #include <2geom/transforms.h> #include <2geom/pathvector.h> -#include <2geom/svg-path.h> +#include <2geom/path-sink.h> #include "document.h" #include "sp-ellipse.h" #include "preferences.h" @@ -441,7 +441,7 @@ void SPGenericEllipse::set_shape() pb.closePath(); } else { // arc only - pb.finish(); + pb.flush(); } curve = new SPCurve(pb.peek()); diff --git a/src/sp-image.cpp b/src/sp-image.cpp index 8f7a60ca6..b08d6f9b0 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -24,6 +24,7 @@ #include <2geom/rect.h> #include <2geom/transforms.h> #include <glibmm/i18n.h> +#include <glibmm/miscutils.h> #include "display/drawing-image.h" #include "display/cairo-utils.h" @@ -75,7 +76,7 @@ static void sp_image_set_curve(SPImage *image); -static Inkscape::Pixbuf *sp_image_repr_read_image(gchar const *href, gchar const *absref, gchar const *base ); +gchar const *sp_image_repr_read_filename(gchar const *href, gchar const *absref, gchar const *base ); static void sp_image_update_arenaitem (SPImage *img, Inkscape::DrawingImage *ai); static void sp_image_update_canvas_image (SPImage *image); @@ -333,11 +334,31 @@ void SPImage::update(SPCtx *ctx, unsigned int flags) { if (this->href) { Inkscape::Pixbuf *pixbuf = NULL; - pixbuf = sp_image_repr_read_image ( + + gchar const* filename = sp_image_repr_read_filename ( this->getRepr()->attribute("xlink:href"), this->getRepr()->attribute("sodipodi:absref"), doc->getBase()); - + + Inkscape::Pixbuf::create_from_data_uri(filename); + if (strncmp (filename,"data:", 5) == 0) { + filename += 5; + pixbuf = Inkscape::Pixbuf::create_from_data_uri(filename); + } else if(filename && g_str_has_suffix(filename, ".svg")) { + // TODO: We want to deal with svg images properly. This + // space allows us to do so later. + g_warning("Including svg images tags is not yet supported."); + } else if (filename) { + pixbuf = Inkscape::Pixbuf::create_from_file(filename); + } + if(!pixbuf) { + /* Nope: We do not find any valid pixmap file :-( */ + pixbuf = new Inkscape::Pixbuf( + gdk_pixbuf_new_from_xpm_data((const gchar **) brokenimage_xpm)); + + /* If the xpm doesn't load, our libraries are broken */ + g_assert (pixbuf != NULL); + } if (pixbuf) { // BLIP #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) @@ -646,86 +667,39 @@ Inkscape::DrawingItem* SPImage::show(Inkscape::Drawing &drawing, unsigned int /* return ai; } -Inkscape::Pixbuf *sp_image_repr_read_image(gchar const *href, gchar const *absref, gchar const *base) +gchar const *sp_image_repr_read_filename(gchar const *href, gchar const *absref, gchar const *base) { - Inkscape::Pixbuf *inkpb = 0; - gchar const *filename = href; - + if (filename != NULL) { if (strncmp (filename,"file:",5) == 0) { - gchar *fullname = g_filename_from_uri(filename, NULL, NULL); - if (fullname) { - inkpb = Inkscape::Pixbuf::create_from_file(fullname); - g_free(fullname); - if (inkpb != NULL) { - return inkpb; - } - } + filename = g_filename_from_uri(filename, NULL, NULL); } else if (strncmp (filename,"data:",5) == 0) { /* data URI - embedded image */ - filename += 5; - inkpb = Inkscape::Pixbuf::create_from_data_uri(filename); - if (inkpb != NULL) { - return inkpb; - } - } else { - - if (!g_path_is_absolute (filename)) { - /* try to load from relative pos combined with document base*/ - const gchar *docbase = base; - if (!docbase) { - docbase = "."; - } - gchar *fullname = g_build_filename(docbase, filename, NULL); - - // document base can be wrong (on the temporary doc when importing bitmap from a - // different dir) or unset (when doc is not saved yet), so we check for base+href existence first, - // and if it fails, we also try to use bare href regardless of its g_path_is_absolute - if (g_file_test (fullname, G_FILE_TEST_EXISTS) && !g_file_test (fullname, G_FILE_TEST_IS_DIR)) { - inkpb = Inkscape::Pixbuf::create_from_file(fullname); - if (inkpb != NULL) { - g_free (fullname); - return inkpb; - } - } - g_free (fullname); - } - - /* try filename as absolute */ - if (g_file_test (filename, G_FILE_TEST_EXISTS) && !g_file_test (filename, G_FILE_TEST_IS_DIR)) { - inkpb = Inkscape::Pixbuf::create_from_file(filename); - if (inkpb != NULL) { - return inkpb; - } - } + return filename; + } else if (!g_path_is_absolute (filename)) { + /* try to load from relative pos combined with document base*/ + const gchar *docbase = base; + if (!docbase) docbase = "."; + filename = g_build_filename(docbase, filename, NULL); } } + if (filename && g_file_test(filename, G_FILE_TEST_EXISTS) ) { + return filename; + } + /* at last try to load from sp absolute path name */ - filename = absref; - if (filename != NULL) { + if (absref != NULL && g_file_test(absref, G_FILE_TEST_EXISTS)) { // using absref is outside of SVG rules, so we must at least warn the user if ( base != NULL && href != NULL ) { g_warning ("<image xlink:href=\"%s\"> did not resolve to a valid image file (base dir is %s), now trying sodipodi:absref=\"%s\"", href, base, absref); } else { g_warning ("xlink:href did not resolve to a valid image file, now trying sodipodi:absref=\"%s\"", absref); } - - inkpb = Inkscape::Pixbuf::create_from_file(filename); - if (inkpb != NULL) { - return inkpb; - } + return absref; } - /* Nope: We do not find any valid pixmap file :-( */ - GdkPixbuf *pixbuf = gdk_pixbuf_new_from_xpm_data((const gchar **) brokenimage_xpm); - inkpb = new Inkscape::Pixbuf(pixbuf); - - /* It should be included xpm, so if it still does not does load, */ - /* our libraries are broken */ - g_assert (inkpb != NULL); - - return inkpb; + return NULL; } /* We assert that realpixbuf is either NULL or identical size to pixbuf */ diff --git a/src/sp-item-transform.cpp b/src/sp-item-transform.cpp index 250713beb..9dbe412d7 100644 --- a/src/sp-item-transform.cpp +++ b/src/sp-item-transform.cpp @@ -132,7 +132,7 @@ Geom::Affine get_scale_transform_for_uniform_stroke(Geom::Rect const &bbox_visua // We will now try to calculate the affine transformation required to transform the first visual bounding box into // the second one, while accounting for strokewidth - if ((fabs(w0 - r0) < 1e-6) && (fabs(h0 - r0) < 1e-6)) { + if ((fabs(w0 - stroke_x) < 1e-6) && (fabs(h0 - stroke_y) < 1e-6)) { return Geom::Affine(); } @@ -140,11 +140,11 @@ Geom::Affine get_scale_transform_for_uniform_stroke(Geom::Rect const &bbox_visua gdouble scale_y = 1; gdouble r1 = r0; - if ((fabs(w0 - r0) < 1e-6) || w1 == 0) { // We have a vertical line at hand + if ((fabs(w0 - stroke_x) < 1e-6) || w1 == 0) { // We have a vertical line at hand r1 = transform_stroke ? r0 * sqrt(h1/h0) : r0; scale_x = 1; scale_y = preserve ? h1/h0 : (h1 - r1)/(h0 - r0); - } else if ((fabs(h0 - r0) < 1e-6) || h1 == 0) { // We have a horizontal line at hand + } else if ((fabs(h0 - stroke_y) < 1e-6) || h1 == 0) { // We have a horizontal line at hand r1 = transform_stroke ? r0 * sqrt(w1/w0) : r0; scale_x = preserve ? w1/w0 : (w1 - r1)/(w0 - r0); scale_y = 1; diff --git a/src/svg/svg-path.cpp b/src/svg/svg-path.cpp index 135f9ff75..59dad9ead 100644 --- a/src/svg/svg-path.cpp +++ b/src/svg/svg-path.cpp @@ -40,7 +40,7 @@ #include <2geom/path.h> #include <2geom/curves.h> #include <2geom/sbasis-to-bezier.h> -#include <2geom/svg-path.h> +#include <2geom/path-sink.h> #include <2geom/svg-path-parser.h> #include <2geom/exception.h> #include <2geom/angle.h> @@ -59,13 +59,13 @@ Geom::PathVector sp_svg_read_pathv(char const * str) typedef std::back_insert_iterator<Geom::PathVector> Inserter; Inserter iter(pathv); - Geom::SVGPathGenerator<Inserter> generator(iter); + Geom::PathIteratorSink<Inserter> generator(iter); try { Geom::parse_svg_path(str, generator); } catch (Geom::SVGPathParseError &e) { - generator.finish(); + generator.flush(); // This warning is extremely annoying when testing //g_warning("Malformed SVG path, truncated path up to where error was found.\n Input path=\"%s\"\n Parsed path=\"%s\"", str, sp_svg_write_path(pathv)); } diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 38e05a1c7..6a3a4c3f1 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -47,6 +47,7 @@ #include "filters/blend.h" #include "filters/colormatrix.h" #include "filters/componenttransfer.h" +#include "filters/componenttransfer-funcnode.h" #include "filters/composite.h" #include "filters/convolvematrix.h" #include "filters/displacementmap.h" @@ -369,6 +370,36 @@ public: } }; +// Used for tableValue in feComponentTransfer +class EntryAttr : public Gtk::Entry, public AttrWidget +{ +public: + EntryAttr(const SPAttributeEnum a, char* tip_text) + : AttrWidget(a) + { + signal_changed().connect(signal_attr_changed().make_slot()); + if (tip_text) { + set_tooltip_text(tip_text); + } + } + + // No validity checking is done + Glib::ustring get_as_attribute() const + { + return get_text(); + } + + void set_from_attribute(SPObject* o) + { + const gchar* val = attribute_value(o); + if(val) { + set_text( val ); + } else { + set_text( "" ); + } + } +}; + /* Displays/Edits the matrix for feConvolveMatrix or feColorMatrix */ class FilterEffectsDialog::MatrixAttr : public Gtk::Frame, public AttrWidget { @@ -746,7 +777,7 @@ public: _groups[i] = new Gtk::VBox; b.pack_start(*_groups[i], false, false); } - _current_type = 0; + //_current_type = 0; If set to 0 then update_and_show() fails to update properly. } ~Settings() @@ -766,9 +797,9 @@ public: for(unsigned i = 0; i < _groups.size(); ++i) _groups[i]->hide(); } - if(t >= 0) - _groups[t]->show_all(); - + if(t >= 0) { + _groups[t]->show(); // Do not use show_all(), it shows children than should be hidden + } _dialog.set_attrs_locked(true); for(unsigned i = 0; i < _attrwidgets[_current_type].size(); ++i) _attrwidgets[_current_type][i]->set_from_attribute(ob); @@ -800,7 +831,10 @@ public: // LightSource LightSourceControl* add_lightsource(); - // CheckBox + // Component Transfer Values + ComponentTransferValues* add_componenttransfervalues(const Glib::ustring& label, SPFeFuncNode::Channel channel); + + // CheckButton CheckButtonAttr* add_checkbutton(bool def, const SPAttributeEnum attr, const Glib::ustring& label, const Glib::ustring& tv, const Glib::ustring& fv, char* tip_text = NULL) { @@ -938,6 +972,18 @@ public: add_attr_widget(combo->get_attrwidget()); return combo->get_attrwidget(); } + + // Entry + EntryAttr* add_entry(const SPAttributeEnum attr, + const Glib::ustring& label, + char* tip_text = NULL) + { + EntryAttr* entry = new EntryAttr(attr, tip_text); + add_widget(entry, label); + add_attr_widget(entry); + return entry; + } + private: void add_attr_widget(AttrWidget* a) { @@ -973,6 +1019,154 @@ private: int _current_type, _max_types; }; +// Displays sliders and/or tables for feComponentTransfer +class FilterEffectsDialog::ComponentTransferValues : public Gtk::Frame, public AttrWidget +{ +public: + ComponentTransferValues(FilterEffectsDialog& d, SPFeFuncNode::Channel channel) + : AttrWidget(SP_ATTR_INVALID), + _dialog(d), + _settings(d, _box, sigc::mem_fun(*this, &ComponentTransferValues::set_func_attr), COMPONENTTRANSFER_TYPE_ERROR), + _type(ComponentTransferTypeConverter, SP_ATTR_TYPE, false), + _channel(channel), + _funcNode(NULL) + { + set_shadow_type(Gtk::SHADOW_IN); + add(_box); + _box.add(_type); + _box.reorder_child(_type, 0); + _type.signal_changed().connect(sigc::mem_fun(*this, &ComponentTransferValues::on_type_changed)); + + _settings.type(COMPONENTTRANSFER_TYPE_LINEAR); + _settings.add_spinscale(1, SP_ATTR_SLOPE, _("Slope"), -10, 10, 0.1, 0.01, 2); + _settings.add_spinscale(0, SP_ATTR_INTERCEPT, _("Intercept"), -10, 10, 0.1, 0.01, 2); + + _settings.type(COMPONENTTRANSFER_TYPE_GAMMA); + _settings.add_spinscale(1, SP_ATTR_AMPLITUDE, _("Amplitude"), 0, 10, 0.1, 0.01, 2); + _settings.add_spinscale(1, SP_ATTR_EXPONENT, _("Exponent"), 0, 10, 0.1, 0.01, 2); + _settings.add_spinscale(0, SP_ATTR_OFFSET, _("Offset"), -10, 10, 0.1, 0.01, 2); + + _settings.type(COMPONENTTRANSFER_TYPE_TABLE); + _settings.add_entry(SP_ATTR_TABLEVALUES, _("Table")); + + _settings.type(COMPONENTTRANSFER_TYPE_DISCRETE); + _settings.add_entry(SP_ATTR_TABLEVALUES, _("Discrete")); + + //_settings.type(COMPONENTTRANSFER_TYPE_IDENTITY); + _settings.type(-1); // Force update_and_show() to show/hide windows correctly + } + + // FuncNode can be in any order so we must search to find correct one. + SPFeFuncNode* find_node(SPFeComponentTransfer* ct) + { + SPObject* node = ct->children; + SPFeFuncNode* funcNode = NULL; + bool found = false; + for(;node;node=node->next){ + funcNode = SP_FEFUNCNODE(node); + if( funcNode->channel == _channel ) { + found = true; + break; + } + } + if( !found ) + funcNode = NULL; + + return funcNode; + } + + void set_func_attr(const AttrWidget* input) + { + _dialog.set_attr( _funcNode, input->get_attribute(), input->get_as_attribute().c_str()); + } + + // Set new type and update widget visibility + virtual void set_from_attribute(SPObject* o) + { + // See componenttransfer.cpp + if(SP_IS_FECOMPONENTTRANSFER(o)) { + SPFeComponentTransfer* ct = SP_FECOMPONENTTRANSFER(o); + + _funcNode = find_node(ct); + if( _funcNode ) { + _type.set_from_attribute( _funcNode ); + } else { + // Create <funcNode> + SPFilterPrimitive* prim = _dialog._primitive_list.get_selected(); + if(prim) { + Inkscape::XML::Document *xml_doc = prim->document->getReprDoc(); + Inkscape::XML::Node *repr = NULL; + switch(_channel) { + case SPFeFuncNode::R: + repr = xml_doc->createElement("svg:feFuncR"); + break; + case SPFeFuncNode::G: + repr = xml_doc->createElement("svg:feFuncG"); + break; + case SPFeFuncNode::B: + repr = xml_doc->createElement("svg:feFuncB"); + break; + case SPFeFuncNode::A: + repr = xml_doc->createElement("svg:feFuncA"); + break; + } + + //XML Tree being used directly here while it shouldn't be. + prim->getRepr()->appendChild(repr); + Inkscape::GC::release(repr); + + // Now we should find it! + _funcNode = find_node(ct); + if( _funcNode ) { + _funcNode->setAttribute( "type", "identity" ); + } else { + //std::cout << "ERROR ERROR: feFuncX not found!" << std::endl; + } + } + } + + update(); + } + } + +private: + void on_type_changed() + { + SPFilterPrimitive* prim = _dialog._primitive_list.get_selected(); + if(prim) { + + _funcNode->getRepr()->setAttribute( "type", _type.get_as_attribute().c_str() ); + + SPFilter* filter = _dialog._filter_modifier.get_selected_filter(); + filter->requestModified(SP_OBJECT_MODIFIED_FLAG); + + DocumentUndo::done(prim->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("New transfer function type")); + update(); + } + } + + void update() + { + SPFilterPrimitive* prim = _dialog._primitive_list.get_selected(); + if(prim && _funcNode) { + _settings.show_and_update(_type.get_active_data()->id, _funcNode); + } + } + +public: + virtual Glib::ustring get_as_attribute() const + { + return ""; + } + + FilterEffectsDialog& _dialog; + Gtk::VBox _box; + Settings _settings; + ComboBoxEnum<FilterComponentTransferType> _type; + SPFeFuncNode::Channel _channel; // RGBA + SPFeFuncNode* _funcNode; +}; + // Settings for the three light source objects class FilterEffectsDialog::LightSourceControl : public AttrWidget { @@ -1012,6 +1206,9 @@ public: _settings.add_spinscale(1, SP_ATTR_SPECULAREXPONENT, _("Specular Exponent"), 1, 100, 1, 1, 0, _("Exponent value controlling the focus for the light source")); //TODO: here I have used 100 degrees as default value. But spec says that if not specified, no limiting cone is applied. So, there should be a way for the user to set a "no limiting cone" option. _settings.add_spinscale(100, SP_ATTR_LIMITINGCONEANGLE, _("Cone Angle"), 1, 100, 1, 1, 0, _("This is the angle between the spot light axis (i.e. the axis between the light source and the point to which it is pointing at) and the spot light cone. No light is projected outside this cone.")); + + _settings.type(-1); // Force update_and_show() to show/hide windows correctly + } Gtk::VBox& get_box() @@ -1102,6 +1299,16 @@ private: bool _locked; }; + // ComponentTransferValues +FilterEffectsDialog::ComponentTransferValues* FilterEffectsDialog::Settings::add_componenttransfervalues(const Glib::ustring& label, SPFeFuncNode::Channel channel) + { + ComponentTransferValues* ct = new ComponentTransferValues(_dialog, channel); + add_widget(ct, label); + add_attr_widget(ct); + return ct; + } + + FilterEffectsDialog::LightSourceControl* FilterEffectsDialog::Settings::add_lightsource() { LightSourceControl* ls = new LightSourceControl(_dialog); @@ -2527,7 +2734,6 @@ FilterEffectsDialog::FilterEffectsDialog() _sizegroup->set_ignore_hidden(); _add_primitive_type.remove_row(NR_FILTER_TILE); - _add_primitive_type.remove_row(NR_FILTER_COMPONENTTRANSFER); // Initialize widget hierarchy #if WITH_GTKMM_3_0 @@ -2629,15 +2835,10 @@ void FilterEffectsDialog::init_settings_widgets() colmat->signal_attr_changed().connect(sigc::mem_fun(*this, &FilterEffectsDialog::update_color_matrix)); _settings->type(NR_FILTER_COMPONENTTRANSFER); - _settings->add_notimplemented(); - /* - //TRANSLATORS: for info on "Slope" and "Intercept", see http://id.mind.net/~zona/mmts/functionInstitute/linearFunctions/lsif.html - _settings->add_combo(COMPONENTTRANSFER_TYPE_IDENTITY, SP_ATTR_TYPE, _("Type"), ComponentTransferTypeConverter); - _ct_slope = _settings->add_spinscale(1, SP_ATTR_SLOPE, _("Slope"), -10, 10, 0.1, 0.01, 2); - _ct_intercept = _settings->add_spinscale(0, SP_ATTR_INTERCEPT, _("Intercept"), -10, 10, 0.1, 0.01, 2); - _ct_amplitude = _settings->add_spinscale(1, SP_ATTR_AMPLITUDE, _("Amplitude"), 0, 10, 0.1, 0.01, 2); - _ct_exponent = _settings->add_spinscale(1, SP_ATTR_EXPONENT, _("Exponent"), 0, 10, 0.1, 0.01, 2); - _ct_offset = _settings->add_spinscale(0, SP_ATTR_OFFSET, _("Offset"), -10, 10, 0.1, 0.01, 2);*/ + _settings->add_componenttransfervalues(_("R:"), SPFeFuncNode::R); + _settings->add_componenttransfervalues(_("G:"), SPFeFuncNode::G); + _settings->add_componenttransfervalues(_("B:"), SPFeFuncNode::B); + _settings->add_componenttransfervalues(_("A:"), SPFeFuncNode::A); _settings->type(NR_FILTER_COMPOSITE); _settings->add_combo(COMPOSITE_OVER, SP_ATTR_OPERATOR, _("Operator:"), CompositeOperatorConverter); @@ -2953,21 +3154,6 @@ void FilterEffectsDialog::update_settings_sensitivity() _k3->set_sensitive(use_k); _k4->set_sensitive(use_k); -// Component transfer not yet implemented -/* - if(SP_IS_FECOMPONENTTRANSFER(prim)) { - SPFeComponentTransfer* ct = SP_FECOMPONENTTRANSFER(prim); - const bool linear = ct->type == COMPONENTTRANSFER_TYPE_LINEAR; - const bool gamma = ct->type == COMPONENTTRANSFER_TYPE_GAMMA; - - _ct_table->set_sensitive(ct->type == COMPONENTTRANSFER_TYPE_TABLE || ct->type == COMPONENTTRANSFER_TYPE_DISCRETE); - _ct_slope->set_sensitive(linear); - _ct_intercept->set_sensitive(linear); - _ct_amplitude->set_sensitive(gamma); - _ct_exponent->set_sensitive(gamma); - _ct_offset->set_sensitive(gamma); - } -*/ } void FilterEffectsDialog::update_color_matrix() diff --git a/src/ui/dialog/filter-effects-dialog.h b/src/ui/dialog/filter-effects-dialog.h index a2a2a3c6e..ccf79e60d 100644 --- a/src/ui/dialog/filter-effects-dialog.h +++ b/src/ui/dialog/filter-effects-dialog.h @@ -282,6 +282,7 @@ private: class Settings; class MatrixAttr; class ColorMatrixValues; + class ComponentTransferValues; class LightSourceControl; Settings* _settings; Settings* _filter_general_settings; @@ -290,6 +291,9 @@ private: // Color Matrix ColorMatrixValues* _color_matrix_values; + // Component Transfer + ComponentTransferValues* _component_transfer_values; + // Convolve Matrix MatrixAttr* _convolve_matrix; DualSpinButton* _convolve_order; @@ -297,7 +301,6 @@ private: // For controlling setting sensitivity Gtk::Widget* _k1, *_k2, *_k3, *_k4; - Gtk::Widget* _ct_table, *_ct_slope, *_ct_intercept, *_ct_amplitude, *_ct_exponent, *_ct_offset; // To prevent unwanted signals bool _locked; diff --git a/src/ui/dialog/new-from-template.cpp b/src/ui/dialog/new-from-template.cpp index 177f15195..71d1c22d0 100644 --- a/src/ui/dialog/new-from-template.cpp +++ b/src/ui/dialog/new-from-template.cpp @@ -44,10 +44,13 @@ NewFromTemplate::NewFromTemplate() void NewFromTemplate::_createFromTemplate() { _main_widget.createTemplate(); - - response(0); + _onClose(); } +void NewFromTemplate::_onClose() +{ + response(0); +} void NewFromTemplate::load_new_from_template() { diff --git a/src/ui/dialog/new-from-template.h b/src/ui/dialog/new-from-template.h index 8ebcb2863..2b40af2a6 100644 --- a/src/ui/dialog/new-from-template.h +++ b/src/ui/dialog/new-from-template.h @@ -23,6 +23,8 @@ namespace UI { class NewFromTemplate : public Gtk::Dialog { + +friend class TemplateLoadTab; public: static void load_new_from_template(); @@ -32,6 +34,7 @@ private: TemplateLoadTab _main_widget; void _createFromTemplate(); + void _onClose(); }; } diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index fb353fec1..c33920117 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -38,6 +38,7 @@ #include <gtkmm/liststore.h> #include <gtkmm/treemodelcolumn.h> #include <gtkmm/clipboard.h> +#include <glibmm/stringutils.h> #include <glibmm/i18n.h> #include "path-prefix.h" @@ -73,8 +74,6 @@ namespace Inkscape { namespace UI { -static Cache::SvgPreview svg_preview_cache; - namespace Dialog { // See: http://developer.gnome.org/gtkmm/stable/classGtk_1_1TreeModelColumnRecord.html @@ -276,7 +275,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : instanceConns.push_back(documentReplacedConn); get_symbols(); - draw_symbols( currentDocument ); /* Defaults to current document */ + add_symbols( currentDocument ); /* Defaults to current document */ sigc::connection desktopChangeConn = deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &SymbolsDialog::setTargetDesktop) ); @@ -329,7 +328,7 @@ void SymbolsDialog::rebuild() { addSymbol->set_sensitive( false ); removeSymbol->set_sensitive( false ); } - draw_symbols( symbolDocument ); + add_symbols( symbolDocument ); } void SymbolsDialog::insertSymbol() { @@ -540,7 +539,8 @@ void SymbolsDialog::get_symbols() { gchar *fullname = g_build_filename((*it).c_str(), filename, NULL); - if ( !Inkscape::IO::file_test( fullname, G_FILE_TEST_IS_DIR ) ) { + if ( !Inkscape::IO::file_test( fullname, G_FILE_TEST_IS_DIR ) + && ( Glib::str_has_suffix(fullname, ".svg") || Glib::str_has_suffix(fullname, ".vss") ) ) { Glib::ustring fn( filename ); Glib::ustring tag = fn.substr( fn.find_last_of(".") + 1 ); @@ -562,7 +562,7 @@ void SymbolsDialog::get_symbols() { symbol_doc = SPDocument::createNewDoc( fullname, FALSE ); if( symbol_doc ) { - gchar *title = symbol_doc->getRoot()->title(); + const gchar *title = g_dpgettext2(NULL, "Symbol", symbol_doc->getRoot()->title()); if( title == NULL ) { title = _("Unnamed Symbols"); } @@ -651,18 +651,18 @@ gchar const* SymbolsDialog::style_from_use( gchar const* id, SPDocument* documen return style; } -void SymbolsDialog::draw_symbols( SPDocument* symbolDocument ) { +void SymbolsDialog::add_symbols( SPDocument* symbolDocument ) { GSList* l = symbols_in_doc( symbolDocument ); for( ; l != NULL; l = l->next ) { SPObject* symbol = SP_OBJECT(l->data); if (SP_IS_SYMBOL(symbol)) { - draw_symbol( symbol ); + add_symbol( symbol ); } } } -void SymbolsDialog::draw_symbol( SPObject* symbol ) { +void SymbolsDialog::add_symbol( SPObject* symbol ) { SymbolColumns* columns = getColumns(); @@ -672,12 +672,12 @@ void SymbolsDialog::draw_symbol( SPObject* symbol ) { title = id; } - Glib::RefPtr<Gdk::Pixbuf> pixbuf = create_symbol_image(id, symbol ); + Glib::RefPtr<Gdk::Pixbuf> pixbuf = draw_symbol( symbol ); if( pixbuf ) { Gtk::ListStore::iterator row = store->append(); (*row)[columns->symbol_id] = Glib::ustring( id ); - (*row)[columns->symbol_title] = Glib::ustring( title ); + (*row)[columns->symbol_title] = Glib::ustring( g_dpgettext2(NULL, "Symbol", title) ); (*row)[columns->symbol_image] = pixbuf; } @@ -694,7 +694,7 @@ void SymbolsDialog::draw_symbol( SPObject* symbol ) { * the temporary document is rendered. */ Glib::RefPtr<Gdk::Pixbuf> -SymbolsDialog::create_symbol_image(gchar const *symbol_id, SPObject *symbol) +SymbolsDialog::draw_symbol(SPObject *symbol) { // Create a copy repr of the symbol with id="the_symbol" Inkscape::XML::Document *xml_doc = previewDocument->getReprDoc(); @@ -713,7 +713,8 @@ SymbolsDialog::create_symbol_image(gchar const *symbol_id, SPObject *symbol) if( !style ) { // If no default style in <symbol>, look in documents. if( symbol->document == currentDocument ) { - style = style_from_use( symbol_id, symbol->document ); + gchar const *id = symbol->getRepr()->attribute("id"); + style = style_from_use( id, symbol->document ); } else { style = symbol->document->getReprRoot()->attribute("style"); } @@ -722,9 +723,7 @@ SymbolsDialog::create_symbol_image(gchar const *symbol_id, SPObject *symbol) if( !style ) style = "fill:#bbbbbb;stroke:#808080"; // This is for display in Symbols dialog only - if( style ) { - repr->setAttribute( "style", style ); - } + if( style ) repr->setAttribute( "style", style ); // BUG: Symbols don't work if defined outside of <defs>. Causes Inkscape // crash when trying to read in such a file. @@ -733,7 +732,7 @@ SymbolsDialog::create_symbol_image(gchar const *symbol_id, SPObject *symbol) Inkscape::GC::release(repr); // Uncomment this to get the previewDocument documents saved (useful for debugging) - // FILE *fp = fopen (g_strconcat(symbol_id, ".svg", NULL), "w"); + // FILE *fp = fopen (g_strconcat(id, ".svg", NULL), "w"); // sp_repr_save_stream(previewDocument->getReprDoc(), fp); // fclose (fp); @@ -746,55 +745,31 @@ SymbolsDialog::create_symbol_image(gchar const *symbol_id, SPObject *symbol) previewDocument->getRoot()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); previewDocument->ensureUpToDate(); - // if( object_temp == NULL || !SP_IS_ITEM(object_temp) ) { - // //std::cout << " previewDocument broken?" << std::endl; - // //return 0; - // } - SPItem *item = SP_ITEM(object_temp); - unsigned psize = SYMBOL_ICON_SIZES[in_sizes]; - /* Update to renderable state */ - Glib::ustring key = svg_preview_cache.cache_key(previewDocument->getURI(), symbol_id, psize); - //std::cout << " Key: " << key << std::endl; - Glib::RefPtr<Gdk::Pixbuf> pixbuf(NULL); - GdkPixbuf *pixbuf_gobj = svg_preview_cache.get_preview_from_cache(key); - if (pixbuf_gobj) { - g_object_ref(pixbuf_gobj); // the reference in svg_preview_cache will get destroyed when it's freed - pixbuf = Glib::wrap(pixbuf_gobj); - } + // We could use cache here, but it doesn't really work with the structure + // of this user interface and we've already cached the pixbuf in the gtklist // Find object's bbox in document. // Note symbols can have own viewport... ignore for now. //Geom::OptRect dbox = item->geometricBounds(); Geom::OptRect dbox = item->documentVisualBounds(); - if (!dbox) { - //std::cout << " No dbox" << std::endl; - return pixbuf; - } - - if (!pixbuf) { + if (dbox) { /* Scale symbols to fit */ double scale = 1.0; double width = dbox->width(); double height = dbox->height(); - if( width == 0.0 ) { - width = 1.0; - } - if( height == 0.0 ) { - height = 1.0; - } - if( fitSymbol->get_active() ) { - /* Fit */ - scale = psize/std::max(width,height); - } + if( width == 0.0 ) width = 1.0; + if( height == 0.0 ) height = 1.0; + + if( fitSymbol->get_active() ) + scale = psize / std::max(width, height); pixbuf = Glib::wrap(render_pixbuf(renderDrawing, scale, *dbox, psize)); - svg_preview_cache.set_preview_in_cache(key, pixbuf->gobj()); } return pixbuf; diff --git a/src/ui/dialog/symbols.h b/src/ui/dialog/symbols.h index 074af6764..8021fb0c1 100644 --- a/src/ui/dialog/symbols.h +++ b/src/ui/dialog/symbols.h @@ -79,8 +79,8 @@ private: void iconDragDataGet(const Glib::RefPtr<Gdk::DragContext>& context, Gtk::SelectionData& selection_data, guint info, guint time); void get_symbols(); - void draw_symbols( SPDocument* symbol_document ); - void draw_symbol( SPObject* symbol_document ); + void add_symbols( SPDocument* symbol_document ); + void add_symbol( SPObject* symbol_document ); SPDocument* symbols_preview_doc(); GSList* symbols_in_doc_recursive(SPObject *r, GSList *l); @@ -89,8 +89,7 @@ private: GSList* use_in_doc( SPDocument* document ); gchar const* style_from_use( gchar const* id, SPDocument* document); - Glib::RefPtr<Gdk::Pixbuf> - create_symbol_image(gchar const *symbol_name, SPObject *symbol); + Glib::RefPtr<Gdk::Pixbuf> draw_symbol(SPObject *symbol); /* Keep track of all symbol template documents */ std::map<Glib::ustring, SPDocument*> symbolSets; diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 057eff337..4f2d51ef7 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -10,6 +10,7 @@ #include "template-widget.h" #include "template-load-tab.h" +#include "new-from-template.h" #include <gtkmm/messagedialog.h> #include <gtkmm/scrolledwindow.h> @@ -31,10 +32,8 @@ #include "xml/document.h" #include "xml/node.h" - namespace Inkscape { namespace UI { - TemplateLoadTab::TemplateLoadTab() : _current_keyword("") @@ -84,7 +83,9 @@ void TemplateLoadTab::createTemplate() void TemplateLoadTab::_onRowActivated(const Gtk::TreeModel::Path &, Gtk::TreeViewColumn*) { - _info_widget->create(); + createTemplate(); + NewFromTemplate* parent = static_cast<NewFromTemplate*> (this->get_toplevel()); + parent->_onClose(); } void TemplateLoadTab::_displayTemplateInfo() @@ -290,26 +291,26 @@ void TemplateLoadTab::_getDataFromNode(Inkscape::XML::Node *dataNode, TemplateDa { Inkscape::XML::Node *currentData; if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:_name")) != NULL) - data.display_name = dgettext("Document template name", currentData->firstChild()->content()); + data.display_name = _(currentData->firstChild()->content()); if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:author")) != NULL) data.author = currentData->firstChild()->content(); if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:_shortdesc")) != NULL) - data.short_description = dgettext("Document template short description", currentData->firstChild()->content()); + data.short_description = _( currentData->firstChild()->content()); if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:_long") )!= NULL) - data.long_description = dgettext("Document template long description", currentData->firstChild()->content()); + data.long_description = _(currentData->firstChild()->content()); if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:preview")) != NULL) data.preview_name = currentData->firstChild()->content(); if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:date")) != NULL) data.creation_date = currentData->firstChild()->content(); if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:_keywords")) != NULL){ - Glib::ustring tplKeywords = currentData->firstChild()->content(); + Glib::ustring tplKeywords = _(currentData->firstChild()->content()); while (!tplKeywords.empty()){ std::size_t pos = tplKeywords.find_first_of(" "); if (pos == Glib::ustring::npos) pos = tplKeywords.size(); - Glib::ustring keyword = dgettext("Document template keyword", tplKeywords.substr(0, pos).data()); + Glib::ustring keyword = tplKeywords.substr(0, pos).data(); data.keywords.insert(keyword.lowercase()); _keywords.insert(keyword.lowercase()); diff --git a/src/ui/tool/multi-path-manipulator.cpp b/src/ui/tool/multi-path-manipulator.cpp index c77d2d795..b7f3ac29b 100644 --- a/src/ui/tool/multi-path-manipulator.cpp +++ b/src/ui/tool/multi-path-manipulator.cpp @@ -30,17 +30,6 @@ #include <gdk/gdkkeysyms.h> -#ifdef USE_GNU_HASHES -namespace __gnu_cxx { -template<> -struct hash<Inkscape::UI::NodeList::iterator> { - size_t operator()(Inkscape::UI::NodeList::iterator const &n) const { - return reinterpret_cast<size_t>(n.ptr()); - } -}; -} // namespace __gnu_cxx -#endif // USE_GNU_HASHES - namespace Inkscape { namespace UI { diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 8a0568fbd..7bbe39f8d 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -18,7 +18,7 @@ #include <boost/shared_ptr.hpp> #include <2geom/bezier-curve.h> #include <2geom/bezier-utils.h> -#include <2geom/svg-path.h> +#include <2geom/path-sink.h> #include <glibmm/i18n.h> #include "ui/tool/path-manipulator.h" #include "desktop.h" @@ -1308,7 +1308,7 @@ void PathManipulator::_createGeometryFromControlPoints(bool alert_LPE) } ++spi; } - builder.finish(); + builder.flush(); Geom::PathVector pathv = builder.peek() * (_edit_transform * _i2d_transform).inverse(); _spcurve->set_pathvector(pathv); if (alert_LPE) { diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp index e4ab7b424..10f78a8a8 100644 --- a/src/ui/tools/gradient-tool.cpp +++ b/src/ui/tools/gradient-tool.cpp @@ -339,10 +339,12 @@ sp_gradient_context_add_stops_between_selected_stops (GradientTool *rc) SPGradient *gradient = getGradient(d->item, d->fill_or_stroke); SPGradient *vector = sp_gradient_get_forked_vector_if_necessary (gradient, false); SPStop *this_stop = sp_get_stop_i (vector, d->point_i); - SPStop *next_stop = this_stop->getNextStop(); - if (this_stop && next_stop) { - these_stops = g_slist_prepend (these_stops, this_stop); - next_stops = g_slist_prepend (next_stops, next_stop); + if (this_stop) { + SPStop *next_stop = this_stop->getNextStop(); + if (next_stop) { + these_stops = g_slist_prepend (these_stops, this_stop); + next_stops = g_slist_prepend (next_stops, next_stop); + } } } } diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp index 2927606a7..c73164c09 100644 --- a/src/ui/tools/text-tool.cpp +++ b/src/ui/tools/text-tool.cpp @@ -154,6 +154,7 @@ void TextTool::setup() { this->indicator = sp_canvas_item_new(sp_desktop_controls(desktop), SP_TYPE_CTRLRECT, NULL); SP_CTRLRECT(this->indicator)->setRectangle(Geom::Rect(Geom::Point(0, 0), Geom::Point(100, 100))); SP_CTRLRECT(this->indicator)->setColor(0x0000ff7f, false, 0); + SP_CTRLRECT(this->indicator)->setShadow(1, 0xffffff7f); sp_canvas_item_hide(this->indicator); this->frame = sp_canvas_item_new(sp_desktop_controls(desktop), SP_TYPE_CTRLRECT, NULL); diff --git a/src/uri-references.cpp b/src/uri-references.cpp index 2c09695d4..718b2d451 100644 --- a/src/uri-references.cpp +++ b/src/uri-references.cpp @@ -12,6 +12,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include <iostream> #include <cstring> #include <string> @@ -21,6 +22,7 @@ #include "uri-references.h" #include "extract-uri.h" +#include <glibmm/miscutils.h> #include <sigc++/functors/mem_fun.h> namespace Inkscape { @@ -45,15 +47,31 @@ URIReference::~URIReference() void URIReference::attach(const URI &uri) throw(BadURIException) { - SPDocument *document; + SPDocument *document = NULL; + + // Attempt to get the document that contains the URI if (_owner) { document = _owner->document; } else if (_owner_document) { document = _owner_document; - } else { - g_assert_not_reached(); } + // The path contains references to seperate document files to load. + const char *path = uri.getPath(); + if(path) { + if(document != NULL) { + // Calculate the absolute path from an available document + std::string basePath = std::string( document->getBase() ); + std::string absPath = Glib::build_filename(basePath, std::string( path ) ); + path = absPath.c_str(); + } + // TODO: This is inefficient because it will load the same svg file + // many times if it's used many times. A global list of documents would + // be useful for tracking linked items. + document = SPDocument::createNewDoc(path, FALSE); + } + g_return_if_fail(document != NULL); + gchar const *fragment = uri.getFragment(); if ( !uri.isRelative() || uri.getQuery() || !fragment ) { throw UnsupportedURIException(); diff --git a/src/util/unordered-containers.h b/src/util/unordered-containers.h index 70d36c4dc..98c2fa3c9 100644 --- a/src/util/unordered-containers.h +++ b/src/util/unordered-containers.h @@ -19,8 +19,24 @@ #include <glibmm/ustring.h> #ifndef DOXYGEN_SHOULD_SKIP_THIS -#if defined(HAVE_TR1_UNORDERED_SET) +#if defined(HAVE_NATIVE_UNORDERED_SET) +# include <unordered_set> +# include <unordered_map> +# define INK_UNORDERED_SET std::unordered_set +# define INK_UNORDERED_MAP std::unordered_map +# define INK_HASH std::hash + +namespace std { +template <> +struct hash<Glib::ustring> : public std::unary_function<Glib::ustring, std::size_t> { + std::size_t operator()(Glib::ustring const &s) const { + return hash<std::string>()(s.raw()); + } +}; +} // namespace std + +#elif defined(HAVE_TR1_UNORDERED_SET) # include <tr1/unordered_set> # include <tr1/unordered_map> # define INK_UNORDERED_SET std::tr1::unordered_set diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp index 8fa29e60a..4bed3101d 100644 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@ -1171,7 +1171,7 @@ void sp_gradient_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, { EgeAdjustmentAction* eact = 0; eact = create_adjustment_action( "GradientEditOffsetAction", - _("Offset"), _("Offset:"), _("Offset of selected stop"), + _("Offset"), C_("Gradient", "Offset:"), _("Offset of selected stop"), "/tools/gradient/stopoffset", 0, GTK_WIDGET(desktop->canvas), holder, FALSE, NULL, 0.0, 1.0, 0.01, 0.1, diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index e9fc426f6..17ac887c4 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -923,7 +923,7 @@ static GtkWidget * sp_gradient_vector_widget_new(SPGradient *gradient, SPStop *s #endif /* Label */ - GtkWidget *l = gtk_label_new(_("Offset:")); + GtkWidget *l = gtk_label_new(C_("Gradient","Offset:")); gtk_misc_set_alignment(GTK_MISC(l), 1.0, 0.5); gtk_box_pack_start(GTK_BOX(hb),l, FALSE, FALSE, AUX_BETWEEN_BUTTON_GROUPS); gtk_widget_show(l); diff --git a/src/widgets/star-toolbar.cpp b/src/widgets/star-toolbar.cpp index 1691a9b25..28b2c7e0c 100644 --- a/src/widgets/star-toolbar.cpp +++ b/src/widgets/star-toolbar.cpp @@ -568,13 +568,14 @@ void sp_star_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje { /* Reset */ { - GtkAction* act = gtk_action_new( "StarResetAction", + InkAction* inky = ink_action_new( "StarResetAction", _("Defaults"), _("Reset shape parameters to defaults (use Inkscape Preferences > Tools to change defaults)"), - INKSCAPE_ICON("edit-clear")); - g_signal_connect_after( G_OBJECT(act), "activate", G_CALLBACK(sp_stb_defaults), holder ); - gtk_action_group_add_action( mainActions, act ); - gtk_action_set_sensitive( act, TRUE ); + INKSCAPE_ICON("edit-clear"), + Inkscape::ICON_SIZE_SMALL_TOOLBAR); + g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_stb_defaults), holder ); + gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + gtk_action_set_sensitive( GTK_ACTION(inky), TRUE ); } } |
