Module: JXL::IO::PFM

Defined in:
lib/jxl/io/pfm.rb

Class Method Summary collapse

Class Method Details

.dump(image) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/jxl/io/pfm.rb', line 8

def dump(image)
  grayscale = image.num_color_channels == 1
  planes = grayscale ? [image.channels.first] : image.channels.first(3)
  values = []
  (image.height - 1).downto(0) do |y|
    image.width.times do |x|
      planes.each { |plane| values << plane[x, y] }
    end
  end
  "#{grayscale ? 'Pf' : 'PF'}\n#{image.width} #{image.height}\n-1.0\n".b + values.pack("e*")
end