Class: Emfsvg::Translation::Handlers::ImageHandler

Inherits:
Object
  • Object
show all
Includes:
Emf::Emr::Binary::TypeCodes, SharedGdi
Defined in:
lib/emfsvg/translation/handlers/image_handler.rb

Overview

Translate into EMR_STRETCHDIBITS with an embedded BI_RGB DIB.

v1 limitations:

* PNG data URIs only. JPEG and other formats fall through silently.
* No aspect-ratio handling (uses width/height verbatim).

Constant Summary collapse

STRETCHDIBITS_FIXED_SIZE =

Fixed portion of StretchDIBits record: 8 (emr) + 16 (bounds) + 64 (int32 src/dest dims) + 64 (off/cb/i_usage/dw_rop/cx/cy)

80 bytes.

80

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SharedGdi

#clip_bounds_for, #emit_create_brush, #emit_create_pen, #emit_delete, #emit_restore_dc, #emit_save_dc, #with_gdi_state

Class Method Details

.call(element, context) ⇒ Object



24
25
26
# File 'lib/emfsvg/translation/handlers/image_handler.rb', line 24

def self.call(element, context)
  new.translate(element, context)
end

Instance Method Details

#translate(element, context) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/emfsvg/translation/handlers/image_handler.rb', line 28

def translate(element, context)
  return unless element.data_uri?
  return unless element.mime_type == "image/png"

  dib = build_dib(element)
  return unless dib

  emit_stretch_dibits(element, dib, context)
end