KiCad PCB EDA Suite
Loading...
Searching...
No Matches
ole_image.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your option)
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
22#include <cstddef>
23#include <cstdint>
24#include <optional>
25#include <string>
26#include <utility>
27#include <vector>
28
29#include <math/vector2d.h>
30#include <wx/string.h>
31
32class wxImage;
33class wxMemoryBuffer;
34
35
37{
39 BMP, // Encoded raster data, including PNG and JPEG.
42};
43
44
46{
48 std::vector<uint8_t> data;
49 std::string streamName;
50};
51
52
54OLE_IMAGE_PAYLOAD ExtractOleImage( const uint8_t* aCfb, size_t aSize );
55
56inline OLE_IMAGE_PAYLOAD ExtractOleImage( const std::vector<uint8_t>& aCfb )
57{
58 return ExtractOleImage( aCfb.data(), aCfb.size() );
59}
60
62std::optional<std::pair<size_t, size_t>> OleEmbeddedCompoundFile( const std::vector<uint8_t>& aPayload );
63
65OLE_IMAGE_PAYLOAD ExtractOleImageFromPayload( const std::vector<uint8_t>& aPayload );
66
68std::vector<uint8_t> OleExtractEmbeddedEmf( const std::vector<uint8_t>& aWmf );
69
71std::vector<uint8_t> OleExtractCiImage( const std::vector<uint8_t>& aPayload );
72
74wxString OleDescribeImagePayload( const std::vector<uint8_t>& aPayload );
75
76bool OleMakeBmpFromDib( const std::vector<uint8_t>& aDib, wxMemoryBuffer& aOut );
77
78bool OleRenderWmf( const std::vector<uint8_t>& aWmf, int aMaxWidth, int aMaxHeight, wxImage& aImage,
79 double aTargetAspect = 0.0 );
80
82bool OleRenderMetafilePreview( const std::vector<uint8_t>& aWmf, int aMaxWidth, int aMaxHeight,
83 wxImage& aImage, double aTargetAspect = 0.0,
84 bool* aUsedEmbeddedEmf = nullptr );
85
86bool OleRenderEmf( const std::vector<uint8_t>& aEmf, int aMaxWidth, int aMaxHeight, wxImage& aImage,
87 double aTargetAspect = 0.0 );
88
89VECTOR2I OleWmfRenderSize( int aNaturalWidth, int aNaturalHeight, int aMaxWidth, int aMaxHeight,
90 double aTargetAspect );
@ NONE
Definition eda_fill.h:42
bool OleRenderWmf(const std::vector< uint8_t > &aWmf, int aMaxWidth, int aMaxHeight, wxImage &aImage, double aTargetAspect=0.0)
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.
VECTOR2I OleWmfRenderSize(int aNaturalWidth, int aNaturalHeight, int aMaxWidth, int aMaxHeight, double aTargetAspect)
OLE_IMAGE_TYPE
Definition ole_image.h:37
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.
bool OleRenderEmf(const std::vector< uint8_t > &aEmf, int aMaxWidth, int aMaxHeight, wxImage &aImage, double aTargetAspect=0.0)
Definition ole_emf.cpp:122
std::vector< uint8_t > OleExtractEmbeddedEmf(const std::vector< uint8_t > &aWmf)
Reassemble an EMF carried by WMF META_ESCAPE_ENHANCED_METAFILE records.
bool OleMakeBmpFromDib(const std::vector< uint8_t > &aDib, wxMemoryBuffer &aOut)
wxString OleDescribeImagePayload(const std::vector< uint8_t > &aPayload)
Include leading bytes when the payload format is unknown.
OLE_IMAGE_PAYLOAD ExtractOleImage(const uint8_t *aCfb, size_t aSize)
Prefer CONTENTS, then OlePres000, then the native stream.
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.
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.
std::vector< uint8_t > data
Definition ole_image.h:48
std::string streamName
Definition ole_image.h:49
OLE_IMAGE_TYPE type
Definition ole_image.h:47
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683