xref: /aosp_15_r20/external/sandboxed-api/contrib/lodepng/examples/helpers.h (revision ec63e07ab9515d95e79c211197c445ef84cefa6a)
1 // Copyright 2020 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef CONTRIB_LODEPNG_EXAMPLES_HELPERS_H_
16 #define CONTRIB_LODEPNG_EXAMPLES_HELPERS_H_
17 
18 #include <cstddef>
19 #include <cstdint>
20 
21 #include "absl/log/log.h"
22 #include "sandboxed_api/util/fileops.h"
23 #include "sandboxed_api/util/temp_file.h"
24 
25 inline constexpr size_t kWidth = 512;
26 inline constexpr size_t kHeight = 512;
27 inline constexpr size_t kImgLen = kWidth * kHeight * 4;
28 
29 // Returns a vector that contains values used for testing.
30 // This part of code is taken from
31 // https://github.com/lvandeve/lodepng/blob/master/examples/example_encode.c#L96-L104.
32 // The generated image contains square fractals.
33 std::vector<uint8_t> GenerateValues();
34 
35 // Creates a temporary directory in the current working directory and returns
36 // the path.
37 std::string CreateTempDirAtCWD();
38 
39 #endif  // CONTRIB_LODEPNG_EXAMPLES_HELPERS_H_
40