/** * @class vetFrameRGB24 * * @brief This Class implements standard VETLib I/O Frame format. * An image consisting of red, green and blue pixels. * PixelRGB24 Array [width*height] (raster scan) * Currently PixelRGB24 is difined as 3 char (3 * 8 = 24bits) * * * @see PixelRGB24 * @see vetFrame * * @version 0.6 * @date 12/07/2005 - //2005 * @author Alessandro Polo * * **************************************************************************** * VETLib Framework 1.0.2 * Copyright (C) Alessandro Polo 2006 * http://www.ewgate.net/vetlib * ****************************************************************************/ #ifndef __VETLIBVETFRAMERGB24_H__ #define __VETLIBVETFRAMERGB24_H__ #define VETFRAMERGB24_SLOWMODE #include "vetDefs.h" #include "PixelRGB24.h" #include "vetFrame.h" class vetFrameRGB24; #include "vetFrameYUV420.h" #include "vetFrameRGB96.h" #include "vetFrameRGBA32.h" class vetFrameRGB24 : public virtual vetFrame { public: /** * @var This value is used only by destructor, if true array will be deleted. */ bool autoFreeData; /** * @var RGB data array pointer. Size is width * height. */ PixelRGB24 *data; public: /** * @var Enumerate available Channels. */ enum ChannelRGB { RED, GREEN, BLUE }; /** * @brief Default constructor, initialize height and width to 0. */ vetFrameRGB24(); /** * @brief Create an image with the given dimensions, allocates empty data. * @param width Width of the image. * @param height Height of the image. */ vetFrameRGB24(unsigned int width, unsigned int height); /** * @brief Copy Constructor, create an image from another image, copying memory. * @param img source image. */ vetFrameRGB24(vetFrameRGB24& img); /** * @brief Copy Constructor, create an image from another image, copying memory. * @param img source image. */ vetFrameRGB24(vetFrameRGB96& img); /** * @brief Copy Constructor, create an image from another image, copying memory. * @param img source image. */ vetFrameRGB24(vetFrameRGBA32& img); /** * @brief Destructor currenly clear pixel data (array). */ ~vetFrameRGB24(); void* dump_buffer() { return static_cast(data); }; unsigned int getBufferSize() { return (unsigned int)( width * height * 3); }; VETRESULT reAllocCanvas(unsigned int w, unsigned int h); unsigned int getBpp() { return sizeof(PixelRGB24) * 8; }; VETRESULT setBlack(); VETRESULT setWhite(); VETRESULT extractBrightness(unsigned char* buffer, unsigned int* size = NULL ); /** * @brief Clear all pixel to the specified value. * * @param bg a PixelRGB to overwrite on all image. * * @return current instance address. */ vetFrameRGB24& clearWith(PixelRGB24& bg); /** * @brief Set pixel (x, y) to the specified value. * * @param x x position of the pixel. * @param y y position of the pixel. * @param p new value for the selected coords. * * @note No check is made that x and y are in range. */ VETRESULT setPixel(unsigned int x, unsigned int y, PixelRGB24 p); /** * @brief Get pixel (x, y) value and store it to p. * * @param x x position of the pixel. * @param y y position of the pixel. * @param p address to store selected pixel's value. * * @note No check is made that x and y are in range. */ VETRESULT getPixel(unsigned int x, unsigned int y, PixelRGB24& p); /** * @brief Copies all pixel data from img. * Throws an exception if images are of different size. * * @param img The image to copy the data from. * * @return current instance. */ vetFrameRGB24& operator = (vetFrameRGB24& img); /** * @brief Overload equals-add (+=) operator for two images (pixel += loop) * Throws an exception if images are of different size. * * @param img The image to add to current data. * * @return current instance. */ vetFrameRGB24& operator += (vetFrameRGB24& img); /** * @brief Overload equals-sub (-=) operator for two images (pixel -= loop) * Throws an exception if images are of different size. * * @param img The image to add to current data. * * @return current instance. */ vetFrameRGB24& operator -= (vetFrameRGB24& img); void operator << (const vetFrameYUV420& img); void operator << (const vetFrameRGB96& img); void operator << (const vetFrameRGBA32& img); vetFrameRGB24& operator >> (vetFrameYUV420& img); vetFrameRGB24& operator >> (vetFrameRGB96& img); vetFrameRGB24& operator >> (vetFrameRGBA32& img); VETFRAME_PROFILE getProfile() { return vetFrame::VETFRAME_RGB24; }; VETFRAME_CHANNEL_TYPE getChannelType() { return vetFrame::VETFRAME_CT_PACKED; }; int getFOURCC() { return 0x32424752; }; // same as RGB32 }; #endif //__VETLIBVETFRAMERGB24_H__