### Godot version

5ee983188de97ae027f9b9c1443438063f708a7e

### System information

Windows 11

### Issue description

Godot editor will throw an error and fail to generate preview icons for terrain tiles which use a base image which is not RGBA8 format.
`core\io\image.cpp:2788 - Condition "format != p_src->format" is true.`

### Steps to reproduce

- Import a non-RGBA8 image into Godot.
- Create a TileMap
- Create an associated TileSet
- Create a terrain for this tileset
- Add the image as an atlas
- Go to the paint tab
- Paint the terrain on the TileSet
- An error will occur any time terrains are edited in the TileSet editor or selected in the TileMap editor terrain tab.

### Minimal reproduction project

[tileset_terrain_bug.zip](https://github.com/godotengine/godot/files/13264213/tileset_terrain_bug.zip)

property_info = PropertyInfo(Variant::FLOAT, vformat("animation_frame_%d/duration", i), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR);
			if (!store_durations) {
				property_info.usage ^= PROPERTY_USAGE_STORAGE;
			}
			tile_property_list.push_back(property_info);
		}
		for (const KeyValue<int, TileData *> &E_alternative : E_tile.value.alternatives) {
			
			tile_property_list.push_back(PropertyInfo(Variant::INT, vformat("%d", E_alternative.key), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR));
			
			List<PropertyInfo> alternative_property_list;
			E_alternative.value->get_property_list(&alternative_property_list);
			for (PropertyInfo &alternative_property_info : alternative_property_list) {
				Variant default_value = ClassDB::class_get_default_property_value("TileData", alternative_property_info.name);
				Variant value = E_alternative.value->get(alternative_property_info.name);
				if (default_value.get_type() != Variant::NIL && bool(Variant::evaluate(Variant::OP_EQUAL, value, default_value))) {
					alternative_property_info.usage ^= PROPERTY_USAGE_STORAGE;
				}
				alternative_property_info.name = vformat("%s/%s", vformat("%d", E_alternative.key), alternative_property_info.name);
				tile_property_list.push_back(alternative_property_info);
			}
		}
		
		for (PropertyInfo &tile_property_info : tile_property_list) {
			tile_property_info.name = vformat("%s/%s", vformat("%d:%d", E_tile.key.x, E_tile.key.y), tile_property_info.name);
			p_list->push_back(tile_property_info);
		}
	}
}
void TileSetAtlasSource::create_tile(const Vector2i p_atlas_coords, const Vector2i p_size) {