KiCad PCB EDA Suite
Loading...
Searching...
No Matches
ole_image.h File Reference
#include <cstddef>
#include <cstdint>
#include <optional>
#include <string>
#include <utility>
#include <vector>
#include <math/vector2d.h>
#include <wx/string.h>

Go to the source code of this file.

Classes

struct  OLE_IMAGE_PAYLOAD
 

Enumerations

enum class  OLE_IMAGE_TYPE { NONE , BMP , DIB , WMF }
 

Functions

OLE_IMAGE_PAYLOAD ExtractOleImage (const uint8_t *aCfb, size_t aSize)
 Prefer CONTENTS, then OlePres000, then the native stream.
 
OLE_IMAGE_PAYLOAD ExtractOleImage (const std::vector< uint8_t > &aCfb)
 
std::optional< std::pair< size_t, size_t > > OleEmbeddedCompoundFile (const std::vector< uint8_t > &aPayload)
 The 26-byte prologue stores length at offset 22 and length plus 22 at offset 0.
 
OLE_IMAGE_PAYLOAD ExtractOleImageFromPayload (const std::vector< uint8_t > &aPayload)
 Read the picture out of an OLE object payload that carries the 26-byte prologue.
 
std::vector< uint8_t > OleExtractEmbeddedEmf (const std::vector< uint8_t > &aWmf)
 Reassemble an EMF carried by WMF META_ESCAPE_ENHANCED_METAFILE records.
 
std::vector< uint8_t > OleExtractCiImage (const std::vector< uint8_t > &aPayload)
 The CI marker follows the preview DIB; the raster has a counted decimal length.
 
wxString OleDescribeImagePayload (const std::vector< uint8_t > &aPayload)
 Include leading bytes when the payload format is unknown.
 
bool OleMakeBmpFromDib (const std::vector< uint8_t > &aDib, wxMemoryBuffer &aOut)
 
bool OleRenderWmf (const std::vector< uint8_t > &aWmf, int aMaxWidth, int aMaxHeight, wxImage &aImage, double aTargetAspect=0.0)
 
bool OleRenderMetafilePreview (const std::vector< uint8_t > &aWmf, int aMaxWidth, int aMaxHeight, wxImage &aImage, double aTargetAspect=0.0, bool *aUsedEmbeddedEmf=nullptr)
 Render a metafile preview, preferring an EMF the WMF carries over the WMF itself.
 
bool OleRenderEmf (const std::vector< uint8_t > &aEmf, int aMaxWidth, int aMaxHeight, wxImage &aImage, double aTargetAspect=0.0)
 
VECTOR2I OleWmfRenderSize (int aNaturalWidth, int aNaturalHeight, int aMaxWidth, int aMaxHeight, double aTargetAspect)
 

Enumeration Type Documentation

◆ OLE_IMAGE_TYPE

enum class OLE_IMAGE_TYPE
strong
Enumerator
NONE 
BMP 
DIB 
WMF 

Definition at line 36 of file ole_image.h.

Function Documentation

◆ ExtractOleImage() [1/2]

OLE_IMAGE_PAYLOAD ExtractOleImage ( const std::vector< uint8_t > & aCfb)
inline

Definition at line 56 of file ole_image.h.

References ExtractOleImage().

◆ ExtractOleImage() [2/2]

OLE_IMAGE_PAYLOAD ExtractOleImage ( const uint8_t * aCfb,
size_t aSize )

Prefer CONTENTS, then OlePres000, then the native stream.

Definition at line 276 of file ole_image.cpp.

References NONE, and result.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), ExtractOleImage(), and ExtractOleImageFromPayload().

◆ ExtractOleImageFromPayload()

OLE_IMAGE_PAYLOAD ExtractOleImageFromPayload ( const std::vector< uint8_t > & aPayload)

Read the picture out of an OLE object payload that carries the 26-byte prologue.

Definition at line 331 of file ole_image.cpp.

References ExtractOleImage(), and OleEmbeddedCompoundFile().

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and ORCAD_CONVERTER::placeBitmap().

◆ OleDescribeImagePayload()

wxString OleDescribeImagePayload ( const std::vector< uint8_t > & aPayload)

Include leading bytes when the payload format is unknown.

Definition at line 697 of file ole_image.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), and ORCAD_CONVERTER::placeBitmap().

◆ OleEmbeddedCompoundFile()

std::optional< std::pair< size_t, size_t > > OleEmbeddedCompoundFile ( const std::vector< uint8_t > & aPayload)

The 26-byte prologue stores length at offset 22 and length plus 22 at offset 0.

Definition at line 250 of file ole_image.cpp.

Referenced by ExtractOleImageFromPayload(), and OleExtractCiImage().

◆ OleExtractCiImage()

std::vector< uint8_t > OleExtractCiImage ( const std::vector< uint8_t > & aPayload)

The CI marker follows the preview DIB; the raster has a counted decimal length.

Definition at line 477 of file ole_image.cpp.

References image, and OleEmbeddedCompoundFile().

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and ORCAD_CONVERTER::placeBitmap().

◆ OleExtractEmbeddedEmf()

std::vector< uint8_t > OleExtractEmbeddedEmf ( const std::vector< uint8_t > & aWmf)

Reassemble an EMF carried by WMF META_ESCAPE_ENHANCED_METAFILE records.

Definition at line 384 of file ole_image.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and OleRenderMetafilePreview().

◆ OleMakeBmpFromDib()

bool OleMakeBmpFromDib ( const std::vector< uint8_t > & aDib,
wxMemoryBuffer & aOut )

Definition at line 348 of file ole_image.cpp.

Referenced by ORCAD_CONVERTER::placeBitmap().

◆ OleRenderEmf()

bool OleRenderEmf ( const std::vector< uint8_t > & aEmf,
int aMaxWidth,
int aMaxHeight,
wxImage & aImage,
double aTargetAspect = 0.0 )

◆ OleRenderMetafilePreview()

bool OleRenderMetafilePreview ( const std::vector< uint8_t > & aWmf,
int aMaxWidth,
int aMaxHeight,
wxImage & aImage,
double aTargetAspect = 0.0,
bool * aUsedEmbeddedEmf = nullptr )

Render a metafile preview, preferring an EMF the WMF carries over the WMF itself.

Definition at line 677 of file ole_image.cpp.

References OleExtractEmbeddedEmf(), OleRenderEmf(), and OleRenderWmf().

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and ORCAD_CONVERTER::placeBitmap().

◆ OleRenderWmf()

bool OleRenderWmf ( const std::vector< uint8_t > & aWmf,
int aMaxWidth,
int aMaxHeight,
wxImage & aImage,
double aTargetAspect = 0.0 )

◆ OleWmfRenderSize()

VECTOR2I OleWmfRenderSize ( int aNaturalWidth,
int aNaturalHeight,
int aMaxWidth,
int aMaxHeight,
double aTargetAspect )

Definition at line 554 of file ole_image.cpp.

References KiROUND(), and scale.

Referenced by BOOST_AUTO_TEST_CASE(), OleRenderEmf(), and OleRenderWmf().