mirror of
https://github.com/sdsykes/fastimage.git
synced 2025-11-09 00:02:45 -05:00
Add read_string_int method to StreamUtil
This commit is contained in:
parent
39d9dfbf05
commit
035ebe3ed6
@ -343,6 +343,14 @@ class FastImage
|
|||||||
def read_int
|
def read_int
|
||||||
read(2).unpack('n')[0]
|
read(2).unpack('n')[0]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def read_string_int
|
||||||
|
value = []
|
||||||
|
while read(1) =~ /(\d)/
|
||||||
|
value << $1
|
||||||
|
end
|
||||||
|
value.join.to_i
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class FiberStream # :nodoc:
|
class FiberStream # :nodoc:
|
||||||
@ -625,10 +633,12 @@ class FastImage
|
|||||||
case char
|
case char
|
||||||
when "="
|
when "="
|
||||||
if attr_name.join =~ /width/i
|
if attr_name.join =~ /width/i
|
||||||
@width = attr_value.to_i
|
@stream.read(1)
|
||||||
|
@width = @stream.read_string_int
|
||||||
return if @height
|
return if @height
|
||||||
elsif attr_name.join =~ /height/i
|
elsif attr_name.join =~ /height/i
|
||||||
@height = attr_value.to_i
|
@stream.read(1)
|
||||||
|
@height = @stream.read_string_int
|
||||||
return if @width
|
return if @width
|
||||||
elsif attr_name.join =~ /viewbox/i
|
elsif attr_name.join =~ /viewbox/i
|
||||||
values = attr_value.split(/\s/)
|
values = attr_value.split(/\s/)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user