32 #ifndef Image_INCUDE_ONCE 33 #define Image_INCUDE_ONCE 66 Image(
void* buffer_ptr,
int buffer_bytes);
98 int byteAlignment()
const;
100 void setByteAlignment(
int bytealign);
106 int requiredMemory()
const;
108 static int requiredMemory(
int x,
int y,
int z,
int bytealign,
EImageFormat format,
EImageType type,
bool is_cubemap);
112 static int requiredMemory2D(
int x,
int y,
int bytealign,
EImageFormat format,
EImageType type) {
return requiredMemory(x, y, 0, bytealign, format, type,
false); }
114 static int requiredMemory3D(
int x,
int y,
int z,
int bytealign,
EImageFormat format,
EImageType type) {
return requiredMemory(x, y, z, bytealign, format, type,
false); }
116 static int requiredMemoryCubemap(
int x,
int y,
int bytealign,
EImageFormat format,
EImageType type) {
return requiredMemory(x, y, 0, bytealign, format, type,
true); }
122 String printFormat()
const;
124 void setWidth(
int x) { mWidth = x; updatePitch(); }
141 int alphaBits()
const;
170 const unsigned char*
pixels()
const {
if (mPixels->bytesUsed())
return mPixels->ptr();
else return NULL; }
173 unsigned char*
pixels() {
if (mPixels->bytesUsed())
return mPixels->ptr();
else return NULL; }
179 unsigned char* pixelsZSlice(
int zth_slice);
182 unsigned char* pixelsXP();
184 unsigned char* pixelsXN();
186 unsigned char* pixelsYP();
188 unsigned char* pixelsYN();
190 unsigned char* pixelsZP();
192 unsigned char* pixelsZN();
194 const unsigned char* pixelsXP()
const;
195 const unsigned char* pixelsXN()
const;
196 const unsigned char* pixelsYP()
const;
197 const unsigned char* pixelsYN()
const;
198 const unsigned char* pixelsZP()
const;
199 const unsigned char* pixelsZN()
const;
203 const std::vector< ref<Image> >&
mipmaps()
const {
return mMipmaps; };
205 std::vector< ref<Image> >&
mipmaps() {
return mMipmaps; };
207 int width()
const {
return mWidth; }
211 int depth()
const {
return mDepth; }
213 int pitch()
const {
return mPitch; }
221 void flipVertically();
280 bool contrast(
float black,
float white);
283 bool contrastHounsfieldAuto();
286 bool contrastHounsfield(
float center,
float width,
float intercept,
float range);
289 fvec4 sampleLinear(
double x)
const;
292 fvec4 sampleLinear(
double x,
double y)
const;
295 fvec4 sampleLinear(
double x,
double y,
double z)
const;
325 fvec4 sample(
int x,
int y=0,
int z=0)
const;
334 ref<Image> subImage(
int xstart,
int ystart,
int width,
int height);
354 void substituteColorRGB_RGBA(
unsigned int before,
unsigned int after);
366 void substituteColorRGB_RGB(
unsigned int before,
unsigned int after);
368 void substituteColorGreenKey(
unsigned int col0,
unsigned int col1);
static int requiredMemoryCubemap(int x, int y, int bytealign, EImageFormat format, EImageType type)
const Buffer * imageBuffer() const
The buffer used to store the image pixels.
void setImageBuffer(Buffer *buffer)
The buffer used to store the image pixels.
static int requiredMemory1D(int x, EImageFormat format, EImageType type)
An abstract class representing a file.
KeyValues * tags()
A set of key/value couples that can be used to attach extra information to an image like DICOM inform...
The RectI class represents a 2D rectangular area using int precision.
const unsigned char * pixels() const
Raw pointer to pixels.
The String class implements an advanced UTF16 (Unicode BMP) string manipulation engine.
VLCORE_EXPORT ref< Image > loadRAW(VirtualFile *file, long long file_offset, int width, int height, int depth, int bytealign, EImageFormat format, EImageType type)
Loads a raw image file.
const String & filePath() const
The file from which the image was loaded.
VLCORE_EXPORT ref< Image > loadCubemap(const String &xp_file, const String &xn_file, const String &yp_file, const String &yn_file, const String &zp_file, const String &zn_file)
Loads six images and assembles them into a cubemap image.
std::vector< ref< Image > > & mipmaps()
std::vector< ref< Image > > mMipmaps
Implements a buffer whose storage is in local memory.
VLCORE_EXPORT bool loadImagesFromDir(const String &dir_path, const String &ext, std::vector< ref< Image > > &images)
Loads all the images with the specified extension from the given directory.
void setType(EImageType type)
VLCORE_EXPORT ref< Image > makeColorSpectrum(size_t width, const std::vector< fvec4 > &colors)
Creates a 1D Image whose color is interpolated from left to right from the specified spectrum...
VLCORE_EXPORT ref< Image > loadImage(VirtualFile *file)
Loads an image from the specified file.
#define VL_INSTRUMENT_CLASS(ClassName, BaseClass)
bool hasAlpha() const
Whether an image contains relevant alpha information.
VLCORE_EXPORT ref< Image > assemble3DImage(const std::vector< ref< Image > > &images)
Assembles the given 2D images in a single 2D image, all the images must be 2D images and have the sam...
void setFilePath(const String &path)
The file from which the image was loaded.
Visualization Library main namespace.
ref< Image > createCubemap(const Image *xp, const Image *xn, const Image *yp, const Image *yn, const Image *zp, const Image *zn)
Assembles a cubemap image.
bool isNormalMap() const
Whether an image represents a normal map.
void setMipmaps(const std::vector< ref< Image > > &mipmaps)
bool empty()
True if image is empty.
const KeyValues * tags() const
A set of key/value couples that can be used to attach extra information to an image like DICOM inform...
VLCORE_EXPORT bool saveImage(Image *img, VirtualFile *file)
Writes an image on the specified file.
The base class for all the reference counted objects.
Buffer * imageBuffer()
The buffer used to store the image pixels.
VLCORE_EXPORT ref< Image > makeNonUniformColorSpectrum(size_t width, size_t col_count, const fvec4 *colors, const float *col_pos)
Creates a 1D Image whose color is interpolated from left to right from the specified spectrum...
const std::vector< ref< Image > > & mipmaps() const
void setFormat(EImageFormat format)
static int requiredMemory3D(int x, int y, int z, int bytealign, EImageFormat format, EImageType type)
void setTags(KeyValues *tags)
A set of key/value couples that can be used to attach extra information to an image like DICOM inform...
Implements a generic 1d, 2d, 3d and cubemap image that can have mipmaps.
The ref<> class is used to reference-count an Object.
void setHasAlpha(bool has_alpha)
Whether an image contains relevant alpha information.
unsigned char * pixels()
Raw pointer to pixels.
Visualization Library's enums in the 'vl' namespace.
static int requiredMemory2D(int x, int y, int bytealign, EImageFormat format, EImageType type)
A set of key/value pairs usually used to associate generic information, tags, attributes etc...
void setIsNormalMap(bool is_normalmap)
Whether an image represents a normal map.
EImageFormat format() const