Dillo v3.1.1-111-gd4f56d0d
Loading...
Searching...
No Matches
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)
 Creates an image buffer with same parameters (type, gamma etc.) except size.
 
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
 Copies another image buffer into this image buffer.
 
- 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.
 
virtual bool equals (Object *other)
 Returns, whether two objects are equal.
 
virtual int hashValue ()
 Return a hash value for the object.
 
virtual Objectclone ()
 Return an exact copy of the object.
 
virtual void intoStringBuffer (misc::StringBuffer *sb)
 Store a textual representation of the object in a misc::StringBuffer.
 
const char * toString ()
 Use object::Object::intoStringBuffer to return a textual representation of the object.
 
virtual size_t sizeOf ()
 Return the number of bytes, this object totally uses.
 
- 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)
 General method to scale an image buffer.
 

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.
 

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
}
 

Detailed Description

Definition at line 11 of file fltkimgbuf.hh.

Constructor & Destructor Documentation

◆ FltkImgbuf() [1/2]

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

Definition at line 87 of file fltkimgbuf.cc.

References _MSG, DBG_OBJ_CREATE, gamma, height, init(), root, type, and width.

◆ ~FltkImgbuf()

dw::fltk::FltkImgbuf::~FltkImgbuf ( )
protected

Definition at line 170 of file fltkimgbuf.cc.

References _MSG, copiedRows, DBG_OBJ_DELETE, detachScaledBuf(), isRoot(), rawdata, root, and scaledBuffers.

◆ FltkImgbuf() [2/2]

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

Definition at line 79 of file fltkimgbuf.cc.

References _MSG, DBG_OBJ_CREATE, gamma, height, init(), type, and width.

Member Function Documentation

◆ backscaledY()

int dw::fltk::FltkImgbuf::backscaledY ( int  yScaled)
private

Definition at line 575 of file fltkimgbuf.cc.

References height, and root.

Referenced by scaleRowBeautiful().

◆ copyRow()

void dw::fltk::FltkImgbuf::copyRow ( int  row,
const core::byte data 
)
virtual

◆ copyTo()

void dw::fltk::FltkImgbuf::copyTo ( Imgbuf dest,
int  xDestRoot,
int  yDestRoot,
int  xSrc,
int  ySrc,
int  widthSrc,
int  heightSrc 
)

Definition at line 488 of file fltkimgbuf.cc.

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

◆ createSimilarBuf()

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.

Definition at line 483 of file fltkimgbuf.cc.

References gamma, height, type, and width.

◆ detachScaledBuf()

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

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

Definition at line 190 of file fltkimgbuf.cc.

References _MSG, deleteOnUnref, refCount, and scaledBuffers.

Referenced by ~FltkImgbuf().

◆ draw()

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

Definition at line 586 of file fltkimgbuf.cc.

References _MSG, bpp, height, rawdata, and width.

◆ excessiveImageDimensions()

bool dw::fltk::FltkImgbuf::excessiveImageDimensions ( int  width,
int  height 
)
staticprivate

Definition at line 66 of file fltkimgbuf.cc.

References height, IMAGE_MAX_AREA, and width.

Referenced by getScaledBuf(), and init().

◆ findGammaCorrectionTable()

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

◆ freeall()

void dw::fltk::FltkImgbuf::freeall ( )
static

Definition at line 72 of file fltkimgbuf.cc.

References _MSG, and gammaCorrectionTables.

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

◆ getRootHeight()

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

Implements dw::core::Imgbuf.

Definition at line 478 of file fltkimgbuf.cc.

References height, and root.

◆ getRootWidth()

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

Implements dw::core::Imgbuf.

Definition at line 473 of file fltkimgbuf.cc.

References root, and width.

◆ getRowArea()

void dw::fltk::FltkImgbuf::getRowArea ( int  row,
dw::core::Rectangle area 
)
virtual

◆ getScaledBuf()

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

◆ init()

◆ isReferred()

bool dw::fltk::FltkImgbuf::isReferred ( )
virtual
Todo:
Comment

Implements dw::core::Imgbuf.

Definition at line 561 of file fltkimgbuf.cc.

References refCount, and scaledBuffers.

◆ isRoot()

int dw::fltk::FltkImgbuf::isRoot ( )
inlineprivate

Definition at line 50 of file fltkimgbuf.hh.

