-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Khronos texture format -- -- This package implements low-level encoding and decoding for .ktx and -- .ktx2 files. -- -- A framework-specific wrapper may be needed to work with the decoded -- data and/or supercompression. Check out test/Spec.hs for usage -- examples. -- -- KTX 1: -- https://registry.khronos.org/KTX/specs/1.0/ktxspec.v1.html -- -- KTX 2: -- https://registry.khronos.org/KTX/specs/2.0/ktxspec.v2.html#_abstract @package ktx-codec @version 0.0.2.0 module Codec.Ktx.KeyValue type KeyValueData = Map Text Value -- | A wrapper for raw data. -- -- Use FromValue/ToValue to process. newtype Value Value :: ByteString -> Value text :: Text -> Value bytes :: ByteString -> Value number :: (Num a, Show a) => a -> Value class FromValue a fromValue :: FromValue a => Value -> Maybe a -- | Extract all valid (null-terminated utf8) values. textual :: KeyValueData -> Map Text Text getDataLe :: Int -> Get KeyValueData getData :: Get Word32 -> Int -> Get KeyValueData putDataLe :: KeyValueData -> Put putData :: (Word32 -> Put) -> KeyValueData -> Put instance GHC.Generics.Generic Codec.Ktx.KeyValue.Value instance GHC.Show.Show Codec.Ktx.KeyValue.Value instance GHC.Classes.Eq Codec.Ktx.KeyValue.Value instance Codec.Ktx.KeyValue.FromValue Data.Text.Internal.Text instance Codec.Ktx.KeyValue.FromValue Data.ByteString.Internal.ByteString module Codec.Ktx fromByteStringLazy :: ByteString -> Either (ByteOffset, String) Ktx fromByteString :: ByteString -> Either (ByteOffset, String) Ktx fromFile :: FilePath -> IO (Either (ByteOffset, String) Ktx) toBuilder :: Ktx -> Builder toFile :: FilePath -> Ktx -> IO () data Ktx Ktx :: Header -> KeyValueData -> MipLevels -> Ktx [header] :: Ktx -> Header [kvs] :: Ktx -> KeyValueData [images] :: Ktx -> MipLevels data Header Header :: ByteString -> Word32 -> Word32 -> Word32 -> Word32 -> Word32 -> Word32 -> Word32 -> Word32 -> Word32 -> Word32 -> Word32 -> Word32 -> Word32 -> Header [identifier] :: Header -> ByteString [endianness] :: Header -> Word32 [glType] :: Header -> Word32 [glTypeSize] :: Header -> Word32 [glFormat] :: Header -> Word32 [glInternalFormat] :: Header -> Word32 [glBaseInternalFormat] :: Header -> Word32 [pixelWidth] :: Header -> Word32 [pixelHeight] :: Header -> Word32 [pixelDepth] :: Header -> Word32 [numberOfArrayElements] :: Header -> Word32 [numberOfFaces] :: Header -> Word32 [numberOfMipmapLevels] :: Header -> Word32 [bytesOfKeyValueData] :: Header -> Word32 endiannessLE :: Word32 canonicalIdentifier :: ByteString type MipLevels = Vector MipLevel data MipLevel MipLevel :: Word32 -> Vector ArrayElement -> MipLevel [imageSize] :: MipLevel -> Word32 [arrayElements] :: MipLevel -> Vector ArrayElement newtype ArrayElement ArrayElement :: Vector Face -> ArrayElement [faces] :: ArrayElement -> Vector Face newtype Face Face :: Vector ZSlice -> Face [zSlices] :: Face -> Vector ZSlice newtype ZSlice ZSlice :: ByteString -> ZSlice [block] :: ZSlice -> ByteString getImages :: Header -> Get MipLevels putImages :: (Word32 -> Put) -> MipLevels -> Put mkGetWord32 :: Word32 -> Get Word32 mkPutWord32 :: Word32 -> Word32 -> Put instance GHC.Generics.Generic Codec.Ktx.Header instance GHC.Show.Show Codec.Ktx.Header instance GHC.Generics.Generic Codec.Ktx.ZSlice instance GHC.Generics.Generic Codec.Ktx.Face instance GHC.Show.Show Codec.Ktx.Face instance GHC.Generics.Generic Codec.Ktx.ArrayElement instance GHC.Show.Show Codec.Ktx.ArrayElement instance GHC.Generics.Generic Codec.Ktx.MipLevel instance GHC.Show.Show Codec.Ktx.MipLevel instance GHC.Generics.Generic Codec.Ktx.Ktx instance GHC.Show.Show Codec.Ktx.Ktx instance Data.Binary.Class.Binary Codec.Ktx.Ktx instance GHC.Show.Show Codec.Ktx.ZSlice instance Data.Binary.Class.Binary Codec.Ktx.Header module Codec.Ktx2.DFD data DFD DFD :: Word32 -> Vector Block -> DFD [dfdTotalSize] :: DFD -> Word32 [dfdBlocks] :: DFD -> Vector Block data Block Block :: Word32 -> Word32 -> Word32 -> Word32 -> ByteString -> Block [descriptorType] :: Block -> Word32 [vendorId] :: Block -> Word32 [descriptorBlockSize] :: Block -> Word32 [versionNumber] :: Block -> Word32 [body] :: Block -> ByteString instance GHC.Generics.Generic Codec.Ktx2.DFD.Block instance GHC.Show.Show Codec.Ktx2.DFD.Block instance GHC.Classes.Eq Codec.Ktx2.DFD.Block instance GHC.Generics.Generic Codec.Ktx2.DFD.DFD instance GHC.Show.Show Codec.Ktx2.DFD.DFD instance GHC.Classes.Eq Codec.Ktx2.DFD.DFD instance Data.Binary.Class.Binary Codec.Ktx2.DFD.DFD instance Data.Binary.Class.Binary Codec.Ktx2.DFD.Block module Codec.Ktx2.DFD.Khronos.BasicV2 -- | Khronos pattern VENDOR_ID :: (Eq a, Num a) => a -- | Basic DFD Block pattern DESCRIPTOR_TYPE :: (Eq a, Num a) => a -- | KDF v1.3 pattern VERSION :: (Eq a, Num a) => a -- | A basic descriptor block is designed to encode common metadata -- associated with bulk data — especially image or texture data. -- -- While this descriptor holds more information about the data -- interpretation than is needed by many applications, a comprehensive -- encoding reduces the risk of metadata needed by different APIs being -- lost in translation. -- -- The format is described in terms of a repeating axis-aligned texel -- block composed of samples. Each sample contains a single channel of -- information with a single spatial offset within the texel block, and -- consists of an amount of contiguous data. This descriptor block -- consists of information about the interpretation of the texel block as -- a whole, supplemented by a description of a number of samples taken -- from one or more planes of contiguous memory. -- -- -- https://registry.khronos.org/DataFormat/specs/1.3/dataformat.1.3.html data BasicV2 BasicV2 :: Word8 -> Word8 -> Word8 -> Word8 -> Word8 -> Word8 -> Word8 -> Word8 -> Word8 -> Word8 -> Word8 -> Word8 -> Word8 -> Word8 -> Word8 -> Word8 -> Vector Sample -> BasicV2 [colorModel] :: BasicV2 -> Word8 [colorPrimaries] :: BasicV2 -> Word8 [transferFunction] :: BasicV2 -> Word8 [flags] :: BasicV2 -> Word8 -- | The value held in each of these fields is one fewer than the size of -- the block in that dimension — that is, a value of 0 represents a size -- of 1, a value of 1 represents a size of 2, etc. -- -- A texel block which covers fewer than four dimensions should have a -- size of 1 in each dimension that it lacks, and therefore the -- corresponding fields in the representation should be 0. [texelBlockDimension0] :: BasicV2 -> Word8 [texelBlockDimension1] :: BasicV2 -> Word8 [texelBlockDimension2] :: BasicV2 -> Word8 [texelBlockDimension3] :: BasicV2 -> Word8 [bytesPlane0] :: BasicV2 -> Word8 [bytesPlane1] :: BasicV2 -> Word8 [bytesPlane2] :: BasicV2 -> Word8 [bytesPlane3] :: BasicV2 -> Word8 [bytesPlane4] :: BasicV2 -> Word8 [bytesPlane5] :: BasicV2 -> Word8 [bytesPlane6] :: BasicV2 -> Word8 [bytesPlane7] :: BasicV2 -> Word8 [samples] :: BasicV2 -> Vector Sample getter :: Int -> Get BasicV2 putter :: BasicV2 -> PutM () data Sample Sample :: Word16 -> Word8 -> Word8 -> Word8 -> Word8 -> Word8 -> Word8 -> Word32 -> Word32 -> Sample [bitOffset] :: Sample -> Word16 [bitLength] :: Sample -> Word8 [channelType] :: Sample -> Word8 [samplePosition0] :: Sample -> Word8 [samplePosition1] :: Sample -> Word8 [samplePosition2] :: Sample -> Word8 [samplePosition3] :: Sample -> Word8 [sampleLower] :: Sample -> Word32 [sampleUpper] :: Sample -> Word32 fromBlock :: Block -> Maybe BasicV2 toBlock :: BasicV2 -> Block instance GHC.Generics.Generic Codec.Ktx2.DFD.Khronos.BasicV2.Sample instance GHC.Show.Show Codec.Ktx2.DFD.Khronos.BasicV2.Sample instance GHC.Classes.Eq Codec.Ktx2.DFD.Khronos.BasicV2.Sample instance GHC.Generics.Generic Codec.Ktx2.DFD.Khronos.BasicV2.BasicV2 instance GHC.Show.Show Codec.Ktx2.DFD.Khronos.BasicV2.BasicV2 instance GHC.Classes.Eq Codec.Ktx2.DFD.Khronos.BasicV2.BasicV2 instance Data.Binary.Class.Binary Codec.Ktx2.DFD.Khronos.BasicV2.Sample module Codec.Ktx2.Header data Header Header :: Word32 -> Word32 -> Word32 -> Word32 -> Word32 -> Word32 -> Word32 -> Word32 -> Word32 -> Word32 -> Word32 -> Word32 -> Word32 -> Word64 -> Word64 -> Header -- | Specifies the image format using Vulkan VkFormat enum values. -- It can be any value defined in core Vulkan 1.2, future core versions -- or registered Vulkan extensions, except for values listed in Table 1, -- “Prohibited Formats” and any *SCALED* or -- *[2-9]PLANE* formats added in future. [vkFormat] :: Header -> Word32 -- | Specifies the size of the data type in bytes used to upload the data -- to a graphics API. When typeSize is greater than 1, software -- on big-endian systems must endian convert all image data since it is -- little-endian. When format is VK_FORMAT_UNDEFINED, typeSize -- must equal 1. [typeSize] :: Header -> Word32 [pixelWidth] :: Header -> Word32 [pixelHeight] :: Header -> Word32 [pixelDepth] :: Header -> Word32 -- | Specifies the number of array elements. If the texture is not an array -- texture, layerCount must equal 0. [layerCount] :: Header -> Word32 -- | If faceCount is equal to 6, pixelHeight must be -- equal to pixelWidth, and pixelDepth must be 0. [faceCount] :: Header -> Word32 -- | Specifies the number of levels in the Mip Level Array and, by -- extension, the number of indices in the Level Index array. A KTX file -- does not need to contain a complete mipmap pyramid. [levelCount] :: Header -> Word32 -- | Indicates if a supercompression scheme has been applied to the data in -- levelImages. It must be one of the values from Table 2, -- “Supercompression Schemes”. A value of 0 indicates no -- supercompression. [supercompressionScheme] :: Header -> Word32 -- | The offset from the start of the file of the dfdTotalSize -- field of the Data Format Descriptor. [dfdByteOffset] :: Header -> Word32 -- | The total number of bytes in the Data Format Descriptor including the -- dfdTotalSize field. dfdByteLength must equal -- dfdTotalSize. [dfdByteLength] :: Header -> Word32 -- | An arbitrary number of keyvalue pairs may follow the Index. These -- can be used to encode any arbitrary data. The kvdByteOffset field -- gives the offset of this data, i.e. that of first keyvalue pair, -- from the start of the file. The value must be 0 when kvdByteLength = -- 0. [kvdByteOffset] :: Header -> Word32 -- | The total number of bytes of key/value data including all -- keyAndValueByteLength fields, all keyAndValue fields and all -- valuePadding fields. [kvdByteLength] :: Header -> Word32 -- | The offset from the start of the file of supercompressionGlobalData. -- The value must be 0 when sgdByteLength = 0. [sgdByteOffset] :: Header -> Word64 -- | The number of bytes of supercompressionGlobalData. For -- supercompression schemes for which no reference is provided in the -- Global Data Format column of Table 2, “Supercompression Schemes”. the -- value must be 0. [sgdByteLength] :: Header -> Word64 canonicalIdentifier :: ByteString pattern SC_NONE :: (Eq a, Num a) => a pattern SC_BASISLZ :: (Eq a, Num a) => a pattern SC_ZSTANDARD :: (Eq a, Num a) => a pattern SC_ZLIB :: (Eq a, Num a) => a instance GHC.Generics.Generic Codec.Ktx2.Header.Header instance GHC.Show.Show Codec.Ktx2.Header.Header instance GHC.Classes.Eq Codec.Ktx2.Header.Header instance Data.Binary.Class.Binary Codec.Ktx2.Header.Header module Codec.Ktx2.Level data Level Level :: Word64 -> Word64 -> Word64 -> Level -- | The offset from the start of the file of the first byte of image data -- for mip level. It is the offset of the first byte after any -- mipPadding. [byteOffset] :: Level -> Word64 -- | The total size of the data for supercompressed mip level. [byteLength] :: Level -> Word64 -- | the number of bytes of pixel data in LOD level after reflation from -- supercompression. This includes all z slices, all faces, all rows (or -- rows of blocks) and all pixels (or blocks) in each row for the mipmap -- level. When supercompressionScheme == 0, byteLength -- must have the same value as this. When supercompressionScheme == -- 1 (BasisLZ) the value must be 0. [uncompressedByteLength] :: Level -> Word64 instance GHC.Generics.Generic Codec.Ktx2.Level.Level instance GHC.Show.Show Codec.Ktx2.Level.Level instance GHC.Classes.Eq Codec.Ktx2.Level.Level instance Data.Binary.Class.Binary Codec.Ktx2.Level.Level -- | Block-by-block extraction of data from a KTX2 file. -- --