gKit2 light
Loading...
Searching...
No Matches
image_io.h
Go to the documentation of this file.
1
2#ifndef _IMAGE_IO_H
3#define _IMAGE_IO_H
4
5#include "image.h"
6
7
10
13
16Image read_image( const char *filename, const bool flipY= true );
17Image read_image_hdr( const char *filename, const bool flipY= true );
18
20unsigned read_image_size( const char *filename );
21
23bool write_image( const Image& image, const char *filename, const bool flipY= true );
25bool write_image_png( const Image& image, const char *filename, const bool flipY= true );
27bool write_image_bmp( const Image& image, const char *filename, const bool flipY= true );
29bool write_image_hdr( const Image& image, const char *filename, const bool flipY= true );
30
32bool write_image_preview( const Image& image, const char *filename, const bool flipY= true );
33
35Image mipmap( const Image& image );
36
38Image srgb( const Image& image );
40Image linear( const Image& image );
41
43Image flipY( const Image& image );
45Image flipX( const Image& image );
46
48Image copy( const Image& image, const unsigned xmin, const unsigned ymin, const unsigned width, const unsigned height );
49
50
52struct ImageData
53{
54 ImageData( ) : pixels(), width(0), height(0), channels(0), size(0) {}
55 ImageData( const unsigned w, const unsigned h, const unsigned c, const unsigned s= 1 ) : pixels(w*h*c*s, 0), width(w), height(h), channels(c), size(s) {}
56
57 unsigned offset( const unsigned x, const unsigned y, const unsigned c= 0 ) const { return (y * width +x) * channels * size + c * size; }
58 const void *data( ) const { return pixels.data(); }
59 void *data( ) { return pixels.data(); }
60
61 std::vector<unsigned char> pixels;
62
63 unsigned width;
64 unsigned height;
65 unsigned channels;
66 unsigned size;
67};
68
69
71ImageData read_image_data( const char *filename, const bool flipY= true );
72
74int write_image_data( ImageData& image, const char *filename, const bool flipY= true );
75
77ImageData read_image_data( const void *buffer, const unsigned size, const bool flipY= true );
78
79
81ImageData flipY( const ImageData& image );
83ImageData flipX( const ImageData& image );
84
86ImageData copy( const ImageData& image, const unsigned xmin, const unsigned ymin, const unsigned width, const unsigned height );
87
89ImageData mipmap( const ImageData& image );
90
92int miplevels( const int width, const int height );
93
95
96#endif
representation d'une image.
Definition image.h:21
bool write_image_png(const Image &image, const char *filename, const bool flipY=true)
enregistre une image au format .png
Definition image_io.cpp:206
bool write_image_preview(const Image &image, const char *filename, const bool flipY=true)
raccourci pour write_image_png(tone(image, range(image)), "image.png")
Definition image_io.cpp:258
bool write_image_hdr(const Image &image, const char *filename, const bool flipY=true)
enregistre une image au format .hdr
Definition image_io.cpp:249
unsigned read_image_size(const char *filename)
renvoie la taille en octets de l'image chargee. ou 0 si erreur.
Definition image_io.cpp:162
bool write_image_bmp(const Image &image, const char *filename, const bool flipY=true)
enregistre une image au format .bmp
Definition image_io.cpp:230
Image mipmap(const Image &image)
reduit une image.
Definition image_io.cpp:94
ImageData read_image_data(const char *filename, const bool flipY=true)
charge les donnees d'un fichier png. renvoie une image initialisee par defaut en cas d'echec.
Definition image_io.cpp:330
Image flipY(const Image &image)
retourne l'image
Definition image_io.cpp:112
Image flipX(const Image &image)
retourne l'image
Definition image_io.cpp:129
Image read_image(const char *filename, const bool flipY=true)
Definition image_io.cpp:171
int write_image_data(ImageData &image, const char *filename, const bool flipY=true)
enregistre des donnees dans un fichier png.
Definition image_io.cpp:346
Image linear(const Image &image)
transformation couleur : srgb vers rgb lineaire
Definition image_io.cpp:25
bool write_image(const Image &image, const char *filename, const bool flipY=true)
enregistre une image au format .png
Definition image_io.cpp:225
Image copy(const Image &image, const unsigned xmin, const unsigned ymin, const unsigned width, const unsigned height)
renvoie un bloc de l'image
Definition image_io.cpp:145
int miplevels(const int width, const int height)
renvoie le nombre de mipmap d'une image width x height.
Definition image_io.cpp:453
Image srgb(const Image &image)
transformation couleur : rgb lineaire vers srgb
Definition image_io.cpp:15
stockage temporaire des donnees d'une image.
Definition image_io.h:53