Fix resized to power of two skin initialising the unused area with garbage, which could be seen with custom models

This commit is contained in:
UnknownShadow200 2025-05-15 21:12:39 +10:00
parent e25df6065c
commit 12ec05879e
2 changed files with 7 additions and 2 deletions

View File

@ -301,7 +301,9 @@ static cc_result EnsurePow2Skin(struct Entity* e, struct Bitmap* bmp) {
height = Math_NextPowOf2(bmp->height);
if (width == bmp->width && height == bmp->height) return 0;
Bitmap_TryAllocate(&scaled, width, height);
scaled.width = width;
scaled.height = height;
scaled.scan0 = (BitmapCol*)Mem_TryAllocCleared(width * height, BITMAPCOLOR_SIZE);
if (!scaled.scan0) return ERR_OUT_OF_MEMORY;
e->uScale = (float)bmp->width / width;

View File

@ -115,7 +115,10 @@ static void LBackend_ScaleFlag(struct Bitmap* bmp) {
/* at default DPI don't need to rescale it */
if (width == bmp->width && height == bmp->height) return;
Bitmap_TryAllocate(&scaled, width, height);
scaled.width = width;
scaled.height = height;
scaled.scan0 = (BitmapCol*)Mem_TryAlloc(width * height, BITMAPCOLOR_SIZE);
if (!scaled.scan0) {
Logger_SysWarn(ERR_OUT_OF_MEMORY, "resizing flags bitmap"); return;
}