My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Private Attributes | Friends | List of all members
Image Class Reference

#include <image.h>

Public Member Functions

 Image (int w, int h)
 
 ~Image ()
 
void setPixel (int x, int y, uchar val)
 
uchar getPixel (int x, int y) const
 
void writeChar (int x, int y, char c, uchar fg)
 
void writeString (int x, int y, const char *s, uchar fg)
 
void drawHorzLine (int y, int xs, int xe, uchar colIndex, uint mask)
 
void drawHorzArrow (int y, int xs, int xe, uchar colIndex, uint mask)
 
void drawVertLine (int x, int ys, int ye, uchar colIndex, uint mask)
 
void drawVertArrow (int x, int ys, int ye, uchar colIndex, uint mask)
 
void drawRect (int x, int y, int width, int height, uchar colIndex, uint mask)
 
void fillRect (int x, int y, int width, int height, uchar colIndex, uint mask)
 
bool save (const char *fileName, int mode=0)
 
uint getWidth () const
 
uint getHeight () const
 
uchar * getData () const
 

Static Public Member Functions

static uint stringLength (const char *s)
 

Private Attributes

int width
 
int height
 
uchar * data
 

Friends

uint stringLength (const char *s)
 

Detailed Description

Class representing a bitmap image generated by doxygen.

Definition at line 24 of file image.h.

Constructor & Destructor Documentation

Image::Image ( int  w,
int  h 
)

Definition at line 210 of file image.cpp.

References Color::blue, Config_getInt, data, Color::green, height, ColoredImage::hsl2rgb(), Color::red, and width.

{
static int hue = Config_getInt(HTML_COLORSTYLE_HUE);
static int sat = Config_getInt(HTML_COLORSTYLE_SAT);
static int gamma = Config_getInt(HTML_COLORSTYLE_GAMMA);
double red1,green1,blue1;
double red2,green2,blue2;
ColoredImage::hsl2rgb(hue/360.0, // hue
sat/255.0, // saturation
pow(235/255.0,gamma/100.0), // luma (gamma corrected)
&red1,&green1,&blue1
);
ColoredImage::hsl2rgb(hue/360.0, // hue
sat/255.0, // saturation
pow(138/255.0,gamma/100.0), // luma (gamma corrected)
&red2,&green2,&blue2
);
palette[2].red = (int)(red1 * 255.0);
palette[2].green = (int)(green1 * 255.0);
palette[2].blue = (int)(blue1 * 255.0);
palette[3].red = (int)(red2 * 255.0);
palette[3].green = (int)(green2 * 255.0);
palette[3].blue = (int)(blue2 * 255.0);
data = new uchar[w*h];
memset(data,0,w*h);
width = w;
height = h;
}
Image::~Image ( )

Definition at line 245 of file image.cpp.

References data.

{
delete[] data;
}

Member Function Documentation

void Image::drawHorzArrow ( int  y,
int  xs,
int  xe,
uchar  colIndex,
uint  mask 
)

Definition at line 335 of file image.cpp.

References drawHorzLine(), and drawVertLine().

Referenced by TreeDiagram::drawConnectors().

{
drawHorzLine(y,xs,xe,colIndex,mask);
int i;
for (i=0;i<6;i++)
{
int h=i>>1;
drawVertLine(xe-i,y-h,y+h,colIndex,0xffffffff);
}
}
void Image::drawHorzLine ( int  y,
int  xs,
int  xe,
uchar  colIndex,
uint  mask 
)

Definition at line 325 of file image.cpp.

References setPixel().

Referenced by TreeDiagram::drawConnectors(), drawHorzArrow(), drawRect(), drawVertArrow(), and writeBitmapBox().

{
int x,i=0,j=0;
for (x=xs;x<=xe;x++,j++)
{
if (j&1) i++;
if (mask&(1<<(i&0x1f))) setPixel(x,y,colIndex);
}
}
void Image::drawRect ( int  x,
int  y,
int  width,
int  height,
uchar  colIndex,
uint  mask 
)

Definition at line 366 of file image.cpp.

References drawHorzLine(), and drawVertLine().

Referenced by writeBitmapBox().

{
drawHorzLine(y,x,x+w-1,colIndex,mask);
drawHorzLine(y+h-1,x,x+w-1,colIndex,mask);
drawVertLine(x,y,y+h-1,colIndex,mask);
drawVertLine(x+w-1,y,y+h-1,colIndex,mask);
}
void Image::drawVertArrow ( int  x,
int  ys,
int  ye,
uchar  colIndex,
uint  mask 
)

Definition at line 355 of file image.cpp.

References drawHorzLine(), and drawVertLine().

Referenced by TreeDiagram::drawConnectors().

{
drawVertLine(x,ys,ye,colIndex,mask);
int i;
for (i=0;i<6;i++)
{
int h=i>>1;
drawHorzLine(ys+i,x-h,x+h,colIndex,0xffffffff);
}
}
void Image::drawVertLine ( int  x,
int  ys,
int  ye,
uchar  colIndex,
uint  mask 
)

Definition at line 346 of file image.cpp.

References setPixel().

Referenced by TreeDiagram::drawConnectors(), drawHorzArrow(), drawRect(), and drawVertArrow().

{
int y,i=0;
for (y=ys;y<=ye;y++,i++)
{
if (mask&(1<<(i&0x1f))) setPixel(x,y,colIndex);
}
}
void Image::fillRect ( int  x,
int  y,
int  width,
int  height,
uchar  colIndex,
uint  mask 
)

Definition at line 374 of file image.cpp.

References setPixel().

Referenced by writeBitmapBox().

