Class: WirisPlugin::ImageFormatControllerPng
- Inherits:
-
Object
- Object
- WirisPlugin::ImageFormatControllerPng
- Extended by:
- ImageFormatControllerInterface
- Includes:
- Wiris
- Defined in:
- lib/com/wiris/plugin/impl/ImageFormatControllerPng.rb
Instance Method Summary collapse
- #getContentType ⇒ Object
- #getMetrics(bytes, ref_output) ⇒ Object
-
#initialize ⇒ ImageFormatControllerPng
constructor
A new instance of ImageFormatControllerPng.
- #scalateMetrics(dpi, metrics) ⇒ Object
Methods included from ImageFormatControllerInterface
Constructor Details
#initialize ⇒ ImageFormatControllerPng
Returns a new instance of ImageFormatControllerPng.
10 11 12 |
# File 'lib/com/wiris/plugin/impl/ImageFormatControllerPng.rb', line 10 def initialize() super() end |
Instance Method Details
#getContentType ⇒ Object
13 14 15 |
# File 'lib/com/wiris/plugin/impl/ImageFormatControllerPng.rb', line 13 def getContentType() return "image/png" end |
#getMetrics(bytes, ref_output) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/com/wiris/plugin/impl/ImageFormatControllerPng.rb', line 16 def getMetrics(bytes, ref_output) output = ref_output width = 0 height = 0 dpi = 0 baseline = 0 bi = BytesInput.new(bytes) n = bytes::length() alloc = 10 b = Bytes::alloc(alloc) bi::readBytes(b,0,8) n -= 8 while n > 0 len = bi::readInt32() typ = bi::readInt32() if typ == 1229472850 width = bi::readInt32() height = bi::readInt32() bi::readInt32() bi::readByte() else if typ == 1650545477 baseline = bi::readInt32() else if typ == 1883789683 dpi = bi::readInt32() dpi = (Math::round(dpi/39.37)) bi::readInt32() bi::readByte() else if len > alloc alloc = len b = Bytes::alloc(alloc) end bi::readBytes(b,0,len) end end end bi::readInt32() n -= len + 12 end if output != nil PropertiesTools::setProperty(output,"width","" + width.to_s) PropertiesTools::setProperty(output,"height","" + height.to_s) PropertiesTools::setProperty(output,"baseline","" + baseline.to_s) if dpi != 96 PropertiesTools::setProperty(output,"dpi","" + dpi.to_s) end r = "" else r = (((("&cw=" + width.to_s) + "&ch=") + height.to_s) + "&cb=") + baseline.to_s if dpi != 96 r = (r + "&dpi=") + dpi.to_s end end return r end |
#scalateMetrics(dpi, metrics) ⇒ Object
73 74 75 76 77 78 |
# File 'lib/com/wiris/plugin/impl/ImageFormatControllerPng.rb', line 73 def scalateMetrics(dpi, metrics) f = 96/dpi metrics::set("width",(f*metrics::get("width"))) metrics::set("height",(f*metrics::get("height"))) metrics::set("baseline",(f*metrics::get("baseline"))) end |