blob: e6903bc5e8eb9972a6a86ebde92c5b7fc257c371 [file] [log] [blame]
Hal Canarydb683012016-11-23 08:55:18 -07001/*
2 * Copyright 2016 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#ifndef SkImageEncoderPriv_DEFINED
9#define SkImageEncoderPriv_DEFINED
10
11#include "SkImageEncoder.h"
Matt Sarettc367d032017-05-05 11:13:26 -040012#include "SkImageInfoPriv.h"
13
14static inline bool SkPixmapIsValid(const SkPixmap& src,
15 SkTransferFunctionBehavior unpremulBehavior)
16{
17 if (SkTransferFunctionBehavior::kRespect == unpremulBehavior) {
18 if (!SkImageInfoIsValidRenderingCS(src.info())) {
19 return false;
20 }
21 } else {
22 if (!SkImageInfoIsValidAllowNumericalCS(src.info())) {
23 return false;
24 }
25 }
26
27 if (!src.addr() || src.rowBytes() < src.info().minRowBytes()) {
28 return false;
29 }
30
31 return true;
32}
Hal Canarydb683012016-11-23 08:55:18 -070033
Hal Canarydb683012016-11-23 08:55:18 -070034#if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
Hal Canary1fcc4042016-11-30 17:07:59 -050035 bool SkEncodeImageWithCG(SkWStream*, const SkPixmap&, SkEncodedImageFormat);
36#else
37 #define SkEncodeImageWithCG(...) false
Hal Canarydb683012016-11-23 08:55:18 -070038#endif
39
Hal Canary1fcc4042016-11-30 17:07:59 -050040#ifdef SK_BUILD_FOR_WIN
41 bool SkEncodeImageWithWIC(SkWStream*, const SkPixmap&, SkEncodedImageFormat, int quality);
42#else
43 #define SkEncodeImageWithWIC(...) false
Hal Canarydb683012016-11-23 08:55:18 -070044#endif
45
Hal Canarydb683012016-11-23 08:55:18 -070046#endif // SkImageEncoderPriv_DEFINED