class WirisPlugin::ImageFormatControllerPng
Public Class Methods
new()
click to toggle source
Calls superclass method
# File lib/com/wiris/plugin/impl/ImageFormatControllerPng.rb, line 10 def initialize() super() end
Public Instance Methods
getContentType()
click to toggle source
# File lib/com/wiris/plugin/impl/ImageFormatControllerPng.rb, line 13 def getContentType() return "image/png" end
getMetrics(bytes, ref_output)
click to toggle source
# 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)
click to toggle source
# 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