| Flutter Impeller |

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

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

`#include <metal_screenshot.h>`

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

## Friends
class | MetalScreenshotter

## Detailed Description

A screenshot that was produced from `MetalScreenshotter`.

Definition at line 18 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 }

## ◆ GetBytesPerRow()

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

Definition at line 32 of file metal_screenshot.mm.

32 {
33 return CGImageGetBytesPerRow(cg_image_);
34 }

## ◆ 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 36 of file metal_screenshot.mm.

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

## Friends And Related Function Documentation

## ◆ MetalScreenshotter

friend class MetalScreenshotter
| friend

Definition at line 33 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