public void Should_correctly_read_image_data_section([NotNull] string path) { const string exportedPngPath = "files/image-data/empty.png"; using var photoshopFile = PhotoshopFile.Open(path); var image = Image.Load <Rgb24>(exportedPngPath); var channelStride = photoshopFile.Width * photoshopFile.Height; for (var i = 0; i < image.Height; i++) { var row = image.GetPixelRowSpan(i); for (var j = 0; j < image.Width; j++) { var expectedPixel = row[j]; var actualR = photoshopFile.ImageData[i * image.Width + j]; var actualG = photoshopFile.ImageData[channelStride + i * image.Width + j]; var actualB = photoshopFile.ImageData[channelStride * 2 + i * image.Width + j]; actualR.Should() .Be(expectedPixel.R); actualG.Should() .Be(expectedPixel.G); actualB.Should() .Be(expectedPixel.B); } } }
public void Should_correctly_read_image_size([NotNull] string path, int expectedHeight, int expectedWidth) { using var photoshopFile = PhotoshopFile.Open(path); photoshopFile.Height.Should() .Be(expectedHeight); photoshopFile.Width.Should() .Be(expectedWidth); }
public void Should_save_file_correctly([NotNull] string path) { using var photoshopFile = PhotoshopFile.Open(path); var tempPath = Path.GetTempPath(); var guid = Guid.NewGuid(); var tempFilePath = Path.Combine(tempPath, guid.ToString()); photoshopFile.SaveAs(tempFilePath); File.Exists(tempFilePath) .Should() .Be(true); var expectedBytes = File.ReadAllBytes(path); var actualBytes = File.ReadAllBytes(tempFilePath); actualBytes.Should() .Equal(expectedBytes); // TODO: move cleanup out of here File.Delete(tempFilePath); }
public void Should_correctly_read_color_mode([NotNull] string path, ColorMode expectedColorMode) { using var photoshopFile = PhotoshopFile.Open(path); photoshopFile.ColorMode.Should() .Be(expectedColorMode); }
public void Should_correctly_read_depth([NotNull] string path, int expectedDepth) { using var photoshopFile = PhotoshopFile.Open(path); photoshopFile.Depth.Should() .Be(expectedDepth); }
public void Should_correctly_read_channel_count([NotNull] string path, int expectedChannelCount) { using var photoshopFile = PhotoshopFile.Open(path); photoshopFile.ChannelCount.Should() .Be(expectedChannelCount); }
public void Should_correctly_read_empty_data_section([NotNull] string path) { using var photoshopFile = PhotoshopFile.Open(path); photoshopFile.ColorModeData.Should() .BeEmpty(); }
public void Should_open_valid_file([NotNull] string path) { using var photoshopFile = PhotoshopFile.Open(path); }