Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions PhotoLocator/BitmapOperations/FloatBitmap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public FloatBitmap(BitmapSource source, double gamma)

public override string ToString()
{
return Stride + " x " + Height;
return $"{Width}x{Height}x{PlaneCount}";
}

public void New(int width, int height, int planes)
Expand Down Expand Up @@ -463,7 +463,7 @@ public void ProcessElementWise(FloatBitmap other, Func<float, float, float> oper
});
}
else
throw new InvalidOperationException("Unsupported number of planes");
throw new InvalidOperationException("Unsupported number of planes " + PlaneCount);
}
}

Expand Down
4 changes: 3 additions & 1 deletion PhotoLocator/BitmapOperations/IIRSmoothOperation.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Threading.Tasks;
using System.Diagnostics;
using System.Threading.Tasks;

namespace PhotoLocator.BitmapOperations
{
Expand All @@ -8,6 +9,7 @@ public static void Apply(FloatBitmap plane, float filterSize)
{
if (filterSize == 0)
return;
Debug.Assert(plane.PlaneCount == 1);
filterSize /= 4f;
var scale = 1f / (1f + filterSize);
unsafe
Expand Down
11 changes: 10 additions & 1 deletion PhotoLocator/PictureFileFormats/PhotoshopFileFormatHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public static BitmapSource LoadFromStream(Stream stream, Rotation rotation, int
var psd = new PsdFile(stream, new LoadContext());
foreach (var psdLayer in (new[] { psd.BaseLayer }).Concat(psd.Layers))
{
ct.ThrowIfCancellationRequested();
if (psdLayer != psd.BaseLayer && (!psdLayer.Visible || psdLayer.Opacity == 0)
|| psdLayer.Rect.Width == 0 || psdLayer.Rect.Height == 0)
continue;
Expand Down Expand Up @@ -67,7 +68,7 @@ public static BitmapSource CreateLayerBitmap(PsdFile psd, Layer layer)
if (psd.BitDepth == 8)
{
var pixels = new byte[layer.Rect.Width * layer.Rect.Height * 4];
Parallel.For(0, 4, ch => GetChannelPixels8(layer.Channels.GetId(ch), pixels, ch, 4));
Parallel.For(0, 4, ch => GetChannelPixels8Inverted(layer.Channels.GetId(ch), pixels, ch, 4));
return BitmapSource.Create(layer.Rect.Width, layer.Rect.Height, 96, 96, PixelFormats.Cmyk32, null,
pixels, layer.Rect.Width * 4);
}
Expand All @@ -83,6 +84,14 @@ private static void GetChannelPixels8(Channel channel, byte[] dest, int offset,
dest[iDst] = source[iSrc];
}

private static void GetChannelPixels8Inverted(Channel channel, byte[] dest, int offset, int dist)
{
var size = channel.Rect.Width * channel.Rect.Height;
var source = channel.ImageData;
for (int iSrc = 0, iDst = offset; iSrc < size; iSrc++, iDst += dist)
dest[iDst] = (byte)(255 - source[iSrc]);
}

private static void GetChannelPixels16(Channel channel, byte[] dest, int offset, int dist)
{
dist -= 2;
Expand Down
6 changes: 0 additions & 6 deletions PhotoshopImageLoader/PhotoLocator.PhotoshopImageLoader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@
<Compile Include="..\PsdPlugin\PsdFile\Util.cs" Link="PsdFile\Util.cs" />
</ItemGroup>

<ItemGroup>
<Folder Include="PsdFile\Compression\" />
<Folder Include="PsdFile\ImageResources\" />
<Folder Include="PsdFile\Layers\LayerInfo\" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Drawing.Common" Version="10.0.1" />
</ItemGroup>
Expand Down
Loading