Skip to content

Commit 5370094

Browse files
committed
fix DDS_FLAGS for exported dds files
1 parent ea9008f commit 5370094

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

addons/blender_dds_addon/directx/dds.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,20 +105,20 @@ class DDS_FLAGS(IntEnum):
105105
CAPS = 0x1
106106
HEIGHT = 0x2
107107
WIDTH = 0x4
108-
PITCH = 0x8 # Use "w * h * bpp" for pitch_or_linear_size
108+
PITCH = 0x8 # Use "w * bpp" for pitch_or_linear_size
109109
PIXELFORMAT = 0x1000
110110
MIPMAPCOUNT = 0x20000
111-
LINEARSIZE = 0x80000 # Use "w * bpp" for pitch_or_linear_size
111+
LINEARSIZE = 0x80000 # Use "w * h * bpp" for pitch_or_linear_size
112112
DEPTH = 0x800000 # For volume textures
113113
DEFAULT = CAPS | HEIGHT | WIDTH | PIXELFORMAT | MIPMAPCOUNT
114114

115115
@staticmethod
116116
def get_flags(is_compressed, is_3d):
117117
flags = DDS_FLAGS.DEFAULT
118118
if is_compressed:
119-
flags |= DDS_FLAGS.PITCH
120-
else:
121119
flags |= DDS_FLAGS.LINEARSIZE
120+
else:
121+
flags |= DDS_FLAGS.PITCH
122122
if is_3d:
123123
flags |= DDS_FLAGS.DEPTH
124124
return flags
@@ -343,9 +343,9 @@ def update(self, depth, array_size):
343343

344344
self.flags = DDS_FLAGS.get_flags(self.is_compressed(), is_3d)
345345
if DDS_FLAGS.has_pitch(self.flags):
346-
self.pitch_or_linear_size = int(self.width * self.height * bpp)
347-
else:
348346
self.pitch_or_linear_size = int(self.width * bpp)
347+
else:
348+
self.pitch_or_linear_size = int(self.width * self.height * bpp)
349349
self.caps = DDS_CAPS.get_caps(has_mips, is_cube)
350350
self.caps2 = DDS_CAPS2.get_caps2(is_cube, is_3d)
351351

@@ -354,7 +354,7 @@ def update(self, depth, array_size):
354354

355355
def get_bpp(self):
356356
bpp = self.pitch_or_linear_size // self.width
357-
if DDS_FLAGS.has_pitch(self.flags):
357+
if not DDS_FLAGS.has_pitch(self.flags):
358358
bpp = bpp // self.height
359359
return bpp
360360

changelog.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
- Fixed a bug that exported dds files have wrong flags.
2+
13
ver 0.4.1
24
- Added support for drag-drop import
35

0 commit comments

Comments
 (0)