{
int xp,yp,xi,yi;
for (yp=y,yi=0;yp<y+lheight;yp++,yi++)
for (xp=x,xi=0;xp<x+lwidth;xp++,xi++)
if (mask&(1<<((xi+yi)&0x1f)))
setPixel(xp,yp,colIndex);
}
uchar* Image::getData ( ) const
inline

Definition at line 44 of file image.h.

References data.

{ return data; }
uint Image::getHeight ( ) const
inline

Definition at line 43 of file image.h.

References height.

Referenced by TreeDiagram::drawBoxes(), TreeDiagram::drawConnectors(), and FormulaList::generateBitmaps().

{ return height; }
uchar Image::getPixel ( int  x,
int  y 
) const

Definition at line 256 of file image.cpp.

References data, height, and width.

Referenced by writeChar().

{
if (x>=0 && x<width && y>=0 && y<height)
return data[y*width+x];
else
return 0;
}
uint Image::getWidth ( ) const
inline

Definition at line 42 of file image.h.

References width.

Referenced by FormulaList::generateBitmaps().

{ return width; }
bool Image::save ( const char *  fileName,
int  mode = 0 
)

Definition at line 383 of file image.cpp.

References Color::alpha, Color::blue, LodePNG_InfoPng::color, LodePNG_InfoRaw::color, LodePNG_InfoColor::colorType, Config_getBool, data, Color::green, height, LodePNG_Encoder::infoPng, LodePNG_Encoder::infoRaw, LodePNG_encode(), LodePNG_Encoder_cleanup(), LodePNG_Encoder_init(), LodePNG_InfoColor_addPalette(), LodePNG_saveFile(), palette3, Color::red, and width.

Referenced by FormulaList::generateBitmaps().

{
#if 0
GifEncoder gifenc(data,
mode==0 ? palette : palette2,
mode==0 ? 3 : 4,
0);
QFile file(fileName);
if (file.open(IO_WriteOnly))
{
gifenc.writeGIF(file);
return TRUE;
}
else
{
return FALSE;
}
#endif
static bool useTransparency = Config_getBool(FORMULA_TRANSPARENT);
uchar* buffer;
size_t bufferSize;
LodePNG_Encoder encoder;
int numCols = mode==0 ? 8 : 16;
Color *pPal = mode==0 ? palette :
useTransparency ? palette2 :
int i;
for (i=0;i<numCols;i++,pPal++)
{
pPal->red,pPal->green,pPal->blue,pPal->alpha);
}
encoder.infoPng.color.colorType = 3;
encoder.infoRaw.color.colorType = 3;
LodePNG_encode(&encoder, &buffer, &bufferSize, data, width, height);
LodePNG_saveFile(buffer, bufferSize, fileName);
free(buffer);
return TRUE;
}
void Image::setPixel ( int  x,
int  y,
uchar  val 
)

Definition at line 250 of file image.cpp.

References data, height, and width.

Referenced by drawHorzLine(), drawVertLine(), fillRect(), FormulaList::generateBitmaps(), and writeChar().

{
if (x>=0 && x<width && y>=0 && y<height)
data[y*width+x] = val;
}
static uint Image::stringLength ( const char *  s)
static
void Image::writeChar ( int  x,
int  y,
char  c,
uchar  fg 
)

Definition at line 264 of file image.cpp.

References charHeight, charPos, charSetWidth, charWidth, fontRaw, getPixel(), and setPixel().

Referenced by writeString().

{
if (c>=' ')
{
int xf,yf,ci=c-' ';
int rowOffset=0;
int cw = charWidth[ci];
int cp = charPos[ci];
for (yf=0;yf<charHeight;yf++)
{
unsigned short bitPattern=0;
int bitsLeft=cw;
int byteOffset = rowOffset+(cp>>3);
int bitOffset = cp&7;
// get the bit pattern for row yf of the character from the font data
while (bitsLeft>0)
{
int bits=8-bitOffset;
if (bits>bitsLeft) bits=bitsLeft;
bitPattern<<=bits;
bitPattern|=((fontRaw[byteOffset]<<bitOffset)&0xff)>>(8-bits);
bitsLeft-=bits;
bitOffset=0;
byteOffset++;
}
int mask=1<<(cw-1);
// draw character row yf
for (xf=0;xf<cw;xf++)
{
setPixel(x+xf,y+yf,(bitPattern&mask) ? fg : getPixel(x+xf,y+yf));
mask>>=1;
}
rowOffset+=charSetWidth;
}
}
}
void Image::writeString ( int  x,
int  y,
const char *  s,
uchar  fg 
)

Definition at line 301 of file image.cpp.

References charWidth, and writeChar().

Referenced by writeBitmapBox().

{
if (s)
{
char c;
while ((c=*s++))
{
writeChar(x,y,c,fg);
x+=charWidth[c-' '];
}
}
}

Friends And Related Function Documentation

uint Image::stringLength ( const char *  s)
friend

Definition at line 314 of file image.cpp.

Referenced by TreeDiagram::computeExtremes(), and writeBitmapBox().

{
int w=0;
if (s)
{
char c;
while ((c=*s++)) w+=charWidth[c-' '];
}
return w;
}

Member Data Documentation

uchar* Image::data
private

Definition at line 50 of file image.h.

Referenced by getData(), getPixel(), Image(), save(), setPixel(), and ~Image().

int Image::height
private

Definition at line 49 of file image.h.

Referenced by getHeight(), getPixel(), Image(), save(), and setPixel().

int Image::width
private

Definition at line 48 of file image.h.

Referenced by getPixel(), getWidth(), Image(), save(), and setPixel().


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