# Path: xnb_parse/type_reader.py
# class ReaderError(Error):
#     pass


from struct import Struct
from xnb_parse.type_reader import ReaderError
"""
Decode DXT/other textures to RGBA
"""

from __future__ import print_function




def decode_bgra(data, width, height, needs_swap, alpha='yes'):
    if needs_swap:
        conv = 'argb_rgba'
    else:
        conv = 'bgra_rgba'
    return decode32(data, width, height, conv, alpha=alpha)


def decode_rgba(data, width, height, needs_swap, alpha='yes'):
    if needs_swap:
        conv = 'abgr_rgba'
    else:
        conv = 'rgba_rgba'
    return decode32(data, width, height, conv, alpha=alpha)


def decode32(data, width, height, conv, alpha='yes'):
    if conv not in ('rgba_rgba', 'abgr_rgba', 'bgra_rgba', 'argb_rgba'):

# Path: xnb_parse/type_reader.py
# class ReaderError(Error):
#     pass


# Path: xnb_parse/file_formats/img_decode.py
from struct import Struct
from xnb_parse.type_reader import ReaderError

"""
Decode DXT/other textures to RGBA
"""

from __future__ import print_function




def decode_bgra(data, width, height, needs_swap, alpha='yes'):
    if needs_swap:
        conv = 'argb_rgba'
    else:
        conv = 'bgra_rgba'
    return decode32(data, width, height, conv, alpha=alpha)


def decode_rgba(data, width, height, needs_swap, alpha='yes'):
    if needs_swap:
        conv = 'abgr_rgba'
    else:
        conv = 'rgba_rgba'
    return decode32(data, width, height, conv, alpha=alpha)


def decode32(data, width, height, conv, alpha='yes'):
    if conv not in ('rgba_rgba', 'abgr_rgba', 'bgra_rgba', 'argb_rgba'):

        raise ReaderError("Unknown conversion: '{}'".format(conv))