Dillo
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
dw::fltk::FltkImgbuf Class Reference

#include <fltkimgbuf.hh>

Classes

class  GammaCorrectionTable
 

Public Member Functions

 FltkImgbuf (Type type, int width, int height, double gamma)
 
void setCMap (int *colors, int num_colors)
 
void scaleRow (int row, const core::byte *data)
 
void scaleRowSimple (int row, const core::byte *data)
 
void scaleRowBeautiful (int row, const core::byte *data)
 
void newScan ()
 
void copyRow (int row, const core::byte *data)
 
core::ImgbufgetScaledBuf (int width, int height)
 
void getRowArea (int row, dw::core::Rectangle *area)
 
int getRootWidth ()
 
int getRootHeight ()
 
core::ImgbufcreateSimilarBuf (int width, int height)
 
void copyTo (Imgbuf *dest, int xDestRoot, int yDestRoot, int xSrc, int ySrc, int widthSrc, int heightSrc)
 
void ref ()
 
void unref ()
 
bool lastReference ()
 
void setDeleteOnUnref (bool deleteOnUnref)
 
bool isReferred ()
 
void draw (Fl_Widget *target, int xRoot, int yRoot, int x, int y, int width, int height)
 
- Public Member Functions inherited from dw::core::Imgbuf
 Imgbuf ()
 
 ~Imgbuf ()
 
virtual void copyTo (Imgbuf *dest, int xDestRoot, int yDestRoot, int xSrc, int ySrc, int widthSrc, int heightSrc)=0
 
- Public Member Functions inherited from lout::object::Object
virtual ~Object ()
 The destructor is defined as virtual (but not abstract), so that destruction of Object's works properly. More...
 
virtual bool equals (Object *other)
 Returns, whether two objects are equal. More...
 
virtual int hashValue ()
 Return a hash value for the object. More...
 
virtual Objectclone ()
 Return an exact copy of the object. More...
 
virtual void intoStringBuffer (misc::StringBuffer *sb)
 Store a textual representation of the object in a misc::StringBuffer. More...
 
const char * toString ()
 Use object::Object::intoStringBuffer to return a textual representation of the object. More...
 
virtual size_t sizeOf ()
 Return the number of bytes, this object totally uses. More...
 
- Public Member Functions inherited from lout::signal::ObservedObject
virtual ~ObservedObject ()
 
void connectDeletion (DeletionReceiver *receiver)
 

Static Public Member Functions

static void freeall ()
 
static void scaleBuffer (const core::byte *src, int srcWidth, int srcHeight, core::byte *dest, int destWidth, int destHeight, int bpp, double gamma)
 

Protected Member Functions

 ~FltkImgbuf ()
 

Private Member Functions

 FltkImgbuf (Type type, int width, int height, double gamma, FltkImgbuf *root)
 
void init (Type type, int width, int height, double gamma, FltkImgbuf *root)
 
int scaledY (int ySrc)
 
int backscaledY (int yScaled)
 
int isRoot ()
 
void detachScaledBuf (FltkImgbuf *scaledBuf)
 This method is called for the root buffer, when a scaled buffer removed. More...
 

Static Private Member Functions

static uchar * findGammaCorrectionTable (double gamma)
 
static bool excessiveImageDimensions (int width, int height)
 

Private Attributes

FltkImgbufroot
 
int refCount
 
bool deleteOnUnref
 
lout::container::typed::List
< FltkImgbuf > * 
scaledBuffers
 
int width
 
int height
 
Type type
 
double gamma
 
int bpp
 
uchar * rawdata
 
lout::misc::BitSetcopiedRows
 

Static Private Attributes

static
lout::container::typed::Vector
< GammaCorrectionTable > * 
gammaCorrectionTables = new Vector <FltkImgbuf::GammaCorrectionTable> (true, 2)
 

Additional Inherited Members

- Public Types inherited from dw::core::Imgbuf
enum  Type {
  RGB, RGBA, GRAY, INDEXED,
  INDEXED_ALPHA
}
 

Constructor & Destructor Documentation

dw::fltk::FltkImgbuf::FltkImgbuf ( Type  type,
int  width,
int  height,
double  gamma,
FltkImgbuf root 
)
private
dw::fltk::FltkImgbuf::~FltkImgbuf ( )
protected

References DBG_OBJ_DELETE.

dw::fltk::FltkImgbuf::FltkImgbuf ( Type  type,
int  width,
int  height,
double  gamma 
)

Member Function Documentation

int dw::fltk::FltkImgbuf::backscaledY ( int  yScaled)
private
void dw::fltk::FltkImgbuf::copyRow ( int  row,
const core::byte data 
)
virtual
void dw::fltk::FltkImgbuf::copyTo ( Imgbuf dest,
int  xDestRoot,
int  yDestRoot,
int  xSrc,
int  ySrc,
int  widthSrc,
int  heightSrc 
)

References bpp, height, lout::misc::min(), rawdata, and width.

core::Imgbuf * dw::fltk::FltkImgbuf::createSimilarBuf ( int  width,
int  height 
)
virtual

Creates an image buffer with same parameters (type, gamma etc.) except size.

Implements dw::core::Imgbuf.

