emf 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +24 -0
  3. data/README.adoc +136 -0
  4. data/exe/emf +113 -0
  5. data/lib/emf/binary/codec.rb +19 -0
  6. data/lib/emf/binary/types.rb +105 -0
  7. data/lib/emf/binary.rb +10 -0
  8. data/lib/emf/detector.rb +58 -0
  9. data/lib/emf/emf_plus/binary.rb +8 -0
  10. data/lib/emf/emf_plus/parser.rb +13 -0
  11. data/lib/emf/emf_plus/serializer.rb +13 -0
  12. data/lib/emf/emf_plus.rb +9 -0
  13. data/lib/emf/emr/binary/header.rb +41 -0
  14. data/lib/emf/emr/binary/record.rb +17 -0
  15. data/lib/emf/emr/binary/records/abort_path.rb +16 -0
  16. data/lib/emf/emr/binary/records/alpha_blend.rb +17 -0
  17. data/lib/emf/emr/binary/records/angle_arc.rb +19 -0
  18. data/lib/emf/emr/binary/records/arc.rb +19 -0
  19. data/lib/emf/emr/binary/records/arc_to.rb +19 -0
  20. data/lib/emf/emr/binary/records/begin_path.rb +16 -0
  21. data/lib/emf/emr/binary/records/bit_blt.rb +37 -0
  22. data/lib/emf/emr/binary/records/chord.rb +19 -0
  23. data/lib/emf/emr/binary/records/close_figure.rb +16 -0
  24. data/lib/emf/emr/binary/records/color_correct_palette.rb +17 -0
  25. data/lib/emf/emr/binary/records/colormatch_to_target_w.rb +17 -0
  26. data/lib/emf/emr/binary/records/comment.rb +20 -0
  27. data/lib/emf/emr/binary/records/create_brush_indirect.rb +20 -0
  28. data/lib/emf/emr/binary/records/create_colorspace.rb +17 -0
  29. data/lib/emf/emr/binary/records/create_colorspace_w.rb +17 -0
  30. data/lib/emf/emr/binary/records/create_dib_pattern_brush_pt.rb +25 -0
  31. data/lib/emf/emr/binary/records/create_font_indirect_w.rb +18 -0
  32. data/lib/emf/emr/binary/records/create_mono_brush.rb +25 -0
  33. data/lib/emf/emr/binary/records/create_palette.rb +17 -0
  34. data/lib/emf/emr/binary/records/create_pen.rb +20 -0
  35. data/lib/emf/emr/binary/records/delete_colorspace.rb +17 -0
  36. data/lib/emf/emr/binary/records/delete_object.rb +16 -0
  37. data/lib/emf/emr/binary/records/draw_escape.rb +17 -0
  38. data/lib/emf/emr/binary/records/ellipse.rb +18 -0
  39. data/lib/emf/emr/binary/records/end_path.rb +16 -0
  40. data/lib/emf/emr/binary/records/eof.rb +21 -0
  41. data/lib/emf/emr/binary/records/exclude_clip_rect.rb +16 -0
  42. data/lib/emf/emr/binary/records/ext_create_pen.rb +17 -0
  43. data/lib/emf/emr/binary/records/ext_escape.rb +17 -0
  44. data/lib/emf/emr/binary/records/ext_flood_fill.rb +17 -0
  45. data/lib/emf/emr/binary/records/ext_select_clip_rgn.rb +19 -0
  46. data/lib/emf/emr/binary/records/ext_text_out_a.rb +27 -0
  47. data/lib/emf/emr/binary/records/ext_text_out_w.rb +41 -0
  48. data/lib/emf/emr/binary/records/fill_path.rb +16 -0
  49. data/lib/emf/emr/binary/records/fill_rgn.rb +17 -0
  50. data/lib/emf/emr/binary/records/flatten_path.rb +16 -0
  51. data/lib/emf/emr/binary/records/force_ufi_mapping.rb +17 -0
  52. data/lib/emf/emr/binary/records/frame_rgn.rb +17 -0
  53. data/lib/emf/emr/binary/records/gls_bounded_record.rb +17 -0
  54. data/lib/emf/emr/binary/records/gls_record.rb +17 -0
  55. data/lib/emf/emr/binary/records/gradient_fill.rb +19 -0
  56. data/lib/emf/emr/binary/records/intersect_clip_rect.rb +16 -0
  57. data/lib/emf/emr/binary/records/invert_rgn.rb +17 -0
  58. data/lib/emf/emr/binary/records/line_to.rb +16 -0
  59. data/lib/emf/emr/binary/records/mask_blt.rb +17 -0
  60. data/lib/emf/emr/binary/records/modify_world_transform.rb +17 -0
  61. data/lib/emf/emr/binary/records/move_to_ex.rb +16 -0
  62. data/lib/emf/emr/binary/records/named_escape.rb +17 -0
  63. data/lib/emf/emr/binary/records/offset_clip_rgn.rb +16 -0
  64. data/lib/emf/emr/binary/records/paint_rgn.rb +17 -0
  65. data/lib/emf/emr/binary/records/pie.rb +19 -0
  66. data/lib/emf/emr/binary/records/pixel_format.rb +17 -0
  67. data/lib/emf/emr/binary/records/plg_blt.rb +17 -0
  68. data/lib/emf/emr/binary/records/poly_bezier.rb +17 -0
  69. data/lib/emf/emr/binary/records/poly_bezier16.rb +17 -0
  70. data/lib/emf/emr/binary/records/poly_bezier_to.rb +17 -0
  71. data/lib/emf/emr/binary/records/poly_bezier_to16.rb +17 -0
  72. data/lib/emf/emr/binary/records/poly_draw.rb +18 -0
  73. data/lib/emf/emr/binary/records/poly_draw16.rb +18 -0
  74. data/lib/emf/emr/binary/records/poly_polygon.rb +19 -0
  75. data/lib/emf/emr/binary/records/poly_polygon16.rb +19 -0
  76. data/lib/emf/emr/binary/records/poly_polyline.rb +19 -0
  77. data/lib/emf/emr/binary/records/poly_polyline16.rb +19 -0
  78. data/lib/emf/emr/binary/records/poly_textout_a.rb +17 -0
  79. data/lib/emf/emr/binary/records/poly_textout_w.rb +17 -0
  80. data/lib/emf/emr/binary/records/polygon.rb +17 -0
  81. data/lib/emf/emr/binary/records/polygon16.rb +17 -0
  82. data/lib/emf/emr/binary/records/polyline.rb +17 -0
  83. data/lib/emf/emr/binary/records/polyline16.rb +17 -0
  84. data/lib/emf/emr/binary/records/polyline_to.rb +17 -0
  85. data/lib/emf/emr/binary/records/polyline_to16.rb +17 -0
  86. data/lib/emf/emr/binary/records/raw.rb +19 -0
  87. data/lib/emf/emr/binary/records/realize_palette.rb +15 -0
  88. data/lib/emf/emr/binary/records/rectangle.rb +18 -0
  89. data/lib/emf/emr/binary/records/resize_palette.rb +17 -0
  90. data/lib/emf/emr/binary/records/restore_dc.rb +17 -0
  91. data/lib/emf/emr/binary/records/round_rect.rb +19 -0
  92. data/lib/emf/emr/binary/records/save_dc.rb +16 -0
  93. data/lib/emf/emr/binary/records/scale_viewport_ext_ex.rb +19 -0
  94. data/lib/emf/emr/binary/records/scale_window_ext_ex.rb +19 -0
  95. data/lib/emf/emr/binary/records/select_clip_path.rb +20 -0
  96. data/lib/emf/emr/binary/records/select_object.rb +16 -0
  97. data/lib/emf/emr/binary/records/select_palette.rb +16 -0
  98. data/lib/emf/emr/binary/records/set_arc_direction.rb +16 -0
  99. data/lib/emf/emr/binary/records/set_bk_color.rb +16 -0
  100. data/lib/emf/emr/binary/records/set_bk_mode.rb +16 -0
  101. data/lib/emf/emr/binary/records/set_brush_org_ex.rb +16 -0
  102. data/lib/emf/emr/binary/records/set_colorspace.rb +17 -0
  103. data/lib/emf/emr/binary/records/set_dibits_to_device.rb +17 -0
  104. data/lib/emf/emr/binary/records/set_icm_mode.rb +16 -0
  105. data/lib/emf/emr/binary/records/set_icm_profile_a.rb +17 -0
  106. data/lib/emf/emr/binary/records/set_icm_profile_w.rb +17 -0
  107. data/lib/emf/emr/binary/records/set_layout.rb +16 -0
  108. data/lib/emf/emr/binary/records/set_linked_ufis.rb +17 -0
  109. data/lib/emf/emr/binary/records/set_map_mode.rb +16 -0
  110. data/lib/emf/emr/binary/records/set_mapper_flags.rb +16 -0
  111. data/lib/emf/emr/binary/records/set_metargn.rb +16 -0
  112. data/lib/emf/emr/binary/records/set_miter_limit.rb +16 -0
  113. data/lib/emf/emr/binary/records/set_palette_entries.rb +17 -0
  114. data/lib/emf/emr/binary/records/set_pixel_v.rb +18 -0
  115. data/lib/emf/emr/binary/records/set_poly_fill_mode.rb +16 -0
  116. data/lib/emf/emr/binary/records/set_rop2.rb +16 -0
  117. data/lib/emf/emr/binary/records/set_stretch_blt_mode.rb +16 -0
  118. data/lib/emf/emr/binary/records/set_text_align.rb +16 -0
  119. data/lib/emf/emr/binary/records/set_text_color.rb +17 -0
  120. data/lib/emf/emr/binary/records/set_text_justification.rb +17 -0
  121. data/lib/emf/emr/binary/records/set_viewport_ext_ex.rb +16 -0
  122. data/lib/emf/emr/binary/records/set_viewport_org_ex.rb +16 -0
  123. data/lib/emf/emr/binary/records/set_window_ext_ex.rb +16 -0
  124. data/lib/emf/emr/binary/records/set_window_org_ex.rb +16 -0
  125. data/lib/emf/emr/binary/records/set_world_transform.rb +16 -0
  126. data/lib/emf/emr/binary/records/small_text_out.rb +28 -0
  127. data/lib/emf/emr/binary/records/stretch_blt.rb +39 -0
  128. data/lib/emf/emr/binary/records/stretch_dibits.rb +42 -0
  129. data/lib/emf/emr/binary/records/stroke_and_fill_path.rb +16 -0
  130. data/lib/emf/emr/binary/records/stroke_path.rb +16 -0
  131. data/lib/emf/emr/binary/records/transparent_blt.rb +17 -0
  132. data/lib/emf/emr/binary/records/widen_path.rb +16 -0
  133. data/lib/emf/emr/binary/records.rb +258 -0
  134. data/lib/emf/emr/binary/type_codes.rb +132 -0
  135. data/lib/emf/emr/binary/with_bounds.rb +15 -0
  136. data/lib/emf/emr/binary.rb +13 -0
  137. data/lib/emf/emr/parser.rb +185 -0
  138. data/lib/emf/emr/path_association.rb +16 -0
  139. data/lib/emf/emr/serializer.rb +24 -0
  140. data/lib/emf/emr.rb +10 -0
  141. data/lib/emf/error.rb +19 -0
  142. data/lib/emf/model/emr/header.rb +93 -0
  143. data/lib/emf/model/emr/records.rb +48 -0
  144. data/lib/emf/model/emr.rb +10 -0
  145. data/lib/emf/model/geometry/color.rb +67 -0
  146. data/lib/emf/model/geometry/matrix.rb +52 -0
  147. data/lib/emf/model/geometry/point.rb +41 -0
  148. data/lib/emf/model/geometry/point_f.rb +33 -0
  149. data/lib/emf/model/geometry/point_s.rb +33 -0
  150. data/lib/emf/model/geometry/rect.rb +57 -0
  151. data/lib/emf/model/geometry/rect_s.rb +49 -0
  152. data/lib/emf/model/geometry/size.rb +33 -0
  153. data/lib/emf/model/geometry.rb +16 -0
  154. data/lib/emf/model/metafile.rb +34 -0
  155. data/lib/emf/model/record.rb +19 -0
  156. data/lib/emf/model/visitor.rb +42 -0
  157. data/lib/emf/model.rb +11 -0
  158. data/lib/emf/version.rb +5 -0
  159. data/lib/emf/visitors/dump.rb +57 -0
  160. data/lib/emf/visitors/stats.rb +63 -0
  161. data/lib/emf/visitors.rb +8 -0
  162. data/lib/emf/wmf/binary.rb +9 -0
  163. data/lib/emf/wmf/parser.rb +13 -0
  164. data/lib/emf/wmf/serializer.rb +13 -0
  165. data/lib/emf/wmf.rb +9 -0
  166. data/lib/emf.rb +56 -0
  167. metadata +226 -0
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bindata"
4
+ require "emf/emr/binary/record"
5
+
6
+ module Emf
7
+ module Emr
8
+ module Binary
9
+ module Records
10
+ class SetWorldTransform < Emf::Emr::Binary::Record
11
+ x_form :xform
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bindata"
4
+ require "emf/emr/binary/record"
5
+
6
+ module Emf
7
+ module Emr
8
+ module Binary
9
+ module Records
10
+ # EMRSMALLTEXTOUT (MS-EMF 2.3.5.37).
11
+ # Layout: emr, Dest, cChars, fuOptions, iGraphicsMode, exScale (float),
12
+ # eyScale (float), [optional RECTL], TextString (1 or 2 bytes per char).
13
+ # The body bytes (after the fixed header) are deferred to the visitor
14
+ # for parsing because the layout depends on fuOptions.
15
+ class SmallTextOut < Emf::Emr::Binary::Record
16
+ int32 :x_dest
17
+ int32 :y_dest
18
+ uint32 :c_chars
19
+ uint32 :fu_options
20
+ uint32 :i_graphics_mode
21
+ float :ex_scale
22
+ float :ey_scale
23
+ rest :body
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bindata"
4
+ require "emf/emr/binary/with_bounds"
5
+
6
+ module Emf
7
+ module Emr
8
+ module Binary
9
+ module Records
10
+ # EMRSTRETCHBLT (MS-EMF 2.3.1.6).
11
+ # Layout: emr, rclBounds, Dest, cDest, dwRop, Src, xformSrc (24
12
+ # bytes), crBkColorSrc, iUsageSrc, offBmiSrc, cbBmiSrc,
13
+ # offBitsSrc, cbBitsSrc, cSrc, then trailing BMI/bitmap data.
14
+ # Only the fields the emfsvg renderer needs are declared; the
15
+ # 32-byte xform+bgcolor+usage blob in the middle is skipped via
16
+ # a fixed-size :bytes buffer (NOT :rest, which would consume the
17
+ # whole tail).
18
+ class StretchBlt < Emf::Emr::Binary::WithBounds
19
+ int32le :x_dest
20
+ int32le :y_dest
21
+ int32le :cx_dest
22
+ int32le :cy_dest
23
+ uint32le :dw_rop
24
+ int32le :x_src
25
+ int32le :y_src
26
+ # xformSrc (24 bytes) + crBkColorSrc (4) + iUsageSrc (4) = 32 bytes
27
+ string :xform_usage_etc, length: 32, read_trim_padding: true
28
+ uint32le :off_bmi_src
29
+ uint32le :cb_bmi_src
30
+ uint32le :off_bits_src
31
+ uint32le :cb_bits_src
32
+ int32le :cx_src
33
+ int32le :cy_src
34
+ rest :body
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bindata"
4
+ require "emf/emr/binary/with_bounds"
5
+
6
+ module Emf
7
+ module Emr
8
+ module Binary
9
+ module Records
10
+ # EMR_STRETCHDIBITS per MS-EMF 2.3.1.7. The full layout:
11
+ # emr
12
+ # rclBounds (RECTL)
13
+ # xDest, yDest (int32)
14
+ # xSrc, ySrc (int32)
15
+ # cxSrc, cySrc (int32)
16
+ # offBmiSrc, cbBmiSrc (uint32) — offset/size of BITMAPINFO from record start
17
+ # offBitsSrc, cbBitsSrc (uint32) — offset/size of pixel array from record start
18
+ # iUsageSrc (uint32) — DIBColors
19
+ # dwRop (uint32) — ternary raster op
20
+ # cxDest, cyDest (int32)
21
+ # [trailing BITMAPINFO + pixel array]
22
+ class StretchDIBits < Emf::Emr::Binary::WithBounds
23
+ int32 :x_dest
24
+ int32 :y_dest
25
+ int32 :x_src
26
+ int32 :y_src
27
+ int32 :cx_src
28
+ int32 :cy_src
29
+ uint32 :off_bmi_src
30
+ uint32 :cb_bmi_src
31
+ uint32 :off_bits_src
32
+ uint32 :cb_bits_src
33
+ uint32 :i_usage_src
34
+ uint32 :dw_rop
35
+ int32 :cx_dest
36
+ int32 :cy_dest
37
+ rest :trailing
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bindata"
4
+ require "emf/emr/binary/with_bounds"
5
+
6
+ module Emf
7
+ module Emr
8
+ module Binary
9
+ module Records
10
+ # EMR_STROKE_AND_FILL_PATH: emr + rclBounds per MS-EMF 2.3.5.9/2.3.5.38/2.3.5.39.
11
+ class StrokeAndFillPath < Emf::Emr::Binary::WithBounds
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bindata"
4
+ require "emf/emr/binary/with_bounds"
5
+
6
+ module Emf
7
+ module Emr
8
+ module Binary
9
+ module Records
10
+ # EMR_STROKE_PATH: emr + rclBounds per MS-EMF 2.3.5.9/2.3.5.38/2.3.5.39.
11
+ class StrokePath < Emf::Emr::Binary::WithBounds
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bindata"
4
+ require "emf/emr/binary/with_bounds"
5
+
6
+ module Emf
7
+ module Emr
8
+ module Binary
9
+ module Records
10
+ # Stub: leading fields per MS-EMF, body captures remaining bytes.
11
+ class TransparentBlt < Emf::Emr::Binary::WithBounds
12
+ rest :body
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bindata"
4
+ require "emf/emr/binary/record"
5
+
6
+ module Emf
7
+ module Emr
8
+ module Binary
9
+ module Records
10
+ # Control record with no payload (just iType and nSize).
11
+ class WidenPath < Emf::Emr::Binary::Record
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,258 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Ensure the shared bindata primitives (rectl, point_l, color_ref, etc.) are
4
+ # registered before any record class is parsed. Referencing the constant
5
+ # triggers autoload of emf/binary/types, which calls
6
+ # BinData::RegisteredClasses.register for each primitive.
7
+
8
+ module Emf
9
+ module Emr
10
+ module Binary
11
+ module Records
12
+ autoload :Raw, "emf/emr/binary/records/raw"
13
+ autoload :Eof, "emf/emr/binary/records/eof"
14
+ autoload :SetTextColor, "emf/emr/binary/records/set_text_color"
15
+ autoload :SetBkColor, "emf/emr/binary/records/set_bk_color"
16
+ autoload :SetBkMode, "emf/emr/binary/records/set_bk_mode"
17
+ autoload :SetMapMode, "emf/emr/binary/records/set_map_mode"
18
+ autoload :SetRop2, "emf/emr/binary/records/set_rop2"
19
+ autoload :SetPolyFillMode, "emf/emr/binary/records/set_poly_fill_mode"
20
+ autoload :SetTextAlign, "emf/emr/binary/records/set_text_align"
21
+ autoload :SetStretchBltMode, "emf/emr/binary/records/set_stretch_blt_mode"
22
+ autoload :SaveDc, "emf/emr/binary/records/save_dc"
23
+ autoload :RestoreDc, "emf/emr/binary/records/restore_dc"
24
+ autoload :SelectObject, "emf/emr/binary/records/select_object"
25
+ autoload :DeleteObject, "emf/emr/binary/records/delete_object"
26
+ autoload :CreatePen, "emf/emr/binary/records/create_pen"
27
+ autoload :CreateBrushIndirect, "emf/emr/binary/records/create_brush_indirect"
28
+ autoload :SetWindowOrgEx, "emf/emr/binary/records/set_window_org_ex"
29
+ autoload :SetWindowExtEx, "emf/emr/binary/records/set_window_ext_ex"
30
+ autoload :SetViewportOrgEx, "emf/emr/binary/records/set_viewport_org_ex"
31
+ autoload :SetViewportExtEx, "emf/emr/binary/records/set_viewport_ext_ex"
32
+ autoload :SetBrushOrgEx, "emf/emr/binary/records/set_brush_org_ex"
33
+ autoload :MoveToEx, "emf/emr/binary/records/move_to_ex"
34
+ autoload :LineTo, "emf/emr/binary/records/line_to"
35
+ autoload :Rectangle, "emf/emr/binary/records/rectangle"
36
+ autoload :Ellipse, "emf/emr/binary/records/ellipse"
37
+ autoload :RoundRect, "emf/emr/binary/records/round_rect"
38
+ autoload :Arc, "emf/emr/binary/records/arc"
39
+ autoload :ArcTo, "emf/emr/binary/records/arc_to"
40
+ autoload :Chord, "emf/emr/binary/records/chord"
41
+ autoload :Pie, "emf/emr/binary/records/pie"
42
+ autoload :AngleArc, "emf/emr/binary/records/angle_arc"
43
+ autoload :SetArcDirection, "emf/emr/binary/records/set_arc_direction"
44
+ autoload :Polygon, "emf/emr/binary/records/polygon"
45
+ autoload :Polyline, "emf/emr/binary/records/polyline"
46
+ autoload :PolyBezier, "emf/emr/binary/records/poly_bezier"
47
+ autoload :Polygon16, "emf/emr/binary/records/polygon16"
48
+ autoload :Polyline16, "emf/emr/binary/records/polyline16"
49
+ autoload :PolyBezier16, "emf/emr/binary/records/poly_bezier16"
50
+ autoload :PolyBezierTo, "emf/emr/binary/records/poly_bezier_to"
51
+ autoload :PolyBezierTo16, "emf/emr/binary/records/poly_bezier_to16"
52
+ autoload :PolylineTo, "emf/emr/binary/records/polyline_to"
53
+ autoload :PolylineTo16, "emf/emr/binary/records/polyline_to16"
54
+ autoload :PolyDraw, "emf/emr/binary/records/poly_draw"
55
+ autoload :PolyDraw16, "emf/emr/binary/records/poly_draw16"
56
+ autoload :PolyPolyline, "emf/emr/binary/records/poly_polyline"
57
+ autoload :PolyPolygon, "emf/emr/binary/records/poly_polygon"
58
+ autoload :PolyPolyline16, "emf/emr/binary/records/poly_polyline16"
59
+ autoload :PolyPolygon16, "emf/emr/binary/records/poly_polygon16"
60
+ autoload :Comment, "emf/emr/binary/records/comment"
61
+ autoload :SetWorldTransform, "emf/emr/binary/records/set_world_transform"
62
+ autoload :ModifyWorldTransform, "emf/emr/binary/records/modify_world_transform"
63
+ autoload :BeginPath, "emf/emr/binary/records/begin_path"
64
+ autoload :EndPath, "emf/emr/binary/records/end_path"
65
+ autoload :CloseFigure, "emf/emr/binary/records/close_figure"
66
+ autoload :FillPath, "emf/emr/binary/records/fill_path"
67
+ autoload :StrokePath, "emf/emr/binary/records/stroke_path"
68
+ autoload :StrokeAndFillPath, "emf/emr/binary/records/stroke_and_fill_path"
69
+ autoload :FlattenPath, "emf/emr/binary/records/flatten_path"
70
+ autoload :WidenPath, "emf/emr/binary/records/widen_path"
71
+ autoload :SelectClipPath, "emf/emr/binary/records/select_clip_path"
72
+ autoload :AbortPath, "emf/emr/binary/records/abort_path"
73
+ autoload :SetMiterLimit, "emf/emr/binary/records/set_miter_limit"
74
+ autoload :ExtTextOutW, "emf/emr/binary/records/ext_text_out_w"
75
+ autoload :ExtTextOutA, "emf/emr/binary/records/ext_text_out_a"
76
+ autoload :CreateFontIndirectW, "emf/emr/binary/records/create_font_indirect_w"
77
+ autoload :ExtCreatePen, "emf/emr/binary/records/ext_create_pen"
78
+ autoload :StretchDIBits, "emf/emr/binary/records/stretch_dibits"
79
+ autoload :SetPixelV, "emf/emr/binary/records/set_pixel_v"
80
+ autoload :SetMetArgn, "emf/emr/binary/records/set_metargn"
81
+ autoload :OffsetClipRgn, "emf/emr/binary/records/offset_clip_rgn"
82
+ autoload :ExcludeClipRect, "emf/emr/binary/records/exclude_clip_rect"
83
+ autoload :IntersectClipRect, "emf/emr/binary/records/intersect_clip_rect"
84
+ autoload :ExtSelectClipRgn, "emf/emr/binary/records/ext_select_clip_rgn"
85
+ autoload :ScaleViewportExtEx, "emf/emr/binary/records/scale_viewport_ext_ex"
86
+ autoload :ScaleWindowExtEx, "emf/emr/binary/records/scale_window_ext_ex"
87
+ autoload :SetMapperFlags, "emf/emr/binary/records/set_mapper_flags"
88
+ autoload :RealizePalette, "emf/emr/binary/records/realize_palette"
89
+ autoload :SelectPalette, "emf/emr/binary/records/select_palette"
90
+ autoload :CreatePalette, "emf/emr/binary/records/create_palette"
91
+ autoload :ResizePalette, "emf/emr/binary/records/resize_palette"
92
+ autoload :SetPaletteEntries, "emf/emr/binary/records/set_palette_entries"
93
+ autoload :ExtFloodFill, "emf/emr/binary/records/ext_flood_fill"
94
+ autoload :FillRgn, "emf/emr/binary/records/fill_rgn"
95
+ autoload :FrameRgn, "emf/emr/binary/records/frame_rgn"
96
+ autoload :InvertRgn, "emf/emr/binary/records/invert_rgn"
97
+ autoload :PaintRgn, "emf/emr/binary/records/paint_rgn"
98
+ autoload :BitBlt, "emf/emr/binary/records/bit_blt"
99
+ autoload :StretchBlt, "emf/emr/binary/records/stretch_blt"
100
+ autoload :MaskBlt, "emf/emr/binary/records/mask_blt"
101
+ autoload :PlgBlt, "emf/emr/binary/records/plg_blt"
102
+ autoload :SetDIBitsToDevice, "emf/emr/binary/records/set_dibits_to_device"
103
+ autoload :AlphaBlend, "emf/emr/binary/records/alpha_blend"
104
+ autoload :TransparentBlt, "emf/emr/binary/records/transparent_blt"
105
+ autoload :SetLayout, "emf/emr/binary/records/set_layout"
106
+ autoload :SetIcmMode, "emf/emr/binary/records/set_icm_mode"
107
+ autoload :CreateMonoBrush, "emf/emr/binary/records/create_mono_brush"
108
+ autoload :CreateDibPatternBrushPt, "emf/emr/binary/records/create_dib_pattern_brush_pt"
109
+ autoload :GradientFill, "emf/emr/binary/records/gradient_fill"
110
+ autoload :SmallTextOut, "emf/emr/binary/records/small_text_out"
111
+ autoload :DrawEscape, "emf/emr/binary/records/draw_escape"
112
+ autoload :ExtEscape, "emf/emr/binary/records/ext_escape"
113
+ autoload :NamedEscape, "emf/emr/binary/records/named_escape"
114
+ autoload :ColorCorrectPalette, "emf/emr/binary/records/color_correct_palette"
115
+ autoload :SetIcmProfileA, "emf/emr/binary/records/set_icm_profile_a"
116
+ autoload :SetIcmProfileW, "emf/emr/binary/records/set_icm_profile_w"
117
+ autoload :ForceUfiMapping, "emf/emr/binary/records/force_ufi_mapping"
118
+ autoload :SetLinkedUfis, "emf/emr/binary/records/set_linked_ufis"
119
+ autoload :ColorMatchToTargetW, "emf/emr/binary/records/colormatch_to_target_w"
120
+ autoload :CreateColorspaceW, "emf/emr/binary/records/create_colorspace_w"
121
+ autoload :CreateColorspace, "emf/emr/binary/records/create_colorspace"
122
+ autoload :SetColorspace, "emf/emr/binary/records/set_colorspace"
123
+ autoload :DeleteColorspace, "emf/emr/binary/records/delete_colorspace"
124
+ autoload :GlsRecord, "emf/emr/binary/records/gls_record"
125
+ autoload :GlsBoundedRecord, "emf/emr/binary/records/gls_bounded_record"
126
+ autoload :PolyTextOutA, "emf/emr/binary/records/poly_textout_a"
127
+ autoload :PolyTextOutW, "emf/emr/binary/records/poly_textout_w"
128
+ autoload :PixelFormat, "emf/emr/binary/records/pixel_format"
129
+ autoload :SetTextJustification, "emf/emr/binary/records/set_text_justification"
130
+
131
+ TYPE_TO_NAME = {
132
+ Binary::TypeCodes::EOF => :Eof,
133
+ Binary::TypeCodes::SETTEXTCOLOR => :SetTextColor,
134
+ Binary::TypeCodes::SETBKCOLOR => :SetBkColor,
135
+ Binary::TypeCodes::SETBKMODE => :SetBkMode,
136
+ Binary::TypeCodes::SETMAPMODE => :SetMapMode,
137
+ Binary::TypeCodes::SETROP2 => :SetRop2,
138
+ Binary::TypeCodes::SETPOLYFILLMODE => :SetPolyFillMode,
139
+ Binary::TypeCodes::SETTEXTALIGN => :SetTextAlign,
140
+ Binary::TypeCodes::SETSTRETCHBLTMODE => :SetStretchBltMode,
141
+ Binary::TypeCodes::SAVEDC => :SaveDc,
142
+ Binary::TypeCodes::RESTOREDC => :RestoreDc,
143
+ Binary::TypeCodes::SELECTOBJECT => :SelectObject,
144
+ Binary::TypeCodes::DELETEOBJECT => :DeleteObject,
145
+ Binary::TypeCodes::CREATEPEN => :CreatePen,
146
+ Binary::TypeCodes::CREATEBRUSHINDIRECT => :CreateBrushIndirect,
147
+ Binary::TypeCodes::SETWINDOWORGEX => :SetWindowOrgEx,
148
+ Binary::TypeCodes::SETWINDOWEXTEX => :SetWindowExtEx,
149
+ Binary::TypeCodes::SETVIEWPORTORGEX => :SetViewportOrgEx,
150
+ Binary::TypeCodes::SETVIEWPORTEXTEX => :SetViewportExtEx,
151
+ Binary::TypeCodes::SETBRUSHORGEX => :SetBrushOrgEx,
152
+ Binary::TypeCodes::MOVETOEX => :MoveToEx,
153
+ Binary::TypeCodes::LINETO => :LineTo,
154
+ Binary::TypeCodes::RECTANGLE => :Rectangle,
155
+ Binary::TypeCodes::ELLIPSE => :Ellipse,
156
+ Binary::TypeCodes::ROUNDRECT => :RoundRect,
157
+ Binary::TypeCodes::ARC => :Arc,
158
+ Binary::TypeCodes::ARCTO => :ArcTo,
159
+ Binary::TypeCodes::CHORD => :Chord,
160
+ Binary::TypeCodes::PIE => :Pie,
161
+ Binary::TypeCodes::ANGLEARC => :AngleArc,
162
+ Binary::TypeCodes::SETARCDIRECTION => :SetArcDirection,
163
+ Binary::TypeCodes::POLYGON => :Polygon,
164
+ Binary::TypeCodes::POLYLINE => :Polyline,
165
+ Binary::TypeCodes::POLYBEZIER => :PolyBezier,
166
+ Binary::TypeCodes::POLYGON16 => :Polygon16,
167
+ Binary::TypeCodes::POLYLINE16 => :Polyline16,
168
+ Binary::TypeCodes::POLYBEZIER16 => :PolyBezier16,
169
+ Binary::TypeCodes::POLYBEZIERTO => :PolyBezierTo,
170
+ Binary::TypeCodes::POLYBEZIERTO16 => :PolyBezierTo16,
171
+ Binary::TypeCodes::POLYLINETO => :PolylineTo,
172
+ Binary::TypeCodes::POLYLINETO16 => :PolylineTo16,
173
+ Binary::TypeCodes::POLYDRAW => :PolyDraw,
174
+ Binary::TypeCodes::POLYDRAW16 => :PolyDraw16,
175
+ Binary::TypeCodes::POLYPOLYLINE => :PolyPolyline,
176
+ Binary::TypeCodes::POLYPOLYGON => :PolyPolygon,
177
+ Binary::TypeCodes::POLYPOLYLINE16 => :PolyPolyline16,
178
+ Binary::TypeCodes::POLYPOLYGON16 => :PolyPolygon16,
179
+ Binary::TypeCodes::COMMENT => :Comment,
180
+ Binary::TypeCodes::SETWORLDTRANSFORM => :SetWorldTransform,
181
+ Binary::TypeCodes::MODIFYWORLDTRANSFORM => :ModifyWorldTransform,
182
+ Binary::TypeCodes::BEGINPATH => :BeginPath,
183
+ Binary::TypeCodes::ENDPATH => :EndPath,
184
+ Binary::TypeCodes::CLOSEFIGURE => :CloseFigure,
185
+ Binary::TypeCodes::FILLPATH => :FillPath,
186
+ Binary::TypeCodes::STROKEPATH => :StrokePath,
187
+ Binary::TypeCodes::STROKEANDFILLPATH => :StrokeAndFillPath,
188
+ Binary::TypeCodes::FLATTENPATH => :FlattenPath,
189
+ Binary::TypeCodes::WIDENPATH => :WidenPath,
190
+ Binary::TypeCodes::SELECTCLIPPATH => :SelectClipPath,
191
+ Binary::TypeCodes::ABORTPATH => :AbortPath,
192
+ Binary::TypeCodes::SETMITERLIMIT => :SetMiterLimit,
193
+ Binary::TypeCodes::EXTTEXTOUTW => :ExtTextOutW,
194
+ Binary::TypeCodes::EXTTEXTOUTA => :ExtTextOutA,
195
+ Binary::TypeCodes::EXTCREATEFONTINDIRECTW => :CreateFontIndirectW,
196
+ Binary::TypeCodes::EXTCREATEPEN => :ExtCreatePen,
197
+ Binary::TypeCodes::STRETCHDIBITS => :StretchDIBits,
198
+ Binary::TypeCodes::SETPIXELV => :SetPixelV,
199
+ Binary::TypeCodes::OFFSETCLIPRGN => :OffsetClipRgn,
200
+ Binary::TypeCodes::SETMETARGN => :SetMetArgn,
201
+ Binary::TypeCodes::EXCLUDECLIPRECT => :ExcludeClipRect,
202
+ Binary::TypeCodes::INTERSECTCLIPRECT => :IntersectClipRect,
203
+ Binary::TypeCodes::SCALEVIEWPORTEXTEX => :ScaleViewportExtEx,
204
+ Binary::TypeCodes::SCALEWINDOWEXTEX => :ScaleWindowExtEx,
205
+ Binary::TypeCodes::SETMAPPERFLAGS => :SetMapperFlags,
206
+ Binary::TypeCodes::REALIZEPALETTE => :RealizePalette,
207
+ Binary::TypeCodes::SELECTPALETTE => :SelectPalette,
208
+ Binary::TypeCodes::CREATEPALETTE => :CreatePalette,
209
+ Binary::TypeCodes::RESIZEPALETTE => :ResizePalette,
210
+ Binary::TypeCodes::SETPALETTEENTRIES => :SetPaletteEntries,
211
+ Binary::TypeCodes::EXTFLOODFILL => :ExtFloodFill,
212
+ Binary::TypeCodes::EXTSELECTCLIPRGN => :ExtSelectClipRgn,
213
+ Binary::TypeCodes::FILLRGN => :FillRgn,
214
+ Binary::TypeCodes::FRAMERGN => :FrameRgn,
215
+ Binary::TypeCodes::INVERTRGN => :InvertRgn,
216
+ Binary::TypeCodes::PAINTRGN => :PaintRgn,
217
+ Binary::TypeCodes::BITBLT => :BitBlt,
218
+ Binary::TypeCodes::STRETCHBLT => :StretchBlt,
219
+ Binary::TypeCodes::MASKBLT => :MaskBlt,
220
+ Binary::TypeCodes::PLGBLT => :PlgBlt,
221
+ Binary::TypeCodes::SETDIBITSTODEVICE => :SetDIBitsToDevice,
222
+ Binary::TypeCodes::ALPHABLEND => :AlphaBlend,
223
+ Binary::TypeCodes::SETLAYOUT => :SetLayout,
224
+ Binary::TypeCodes::TRANSPARENTBLT => :TransparentBlt,
225
+ Binary::TypeCodes::GRADIENTFILL => :GradientFill,
226
+ Binary::TypeCodes::SETICMMODE => :SetIcmMode,
227
+ Binary::TypeCodes::CREATEMONOBRUSH => :CreateMonoBrush,
228
+ Binary::TypeCodes::CREATEDIBPATTERNBRUSHPT => :CreateDibPatternBrushPt,
229
+ Binary::TypeCodes::SMALLTEXTOUT => :SmallTextOut,
230
+ Binary::TypeCodes::DRAWESCAPE => :DrawEscape,
231
+ Binary::TypeCodes::EXTESCAPE => :ExtEscape,
232
+ Binary::TypeCodes::NAMEDESCAPE => :NamedEscape,
233
+ Binary::TypeCodes::COLORCORRECTPALETTE => :ColorCorrectPalette,
234
+ Binary::TypeCodes::SETICMPROFILEA => :SetIcmProfileA,
235
+ Binary::TypeCodes::SETICMPROFILEW => :SetIcmProfileW,
236
+ Binary::TypeCodes::FORCEUFIMAPPING => :ForceUfiMapping,
237
+ Binary::TypeCodes::SETLINKEDUFIS => :SetLinkedUfis,
238
+ Binary::TypeCodes::COLORMATCHTOTARGETW => :ColorMatchToTargetW,
239
+ Binary::TypeCodes::CREATECOLORSPACEW => :CreateColorspaceW,
240
+ Binary::TypeCodes::CREATECOLORSPACE => :CreateColorspace,
241
+ Binary::TypeCodes::SETCOLORSPACE => :SetColorspace,
242
+ Binary::TypeCodes::DELETECOLORSPACE => :DeleteColorspace,
243
+ Binary::TypeCodes::GLSRECORD => :GlsRecord,
244
+ Binary::TypeCodes::GLSBOUNDEDRECORD => :GlsBoundedRecord,
245
+ Binary::TypeCodes::POLYTEXTOUTA => :PolyTextOutA,
246
+ Binary::TypeCodes::POLYTEXTOUTW => :PolyTextOutW,
247
+ Binary::TypeCodes::PIXELFORMAT => :PixelFormat,
248
+ Binary::TypeCodes::SETTEXTJUSTIFICATION => :SetTextJustification
249
+ }.freeze
250
+
251
+ def self.lookup(type_id)
252
+ name = TYPE_TO_NAME[type_id]
253
+ name ? const_get(name) : Raw
254
+ end
255
+ end
256
+ end
257
+ end
258
+ end
@@ -0,0 +1,132 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Emf
4
+ module Emr
5
+ module Binary
6
+ # EMR record type codes per MS-EMF 2.3.1.
7
+ # Adding a new record type: add the constant here, add an entry in
8
+ # TYPE_TO_NAME in records.rb, and add the wire class file under records/.
9
+ module TypeCodes
10
+ HEADER = 1
11
+ POLYBEZIER = 2
12
+ POLYGON = 3
13
+ POLYLINE = 4
14
+ POLYBEZIERTO = 5
15
+ POLYLINETO = 6
16
+ POLYPOLYLINE = 7
17
+ POLYPOLYGON = 8
18
+ SETWINDOWEXTEX = 9
19
+ SETWINDOWORGEX = 10
20
+ SETVIEWPORTEXTEX = 11
21
+ SETVIEWPORTORGEX = 12
22
+ SETBRUSHORGEX = 13
23
+ EOF = 14
24
+ SETPIXELV = 15
25
+ SETMAPPERFLAGS = 16
26
+ SETMAPMODE = 17
27
+ SETBKMODE = 18
28
+ SETPOLYFILLMODE = 19
29
+ SETROP2 = 20
30
+ SETSTRETCHBLTMODE = 21
31
+ SETTEXTALIGN = 22
32
+ SETCOLORADJUSTMENT = 23
33
+ SETTEXTCOLOR = 24
34
+ SETBKCOLOR = 25
35
+ OFFSETCLIPRGN = 26
36
+ MOVETOEX = 27
37
+ SETMETARGN = 28
38
+ EXCLUDECLIPRECT = 29
39
+ INTERSECTCLIPRECT = 30
40
+ SCALEVIEWPORTEXTEX = 31
41
+ SCALEWINDOWEXTEX = 32
42
+ SAVEDC = 33
43
+ RESTOREDC = 34
44
+ SETWORLDTRANSFORM = 35
45
+ MODIFYWORLDTRANSFORM = 36
46
+ SELECTOBJECT = 37
47
+ CREATEPEN = 38
48
+ CREATEBRUSHINDIRECT = 39
49
+ DELETEOBJECT = 40
50
+ ANGLEARC = 41
51
+ ELLIPSE = 42
52
+ RECTANGLE = 43
53
+ ROUNDRECT = 44
54
+ ARC = 45
55
+ CHORD = 46
56
+ PIE = 47
57
+ SELECTPALETTE = 48
58
+ CREATEPALETTE = 49
59
+ SETPALETTEENTRIES = 50
60
+ RESIZEPALETTE = 51
61
+ REALIZEPALETTE = 52
62
+ EXTFLOODFILL = 53
63
+ LINETO = 54
64
+ ARCTO = 55
65
+ POLYDRAW = 56
66
+ SETARCDIRECTION = 57
67
+ SETMITERLIMIT = 58
68
+ BEGINPATH = 59
69
+ ENDPATH = 60
70
+ CLOSEFIGURE = 61
71
+ FILLPATH = 62
72
+ STROKEANDFILLPATH = 63
73
+ STROKEPATH = 64
74
+ FLATTENPATH = 65
75
+ WIDENPATH = 66
76
+ SELECTCLIPPATH = 67
77
+ ABORTPATH = 68
78
+ COMMENT = 70
79
+ FILLRGN = 71
80
+ FRAMERGN = 72
81
+ INVERTRGN = 73
82
+ PAINTRGN = 74
83
+ EXTSELECTCLIPRGN = 75
84
+ BITBLT = 76
85
+ STRETCHBLT = 77
86
+ MASKBLT = 78
87
+ PLGBLT = 79
88
+ SETDIBITSTODEVICE = 80
89
+ STRETCHDIBITS = 81
90
+ EXTCREATEFONTINDIRECTW = 82
91
+ EXTTEXTOUTA = 83
92
+ EXTTEXTOUTW = 84
93
+ POLYBEZIER16 = 85
94
+ POLYGON16 = 86
95
+ POLYLINE16 = 87
96
+ POLYBEZIERTO16 = 88
97
+ POLYLINETO16 = 89
98
+ POLYPOLYLINE16 = 90
99
+ POLYPOLYGON16 = 91
100
+ POLYDRAW16 = 92
101
+ CREATEMONOBRUSH = 93
102
+ CREATEDIBPATTERNBRUSHPT = 94
103
+ EXTCREATEPEN = 95
104
+ POLYTEXTOUTA = 96
105
+ POLYTEXTOUTW = 97
106
+ SETICMMODE = 98
107
+ CREATECOLORSPACE = 99
108
+ SETCOLORSPACE = 100
109
+ DELETECOLORSPACE = 101
110
+ GLSRECORD = 102
111
+ GLSBOUNDEDRECORD = 103
112
+ PIXELFORMAT = 104
113
+ DRAWESCAPE = 105
114
+ EXTESCAPE = 106
115
+ SMALLTEXTOUT = 108
116
+ FORCEUFIMAPPING = 109
117
+ NAMEDESCAPE = 110
118
+ COLORCORRECTPALETTE = 111
119
+ SETICMPROFILEA = 112
120
+ SETICMPROFILEW = 113
121
+ ALPHABLEND = 114
122
+ SETLAYOUT = 115
123
+ TRANSPARENTBLT = 116
124
+ GRADIENTFILL = 118
125
+ SETLINKEDUFIS = 119
126
+ SETTEXTJUSTIFICATION = 120
127
+ COLORMATCHTOTARGETW = 121
128
+ CREATECOLORSPACEW = 122
129
+ end
130
+ end
131
+ end
132
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bindata"
4
+ require "emf/emr/binary/record"
5
+
6
+ module Emf
7
+ module Emr
8
+ module Binary
9
+ # Many drawing records start with an RECTL bounding box after the header.
10
+ class WithBounds < Emf::Emr::Binary::Record
11
+ rectl :rcl_bounds
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Emf
4
+ module Emr
5
+ module Binary
6
+ autoload :Header, "emf/emr/binary/header"
7
+ autoload :Record, "emf/emr/binary/record"
8
+ autoload :WithBounds, "emf/emr/binary/with_bounds"
9
+ autoload :TypeCodes, "emf/emr/binary/type_codes"
10
+ autoload :Records, "emf/emr/binary/records"
11
+ end
12
+ end
13
+ end