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);
                }
            }
        }
예제 #2
0
 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);
 }
예제 #3
0
        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);
        }
예제 #4
0
 public void Should_correctly_read_color_mode([NotNull] string path, ColorMode expectedColorMode)
 {
     using var photoshopFile = PhotoshopFile.Open(path);
     photoshopFile.ColorMode.Should()
     .Be(expectedColorMode);
 }
예제 #5
0
 public void Should_correctly_read_depth([NotNull] string path, int expectedDepth)
 {
     using var photoshopFile = PhotoshopFile.Open(path);
     photoshopFile.Depth.Should()
     .Be(expectedDepth);
 }
예제 #6
0
 public void Should_correctly_read_channel_count([NotNull] string path, int expectedChannelCount)
 {
     using var photoshopFile = PhotoshopFile.Open(path);
     photoshopFile.ChannelCount.Should()
     .Be(expectedChannelCount);
 }
예제 #7
0
 public void Should_correctly_read_empty_data_section([NotNull] string path)
 {
     using var photoshopFile = PhotoshopFile.Open(path);
     photoshopFile.ColorModeData.Should()
     .BeEmpty();
 }
예제 #8
0
 public void Should_open_valid_file([NotNull] string path)
 {
     using var photoshopFile = PhotoshopFile.Open(path);
 }