# Path: xnb_parse/type_reader.py
# class ReaderError(Error):
#     pass
# 
# Path: xnb_parse/xna_types/xna_primitive.py
# class Enum(object):
#     __slots__ = ('_value', '_name')
#     enum_values = None
#     xml_tag = None
# 
#     def __init__(self, value):
#         self._value = value
#         self._name = None
#         if value is not None:
#             self._name = self.enum_values[value]
# 
#     @property
#     def value(self):
#         return self._value
# 
#     @property
#     def name(self):
#         return self._name
# 
#     def __str__(self):
#         return self._name
# 
#     def __repr__(self):
#         return '{}({})'.format(self.__class__.__name__, self._value)
# 
#     def xml(self, parent):
#         xml_tag = self.xml_tag if self.xml_tag else self.__class__.__name__
#         root = ET.SubElement(parent, xml_tag)
#         root.text = self._name
#         return root
# 
# Path: xnb_parse/file_formats/png.py
# def write_png(filename, width, height, rows):
#     full_filename = filename + '.png'
#     out_png = PyPngWriter(width=width, height=height)
#     out_png.write_bytearray(full_filename, rows)
# 
# Path: xnb_parse/file_formats/xml_utils.py
# def output_xml(xml, filename):
# def output_xml(xml, filename):
# 
# Path: xnb_parse/file_formats/img_decode.py
# 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 decode_a(data, width, height, needs_swap, alpha='yes'):
#     return decode8(data, width, height, 'a_xxxa')
# 
# def decode_dxt1(data, width, height, needs_swap, alpha='yes'):
#     return DxtDecoder(width, height, 'DXT1', data, needs_swap).decode(alpha)
# 
# def decode_dxt3(data, width, height, needs_swap, alpha='yes'):
#     return DxtDecoder(width, height, 'DXT3', data, needs_swap).decode(alpha)
# 
# def decode_dxt5(data, width, height, needs_swap, alpha='yes'):
#     return DxtDecoder(width, height, 'DXT5', data, needs_swap).decode(alpha)


import os
from xnb_parse.type_reader import ReaderError
from xnb_parse.xna_types.xna_primitive import Enum
from xnb_parse.file_formats.png import write_png
from xnb_parse.file_formats.xml_utils import ET
from xnb_parse.file_formats.img_decode import decode_bgra, decode_rgba, decode_a, decode_dxt1, decode_dxt3, decode_dxt5
CUBE_SIDES = ['+x', '-x', '+y', '-y', '+z', '-z']
FORMAT_COLOR = 1
SURFACE_FORMAT = {
    1: ('Color', decode_bgra),
    2: ('Bgr32', None),
    3: ('Bgra1010102', None),
    4: ('Rgba32', decode_rgba),
    5: ('Rgb32', None),
    6: ('Rgba1010102', None),
    7: ('Rg32', None),
    8: ('Rgba64', None),
    9: ('Bgr565', None),
    10: ('Bgra5551', None),
    11: ('Bgr555', None),
    12: ('Bgra4444', None),
    13: ('Bgr444', None),
    14: ('Bgra2338', None),
    15: ('Alpha8', decode_a),
    16: ('Bgr233', None),
    17: ('Bgr24', None),
    18: ('NormalizedByte2', None),
    19: ('NormalizedByte4', None),
    20: ('NormalizedShort2', None),
    21: ('NormalizedShort4', None),
    22: ('Single', None),
    23: ('Vector2', None),
    24: ('Vector4', None),
    25: ('HalfSingle', None),
    26: ('HalfVector2', None),
    27: ('HalfVector4', None),

# Path: xnb_parse/type_reader.py
# class ReaderError(Error):
#     pass
# 
# Path: xnb_parse/xna_types/xna_primitive.py
# class Enum(object):
#     __slots__ = ('_value', '_name')
#     enum_values = None
#     xml_tag = None
# 
#     def __init__(self, value):
#         self._value = value
#         self._name = None
#         if value is not None:
#             self._name = self.enum_values[value]
# 
#     @property
#     def value(self):
#         return self._value
# 
#     @property
#     def name(self):
#         return self._name
# 
#     def __str__(self):
#         return self._name
# 
#     def __repr__(self):
#         return '{}({})'.format(self.__class__.__name__, self._value)
# 
#     def xml(self, parent):
#         xml_tag = self.xml_tag if self.xml_tag else self.__class__.__name__
#         root = ET.SubElement(parent, xml_tag)
#         root.text = self._name
#         return root
# 
# Path: xnb_parse/file_formats/png.py
# def write_png(filename, width, height, rows):
#     full_filename = filename + '.png'
#     out_png = PyPngWriter(width=width, height=height)
#     out_png.write_bytearray(full_filename, rows)
# 
# Path: xnb_parse/file_formats/xml_utils.py
# def output_xml(xml, filename):
# def output_xml(xml, filename):
# 
# Path: xnb_parse/file_formats/img_decode.py
# 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 decode_a(data, width, height, needs_swap, alpha='yes'):
#     return decode8(data, width, height, 'a_xxxa')
# 
# def decode_dxt1(data, width, height, needs_swap, alpha='yes'):
#     return DxtDecoder(width, height, 'DXT1', data, needs_swap).decode(alpha)
# 
# def decode_dxt3(data, width, height, needs_swap, alpha='yes'):
#     return DxtDecoder(width, height, 'DXT3', data, needs_swap).decode(alpha)
# 
# def decode_dxt5(data, width, height, needs_swap, alpha='yes'):
#     return DxtDecoder(width, height, 'DXT5', data, needs_swap).decode(alpha)


# Path: xnb_parse/xna_types/xna_graphics.py
import os
from xnb_parse.type_reader import ReaderError
from xnb_parse.xna_types.xna_primitive import Enum
from xnb_parse.file_formats.png import write_png
from xnb_parse.file_formats.xml_utils import ET
from xnb_parse.file_formats.img_decode import decode_bgra, decode_rgba, decode_a, decode_dxt1, decode_dxt3, decode_dxt5

CUBE_SIDES = ['+x', '-x', '+y', '-y', '+z', '-z']
FORMAT_COLOR = 1
SURFACE_FORMAT = {
    1: ('Color', decode_bgra),
    2: ('Bgr32', None),
    3: ('Bgra1010102', None),
    4: ('Rgba32', decode_rgba),
    5: ('Rgb32', None),
    6: ('Rgba1010102', None),
    7: ('Rg32', None),
    8: ('Rgba64', None),
    9: ('Bgr565', None),
    10: ('Bgra5551', None),
    11: ('Bgr555', None),
    12: ('Bgra4444', None),
    13: ('Bgr444', None),
    14: ('Bgra2338', None),
    15: ('Alpha8', decode_a),
    16: ('Bgr233', None),
    17: ('Bgr24', None),
    18: ('NormalizedByte2', None),
    19: ('NormalizedByte4', None),
    20: ('NormalizedShort2', None),
    21: ('NormalizedShort4', None),
    22: ('Single', None),
    23: ('Vector2', None),
    24: ('Vector4', None),
    25: ('HalfSingle', None),
    26: ('HalfVector2', None),
    27: ('HalfVector4', None),

    28: ('Dxt1', decode_dxt1),