Android-cuttlefish cvd tool
image.h
Go to the documentation of this file.
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 <cstddef>
19#include <cstdint>
20#include <string>
21#include <vector>
22
24
25namespace gfxstream {
26
27struct RGBAImage {
28 size_t width;
29 size_t height;
30 std::vector<uint8_t> pixels;
31};
33 const std::string& filename);
34
36 size_t w, size_t h, const uint8_t* rgbaPixels,
37 const std::string& filename = "");
38
40 size_t width;
41 size_t height;
42 std::vector<uint8_t> y;
43 std::vector<uint8_t> u;
44 std::vector<uint8_t> v;
45};
47 const std::string& filename);
48
49RGBAImage FillWithColor(size_t width, size_t height, uint8_t red, uint8_t green,
50 uint8_t blue, uint8_t alpha);
51
53
54struct PixelDiff {
55 size_t x;
56 size_t y;
57 uint8_t expectedR;
58 uint8_t expectedG;
59 uint8_t expectedB;
60 uint8_t expectedA;
61 uint8_t actualR;
62 uint8_t actualG;
63 uint8_t actualB;
64 uint8_t actualA;
65};
66
68 const RGBAImage& expected, const RGBAImage& actual);
69
70} // namespace gfxstream
Definition: expected.h:33
Definition: egl.cpp:32
gfxstream::expected< Ok, std::string > SaveRGBAToBitmapFile(size_t w, size_t h, const uint8_t *rgbaPixels, const std::string &filename)
Definition: image.cpp:132
RGBAImage FillWithColor(size_t width, size_t height, uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha)
Definition: image.cpp:213
gfxstream::expected< Ok, std::vector< PixelDiff > > CompareImages(const RGBAImage &expected, const RGBAImage &actual)
Definition: image.cpp:318
gfxstream::expected< YUV420Image, std::string > LoadYUV420FromBitmapFile(const std::string &filename)
Definition: image.cpp:207
YUV420Image ConvertRGBA8888ToYUV420(const RGBAImage &rgbaImage)
Definition: image.cpp:259
gfxstream::expected< RGBAImage, std::string > LoadRGBAFromBitmapFile(const std::string &filename)
Definition: image.cpp:37
Definition: image.h:54
uint8_t expectedA
Definition: image.h:60
uint8_t expectedG
Definition: image.h:58
uint8_t expectedR
Definition: image.h:57
uint8_t actualG
Definition: image.h:62
uint8_t actualA
Definition: image.h:64
size_t y
Definition: image.h:56
size_t x
Definition: image.h:55
uint8_t actualB
Definition: image.h:63
uint8_t actualR
Definition: image.h:61
uint8_t expectedB
Definition: image.h:59
Definition: image.h:27
size_t width
Definition: image.h:28
size_t height
Definition: image.h:29
std::vector< uint8_t > pixels
Definition: image.h:30
Definition: image.h:39
size_t width
Definition: image.h:40
std::vector< uint8_t > y
Definition: image.h:42
std::vector< uint8_t > u
Definition: image.h:43
size_t height
Definition: image.h:41
std::vector< uint8_t > v
Definition: image.h:44
Definition: image.h:38