pngleam
Types
pub type BinaryRowData =
List(BitArray)
pub type ColorType {
Greyscale
Color
Indexed
GreyscaleWithAlpha
ColorWithAlpha
}
Constructors
-
Greyscale
-
Color
-
Indexed
-
GreyscaleWithAlpha
-
ColorWithAlpha
pub type ColorValue =
#(Int, Int, Int)
pub type ColorWithAlphaValue =
#(Int, Int, Int, Int)
pub type CompressionLevel =
gzlib.CompressionLevel
pub type FilterType {
None
Sub
Up
Average
Paeth
}
Constructors
-
None
-
Sub
-
Up
-
Average
-
Paeth
pub type GreyscaleValue =
Int
pub type GreyscaleWithAlphaValue =
#(Int, Int)
pub type PaletteColor =
#(Int, Int, Int)
pub type PaletteColors =
List(PaletteColor)
pub type PalleteIndex =
Int
pub type ParseError {
InvalidSignature
InvalidChunkTag
ChecksumMismatch
InvalidChunkOrder
MissingHeaderChunk
InvalidChunkData
InvalidColorType
InvalidBitDepth
InvalidCompressionType
InvalidFilterMethod
InvalidInterlaceMethod
UnsupportedInterlaceMethod
InvalidRowFilterType
InvalidRowData
}
Constructors
-
InvalidSignature
-
InvalidChunkTag
-
ChecksumMismatch
-
InvalidChunkOrder
-
MissingHeaderChunk
-
InvalidChunkData
-
InvalidColorType
-
InvalidBitDepth
-
InvalidCompressionType
-
InvalidFilterMethod
-
InvalidInterlaceMethod
-
UnsupportedInterlaceMethod
-
InvalidRowFilterType
-
InvalidRowData
pub type PixelData {
GreyscaleData(Grid(GreyscaleValue))
ColorData(Grid(ColorValue))
IndexedData(Grid(PalleteIndex))
GreyscaleWithAlphaData(Grid(GreyscaleWithAlphaValue))
ColorWithAlphaData(Grid(ColorWithAlphaValue))
}
Constructors
-
GreyscaleData(Grid(GreyscaleValue))
-
ColorData(Grid(ColorValue))
-
IndexedData(Grid(PalleteIndex))
-
GreyscaleWithAlphaData(Grid(GreyscaleWithAlphaValue))
-
ColorWithAlphaData(Grid(ColorWithAlphaValue))
pub type PngBitArrayData =
PngData(RawPalette, BinaryRowData)
pub type PngData(p, i) {
PngData(
metadata: PngMetadata,
palette: option.Option(p),
image_data: i,
)
}
Constructors
-
PngData( metadata: PngMetadata, palette: option.Option(p), image_data: i, )
pub type PngMetadata {
PngMetadata(width: Int, height: Int, color_info: ColorInfo)
}
Constructors
-
PngMetadata(width: Int, height: Int, color_info: ColorInfo)
pub type PngPixelData =
PngData(PaletteColors, PixelData)
pub type RawPalette =
BitArray
Constants
pub const compression_level: fn(Int) ->
Result(CompressionLevel, Nil)
pub const default_compression: CompressionLevel
pub const greyscale_8bit: ColorInfo
pub const max_compression: CompressionLevel
pub const min_compression: CompressionLevel
pub const no_compression: CompressionLevel
pub const rgba_16bit: ColorInfo
Functions
pub fn color_info(
color_type color_type: ColorType,
bit_depth bit_depth: Int,
) -> Result(ColorInfo, Nil)
pub fn color_info_bits(color_info: ColorInfo) -> Int
pub fn filter_type_to_int(filter_type: FilterType) -> Int
pub fn from_packed(
row_data row_data: List(BitArray),
width width: Int,
height height: Int,
color_info color_info: ColorInfo,
compression_level compression_level: CompressionLevel,
) -> BitArray
pub fn int_to_filter_type(
filter_type: Int,
) -> Result(FilterType, Nil)
pub fn parse_metadata(
data: BitArray,
) -> Result(PngMetadata, ParseError)
pub fn parse_to_bit_arrays(
data: BitArray,
) -> Result(PngData(BitArray, List(BitArray)), ParseError)
pub fn parse_to_pixel_data(
data: BitArray,
) -> Result(
PngData(List(#(Int, Int, Int)), PixelData),
ParseError,
)