JuicyPixels-blurhash-0.1.0.0: Blurhash is a very compact represenation of a placeholder for an image

Copyright(c) 2020 Sam Protas
LicenseBSD3
MaintainerSam Protas <sam.protas@gmail.com>
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Codec.Picture.Blurhash.Internal.Decode

Description

Internal Blurhash decoding implementation.

Note: This is an internal module not subject to PVP adherence.

Synopsis

Documentation

data DecodeConfig Source #

Configuration for how to decode a blurhash to an image.

>>> let myDecodeConfig = decodeConfigDefault { punch = 1.1, outputWidth = 64, outputHeight = 64}

Constructors

DecodeConfig 

Fields

Instances
Show DecodeConfig Source # 
Instance details

Defined in Codec.Picture.Blurhash.Internal.Decode

Generic DecodeConfig Source # 
Instance details

Defined in Codec.Picture.Blurhash.Internal.Decode

Associated Types

type Rep DecodeConfig :: Type -> Type #

type Rep DecodeConfig Source # 
Instance details

Defined in Codec.Picture.Blurhash.Internal.Decode

type Rep DecodeConfig = D1 (MetaData "DecodeConfig" "Codec.Picture.Blurhash.Internal.Decode" "JuicyPixels-blurhash-0.1.0.0-DaqpokmttsPFp5F95koWnn" False) (C1 (MetaCons "DecodeConfig" PrefixI True) (S1 (MetaSel (Just "punch") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Float) :*: (S1 (MetaSel (Just "outputWidth") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Int) :*: S1 (MetaSel (Just "outputHeight") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Int))))

data DecodeError Source #

Decoding error types.

Constructors

InvalidCharacterError Word8

The provided blurhash included an un-decodable byte.

InvalidHashLength

The provided blurhash length was wrong.

Instances
Show DecodeError Source # 
Instance details

Defined in Codec.Picture.Blurhash.Internal.Decode

Generic DecodeError Source # 
Instance details

Defined in Codec.Picture.Blurhash.Internal.Decode

Associated Types

type Rep DecodeError :: Type -> Type #

type Rep DecodeError Source # 
Instance details

Defined in Codec.Picture.Blurhash.Internal.Decode

type Rep DecodeError = D1 (MetaData "DecodeError" "Codec.Picture.Blurhash.Internal.Decode" "JuicyPixels-blurhash-0.1.0.0-DaqpokmttsPFp5F95koWnn" False) (C1 (MetaCons "InvalidCharacterError" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Word8)) :+: C1 (MetaCons "InvalidHashLength" PrefixI False) (U1 :: Type -> Type))

decodeConfigDefault :: DecodeConfig Source #

A reasonable default configuration for decoding.

>>> punch decodeConfigDefault == 1
True
>>> outputWidth decodeConfigDefault == 32
True
>>> outputHeight decodeConfigDefault == 32
True

decodeRGB8 Source #

Arguments

:: ByteString

The blurhash

-> Either DecodeError (Image PixelRGB8) 

Decode a blurhash into an Image PixelRGB8. Calls decodeRGB8WithConfig with decodeConfigDefault.

When in doubt, use this function to decode a blurhash.

decodeRGB8WithConfig Source #

Arguments

:: DecodeConfig 
-> ByteString

The blurhash.

-> Either DecodeError (Image PixelRGB8) 

Decode a blurhash into an Image PixelRGB8 given a DecodeConfig

decodeLinear Source #

Arguments

:: ByteString

The blurhash

-> Either DecodeError (Image PixelRGBF) 

Decode a blurhash into an Image PixelRGBF. Calls decodeLinearWithConfig with decodeConfigDefault.

Note: Blurhash implementations use a non-naive PixelRGBF to PixelRGB8 conversion. If your ultimate goal is to end up with an Image PixelRGB8, be careful using this function and scaling pixels by 255 as you will get different results.

decodeLinearWithConfig Source #

Arguments

:: DecodeConfig 
-> ByteString

The blurhash

-> Either DecodeError (Image PixelRGBF) 

Decode a blurhash into an Image PixelRGBF given a DecodeConfig.

Note: Blurhash implementations use a non-naive PixelRGBF to PixelRGB8 conversion. If your ultimate goal is to end up with an Image PixelRGB8, be careful using this function and scaling pixels by 255 as you will get different results.

decodePixel :: Vector PixelRGBF -> Int -> Int -> Int -> Int -> Int -> Int -> PixelRGBF Source #

Helper function to decode a single pixel.

base83DecodeTagged :: ByteString -> Either DecodeError Int Source #

Helper function to decode a base83 value or return an errorl