file tools load from file

This commit is contained in:
Nordup 2025-08-29 19:38:00 +07:00
parent b35dda2520
commit 0c15468d7e
2 changed files with 2 additions and 15 deletions

View file

@ -95,7 +95,6 @@ mouse_filter = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_od0ga")
[node name="Icon" type="TextureRect" parent="JumpAnimation/Mask"]
custom_minimum_size = Vector2(40, 40)
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0

View file

@ -30,18 +30,6 @@ static func load_external_tex(path: String) -> Texture2D:
if path.begins_with("res://"): return load(path)
if not FileAccess.file_exists(path): return null
var file = FileAccess.open(path, FileAccess.READ)
var bytes = file.get_buffer(file.get_length())
var image = Image.new()
match path.get_extension():
"png":
image.load_png_from_buffer(bytes)
"jpeg", "jpg":
image.load_jpg_from_buffer(bytes)
"webp":
image.load_webp_from_buffer(bytes)
"bmp":
image.load_bmp_from_buffer(bytes)
_:
return null
var image = Image.load_from_file(path)
if not is_instance_valid(image): return null
return ImageTexture.create_from_image(image) as Texture2D