void dw::fltk::FltkImgbuf::detachScaledBuf ( FltkImgbuf scaledBuf)
private

This method is called for the root buffer, when a scaled buffer removed.

void dw::fltk::FltkImgbuf::draw ( Fl_Widget *  target,
int  xRoot,
int  yRoot,
int  x,
int  y,
int  width,
int  height 
)
bool dw::fltk::FltkImgbuf::excessiveImageDimensions ( int  width,
int  height 
)
staticprivate

References IMAGE_MAX_AREA.

uchar * dw::fltk::FltkImgbuf::findGammaCorrectionTable ( double  gamma)
staticprivate
void dw::fltk::FltkImgbuf::freeall ( )
static

Referenced by dw::fltk::freeall().

int dw::fltk::FltkImgbuf::getRootHeight ( )
virtual

Implements dw::core::Imgbuf.

int dw::fltk::FltkImgbuf::getRootWidth ( )
virtual

Implements dw::core::Imgbuf.

void dw::fltk::FltkImgbuf::getRowArea ( int  row,
dw::core::Rectangle area 
)
virtual
core::Imgbuf * dw::fltk::FltkImgbuf::getScaledBuf ( int  width,
int  height 
)
virtual
void dw::fltk::FltkImgbuf::init ( Type  type,
int  width,
int  height,
double  gamma,
FltkImgbuf root 
)
private
bool dw::fltk::FltkImgbuf::isReferred ( )
virtual
Todo:
Comment

Implements dw::core::Imgbuf.

int dw::fltk::FltkImgbuf::isRoot ( )
inlineprivate
bool dw::fltk::FltkImgbuf::lastReference ( )
virtual
Todo:
Comment

Implements dw::core::Imgbuf.

void dw::fltk::FltkImgbuf::newScan ( )
virtual
void dw::fltk::FltkImgbuf::ref ( )
virtual

Implements dw::core::Imgbuf.

Referenced by getScaledBuf().

void dw::fltk::FltkImgbuf::scaleBuffer ( const core::byte src,
int  srcWidth,
int  srcHeight,
core::byte dest,
int  destWidth,
int  destHeight,
int  bpp,
double  gamma 
)
inlinestatic

General method to scale an image buffer. Used to scale single lines in scaleRowBeautiful.

The algorithm is rather simple. If the scaled buffer is smaller (both width and height) than the original buffer, each pixel in the scaled buffer is assigned a rectangle of pixels in the original buffer; the resulting pixel value (red, green, blue) is simply the average of all pixel values. This is pretty fast and leads to rather good results.

Nothing special (like interpolation) is done when scaling up.

If scaleMode is set to BEAUTIFUL_GAMMA, gamma correction is considered, see http://www.4p8.com/eric.brasseur/gamma.html.

TODO Could be optimized as in scaleRowSimple: when the destination image is larger, calculate only one row/column, and copy it to the other rows/columns.

References dw::fltk::BEAUTIFUL_GAMMA, lout::misc::max(), and dw::fltk::scaleMode.

int dw::fltk::FltkImgbuf::scaledY ( int  ySrc)
private
void dw::fltk::FltkImgbuf::scaleRow ( int  row,
const core::byte data 
)
inline

References dw::fltk::scaleMode, and dw::fltk::SIMPLE.

Referenced by copyRow().

void dw::fltk::FltkImgbuf::scaleRowBeautiful ( int  row,
const core::byte data 
)
inline
void dw::fltk::FltkImgbuf::scaleRowSimple ( int  row,
const core::byte data 
)
inline
void dw::fltk::FltkImgbuf::setCMap ( int *  colors,
int  num_colors 
)
virtual

Implements dw::core::Imgbuf.

void dw::fltk::FltkImgbuf::setDeleteOnUnref ( bool  deleteOnUnref)
virtual
Todo:
Comment

Implements dw::core::Imgbuf.

void dw::fltk::FltkImgbuf::unref ( )
virtual

Implements dw::core::Imgbuf.

Member Data Documentation

int dw::fltk::FltkImgbuf::bpp
private

Referenced by copyTo(), and init().

lout::misc::BitSet* dw::fltk::FltkImgbuf::copiedRows
private

Referenced by init(), and newScan().

bool dw::fltk::FltkImgbuf::deleteOnUnref
private
double dw::fltk::FltkImgbuf::gamma
private
Vector< FltkImgbuf::GammaCorrectionTable > * dw::fltk::FltkImgbuf::gammaCorrectionTables = new Vector <FltkImgbuf::GammaCorrectionTable> (true, 2)
staticprivate
int dw::fltk::FltkImgbuf::height
private

Referenced by copyTo(), getScaledBuf(), and init().

uchar* dw::fltk::FltkImgbuf::rawdata
private

Referenced by copyTo(), and init().

int dw::fltk::FltkImgbuf::refCount
private
FltkImgbuf* dw::fltk::FltkImgbuf::root
private
lout::container::typed::List<FltkImgbuf>* dw::fltk::FltkImgbuf::scaledBuffers
private
Type dw::fltk::FltkImgbuf::type
private
int dw::fltk::FltkImgbuf::width
private

Referenced by copyTo(), getScaledBuf(), and init().


The documentation for this class was generated from the following files: