| 985 | /*supports_grey_alpha=*/bool>> {}; |
| 986 | |
| 987 | TEST_P(ParameterizedBitmapFormatTests, ReadWriteRGB) { |
| 988 | const auto [kExtension, |
| 989 | kIsLossless, |
| 990 | kSupportsNativeGrey, |
| 991 | kSupportsRGBA, |
| 992 | kSupportsGreyAlpha] = GetParam(); |
| 993 | |
| 994 | constexpr int kWidth = 4; |
| 995 | constexpr int kHeight = 3; |
| 996 | Bitmap write_bitmap(kWidth, kHeight, /*as_rgb=*/true); |
| 997 | for (int y = 0; y < kHeight; ++y) { |
| 998 | for (int x = 0; x < kWidth; ++x) { |
| 999 | const uint8_t r = static_cast<uint8_t>((x + y * kWidth) * 20); |
| 1000 | const uint8_t g = static_cast<uint8_t>((x + y * kWidth) * 15); |
| 1001 | const uint8_t b = static_cast<uint8_t>((x + y * kWidth) * 10); |
| 1002 | write_bitmap.SetPixel(x, y, BitmapColor<uint8_t>(r, g, b)); |
| 1003 | } |
| 1004 | } |
| 1005 | |
| 1006 | const auto filename = CreateTestDir() / ("image" + kExtension); |
| 1007 | EXPECT_TRUE(write_bitmap.Write(filename)); |
| 1008 | |
| 1009 | Bitmap rgb_bitmap; |
| 1010 | EXPECT_TRUE(rgb_bitmap.Read(filename)); |
| 1011 | EXPECT_EQ(rgb_bitmap.Width(), kWidth); |
| 1012 | EXPECT_EQ(rgb_bitmap.Height(), kHeight); |
| 1013 | EXPECT_EQ(rgb_bitmap.Channels(), 3); |
| 1014 | EXPECT_EQ(rgb_bitmap.BitsPerPixel(), 24); |
| 1015 | |
| 1016 | if (kIsLossless) { |
| 1017 | EXPECT_EQ(rgb_bitmap.RowMajorData(), write_bitmap.RowMajorData()); |
| 1018 | } |
| 1019 | |
| 1020 | Bitmap grey_bitmap; |
| 1021 | EXPECT_TRUE(grey_bitmap.Read(filename, /*as_rgb=*/false)); |
| 1022 | EXPECT_EQ(grey_bitmap.Width(), kWidth); |
| 1023 | EXPECT_EQ(grey_bitmap.Height(), kHeight); |
| 1024 | EXPECT_EQ(grey_bitmap.Channels(), 1); |
| 1025 | EXPECT_EQ(grey_bitmap.BitsPerPixel(), 8); |
| 1026 | } |
| 1027 | |
| 1028 | TEST_P(ParameterizedBitmapFormatTests, ReadWriteGrey) { |
| 1029 | const auto [kExtension, |
nothing calls this directly
no test coverage detected