Image distorts when created in C#

I need to load in images at run-time, doing something similar to this:

using System.IO;
using UnityEngine;
using UnityEngine.UI;

public class SpriteCreator : MonoBehaviour {
    // public string textureFilePath => Application.persistentDataPath + FileName;
    void Start () {
        Texture2D texture = new Texture2D(2, 2);
        texture.LoadImage(File.ReadAllBytes(Application.dataPath + "/Logo_Dominoes.png"));
        GetComponent<Image>().sprite = Sprite.Create(texture,
            new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));

But some of my test images become distorted with this code.
This distortion doesn’t happen with all of my test files. I am attaching one of the test files that gets distorted, but I do not believe there is any issue with the test files, as they appear OK when I import them in the Unity Editor.

An Image with the sprite assigned through the editor (top) appears fine, but an Image with the sprite assigned at run-time (bottom & selected in inspector) has a subtle distortion around the words “Card Game Simulator” and “Dominoes”:

Why is this subtle distortion appearing?

The texture that the generated sprite is added to has the ‘Alpha Is Transparency’ setting set to false, which causes these artifacts. You can verify this by disabling the setting on your in-editor texture, you will see the same artifacts on both images.

Sprites that are generated through Sprite.Create() appear to have this setting off, and I couldn’t find a way to enable the setting on the internal texture.

I am not sure exactly why this would happen but it seems like the Texture2D’s format is different then in the editor. When you import things in the unity editor it comes in with a bunch of default settings. You probably need to have those same settings with the dynamically loaded texture. Maybe try setting the textures filterMode before creating the sprite?

texture.filterMode = FilterMode.Bilinear; //try all three filter modes. see if you notice a diference

Since ‘Alpha is Transparency’ is only available in the Unity Editor and not at run-time, the solution is to do what that setting would do. One option is to edit the images beforehand. But this option doesn’t really work for me, since that would put extra work on the people creating these images for me.
Luckily, there is a paid solution in the asset store.