16 const std::string& filename) {
23 FX_SAFE_FILESIZE size = stride;
25 auto input = pdfium::make_span(
26 static_cast<
const uint8_t*>(FPDFBitmap_GetBuffer(bitmap)),
27 pdfium::base::ValueOrDieForType<size_t>(size));
29 std::vector<uint8_t> png;
32 png = image_diff_png::EncodeGrayPNG(input, width, height, stride);
34 png = image_diff_png::EncodeBGRPNG(input, width, height, stride);
36 png = image_diff_png::EncodeBGRAPNG(input, width, height, stride,
41 DCHECK(filename.size() < 256u);
43 std::ofstream png_file;
44 png_file.open(filename,
std::ios_base::out |
std::ios_base::binary);
45 png_file.write(
reinterpret_cast<
char*>(&png.front()), png.size());
46 DCHECK(png_file.good());