Godot 4 Image load from buffer help

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Rodrigo (Spy)

I’m having some issues with Godot 4.0 Beta 6 and the load_*_from_buffer methods of the Image class.
When I call the method the Image object is de-referenced and the variable points to null. This may be a bug, or something I’m missing.

Here is a sample code that I’m using. The image file is within a zip file. But using a regular file produced the same result. (The PackedByteArray data retrieved from the zip file was verified!)

Also, the ZIPReader reads png and jpg, but not bmp files!

Thanks in advance!

var resourceFile = "res://ZIP/testImage2.zip"

var zipSource = ZIPReader.new()
var loaded = zipSource.open(resourceFile)
if loaded!=OK:
	return ERR_FILE_CANT_OPEN
	
var filesInZip = zipSource.get_files()

print(filesInZip)

var zippedGraphic : PackedByteArray

for file in filesInZip:
	zippedGraphic = []
	var imageExtensions = ["PNG", "BMP", "JPG", "JPEG", "TGA", "WEBP"]
	var imageExtension = file.to_upper().split(".")[-1]
	### Only process zippedGraphic images
	if (("spriteSheets/" in file) and (file!="spriteSheets/") and
		imageExtension in imageExtensions):
		$Panel/filefound.text = file
		print("this is the file: "+file)
		
		zippedGraphic = zipSource.read_file(file)
		if (zippedGraphic==null) or (zippedGraphic.is_empty()):
			$Panel/result.text = "File Can't Read"
			break

		### Store the uncompressed stream. This was used to validate the buffer data.
		if true:
			var imgFilename = "user://last-image_import.%s" % imageExtension.to_lower()
			var imgfile = FileAccess.open(imgFilename, FileAccess.WRITE)
			if !imgfile.is_open():
				$Panel/result.text = "File Can't Write to User"
			else:
				imgfile.store_buffer(zippedGraphic)
				imgfile = null
				print("Stored image to:" + imgFilename);		
				
			
		### Image to be passed to Texture and Texture to be saved as Resource
		var loadedImage: Image = Image.new()
		var builtTexture: ImageTexture = ImageTexture.new()
		var img_error_code
		# Create the image according to extension
		match imageExtension:
			"PNG":
				img_error_code=loadedImage.load_png_from_buffer(zippedGraphic) # Set loadedImage to null!
			"BMP":
				img_error_code=loadedImage.load_bmp_from_buffer(zippedGraphic)
			"JPG":
				img_error_code=loadedImage.load_jpg_from_buffer(zippedGraphic)
			"JPEG":
				img_error_code=loadedImage.load_jpg_from_buffer(zippedGraphic)
			"TGA":
				img_error_code=loadedImage.load_tga_from_buffer(zippedGraphic)
			"WEBP":
				img_error_code=loadedImage.load_webp_from_buffer(zippedGraphic)

		if img_error_code!=OK:
			$Panel/result.text = "File Can't Read"
			break
		
		
		builtTexture.create_from_image(loadedImage)