def scanline_positions
      scanline_pos = [0]
      amount = @filtered_data.size
      @interlace_pass_count = []
      if self.interlaced?
        # Adam7
        # Pass 1
        v = 1 + (@width / 8.0).ceil * @sample_size
        (@height / 8.0).ceil.times do
          scanline_pos << scanline_pos.last + v
        end
        @interlace_pass_count << scanline_pos.size
        # Pass 2
        v = 1 + ((@width - 4) / 8.0).ceil * @sample_size
        (@height / 8.0).ceil.times do
          scanline_pos << scanline_pos.last + v
        end
        @interlace_pass_count << scanline_pos.size
        # Pass 3
        v = 1 + (@width / 4.0).ceil * @sample_size
        ((@height - 4) / 8.0).ceil.times do
          scanline_pos << scanline_pos.last + v
        end
        @interlace_pass_count << scanline_pos.size
        # Pass 4
        v = 1 + ((@width - 2) / 4.0).ceil * @sample_size
        (@height / 4.0).ceil.times do
          scanline_pos << scanline_pos.last + v
        end
        @interlace_pass_count << scanline_pos.size
        # Pass 5
        v = 1 + (@width / 2.0).ceil * @sample_size
        ((@height - 2) / 4.0).ceil.times do
          scanline_pos << scanline_pos.last + v
        end
        @interlace_pass_count << scanline_pos.size
        # Pass 6
        v = 1 + ((@width - 1) / 2.0).ceil * @sample_size
        (@height / 2.0).ceil.times do
          scanline_pos << scanline_pos.last + v
        end
        @interlace_pass_count << scanline_pos.size
        # Pass 7
        v = 1 + @width * @sample_size
        ((@height - 1) / 2.0).ceil.times do
          scanline_pos << scanline_pos.last + v
        end
        scanline_pos.pop  # no need to keep last position
      end
      loop do
        v = scanline_pos.last + (1 + @width * @sample_size)
        break if v >= amount
        scanline_pos << v
      end
      scanline_pos
    end
def scanline_positions
      scanline_pos = [0]
      amount = @filtered_data.size
      @interlace_pass_count = []
      if self.interlaced?
        # Adam7
        # Pass 1
        v = 1 + (@width / 8.0).ceil * @sample_size
        (@height / 8.0).ceil.times do
          scanline_pos << scanline_pos.last + v
        end
        @interlace_pass_count << scanline_pos.size
        # Pass 2
        v = 1 + ((@width - 4) / 8.0).ceil * @sample_size
        (@height / 8.0).ceil.times do
          scanline_pos << scanline_pos.last + v
        end
        @interlace_pass_count << scanline_pos.size
        # Pass 3
        v = 1 + (@width / 4.0).ceil * @sample_size
        ((@height - 4) / 8.0).ceil.times do
          scanline_pos << scanline_pos.last + v
        end
        @interlace_pass_count << scanline_pos.size
        # Pass 4
        v = 1 + ((@width - 2) / 4.0).ceil * @sample_size
        (@height / 4.0).ceil.times do
          scanline_pos << scanline_pos.last + v
        end
        @interlace_pass_count << scanline_pos.size
        # Pass 5
        v = 1 + (@width / 2.0).ceil * @sample_size
        ((@height - 2) / 4.0).ceil.times do
          scanline_pos << scanline_pos.last + v
        end
        @interlace_pass_count << scanline_pos.size
        # Pass 6
        v = 1 + ((@width - 1) / 2.0).ceil * @sample_size
        (@height / 2.0).ceil.times do
          scanline_pos << scanline_pos.last + v
        end
        @interlace_pass_count << scanline_pos.size
        # Pass 7
        v = 1 + @width * @sample_size
        ((@height - 1) / 2.0).ceil.times do
          scanline_pos << scanline_pos.last + v
        end
        scanline_pos.pop  # no need to keep last position
      end
      loop do
        v = scanline_pos.last + (1 + @width * @sample_size)
        break if v >= amount
        scanline_pos << v
      end
      scanline_pos
    end
Calculate positions of scanlines