39#include "vpImageIoBackend.h"
41#if defined __SSE2__ || defined _M_X64 || (defined _M_IX86_FP && _M_IX86_FP >= 2)
42#define VISP_HAVE_SSE2 1
49#define STB_IMAGE_IMPLEMENTATION
52#define STB_IMAGE_WRITE_IMPLEMENTATION
53#include <stb_image_write.h>
57 int width = 0, height = 0, channels = 0;
58 unsigned char *image = stbi_load(filename.c_str(), &width, &height, &channels, STBI_grey);
62 I.init(image,
static_cast<unsigned int>(height),
static_cast<unsigned int>(width),
true);
63 stbi_image_free(image);
68 int width = 0, height = 0, channels = 0;
69 unsigned char *image = stbi_load(filename.c_str(), &width, &height, &channels, STBI_rgb_alpha);
73 I.init(
reinterpret_cast<vpRGBa *
>(image),
static_cast<unsigned int>(height),
static_cast<unsigned int>(width),
true);
74 stbi_image_free(image);
79 int res = stbi_write_jpg(filename.c_str(),
static_cast<int>(I.getWidth()),
static_cast<int>(I.getHeight()), STBI_grey,
80 reinterpret_cast<void *
>(I.bitmap), quality);
86void writeJPEGStb(
const vpImage<vpRGBa> &I,
const std::string &filename,
int quality)
88 int res = stbi_write_jpg(filename.c_str(),
static_cast<int>(I.getWidth()),
static_cast<int>(I.getHeight()),
89 STBI_rgb_alpha,
reinterpret_cast<void *
>(I.bitmap), quality);
97 const int stride_in_bytes =
static_cast<int>(I.getWidth());
98 int res = stbi_write_png(filename.c_str(),
static_cast<int>(I.getWidth()),
static_cast<int>(I.getHeight()), STBI_grey,
99 reinterpret_cast<void *
>(I.bitmap), stride_in_bytes);
107 const int stride_in_bytes =
static_cast<int>(4 * I.getWidth());
108 int res = stbi_write_png(filename.c_str(),
static_cast<int>(I.getWidth()),
static_cast<int>(I.getHeight()),
109 STBI_rgb_alpha,
reinterpret_cast<void *
>(I.bitmap), stride_in_bytes);
Error that can be emitted by the vpImage class and its derivatives.
Definition of the vpImage class member functions.