Skip to content

Commit

Permalink
Remove redundant black/white conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanfish committed Jan 4, 2024
1 parent 85fa644 commit 3fe4ab8
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 10 deletions.
5 changes: 0 additions & 5 deletions NAPS2.Sdk/Images/ImageExportHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ public MemoryStream SaveSmallestFormatToMemoryStream(IMemoryImage image, bool lo
if (exportFormat.FileFormat == ImageFileFormat.Png)
{
imageFileFormat = ImageFileFormat.Png;
if (exportFormat.PixelFormat == ImagePixelFormat.BW1 && image.LogicalPixelFormat != ImagePixelFormat.BW1)
{
using var bwImage = image.Clone().PerformTransform(new BlackWhiteTransform());
return bwImage.SaveToMemoryStream(ImageFileFormat.Png);
}
return image.SaveToMemoryStream(ImageFileFormat.Png);
}
if (exportFormat.FileFormat == ImageFileFormat.Jpeg)
Expand Down
5 changes: 0 additions & 5 deletions NAPS2.Sdk/Pdf/PdfExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -709,11 +709,6 @@ public ImageExportFormat PrepareForExport(ImageMetadata metadata)
{
exportFormat = exportFormat with { FileFormat = ImageFileFormat.Jpeg };
}
if (exportFormat.PixelFormat == ImagePixelFormat.BW1 &&
Image.LogicalPixelFormat != ImagePixelFormat.BW1)
{
Image = Image.PerformTransform(new BlackWhiteTransform());
}
return exportFormat;
}

Expand Down

0 comments on commit 3fe4ab8

Please sign in to comment.