• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2023 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 SkJpegGainmapEncoder_DEFINED
9 #define SkJpegGainmapEncoder_DEFINED
10 
11 #include "include/encode/SkJpegEncoder.h"
12 
13 class SkPixmap;
14 class SkWStream;
15 struct SkGainmapInfo;
16 
17 class SK_API SkJpegGainmapEncoder {
18 public:
19     /**
20      *  Encode a JpegR image to |dst|.
21      *
22      *  The base image is specified by |base|, and |baseOptions| controls the encoding behavior for
23      *  the base image.
24      *
25      *  The gainmap image is specified by |gainmap|, and |gainmapOptions| controls the encoding
26      *  behavior for the gainmap image.
27      *
28      *  The rendering behavior of the gainmap image is provided in |gainmapInfo|. Not all gainmap
29      *  based images are compatible with JpegR. If the image is not compatible with JpegR, then
30      *  convert the gainmap to a format that is capable with JpegR. This conversion may result in
31      *  less precise quantization of the gainmap image.
32      *
33      *  Returns true on success.  Returns false on an invalid or unsupported |src|.
34      */
35     static bool EncodeJpegR(SkWStream* dst,
36                             const SkPixmap& base,
37                             const SkJpegEncoder::Options& baseOptions,
38                             const SkPixmap& gainmap,
39                             const SkJpegEncoder::Options& gainmapOptions,
40                             const SkGainmapInfo& gainmapInfo);
41 
42     /**
43      *  Encode an HDRGM image to |dst|.
44      *
45      *  The base image is specified by |base|, and |baseOptions| controls the encoding behavior for
46      *  the base image.
47      *
48      *  The gainmap image is specified by |gainmap|, and |gainmapOptions| controls the encoding
49      *  behavior for the gainmap image.
50      *
51      *  The rendering behavior of the gainmap image is provided in |gainmapInfo|.
52      *
53      *  If |baseOptions| or |gainmapOptions| specify XMP metadata, then that metadata will be
54      *  overwritten.
55      *
56      *  Returns true on success.  Returns false on an invalid or unsupported |src|.
57      */
58     static bool EncodeHDRGM(SkWStream* dst,
59                             const SkPixmap& base,
60                             const SkJpegEncoder::Options& baseOptions,
61                             const SkPixmap& gainmap,
62                             const SkJpegEncoder::Options& gainmapOptions,
63                             const SkGainmapInfo& gainmapInfo);
64 
65     /**
66      *  Write a Multi Picture Format containing the |imageCount| images specified by |images|.
67      */
68     static bool MakeMPF(SkWStream* dst, const SkData** images, size_t imageCount);
69 };
70 
71 #endif
72