Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkJpegMetadataDecoder.h
Go to the documentation of this file.
1/*
2 * Copyright 2013 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 SkJpegMetadataDecoder_DEFINED
9#define SkJpegMetadataDecoder_DEFINED
10
11#include "include/core/SkData.h"
14
15#include <memory>
16#include <vector>
17
18struct SkGainmapInfo;
19
20/**
21 * An interface that can be used to extract metadata from an encoded JPEG file.
22 */
24public:
27
30
31 /**
32 * A segment from a JPEG file. This is usually populated from a jpeg_marker_struct.
33 */
34 struct SK_API Segment {
35 Segment(uint8_t marker, sk_sp<SkData> data) : fMarker(marker), fData(std::move(data)) {}
36
37 // The segment's marker.
38 uint8_t fMarker = 0;
39
40 // The segment's parameters (not including the marker and parameter length).
42 };
43
44 /**
45 * Create metadata for the specified segments from a JPEG file's header (defined as all segments
46 * before the first StartOfScan). This may return nullptr.
47 */
48 static std::unique_ptr<SkJpegMetadataDecoder> Make(std::vector<Segment> headerSegments);
49
50 /**
51 * Return the Exif data attached to the image (if any) and nullptr otherwise. If |copyData| is
52 * false, then the returned SkData may directly reference the data provided when this object was
53 * created.
54 */
55 virtual sk_sp<SkData> getExifMetadata(bool copyData) const = 0;
56
57 /**
58 * Return the ICC profile of the image if any, and nullptr otherwise. If |copyData| is false,
59 * then the returned SkData may directly reference the data provided when this object was
60 * created.
61 */
62 virtual sk_sp<SkData> getICCProfileData(bool copyData) const = 0;
63
64 /**
65 * Return true if there is a possibility that this image contains a gainmap image.
66 */
67 virtual bool mightHaveGainmapImage() const = 0;
68
69 /**
70 * Given a JPEG encoded image |baseImageData|, return in |outGainmapImageData| the JPEG encoded
71 * gainmap image and return in |outGainmapInfo| its gainmap rendering parameters. Return true if
72 * both output variables were successfully populated, otherwise return false.
73 */
74 virtual bool findGainmapImage(sk_sp<SkData> baseImageData,
75 sk_sp<SkData>& outGainmapImagedata,
76 SkGainmapInfo& outGainmapInfo) = 0;
77};
78
79#endif
static const char marker[]
#define SK_API
Definition SkAPI.h:35
static std::unique_ptr< SkEncoder > Make(SkWStream *dst, const SkPixmap *src, const SkYUVAPixmaps *srcYUVA, const SkColorSpace *srcYUVAColorSpace, const SkJpegEncoder::Options &options)
virtual bool mightHaveGainmapImage() const =0
virtual sk_sp< SkData > getExifMetadata(bool copyData) const =0
SkJpegMetadataDecoder & operator=(const SkJpegMetadataDecoder &)=delete
virtual bool findGainmapImage(sk_sp< SkData > baseImageData, sk_sp< SkData > &outGainmapImagedata, SkGainmapInfo &outGainmapInfo)=0
virtual sk_sp< SkData > getICCProfileData(bool copyData) const =0
SkJpegMetadataDecoder(const SkJpegMetadataDecoder &)=delete
Definition ref_ptr.h:256
Segment(uint8_t marker, sk_sp< SkData > data)