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

Unified Diff: tests/EXRTest.cpp

Issue 2344523002: Experimental: EXR
Patch Set: Now we have a decoder Created 4 years, 3 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/images/SkForceLinking.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/EXRTest.cpp
diff --git a/tests/EXRTest.cpp b/tests/EXRTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f0968d941cd2d1dc000b19bdbcf07a8c020728f9
--- /dev/null
+++ b/tests/EXRTest.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "Resources.h"
+#include "Test.h"
+
+#include "SkCodec.h"
+#include "SkImageEncoder.h"
+
+static SkStreamAsset* resource(const char path[]) {
+ SkString fullPath = GetResourcePath(path);
+ return SkStream::NewFromFile(fullPath.c_str());
+}
+
+static void test(skiatest::Reporter* r, const char* path) {
+ SkAutoTDelete<SkStream> stream(resource(path));
+ SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
+ const SkImageInfo& info = codec->getInfo();
+ SkImageInfo infoF16 = info.makeColorType(kRGBA_F16_SkColorType)
+ .makeColorSpace(info.colorSpace()->makeLinearGamma());
+ if (kUnpremul_SkAlphaType == infoF16.alphaType()) {
+ infoF16 = infoF16.makeAlphaType(kPremul_SkAlphaType);
+ }
+
+ SkBitmap bm;
+ bm.allocPixels(infoF16);
+ SkCodec::Result result = codec->getPixels(infoF16, bm.getPixels(), bm.rowBytes());
+ REPORTER_ASSERT(r, SkCodec::kSuccess == result);
+
+ sk_sp<SkData> data(SkImageEncoder::EncodeData(bm, SkImageEncoder::kEXR_Type, 100));
+ SkFILEWStream writeStream("/usr/local/google/home/msarett/skia/mandrill_zfp.exr");
+ writeStream.write(data->data(), data->size());
+}
+
+
+DEF_TEST(EncodeEXR, r) {
+ test(r, "mandrill_512_q075.jpg");
+ //test(r, "color_alpha.png");
+}
« no previous file with comments | « src/images/SkForceLinking.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698