Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [6.0.1] - 2021-09-21
### Fixed
- Removed memory requirement check since we cannot properly determine if there will be enough memory to import the file (case 1357544)
- Fixed artifacts on images when flatten.
- Fixed exception "PsdInvalidException: Unrecognized layer section type" when importing certain files.
  • Loading branch information
Unity Technologies committed Sep 21, 2021
1 parent c10d994 commit 80b0b15
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [6.0.1] - 2021-09-21
### Fixed
- Removed memory requirement check since we cannot properly determine if there will be enough memory to import the file (case 1357544)
- Fixed artifacts on images when flatten.
- Fixed exception "PsdInvalidException: Unrecognized layer section type" when importing certain files.

## [6.0.0] - 2021-08-10
### Fixed
- Fixed performance regression in PSDImporter Editor (case 1349408)
Expand Down
5 changes: 5 additions & 0 deletions Editor/PSDPlugin/PhotoShopFileType/PsdLoad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,10 @@ private static void SetPdnResolutionInfo(PsdFile psdFile, Document document)
/// </remarks>
internal static void CheckSufficientMemory(PsdFile psdFile)
{
/*
Remove memory check since we can't properly ensure there will
be enough memory to import
// Multichannel images have channels converted to layers
var numLayers = (psdFile.ColorMode == PsdColorMode.Multichannel)
? psdFile.BaseLayer.Channels.Count
Expand All @@ -296,6 +300,7 @@ internal static void CheckSufficientMemory(PsdFile psdFile)
{
throw new OutOfMemoryException();
}
*/
}
}
}
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": "6.0.0",
"version": "6.0.1",
"unity": "2021.2",
"displayName": "2D PSD Importer",
"description": "A ScriptedImporter for importing Adobe Photoshop PSB (Photoshop Big) file format. The ScriptedImporter is currently targeted for users who wants to create multi Sprite character animation using Unity 2D Animation Package.\n\nDocumentation for v5.0 is currently being updated.",
Expand All @@ -11,19 +11,19 @@
],
"category": "2D",
"dependencies": {
"com.unity.2d.animation": "7.0.0",
"com.unity.2d.animation": "7.0.1",
"com.unity.2d.common": "6.0.0",
"com.unity.2d.sprite": "1.0.0"
},
"relatedPackages": {
"com.unity.2d.psdimporter.tests": "6.0.0"
"com.unity.2d.psdimporter.tests": "6.0.1"
},
"upmCi": {
"footprint": "060330cf8095556874a02eb362ad40ff0df8455a"
"footprint": "a613628badeb5beba757c208c6433434512ee74d"
},
"repository": {
"url": "https://github.cds.internal.unity3d.com/unity/2d.git",
"type": "git",
"revision": "bcbc5fb1cb18a1a4cf6e15325550ed4b8fbb21bc"
"revision": "b015022decd440f484d85cf6ee096c0ecaa60e30"
}
}

0 comments on commit 80b0b15

Please sign in to comment.