object-fit, multithreaded image loading

This commit is contained in:
Face
2025-08-09 15:54:59 +03:00
parent d47f811670
commit 3a722fdf1e
7 changed files with 150 additions and 17 deletions

View File

@@ -37,10 +37,10 @@ func fetch_image(url: String) -> ImageTexture:
var load_error
# Load image based on content type
if content_type.contains("png") or url.to_lower().ends_with(".png"):
load_error = image.load_png_from_buffer(body)
elif content_type.contains("jpeg") or content_type.contains("jpg") or url.to_lower().ends_with(".jpg") or url.to_lower().ends_with(".jpeg"):
if content_type.contains("jpeg") or content_type.contains("jpg") or url.to_lower().ends_with(".jpg") or url.to_lower().ends_with(".jpeg"):
load_error = image.load_jpg_from_buffer(body)
elif content_type.contains("png") or url.to_lower().ends_with(".png"):
load_error = image.load_png_from_buffer(body)
elif content_type.contains("webp") or url.to_lower().ends_with(".webp"):
load_error = image.load_webp_from_buffer(body)
elif content_type.contains("bmp"):
@@ -48,10 +48,10 @@ func fetch_image(url: String) -> ImageTexture:
elif content_type.contains("tga"):
load_error = image.load_tga_from_buffer(body)
else:
print("Unknown or missing content-type. Attempting bruteforce converting across PNG, JPG and WebP...")
load_error = image.load_png_from_buffer(body)
print("Unknown or missing content-type. Attempting bruteforce converting across JPEG, PNG and WebP...")
load_error = image.load_jpg_from_buffer(body)
if load_error != OK:
load_error = image.load_jpg_from_buffer(body)
load_error = image.load_png_from_buffer(body)
if load_error != OK:
load_error = image.load_webp_from_buffer(body)