1e5c31af7Sopenharmony_ci// Copyright 2019 The Amber Authors.
2e5c31af7Sopenharmony_ci//
3e5c31af7Sopenharmony_ci// Licensed under the Apache License, Version 2.0 (the "License");
4e5c31af7Sopenharmony_ci// you may not use this file except in compliance with the License.
5e5c31af7Sopenharmony_ci// You may obtain a copy of the License at
6e5c31af7Sopenharmony_ci//
7e5c31af7Sopenharmony_ci//     http://www.apache.org/licenses/LICENSE-2.0
8e5c31af7Sopenharmony_ci//
9e5c31af7Sopenharmony_ci// Unless required by applicable law or agreed to in writing, software
10e5c31af7Sopenharmony_ci// distributed under the License is distributed on an "AS IS" BASIS,
11e5c31af7Sopenharmony_ci// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12e5c31af7Sopenharmony_ci// See the License for the specific language governing permissions and
13e5c31af7Sopenharmony_ci// limitations under the License.
14e5c31af7Sopenharmony_ci
15e5c31af7Sopenharmony_ci#ifndef SAMPLES_PNG_H_
16e5c31af7Sopenharmony_ci#define SAMPLES_PNG_H_
17e5c31af7Sopenharmony_ci
18e5c31af7Sopenharmony_ci#include <string>
19e5c31af7Sopenharmony_ci#include <utility>
20e5c31af7Sopenharmony_ci#include <vector>
21e5c31af7Sopenharmony_ci
22e5c31af7Sopenharmony_ci#include "amber/amber.h"
23e5c31af7Sopenharmony_ci
24e5c31af7Sopenharmony_cinamespace png {
25e5c31af7Sopenharmony_ci
26e5c31af7Sopenharmony_ci/// Converts the image of dimensions |width| and |height| and with pixels stored
27e5c31af7Sopenharmony_ci/// in row-major order in |values| with format B8G8R8A8 into PNG format,
28e5c31af7Sopenharmony_ci/// returning the PNG binary as a string.
29e5c31af7Sopenharmony_ciamber::Result ConvertToPNG(uint32_t width,
30e5c31af7Sopenharmony_ci                           uint32_t height,
31e5c31af7Sopenharmony_ci                           const std::vector<amber::Value>& values,
32e5c31af7Sopenharmony_ci                           std::vector<uint8_t>* buffer);
33e5c31af7Sopenharmony_ci
34e5c31af7Sopenharmony_ci/// Loads a PNG image from |file_name|. Image dimensions of the loaded file are
35e5c31af7Sopenharmony_ci/// stored into |width| and |height|, and the image data is stored in a one
36e5c31af7Sopenharmony_ci/// byte per data element format into |values|.
37e5c31af7Sopenharmony_ciamber::Result LoadPNG(const std::string file_name,
38e5c31af7Sopenharmony_ci                      uint32_t* width,
39e5c31af7Sopenharmony_ci                      uint32_t* height,
40e5c31af7Sopenharmony_ci                      std::vector<amber::Value>* values);
41e5c31af7Sopenharmony_ci
42e5c31af7Sopenharmony_ci}  // namespace png
43e5c31af7Sopenharmony_ci
44e5c31af7Sopenharmony_ci#endif  // SAMPLES_PNG_H_
45