def each_scanline # :yield: scanline
      return enum_for :each_scanline unless block_given?
      prev_filters = self.filter_types
      is_refilter_needed = false
      filter_codecs = []
      wrap_with_rewind(@filtered_data) do
        at = 0
        scanline_positions.push(@filtered_data.size).inject do |pos, delimit|
          scanline = Scanline.new @filtered_data, pos, (delimit - pos - 1), at
          yield scanline
          if fabricate_scanline(scanline, prev_filters, filter_codecs)
            is_refilter_needed = true
          end
          at += 1
          delimit
        end
      end
      apply_filters(prev_filters, filter_codecs) if is_refilter_needed
      compress
      self
    end
def each_scanline # :yield: scanline
      return enum_for :each_scanline unless block_given?
      prev_filters = self.filter_types
      is_refilter_needed = false
      filter_codecs = []
      wrap_with_rewind(@filtered_data) do
        at = 0
        scanline_positions.push(@filtered_data.size).inject do |pos, delimit|
          scanline = Scanline.new @filtered_data, pos, (delimit - pos - 1), at
          yield scanline
          if fabricate_scanline(scanline, prev_filters, filter_codecs)
            is_refilter_needed = true
          end
          at += 1
          delimit
        end
      end
      apply_filters(prev_filters, filter_codecs) if is_refilter_needed
      compress
      self
    end
Process each scanline.

 It takes a block with a parameter. The parameter must be an instance of
 PNGlitch::Scanline and it provides ways to edit the filter type and the data
 of the scanlines. Normally it iterates the number of the PNG image height.

 Here is some examples:

   pnglitch.each_scanline do |line|
     line.gsub!(/\w/, '0') # replace all alphabetical chars in data
   end

   pnglicth.each_scanline do |line|
     line.change_filter 3  # change all filter to 3, data will get re-filtering (it won't be a glitch)
   end

   pnglicth.each_scanline do |line|
     line.graft 3          # change all filter to 3 and data remains (it will be a glitch)
   end

 See PNGlitch::Scanline for more details.

 This method is safer than +glitch+ but will be a little bit slow.

 -----

 Please note that +each_scanline+ will apply the filters *after* the loop. It means
 a following example doesn't work as expected.

   pnglicth.each_scanline do |line|
     line.change_filter 3
     line.gsub! /\d/, 'x'  # wants to glitch after changing filters.
   end

 To glitch after applying the new filter types, it should be called separately like:

   pnglicth.each_scanline do |line|
     line.change_filter 3
   end
   pnglicth.each_scanline do |line|
     line.gsub! /\d/, 'x'
   end