diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-12-01 20:24:22 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-12-01 20:24:22 -0500 |
commit | 368b25b5411683192f4398616abed61441457799 (patch) | |
tree | 6e2819b221d9519f2f35ed463ad0c54a14eea058 /src/SMAPI | |
parent | b95d2a3f935dde0118205f94b32f05f115afdf71 (diff) | |
parent | a2944eed5c635ecf9afaefe9cf377f049a40731f (diff) | |
download | SMAPI-368b25b5411683192f4398616abed61441457799.tar.gz SMAPI-368b25b5411683192f4398616abed61441457799.tar.bz2 SMAPI-368b25b5411683192f4398616abed61441457799.zip |
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI')
-rw-r--r-- | src/SMAPI/Constants.cs | 2 | ||||
-rw-r--r-- | src/SMAPI/Framework/Content/AssetDataForImage.cs | 36 |
2 files changed, 19 insertions, 19 deletions
diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs index 02e75e05..c5058e4b 100644 --- a/src/SMAPI/Constants.cs +++ b/src/SMAPI/Constants.cs @@ -52,7 +52,7 @@ namespace StardewModdingAPI internal static int? LogScreenId { get; set; } /// <summary>SMAPI's current raw semantic version.</summary> - internal static string RawApiVersion = "3.18.0"; + internal static string RawApiVersion = "3.18.1"; } /// <summary>Contains SMAPI's constants and assumptions.</summary> diff --git a/src/SMAPI/Framework/Content/AssetDataForImage.cs b/src/SMAPI/Framework/Content/AssetDataForImage.cs index 7c8cc6a8..89ced1ba 100644 --- a/src/SMAPI/Framework/Content/AssetDataForImage.cs +++ b/src/SMAPI/Framework/Content/AssetDataForImage.cs @@ -140,9 +140,11 @@ namespace StardewModdingAPI.Framework.Content /// <exception cref="InvalidOperationException">The content being read isn't an image.</exception> private void PatchImageImpl(Color[] sourceData, int sourceWidth, int sourceHeight, Rectangle sourceArea, Rectangle targetArea, PatchMode patchMode, int startRow = 0) { - // get texture + // get texture info Texture2D target = this.Data; int pixelCount = sourceArea.Width * sourceArea.Height; + int firstPixel = startRow * sourceArea.Width; + int lastPixel = firstPixel + pixelCount - 1; // validate if (sourceArea.X < 0 || sourceArea.Y < 0 || sourceArea.Right > sourceWidth || sourceArea.Bottom > sourceHeight) @@ -155,36 +157,34 @@ namespace StardewModdingAPI.Framework.Content // shortcut: replace the entire area if (patchMode == PatchMode.Replace) { - target.SetData(0, targetArea, sourceData, startRow * sourceArea.Width, pixelCount); + target.SetData(0, targetArea, sourceData, firstPixel, pixelCount); return; } // skip transparent pixels at the start & end (e.g. large spritesheet with a few sprites replaced) int startIndex = -1; int endIndex = -1; + for (int i = firstPixel; i <= lastPixel; i++) { - for (int i = startRow * sourceArea.Width; i < pixelCount; i++) + if (sourceData[i].A >= AssetDataForImage.MinOpacity) { - if (sourceData[i].A >= AssetDataForImage.MinOpacity) - { - startIndex = i; - break; - } + startIndex = i; + break; } - if (startIndex == -1) - return; // blank texture + } + if (startIndex == -1) + return; // blank texture - for (int i = startRow * sourceArea.Width + pixelCount - 1; i >= startIndex; i--) + for (int i = lastPixel; i >= startIndex; i--) + { + if (sourceData[i].A >= AssetDataForImage.MinOpacity) { - if (sourceData[i].A >= AssetDataForImage.MinOpacity) - { - endIndex = i; - break; - } + endIndex = i; + break; } - if (endIndex == -1) - return; // ??? } + if (endIndex == -1) + return; // ??? // update target rectangle int sourceOffset; |