OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2015 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #include "Resources.h" |
| 9 #include "Test.h" |
| 10 |
| 11 #include "SkCodec.h" |
| 12 #include "SkImageEncoder.h" |
| 13 |
| 14 static SkStreamAsset* resource(const char path[]) { |
| 15 SkString fullPath = GetResourcePath(path); |
| 16 return SkStream::NewFromFile(fullPath.c_str()); |
| 17 } |
| 18 |
| 19 static void test(skiatest::Reporter* r, const char* path) { |
| 20 SkAutoTDelete<SkStream> stream(resource(path)); |
| 21 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release())); |
| 22 const SkImageInfo& info = codec->getInfo(); |
| 23 SkImageInfo infoF16 = info.makeColorType(kRGBA_F16_SkColorType) |
| 24 .makeColorSpace(info.colorSpace()->makeLinearGamma
()); |
| 25 if (kUnpremul_SkAlphaType == infoF16.alphaType()) { |
| 26 infoF16 = infoF16.makeAlphaType(kPremul_SkAlphaType); |
| 27 } |
| 28 |
| 29 SkBitmap bm; |
| 30 bm.allocPixels(infoF16); |
| 31 SkCodec::Result result = codec->getPixels(infoF16, bm.getPixels(), bm.rowByt
es()); |
| 32 REPORTER_ASSERT(r, SkCodec::kSuccess == result); |
| 33 |
| 34 sk_sp<SkData> data(SkImageEncoder::EncodeData(bm, SkImageEncoder::kEXR_Type,
100)); |
| 35 SkFILEWStream writeStream("/usr/local/google/home/msarett/skia/mandrill_zfp.
exr"); |
| 36 writeStream.write(data->data(), data->size()); |
| 37 } |
| 38 |
| 39 |
| 40 DEF_TEST(EncodeEXR, r) { |
| 41 test(r, "mandrill_512_q075.jpg"); |
| 42 //test(r, "color_alpha.png"); |
| 43 } |
OLD | NEW |