| 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");
|
| +}
|
|
|