ExPng.Pixel (ExPng v0.2.0)

Represents a single pixel in an image, storing red, green, blue and alpha values, or an index when part of a paletted image.

Link to this section Summary

Functions

Shortcut for returning an opaque black pixel.

Returns a grayscale pixel with the given value for the red, green, and blue values.

Returns a pixel with the arguments as the red, green, and blue values

Returns a pixel with the arguments as the red, green, blue, and alpha values

Shortcut for returning an opaque white pixel.

Link to this section Types

Link to this type

rgba_value()

Specs

rgba_value() :: 0..255

Specs

t() :: %ExPng.Pixel{
  a: rgba_value(),
  b: rgba_value(),
  g: rgba_value(),
  index: ExPng.maybe(integer()),
  r: rgba_value()
}

Link to this section Functions

Specs

black() :: t()

Shortcut for returning an opaque black pixel.

Link to this function

black_or_white?(arg1)

Specs

black_or_white?(t()) :: boolean()
Link to this function

grayscale(gray, alpha \\ 255)

Specs

grayscale(rgba_value(), ExPng.maybe(rgba_value())) :: t()

Returns a grayscale pixel with the given value for the red, green, and blue values.

iex> Pixel.grayscale(100)
%Pixel{r: 100, g: 100, b: 100, a: 255}

If a second argument is passed, it sets the alpha value for the pixel.

iex> Pixel.grayscale(100, 200)
%Pixel{r: 100, g: 100, b: 100, a: 200}
Link to this function

grayscale?(arg1)

Specs

grayscale?(t()) :: boolean()
Link to this function

line_bytesize(raw_data)

Link to this function

line_bytesize(color_mode, bit_depth, width)

Specs

opaque?(t()) :: boolean()
Link to this function

pixel_bytesize(raw_data)

Link to this function

pixel_bytesize(color_mode, bit_depth \\ 8)

Specs

rgb(rgba_value(), rgba_value(), rgba_value()) :: t()

Returns a pixel with the arguments as the red, green, and blue values

iex> Pixel.rgb(50, 100, 200)
%Pixel{r: 50, g: 100, b: 200, a: 255}
Link to this function

rgba(r, g, b, a)

Specs

rgba(rgba_value(), rgba_value(), rgba_value(), rgba_value()) :: t()

Returns a pixel with the arguments as the red, green, blue, and alpha values

iex> Pixel.rgba(20, 100, 100, 75)
%Pixel{r: 20, g: 100, b: 100, a: 75}

Specs

white() :: t()

Shortcut for returning an opaque white pixel.