support EMF
Support of Microsoft EMF format:
https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-emf/e4a35c41-e8e3-43f9-bc07-a18e99bb866d
https://stackoverflow.com/questions/3391087/extracting-width-height-dimensions-from-emf-image-files
Thank you for your extremely diligent feedback. You are a better human being than I am. :-)
Few small things left: CHANGELOG entry, description in gemspec and legacy ruby doesn't understand L< 😞.
I've checked few variants and did a benchmark:
require 'securerandom'
require 'benchmark'
STRINGS = 1_000_000.times.map do
SecureRandom.random_bytes(16)
end
UMAX = 256**4
SMAX = UMAX / 2
Benchmark.bmbm do |x|
x.report('repack') do
STRINGS.map{ |s| s.unpack('V*').pack('L*').unpack('l*') }
end
x.report('conditional') do
STRINGS.map{ |s| s.unpack('V*').map{ |u| u < SMAX ? u : u - UMAX } }
end
x.report('arythemical') do
STRINGS.map{ |s| s.unpack('V*').map{ |u| (u + SMAX) % UMAX - SMAX } }
end
end
outputs:
Rehearsal -----------------------------------------------
repack 4.400000 0.080000 4.480000 ( 4.480014)
conditional 2.860000 0.070000 2.930000 ( 2.934557)
arythemical 3.200000 0.030000 3.230000 ( 3.228823)
------------------------------------- total: 10.640000sec
user system total real
repack 4.590000 0.050000 4.640000 ( 4.641003)
conditional 2.500000 0.010000 2.510000 ( 2.510647)
arythemical 3.000000 0.020000 3.020000 ( 3.012003)
not sure which is better from clarity/readability and maybe there is another option. Alternative can be conditionally used for RUBY_VERSION < '1.9'.
Also forgot to attach non square emf converted from svg using Inkscape + changed values to also be negative 74x77.emf.zip (zip as emf is not supported for upload)
Thank you, will get to these.
Happy for you to squash merge.
And can I say again, Ivan, you are a very good human being, and I'm honoured to have contributed to your gem. Thank you for your help and diligence!