color_convert: re-add npot_height
This commit is contained in:
parent
37e0b80b68
commit
058de2d550
@ -110,7 +110,7 @@ def resize(im, l):
|
|||||||
size=(l, l),
|
size=(l, l),
|
||||||
resample=Image.Resampling.LANCZOS,
|
resample=Image.Resampling.LANCZOS,
|
||||||
)
|
)
|
||||||
new.save(f"{l:03}.png")
|
#new.save(f"{l:03}.png")
|
||||||
return new
|
return new
|
||||||
|
|
||||||
def generate_mips(im):
|
def generate_mips(im):
|
||||||
@ -129,9 +129,10 @@ def write_mip(f, mip: Image, is_twiddled: bool, convert):
|
|||||||
colors = list(convert_colors(convert, pixels))
|
colors = list(convert_colors(convert, pixels))
|
||||||
assert len(colors) == width * height, len(colors)
|
assert len(colors) == width * height, len(colors)
|
||||||
if is_twiddled:
|
if is_twiddled:
|
||||||
new_colors = [0] * width * height
|
npot_height = npot(height)
|
||||||
|
new_colors = [0] * width * npot_height
|
||||||
max_twiddle_ix = twiddle_texture(new_colors, colors, width, height)
|
max_twiddle_ix = twiddle_texture(new_colors, colors, width, height)
|
||||||
assert max_twiddle_ix + 1 == width * height, (max_twiddle_ix, width, height)
|
#assert max_twiddle_ix + 1 == width * height, (max_twiddle_ix, width, height)
|
||||||
colors = new_colors[:max_twiddle_ix+1]
|
colors = new_colors[:max_twiddle_ix+1]
|
||||||
pack_colors(f, colors)
|
pack_colors(f, colors)
|
||||||
|
|
||||||
|
@ -49,11 +49,11 @@ def npot(v):
|
|||||||
return v
|
return v
|
||||||
|
|
||||||
def texture(dst, src, width, height):
|
def texture(dst, src, width, height):
|
||||||
#pot_height = npot(height)
|
pot_height = npot(height)
|
||||||
max_twiddle_ix = -1
|
max_twiddle_ix = -1
|
||||||
for y in range(height):
|
for y in range(height):
|
||||||
for x in range(width):
|
for x in range(width):
|
||||||
twiddle_ix = from_xy(x, y, width, height)
|
twiddle_ix = from_xy(x, y, width, pot_height)
|
||||||
value = src[y * width + x]
|
value = src[y * width + x]
|
||||||
dst[twiddle_ix] = value
|
dst[twiddle_ix] = value
|
||||||
if twiddle_ix > max_twiddle_ix:
|
if twiddle_ix > max_twiddle_ix:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user