Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Unified Diff: tests/ColorSpaceTest.cpp

Issue 1813273002: Parse icc profiles and exif orientation from jpeg markers (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix build error Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/codec/SkRawCodec.cpp ('k') | tests/ExifTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/ColorSpaceTest.cpp
diff --git a/tests/ColorSpaceTest.cpp b/tests/ColorSpaceTest.cpp
index 3361aa3420228ab23e54506b98a598a9365a95b4..37785e238b8b6c93938e85a8bea7209b6591e2c1 100644
--- a/tests/ColorSpaceTest.cpp
+++ b/tests/ColorSpaceTest.cpp
@@ -17,13 +17,11 @@ static SkStreamAsset* resource(const char path[]) {
return SkStream::NewFromFile(fullPath.c_str());
}
-#if (PNG_LIBPNG_VER_MAJOR > 1) || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR >= 6)
static bool almost_equal(float a, float b) {
- return SkTAbs(a - b) < 0.0001f;
+ return SkTAbs(a - b) < 0.001f;
}
-#endif
-DEF_TEST(ColorSpaceParseICCProfile, r) {
+DEF_TEST(ColorSpaceParsePngICCProfile, r) {
SkAutoTDelete<SkStream> stream(resource("color_wheel_with_profile.png"));
REPORTER_ASSERT(r, nullptr != stream);
@@ -55,3 +53,35 @@ DEF_TEST(ColorSpaceParseICCProfile, r) {
REPORTER_ASSERT(r, almost_equal(0.714096f, xyz.fMat[8]));
#endif
}
+
+DEF_TEST(ColorSpaceParseJpegICCProfile, r) {
+ SkAutoTDelete<SkStream> stream(resource("icc-v2-gbr.jpg"));
+ REPORTER_ASSERT(r, nullptr != stream);
+
+ SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
+ REPORTER_ASSERT(r, nullptr != codec);
+
+ SkColorSpace* colorSpace = codec->getColorSpace();
+ REPORTER_ASSERT(r, nullptr != colorSpace);
+
+ // It's important to use almost equal here. This profile sets gamma as
+ // 563 / 256, which actually comes out to about 2.19922.
+ SkFloat3 gammas = colorSpace->gamma();
+ REPORTER_ASSERT(r, almost_equal(2.2f, gammas.fVec[0]));
+ REPORTER_ASSERT(r, almost_equal(2.2f, gammas.fVec[1]));
+ REPORTER_ASSERT(r, almost_equal(2.2f, gammas.fVec[2]));
+
+ // These nine values were extracted from the color profile. Until we know any
+ // better, we'll assume these are the right values and test that we continue
+ // to extract them properly.
+ SkFloat3x3 xyz = colorSpace->xyz();
+ REPORTER_ASSERT(r, almost_equal(0.385117f, xyz.fMat[0]));
+ REPORTER_ASSERT(r, almost_equal(0.716904f, xyz.fMat[1]));
+ REPORTER_ASSERT(r, almost_equal(0.0970612f, xyz.fMat[2]));
+ REPORTER_ASSERT(r, almost_equal(0.143051f, xyz.fMat[3]));
+ REPORTER_ASSERT(r, almost_equal(0.0606079f, xyz.fMat[4]));
+ REPORTER_ASSERT(r, almost_equal(0.713913f, xyz.fMat[5]));
+ REPORTER_ASSERT(r, almost_equal(0.436035f, xyz.fMat[6]));
+ REPORTER_ASSERT(r, almost_equal(0.222488f, xyz.fMat[7]));
+ REPORTER_ASSERT(r, almost_equal(0.013916f, xyz.fMat[8]));
+}
« no previous file with comments | « src/codec/SkRawCodec.cpp ('k') | tests/ExifTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698