BMIParser.h Source File documentation

BMIParser.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3 * This file is a part of the libzmf project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9
10 #ifndef BMIPARSER_H_INCLUDED
11 #define BMIPARSER_H_INCLUDED
12
13 #include <librevenge/librevenge.h>
14
15 #include "libzmf_utils.h"
16
17 #include "BMIHeader.h"
18 #include "ZMFTypes.h"
19
20 namespace libzmf
21 {
22
23 class BMIParser
24 {
25 // disable copying
26 BMIParser(const BMIParser &other) = delete;
27 BMIParser &operator=(const BMIParser &other) = delete;
28
29 struct ColorBitmapHeader;
30
31 public:
32 explicit BMIParser(const RVNGInputStreamPtr &input, librevenge::RVNGDrawingInterface *painter = 0);
33
36 bool parse();
37
40 Image readImage();
41
42 const BMIHeader &header() const;
43
44 private:
45 ColorBitmap readColorBitmap(const ColorBitmapHeader &header);
46
47 std::vector<uint8_t> readData(unsigned endOffset);
48
49 std::vector<Color> readColorPalette(unsigned colorDepth);
50
51 bool reconcileDimensions(ColorBitmapHeader &colorHeader, ColorBitmapHeader &transparencyHeader);
52
53 const RVNGInputStreamPtr m_input;
54 librevenge::RVNGDrawingInterface *m_painter;
55
56 BMIHeader m_header;
57 };
58
59 }
60
61 #endif // BMIPARSER_H_INCLUDED
62
63 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libzmf::ZMFCollector::endDocument
void endDocument()
Definition: ZMFCollector.cpp:339
libzmf::BMIParser::header
const BMIHeader & header() const
Definition: BMIParser.cpp:432
m_row
std::unique_ptr< png_byte[]> m_row
Definition: BMIParser.cpp:179
libzmf::BMIParser::BMIParser
BMIParser(const BMIParser &other)=delete
libzmf::BMIHeader::isSupported
bool isSupported() const
Definition: BMIHeader.cpp:67
ZMF_FALLTHROUGH
#define ZMF_FALLTHROUGH
Definition: libzmf_utils.h:40
libzmf::BMIParser::readColorPalette
std::vector< Color > readColorPalette(unsigned colorDepth)
Definition: BMIParser.cpp:539
libzmf::BMIHeader::reconcileWidth
bool reconcileWidth(unsigned &colorWidth, unsigned &transparencyWidth)
Definition: BMIHeader.cpp:177
libzmf::ColorBitmap
Definition: BMITypes.h:41
libzmf::skip
void skip(const RVNGInputStreamPtr &input, unsigned long numBytes)
Definition: libzmf_utils.cpp:175
libzmf::ZMFCollector::collectImage
void collectImage(const librevenge::RVNGBinaryData &image, const Point &topLeft, double width, double height, double rotation, bool mirrorHorizontal, bool mirrorVertical)
Definition: ZMFCollector.cpp:800
libzmf::ZMFCollector::startPage
void startPage(const ZMFPageSettings &pageSettings)
Definition: ZMFCollector.cpp:352
libzmf::BMIOffset::start
uint32_t start
Definition: BMITypes.h:30
libzmf::BMIParser::readImage
Image readImage()
Parse the bitmap and convert it to PNG.
Definition: BMIParser.cpp:379
libzmf::Image::width
uint32_t width
Definition: ZMFTypes.h:205
libzmf::BMIParser::m_header
BMIHeader m_header
Definition: BMIParser.h:56
ZMFTypes.h
libzmf::BMIHeader::offsets
const std::vector< BMIOffset > & offsets() const
Definition: BMIHeader.cpp:106
libzmf::BMIParser::readData
std::vector< uint8_t > readData(unsigned endOffset)
Definition: BMIParser.cpp:517
libzmf::BMIHeader::startOffset
unsigned startOffset() const
Definition: BMIHeader.cpp:76
libzmf::BMIParser
Definition: BMIParser.h:23
libzmf::ZMFCollector::startLayer
void startLayer()
Definition: ZMFCollector.cpp:385
libzmf::BMIParser::ColorBitmapHeader
Definition: BMIParser.cpp:307
libzmf::ZMFCollector::endPage
void endPage()
Definition: ZMFCollector.cpp:375
libzmf::readU16
uint16_t readU16(const RVNGInputStreamPtr &input, bool bigEndian)
Definition: libzmf_utils.cpp:101
m_info
PNGInfoPtr m_info
Definition: BMIParser.cpp:181
libzmf::ColorBitmap::width
uint32_t width
Definition: BMITypes.h:43
libzmf::RVNGInputStreamPtr
std::shared_ptr< librevenge::RVNGInputStream > RVNGInputStreamPtr
Definition: libzmf_utils.h:80
libzmf::ZMFCollector
Definition: ZMFCollector.h:21
libzmf::BMIParser::ColorBitmapHeader::m_colorDepth
unsigned m_colorDepth
Definition: BMIParser.cpp:315
libzmf::BMIParser::m_painter
librevenge::RVNGDrawingInterface * m_painter
Definition: BMIParser.h:54
libzmf::Point
Definition: ZMFTypes.h:24
m_bitmap
const ColorBitmap & m_bitmap
Definition: BMIParser.cpp:177
m_png
std::shared_ptr< png_struct > m_png
Definition: BMIParser.cpp:163
libzmf::Color::blue
uint8_t blue
Definition: ZMFTypes.h:101
libzmf::Image::data
librevenge::RVNGBinaryData data
Definition: ZMFTypes.h:207
libzmf::Color::red
uint8_t red
Definition: ZMFTypes.h:99
m_error
std::string m_error
Definition: BMIParser.cpp:182
libzmf::BMIParser::reconcileDimensions
bool reconcileDimensions(ColorBitmapHeader &colorHeader, ColorBitmapHeader &transparencyHeader)
Definition: BMIParser.cpp:555
libzmf::Color::green
uint8_t green
Definition: ZMFTypes.h:100
BMIParser.h
BMIHeader.h
libzmf
Definition: BMIHeader.cpp:13
libzmf::BMIParser::ColorBitmapHeader::m_height
unsigned m_height
Definition: BMIParser.cpp:314
libzmf::ZMFPageSettings
Definition: ZMFTypes.h:389
libzmf::readU8
uint8_t readU8(const RVNGInputStreamPtr &input, bool)
Definition: libzmf_utils.cpp:89
libzmf::BMIParser::ColorBitmapHeader::parse
void parse(const RVNGInputStreamPtr &input, const BMIHeader &header, const BMIOffset &offset)
Definition: BMIParser.cpp:329
libzmf::ZMFCollector::startDocument
void startDocument()
Definition: ZMFCollector.cpp:327
libzmf::BMIHeader::reconcileHeight
bool reconcileHeight(unsigned &colorHeight, unsigned &transparencyHeight)
Definition: BMIHeader.cpp:182
libzmf::readNBytes
const unsigned char * readNBytes(const RVNGInputStreamPtr &input, const unsigned long numBytes)
Definition: libzmf_utils.cpp:162
libzmf::BMIParser::ColorBitmapHeader::m_width
unsigned m_width
Definition: BMIParser.cpp:313
libzmf::ZMFCollector::endLayer
void endLayer()
Definition: ZMFCollector.cpp:397
libzmf::seek
void seek(const RVNGInputStreamPtr &input, const unsigned long pos)
Definition: libzmf_utils.cpp:182
libzmf::BMIParser::parse
bool parse()
Parse the bitmap and output it as a drawing doc with an inserted image.
Definition: BMIParser.cpp:357
libzmf_utils.h
libzmf::BMIHeader::width
unsigned width() const
Definition: BMIHeader.cpp:81
libzmf::Color
Definition: ZMFTypes.h:97
libzmf::Image::height
uint32_t height
Definition: ZMFTypes.h:206
libzmf::ColorBitmap::data
std::vector< Color > data
Definition: BMITypes.h:45
libzmf::BMIOffset
Definition: BMITypes.h:27
libzmf::BMIParser::operator=
BMIParser & operator=(const BMIParser &other)=delete
libzmf::BMIParser::ColorBitmapHeader::m_startOffset
unsigned m_startOffset
Definition: BMIParser.cpp:316
libzmf::BMIOffset::end
uint32_t end
Definition: BMITypes.h:31
libzmf::BMIStreamType::BITMAP
libzmf::Image
Definition: ZMFTypes.h:203
libzmf::BMIHeader
Definition: BMIHeader.h:20
libzmf::BMIParser::readColorBitmap
ColorBitmap readColorBitmap(const ColorBitmapHeader &header)
Definition: BMIParser.cpp:437
m_msg
const std::string m_msg
Definition: BMIParser.cpp:137
libzmf::BMIHeader::height
unsigned height() const
Definition: BMIHeader.cpp:86
ZMFCollector.h
libzmf::BMIHeader::load
bool load(const RVNGInputStreamPtr &input)
Definition: BMIHeader.cpp:28
libzmf::BMIParser::ColorBitmapHeader::m_endOffset
unsigned m_endOffset
Definition: BMIParser.cpp:317
ZMF_DEBUG_MSG
#define ZMF_DEBUG_MSG(M)
Definition: libzmf_utils.h:57
libzmf::BMIParser::m_input
const RVNGInputStreamPtr m_input
Definition: BMIParser.h:53
m_transparencyBitmap
const ColorBitmap & m_transparencyBitmap
Definition: BMIParser.cpp:178
libzmf::ColorBitmap::height
uint32_t height
Definition: BMITypes.h:44