Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [2.1.10] - 2021-10-11
### Fixed
- Fixed artifacts on images when flatten.
- Fixed exception "PsdInvalidException: Unrecognized layer section type" when importing certain files
  • Loading branch information
Unity Technologies committed Oct 11, 2021
1 parent afab78a commit b74a34c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## [2.1.10] - 2021-10-11
### Fixed
- Fixed artifacts on images when flatten.
- Fixed exception "PsdInvalidException: Unrecognized layer section type" when importing certain files

## [2.1.9] - 2021-09-11
### Fixed
- Fixed Unity hang when importing certain PSD files (case 1357563)
Expand Down
5 changes: 4 additions & 1 deletion Editor/PSDPlugin/PsdFile/PsdFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,10 @@ internal void VerifyLayerSections()
if (depth < 0)
throw new PsdInvalidException("Layer section ended without matching start marker.");
break;


case LayerSectionType.Layer: // Nothing to do here yet.
break;

default:
throw new PsdInvalidException("Unrecognized layer section type.");
}
Expand Down
17 changes: 12 additions & 5 deletions Editor/Tasks/FlattenImageTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,18 @@ public unsafe void Execute(int index)
{
int sourceIndex = sourceYIndex + j;
int destIndex = destYIndex + j;
float alpha = buffer[sourceIndex].a / 255.0f;
premerge[destIndex].r = (byte)(alpha * (float)(buffer[sourceIndex].r) + (float)((1.0f - alpha) * (float)premerge[destIndex].r));
premerge[destIndex].g = (byte)(alpha * (float)(buffer[sourceIndex].g) + (float)((1.0f - alpha) * (float)premerge[destIndex].g));
premerge[destIndex].b = (byte)(alpha * (float)(buffer[sourceIndex].b) + (float)((1.0f - alpha) * (float)premerge[destIndex].b));
premerge[destIndex].a = (byte)(alpha * (float)(buffer[sourceIndex].a) + (float)((1.0f - alpha) * (float)premerge[destIndex].a));
Color sourceColor = buffer[sourceIndex];
Color destColor = premerge[destIndex];
Color finalColor = new Color();

var destAlpha = destColor.a * (1 - sourceColor.a);
finalColor.a = sourceColor.a + destColor.a * (1 - sourceColor.a);
var premultiplyAlpha = 1 / finalColor.a;
finalColor.r = (sourceColor.r * sourceColor.a + destColor.r * destAlpha) * premultiplyAlpha;
finalColor.g = (sourceColor.g * sourceColor.a + destColor.g * destAlpha) * premultiplyAlpha;
finalColor.b = (sourceColor.b * sourceColor.a + destColor.b * destAlpha) * premultiplyAlpha;

premerge[destIndex] = finalColor;
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.unity.2d.psdimporter",
"version": "2.1.9",
"version": "2.1.10",
"unity": "2019.4",
"unityRelease": "0b11",
"displayName": "2D PSD Importer",
Expand All @@ -13,18 +13,18 @@
"category": "2D",
"dependencies": {
"com.unity.2d.common": "2.1.0",
"com.unity.2d.animation": "3.2.13",
"com.unity.2d.animation": "3.2.14",
"com.unity.2d.sprite": "1.0.0"
},
"relatedPackages": {
"com.unity.2d.psdimporter.tests": "2.1.9"
"com.unity.2d.psdimporter.tests": "2.1.10"
},
"upmCi": {
"footprint": "cb30cdb0e6e9cd8458d6f9be1d58191062b5f918"
"footprint": "3356ee89cf126c40d807c0b82ba1eaa410a99e15"
},
"repository": {
"url": "https://github.cds.internal.unity3d.com/unity/2d.git",
"type": "git",
"revision": "ff5113572ce6bc283f75b25349ccec9f1ea17bd6"
"revision": "97be4f400509652c3a4ce6929a6be114072c3a74"
}
}

0 comments on commit b74a34c

Please sign in to comment.