#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "components/pwg_encoder/pwg_encoder.h"
#include <limits.h>
#include <string.h>
#include <algorithm>
#include <memory>
#include "base/containers/span.h"
#include "base/logging.h"
#include "base/numerics/byte_conversions.h"
#include "components/pwg_encoder/bitmap_image.h"
namespace pwg_encoder {
namespace {
const uint32_t kBitsPerColor = …;
const uint32_t kColorOrder = …;
const uint32_t kRedCoefficient = …;
const uint32_t kGreenCoefficient = …;
const uint32_t kBlueCoefficient = …;
const uint32_t kColorCoefficientDenominator = …;
const char kPwgKeyword[] = …;
const uint32_t kHeaderSize = …;
const uint32_t kHeaderCupsDuplex = …;
const uint32_t kHeaderCupsHwResolutionHorizontal = …;
const uint32_t kHeaderCupsHwResolutionVertical = …;
const uint32_t kHeaderCupsTumble = …;
const uint32_t kHeaderCupsWidth = …;
const uint32_t kHeaderCupsHeight = …;
const uint32_t kHeaderCupsBitsPerColor = …;
const uint32_t kHeaderCupsBitsPerPixel = …;
const uint32_t kHeaderCupsBytesPerLine = …;
const uint32_t kHeaderCupsColorOrder = …;
const uint32_t kHeaderCupsColorSpace = …;
const uint32_t kHeaderCupsNumColors = …;
const uint32_t kHeaderPwgTotalPageCount = …;
const uint32_t kHeaderPwgCrossFeedTransform = …;
const uint32_t kHeaderPwgFeedTransform = …;
const int kPwgMaxPackedRows = …;
const int kPwgMaxPackedPixels = …;
struct RGBA8 { … };
struct BGRA8 { … };
template <class InputStruct>
void EncodePixelToRGB(const void* pixel, std::string* output) { … }
template <class InputStruct>
void EncodePixelToMonochrome(const void* pixel, std::string* output) { … }
std::string EncodePageHeader(const BitmapImage& image,
const PwgHeaderInfo& pwg_header_info) { … }
template <typename InputStruct, class RandomAccessIterator>
void EncodeRow(RandomAccessIterator pos,
RandomAccessIterator row_end,
bool monochrome,
std::string* output) { … }
const uint8_t* GetRow(const BitmapImage& image, int row, bool flipy) { … }
template <typename InputStruct>
std::string EncodePageWithColorspace(const BitmapImage& image,
const PwgHeaderInfo& pwg_header_info) { … }
}
std::string PwgEncoder::GetDocumentHeader() { … }
std::string PwgEncoder::EncodePage(const BitmapImage& image,
const PwgHeaderInfo& pwg_header_info) { … }
}