References root.

Referenced by copyRow(), getRowArea(), getScaledBuf(), init(), newScan(), setDeleteOnUnref(), unref(), and ~FltkImgbuf().

◆ lastReference()

bool dw::fltk::FltkImgbuf::lastReference ( )
virtual
Todo:
Comment

Implements dw::core::Imgbuf.

Definition at line 549 of file fltkimgbuf.cc.

References refCount, and scaledBuffers.

◆ newScan()

◆ ref()

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

Implements dw::core::Imgbuf.

Definition at line 514 of file fltkimgbuf.cc.

References refCount.

Referenced by getScaledBuf().

◆ scaleBuffer()

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.

Definition at line 315 of file fltkimgbuf.cc.

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

Referenced by scaleRowBeautiful().

◆ scaledY()

int dw::fltk::FltkImgbuf::scaledY ( int  ySrc)
private

Definition at line 568 of file fltkimgbuf.cc.

References height, and root.

Referenced by getRowArea(), scaleRowBeautiful(), and scaleRowSimple().

◆ scaleRow()

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

Definition at line 208 of file fltkimgbuf.cc.

References height, dw::fltk::scaleMode, scaleRowBeautiful(), scaleRowSimple(), and dw::fltk::SIMPLE.

Referenced by copyRow(), and init().

◆ scaleRowBeautiful()

void dw::fltk::FltkImgbuf::scaleRowBeautiful ( int  row,
const core::byte data 
)
inline

◆ scaleRowSimple()

void dw::fltk::FltkImgbuf::scaleRowSimple ( int  row,
const core::byte data 
)
inline

◆ setCMap()

void dw::fltk::FltkImgbuf::setCMap ( int *  colors,
int  num_colors 
)
virtual

Implements dw::core::Imgbuf.

Definition at line 204 of file fltkimgbuf.cc.

◆ setDeleteOnUnref()

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

Implements dw::core::Imgbuf.

Definition at line 555 of file fltkimgbuf.cc.

References deleteOnUnref, and isRoot().

◆ unref()

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

Implements dw::core::Imgbuf.

Definition at line 525 of file fltkimgbuf.cc.

References _MSG, deleteOnUnref, isRoot(), refCount, and scaledBuffers.

Member Data Documentation

◆ bpp

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

Definition at line 31 of file fltkimgbuf.hh.

Referenced by copyRow(), copyTo(), draw(), init(), scaleBuffer(), scaleRowBeautiful(), and scaleRowSimple().

◆ copiedRows

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

Definition at line 37 of file fltkimgbuf.hh.

Referenced by copyRow(), init(), newScan(), scaleRowBeautiful(), scaleRowSimple(), and ~FltkImgbuf().

◆ deleteOnUnref

bool dw::fltk::FltkImgbuf::deleteOnUnref
private

Definition at line 23 of file fltkimgbuf.hh.

Referenced by detachScaledBuf(), init(), setDeleteOnUnref(), and unref().

◆ gamma

double dw::fltk::FltkImgbuf::gamma
private

◆ gammaCorrectionTables

Vector< FltkImgbuf::GammaCorrectionTable > * dw::fltk::FltkImgbuf::gammaCorrectionTables = new Vector <FltkImgbuf::GammaCorrectionTable> (true, 2)
staticprivate

Definition at line 40 of file fltkimgbuf.hh.

Referenced by findGammaCorrectionTable(), and freeall().

◆ height

◆ rawdata

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

Definition at line 32 of file fltkimgbuf.hh.

Referenced by copyRow(), copyTo(), draw(), init(), scaleRowBeautiful(), scaleRowSimple(), and ~FltkImgbuf().

◆ refCount

int dw::fltk::FltkImgbuf::refCount
private

Definition at line 22 of file fltkimgbuf.hh.

Referenced by detachScaledBuf(), init(), isReferred(), lastReference(), ref(), and unref().

◆ root

◆ scaledBuffers

lout::container::typed::List<FltkImgbuf>* dw::fltk::FltkImgbuf::scaledBuffers
private

◆ type

Type dw::fltk::FltkImgbuf::type
private

Definition at line 27 of file fltkimgbuf.hh.

Referenced by createSimilarBuf(), FltkImgbuf(), FltkImgbuf(), getScaledBuf(), and init().

◆ width


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