Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func load_image(path : String) -> ImageTexture:
- var file = File.new()
- if file.file_exists(path):
- file.open(path,File.READ)
- var buffer = file.get_buffer(134217728)
- file.close()
- var image = Image.new()
- var image_texture = ImageTexture.new()
- if path.get_extension() == "png":
- image.load_png_from_buffer(buffer)
- elif path.get_extension() == "jpg":
- image.load_jpg_from_buffer(buffer)
- elif path.get_extension() == "bmp":
- image.load_bmp_from_buffer(buffer)
- else:
- return null
- image_texture.create_from_image(image)
- return image_texture
- else:
- return null
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement