Skip to content

Commit

Permalink
Add fix_top_format() to BitmapTag (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShellyHerself committed Sep 19, 2020
2 parents b047fd5 + a691a86 commit 555b8d9
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.MD
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.9.8]
### Added
- Add fix_top_format() to BitmapTag

## [2.9.7]
### Changed
- Assume that 0 scale values in models are equal to 1.
Expand Down
4 changes: 2 additions & 2 deletions reclaimer/__init__.py
Expand Up @@ -12,8 +12,8 @@
# ##############
__author__ = "Sigmmma"
# YYYY.MM.DD
__date__ = "2020.08.17"
__version__ = (2, 9, 7)
__date__ = "2020.09.19"
__version__ = (2, 9, 8)
__website__ = "https://github.com/Sigmmma/reclaimer"
__all__ = (
"animation", "bitmaps", "h2", "h3", "halo_script", "hek", "meta", "misc",
Expand Down
24 changes: 24 additions & 0 deletions reclaimer/hek/defs/objs/bitm.py
Expand Up @@ -68,6 +68,30 @@ def bitmap_format(self, b_index=0, new_value=None):
return self.data.tagdata.bitmaps.bitmaps_array[b_index].format.data
self.data.tagdata.bitmaps.bitmaps_array[b_index].format.data = new_value

def fix_top_format(self):
if len(self.data.tagdata.bitmaps.bitmaps_array) <= 0:
self.data.tagdata.format.data = "color_key_transparency"

# Why can't get_name get the name of the current option?
pixel_format = self.data.tagdata.bitmaps.bitmaps_array[0].format.get_name(
self.data.tagdata.bitmaps.bitmaps_array[0].format.data)

top_format = "color_key_transparency"
if pixel_format in ("a8", "y8", "ay8", "a8y8"):
top_format = "monochrome"
elif pixel_format in ("r5g6b5", "a1r5g5b5", "a4r4g4b4"):
top_format = "color_16bit"
elif pixel_format in ("x8r8g8b8", "a8r8g8b8", "p8_bump"):
top_format = "color_32bit"
elif pixel_format == "dxt1":
top_format = "color_key_transparency"
elif pixel_format == "dxt3":
top_format = "explicit_alpha"
elif pixel_format == "dxt5":
top_format = "interpolated_alpha"

self.data.tagdata.format.set_to(top_format)

def bitmap_width_height_depth(self, b_index=0, new_value=None):
bitmap = self.data.tagdata.bitmaps.bitmaps_array[b_index]
if new_value is None:
Expand Down

0 comments on commit 555b8d9

Please sign in to comment.