OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkCodec.h" | 8 #include "SkCodec.h" |
9 #include "SkCodecPriv.h" | 9 #include "SkCodecPriv.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 private: | 530 private: |
531 // Quick check if the image contains a valid TIFF header as requested by DNG
format. | 531 // Quick check if the image contains a valid TIFF header as requested by DNG
format. |
532 bool isTiffHeaderValid() const { | 532 bool isTiffHeaderValid() const { |
533 const size_t kHeaderSize = 4; | 533 const size_t kHeaderSize = 4; |
534 SkAutoSTMalloc<kHeaderSize, unsigned char> header(kHeaderSize); | 534 SkAutoSTMalloc<kHeaderSize, unsigned char> header(kHeaderSize); |
535 if (!fStream->read(header.get(), 0 /* offset */, kHeaderSize)) { | 535 if (!fStream->read(header.get(), 0 /* offset */, kHeaderSize)) { |
536 return false; | 536 return false; |
537 } | 537 } |
538 | 538 |
539 // Check if the header is valid (endian info and magic number "42"). | 539 // Check if the header is valid (endian info and magic number "42"). |
540 return | 540 bool littleEndian; |
541 (header[0] == 0x49 && header[1] == 0x49 && header[2] == 0x2A && head
er[3] == 0x00) || | 541 if (!is_valid_endian_marker(header, &littleEndian)) { |
542 (header[0] == 0x4D && header[1] == 0x4D && header[2] == 0x00 && head
er[3] == 0x2A); | 542 return false; |
| 543 } |
| 544 |
| 545 return 0x2A == get_endian_short(header + 2, littleEndian); |
543 } | 546 } |
544 | 547 |
545 void init(const int width, const int height, const dng_point& cfaPatternSize
) { | 548 void init(const int width, const int height, const dng_point& cfaPatternSize
) { |
546 fImageInfo = SkImageInfo::Make(width, height, kN32_SkColorType, kOpaque_
SkAlphaType); | 549 fImageInfo = SkImageInfo::Make(width, height, kN32_SkColorType, kOpaque_
SkAlphaType); |
547 | 550 |
548 // The DNG SDK scales only during demosaicing, so scaling is only possib
le when | 551 // The DNG SDK scales only during demosaicing, so scaling is only possib
le when |
549 // a mosaic info is available. | 552 // a mosaic info is available. |
550 fIsScalable = cfaPatternSize.v != 0 && cfaPatternSize.h != 0; | 553 fIsScalable = cfaPatternSize.v != 0 && cfaPatternSize.h != 0; |
551 fIsXtransImage = fIsScalable ? (cfaPatternSize.v == 6 && cfaPatternSize.
h == 6) : false; | 554 fIsXtransImage = fIsScalable ? (cfaPatternSize.v == 6 && cfaPatternSize.
h == 6) : false; |
552 } | 555 } |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 SkISize sizeFloor = this->onGetScaledDimensions(1.f / std::floor(fullShortEd
ge / shortEdge)); | 755 SkISize sizeFloor = this->onGetScaledDimensions(1.f / std::floor(fullShortEd
ge / shortEdge)); |
753 SkISize sizeCeil = this->onGetScaledDimensions(1.f / std::ceil(fullShortEdge
/ shortEdge)); | 756 SkISize sizeCeil = this->onGetScaledDimensions(1.f / std::ceil(fullShortEdge
/ shortEdge)); |
754 return sizeFloor == dim || sizeCeil == dim; | 757 return sizeFloor == dim || sizeCeil == dim; |
755 } | 758 } |
756 | 759 |
757 SkRawCodec::~SkRawCodec() {} | 760 SkRawCodec::~SkRawCodec() {} |
758 | 761 |
759 SkRawCodec::SkRawCodec(SkDngImage* dngImage) | 762 SkRawCodec::SkRawCodec(SkDngImage* dngImage) |
760 : INHERITED(dngImage->getImageInfo(), nullptr) | 763 : INHERITED(dngImage->getImageInfo(), nullptr) |
761 , fDngImage(dngImage) {} | 764 , fDngImage(dngImage) {} |
OLD | NEW |