• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #pragma once
17 
18 #include <string>
19 #include <vector>
20 
21 namespace cuttlefish {
22 
23 void LoadRGBAFromBitmapFile(const std::string& filename, uint32_t* out_w,
24                             uint32_t* out_h, std::vector<uint8_t>* out_pixels);
25 
26 void SaveRGBAToBitmapFile(uint32_t w, uint32_t h, const uint8_t* rgba_pixels,
27                           const std::string& filename = "");
28 
29 void LoadYUV420FromBitmapFile(const std::string& filename, uint32_t* out_w,
30                               uint32_t* out_h, std::vector<uint8_t>* out_y,
31                               std::vector<uint8_t>* out_u,
32                               std::vector<uint8_t>* out_v);
33 
34 void FillWithColor(uint32_t width, uint32_t height, uint8_t red, uint8_t green,
35                    uint8_t blue, uint8_t alpha,
36                    std::vector<uint8_t>* out_pixels);
37 
38 void ConvertRGBA8888ToYUV420(uint32_t width, uint32_t height,
39                              const std::vector<uint8_t>& rgba_pixels,
40                              std::vector<uint8_t>* out_y_pixels,
41                              std::vector<uint8_t>* out_u_pixels,
42                              std::vector<uint8_t>* out_v_pixels);
43 
44 bool ImagesAreSimilar(uint32_t width, uint32_t height,
45                       const std::vector<uint8_t>& image1_rgba8888,
46                       const std::vector<uint8_t>& image2_rgba8888);
47 
48 }  // namespace cuttlefish
49