Image format ARGB4444

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By majidarif

Hello,

I’m trying to read a texture file with ARGB4444 (16bit-A4R4G4B4) format. The format doesn’t seem to be supported out of the box, the closest I can find is RGBA4444 which makes the texture look like the one I’m expecting but the colors are off.

What are my options for this? I’m current reading the texture through an import plug-in I’m writing. (GDScript)

Thank you.

While I’m at it, I’m also looking for a way to img.create_from_data the src format of RGB565.

:bust_in_silhouette: Reply From: Zylann

I’m current reading the texture through an import plug-in I’m writing. (GDScript)

the closest I can find is RGBA4444 which makes the texture look like the one I’m expecting but the colors are off.

So you can load as an RGBA4444 Image, then loop over all pixels to swizzle color components to their correct place:

image.lock()
for y in image.get_height():
	for x in image.get_width():
		var color = image.get_pixel(x, y)
		image.set_pixel(x, y, Color(color.g, color.b, color.a, color.r))
image.unlock()

Tried this, but the resulting image is still off in terms of colors and transparency. The general form is visible just the colors are wrong.

Basically I’m reading the data from a DDS texture file.

majidarif | 2020-03-03 20:06

I edited my answer, it was wrong component order

Zylann | 2020-03-03 20:09

Oh, thank you. This is great. Although my importer is acting weird, it never completes the import and the editor just freezes. But when I check the filesystem, I see all the expected textures already exported but the editor just freezes forever even when the plugin has completed all the importing. Anyway, that is for another question.

Thank you again.

majidarif | 2020-03-03 20:25