22 #include <FreeImage.h>
76 inline const FIBITMAP*
Data()
const;
77 inline FIBITMAP*
Data();
80 inline int Width()
const;
92 inline bool IsRGB()
const;
93 inline bool IsGrey()
const;
132 bool Read(
const std::string&
path,
const bool as_rgb =
true);
137 const FREE_IMAGE_FORMAT
format = FIF_UNKNOWN,
138 const int flags = 0)
const;
141 void Smooth(
const float sigma_x,
const float sigma_y);
144 void Rescale(
const int new_width,
145 const int new_height,
146 const FREE_IMAGE_FILTER filter = FILTER_BILINEAR);
158 const std::string& tag_name,
159 std::string*
result)
const;
162 typedef std::unique_ptr<FIBITMAP, decltype(&FreeImage_Unload)> FIBitmapPtr;
164 void SetPtr(FIBITMAP*
data);
166 static bool IsPtrGrey(FIBITMAP*
data);
167 static bool IsPtrRGB(FIBITMAP*
data);
168 static bool IsPtrSupported(FIBITMAP*
data);
180 static float Red(
const float gray);
181 static float Green(
const float gray);
182 static float Blue(
const float gray);
185 static float Interpolate(
const float val,
190 static float Base(
const float val);
199 template <
typename T1,
typename T2>
201 return std::min(
static_cast<T1
>(std::numeric_limits<T2>::max()),
202 std::max(
static_cast<T1
>(std::numeric_limits<T2>::min()),
208 template <
typename T>
211 template <
typename T>
214 template <
typename T>
216 : r(r), g(g), b(b) {}
218 template <
typename T>
219 template <
typename D>
222 color.r = internal::BitmapColorCast<T, D>(r);
223 color.g = internal::BitmapColorCast<T, D>(g);
224 color.b = internal::BitmapColorCast<T, D>(b);
228 template <
typename T>
230 return r == rhs.
r && g == rhs.
g && b == rhs.
b;
233 template <
typename T>
235 return r != rhs.
r || g != rhs.
g || b != rhs.
b;
238 template <
typename T>
241 static_cast<double>(
color.g),
242 static_cast<double>(
color.b));
254 return FreeImage_GetBPP(data_.get());
258 return FreeImage_GetPitch(data_.get());
filament::Texture::InternalFormat format
bool SetPixel(const int x, const int y, const BitmapColor< uint8_t > &color)
std::vector< uint8_t > ConvertToRowMajorArray() const
bool GetPixel(const int x, const int y, BitmapColor< uint8_t > *color) const
bool ExifCameraModel(std::string *camera_model) const
void Fill(const BitmapColor< uint8_t > &color)
bool Read(const std::string &path, const bool as_rgb=true)
std::vector< uint8_t > ConvertToRawBits() const
const uint8_t * GetScanline(const int y) const
bool Allocate(const int width, const int height, const bool as_rgb)
void Rescale(const int new_width, const int new_height, const FREE_IMAGE_FILTER filter=FILTER_BILINEAR)
void Smooth(const float sigma_x, const float sigma_y)
bool InterpolateBilinear(const double x, const double y, BitmapColor< float > *color) const
void CloneMetadata(Bitmap *target) const
unsigned int ScanWidth() const
std::vector< uint8_t > ConvertToColMajorArray() const
bool InterpolateNearestNeighbor(const double x, const double y, BitmapColor< uint8_t > *color) const
bool ExifAltitude(double *altitude) const
const FIBITMAP * Data() const
bool ExifFocalLength(double *focal_length) const
bool ReadExifTag(const FREE_IMAGE_MDMODEL model, const std::string &tag_name, std::string *result) const
bool ExifLongitude(double *longitude) const
bool ExifLatitude(double *latitude) const
Bitmap CloneAsGrey() const
Bitmap & operator=(const Bitmap &other)
Bitmap CloneAsRGB() const
unsigned int BitsPerPixel() const
bool Write(const std::string &path, const FREE_IMAGE_FORMAT format=FIF_UNKNOWN, const int flags=0) const
static float Red(const float gray)
static float Blue(const float gray)
static float Green(const float gray)
static const std::string path
T2 BitmapColorCast(const T1 value)
std::ostream & operator<<(std::ostream &output, const BitmapColor< T > &color)
std::string StringPrintf(const char *format,...)
friend std::ostream & operator<<(std::ostream &output, const BitmapColor< D > &color)
BitmapColor< D > Cast() const
bool operator!=(const BitmapColor< T > &rhs) const
bool operator==(const BitmapColor< T > &rhs) const