CGVIS Utils
Loading...
Searching...
No Matches
bmp.h
Go to the documentation of this file.
1#pragma once
2
3#include <fstream>
4#include <iostream>
5#include <exception>
6#include <string>
7#include <sstream>
8
9#include "Vec2.h"
10#include "Image.h"
11
30namespace BMP {
34 class BMPException : public std::exception {
35 public:
40 BMPException(const std::string& whatStr) : whatStr(whatStr) {}
45 virtual const char* what() const throw() {
46 return whatStr.c_str();
47 }
48 private:
49 std::string whatStr;
50 };
51
61 bool save(const std::string& filename, const Image& source, bool ignoreSize=false);
62
77 bool save(const std::string& filename, uint32_t w, uint32_t h,
78 const std::vector<uint8_t>& data, uint8_t iComponentCount = 3,
79 bool ignoreSize=false);
80
94 bool save(const std::string& filename, uint32_t w, uint32_t h,
95 const std::vector<float>& data, uint8_t iComponentCount = 3,
96 bool ignoreSize=false);
97
106 Image load(const std::string& filename);
107
125 void blit(const Image& source, const Vec2ui& sourceStart, const Vec2ui& sourceEnd,
126 Image& target, const Vec2ui& targetStart, bool skipChecks=false);
127}
Lightweight image container with basic processing utilities.
2D vector template with arithmetic, length utilities, and helpers.
Vec2t< uint32_t > Vec2ui
32-bit unsigned integer vector (x,y).
Definition Vec2.h:262
BMPException(const std::string &whatStr)
Construct with an explanatory message.
Definition bmp.h:40
virtual const char * what() const
Retrieve the explanatory string.
Definition bmp.h:45
Definition Image.h:22
Definition bmp.cpp:12
bool save(const std::string &filename, const Image &source, bool ignoreSize)
Save an Image to a BMP file.
Definition bmp.cpp:13
Image load(const std::string &filename)
Load a BMP file into an Image.
Definition bmp.cpp:110
void blit(const Image &source, const Vec2ui &rawSourceStart, const Vec2ui &rawSourceEnd, Image &target, const Vec2ui &targetStart, bool skipChecks)
Copy a rectangular region from source to target (blit).
Definition bmp.cpp:202