| Flutter Impeller |

Public Member Functions | Friends | List of all members
impeller::testing::MetalScreenshot Class Reference

A screenshot that was produced from `MetalScreenshoter`. More...

`#include <metal_screenshot.h>`

## Public Member Functions
| ~MetalScreenshot ()
const UInt8 * | GetBytes () const
size_t | GetHeight () const
size_t | GetWidth () const
bool | WriteToPNG (const std::string &path) const

## Friends
class | MetalScreenshoter

## Detailed Description

A screenshot that was produced from `MetalScreenshoter`.

Definition at line 19 of file metal_screenshot.h.

## Constructor & Destructor Documentation

## ◆ ~MetalScreenshot()

impeller::testing::MetalScreenshot::~MetalScreenshot | ( |  | ) |

Definition at line 15 of file metal_screenshot.mm.

15 {
16 CFRelease(pixel_data_);
17 CGImageRelease(cg_image_);
18 }

## Member Function Documentation

## ◆ GetBytes()

const UInt8 * impeller::testing::MetalScreenshot::GetBytes | ( |  | ) | const

Definition at line 20 of file metal_screenshot.mm.

20 {
21 return CFDataGetBytePtr(pixel_data_);
22 }

## ◆ GetHeight()

size_t impeller::testing::MetalScreenshot::GetHeight | ( |  | ) | const

Definition at line 24 of file metal_screenshot.mm.

24 {
25 return CGImageGetHeight(cg_image_);
26 }

## ◆ GetWidth()

size_t impeller::testing::MetalScreenshot::GetWidth | ( |  | ) | const

Definition at line 28 of file metal_screenshot.mm.

28 {
29 return CGImageGetWidth(cg_image_);
30 }

## ◆ WriteToPNG()

bool impeller::testing::MetalScreenshot::WriteToPNG | ( | const std::string & | path | ) | const

Definition at line 32 of file metal_screenshot.mm.

32 {
33 bool result = false;
34 NSURL* output_url =
35 [NSURL fileURLWithPath:[NSString stringWithUTF8String:path.c_str()]];
36 CGImageDestinationRef destination = CGImageDestinationCreateWithURL(
37 (__bridge CFURLRef)output_url, kUTTypePNG, 1, nullptr);
38 if (destination != nullptr) {
39 CGImageDestinationAddImage(destination, cg_image_,
40 (__bridge CFDictionaryRef) @{});
41
42 if (CGImageDestinationFinalize(destination)) {
43 result = true;
44 }
45
46 CFRelease(destination);
47 }
48 return result;
49 }

## Friends And Related Function Documentation

## ◆ MetalScreenshoter

friend class MetalScreenshoter
| friend

Definition at line 32 of file metal_screenshot.h.

The documentation for this class was generated from the following files:

- impeller/golden_tests/metal_screenshot.h
- impeller/golden_tests/metal_screenshot.mm