imagineer v0.3.3 Imagineer.Image.PNG.Filter.Basic.Paeth View Source

Link to this section Summary

Functions

The Paeth prediction is calculated as left + above - upper_left. This function returns the value nearest to the Paeth prediction, breaking ties in the order of left, above, upper_left

Takes in the uncompressed binary representation of a row, the unfiltered row row above it, and the number of bytes per pixel. Decodes according to the Paeth filter

Link to this section Functions

Link to this function predictor(left, above, upper_left) View Source

The Paeth prediction is calculated as left + above - upper_left. This function returns the value nearest to the Paeth prediction, breaking ties in the order of left, above, upper_left.

For more information, see the PNG documentation for the [Paeth filter type] (http://www.w3.org/TR/PNG-Filters.html#Filter-type-4-Paeth)

Example

iex> Imagineer.Image.PNG.Filter.Basic.Paeth.predictor(37, 84, 1)
84

iex> Imagineer.Image.PNG.Filter.Basic.Paeth.predictor(118, 128, 125)
118

iex> Imagineer.Image.PNG.Filter.Basic.Paeth.predictor(37, 84, 61)
61
Link to this function unfilter(row, prior_row, bytes_per_pixel) View Source

Takes in the uncompressed binary representation of a row, the unfiltered row row above it, and the number of bytes per pixel. Decodes according to the Paeth filter.

For more information, see the PNG documentation for the [Paeth filter type] (http://www.w3.org/TR/PNG-Filters.html#Filter-type-4-Paeth)

Examples

iex> unfiltered_prior_row = <<18, 39, 117, 39, 201, 7>>
iex> filtered_row = <<86, 5, 226, 185, 146, 181>>
iex> Imagineer.Image.PNG.Filter.Basic.Paeth.unfilter(filtered_row, unfiltered_prior_row, 3)
<<104, 44, 87, 33, 91, 188>>

iex> unfiltered_prior_row = <<18, 39, 117, 39, 201, 7>>
iex> filtered_row = <<86, 5, 226, 245, 146, 181>>
iex> Imagineer.Image.PNG.Filter.Basic.Paeth.unfilter(filtered_row, unfiltered_prior_row, 2)
<<104, 44, 87, 33, 91, 188>>