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
 
uchargetData () const
 

Static Public Member Functions

static uint stringLength (const char *s)
 

Private Attributes

int width
 
int height
 
uchardata
 

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.

211 {
212  static int hue = Config_getInt("HTML_COLORSTYLE_HUE");
213  static int sat = Config_getInt("HTML_COLORSTYLE_SAT");
214  static int gamma = Config_getInt("HTML_COLORSTYLE_GAMMA");
215 
216  double red1,green1,blue1;
217  double red2,green2,blue2;
218 
219  ColoredImage::hsl2rgb(hue/360.0, // hue
220  sat/255.0, // saturation
221  pow(235/255.0,gamma/100.0), // luma (gamma corrected)
222  &red1,&green1,&blue1
223  );
224 
225  ColoredImage::hsl2rgb(hue/360.0, // hue
226  sat/255.0, // saturation
227  pow(138/255.0,gamma/100.0), // luma (gamma corrected)
228  &red2,&green2,&blue2
229  );
230 
231  palette[2].red = (int)(red1 * 255.0);
232  palette[2].green = (int)(green1 * 255.0);
233  palette[2].blue = (int)(blue1 * 255.0);
234 
235  palette[3].red = (int)(red2 * 255.0);
236  palette[3].green = (int)(green2 * 255.0);
237  palette[3].blue = (int)(blue2 * 255.0);
238 
239  data = new uchar[w*h];
240  memset(data,0,w*h);
241  width = w;
242  height = h;
243 }
int height
Definition: image.h:49
Byte blue
Definition: image.cpp:32
constexpr T pow(T x)
Definition: pow.h:72
Byte red
Definition: image.cpp:30
static void hsl2rgb(double h, double s, double l, double *pRed, double *pGreen, double *pBlue)
Definition: image.cpp:428
int width
Definition: image.h:48
Byte green
Definition: image.cpp:31
unsigned char uchar
Definition: nybbler.cc:11
#define Config_getInt(val)
Definition: config.cpp:661
uchar * data
Definition: image.h:50
double gamma(double KE, const simb::MCParticle *part)
static Color palette[]
Definition: image.cpp:156
Image::~Image ( )

Definition at line 245 of file image.cpp.

246 {
247  delete[] data;
248 }
uchar * data
Definition: image.h:50

Member Function Documentation

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

Definition at line 335 of file image.cpp.

336 {
337  drawHorzLine(y,xs,xe,colIndex,mask);
338  int i;
339  for (i=0;i<6;i++)
340  {
341  int h=i>>1;
342  drawVertLine(xe-i,y-h,y+h,colIndex,0xffffffff);
343  }
344 }
void drawHorzLine(int y, int xs, int xe, uchar colIndex, uint mask)
Definition: image.cpp:325
void drawVertLine(int x, int ys, int ye, uchar colIndex, uint mask)
Definition: image.cpp:346
void Image::drawHorzLine ( int  y,
int  xs,
int  xe,
uchar  colIndex,
uint  mask 
)

Definition at line 325 of file image.cpp.

326 {
327  int x,i=0,j=0;
328  for (x=xs;x<=xe;x++,j++)
329  {
330  if (j&1) i++;
331  if (mask&(1<<(i&0x1f))) setPixel(x,y,colIndex);
332  }
333 }
void setPixel(int x, int y, uchar val)
Definition: image.cpp:250
list x
Definition: train.py:276
void Image::drawRect ( int  x,
int  y,
int  width,
int  height,
uchar  colIndex,
uint  mask 
)

Definition at line 366 of file image.cpp.

367 {
368  drawHorzLine(y,x,x+w-1,colIndex,mask);
369  drawHorzLine(y+h-1,x,x+w-1,colIndex,mask);
370  drawVertLine(x,y,y+h-1,colIndex,mask);
371  drawVertLine(x+w-1,y,y+h-1,colIndex,mask);
372 }
void drawHorzLine(int y, int xs, int xe, uchar colIndex, uint mask)
Definition: image.cpp:325
void drawVertLine(int x, int ys, int ye, uchar colIndex, uint mask)
Definition: image.cpp:346
list x
Definition: train.py:276
void Image::drawVertArrow ( int  x,
int  ys,
int  ye,
uchar  colIndex,
uint  mask 
)

Definition at line 355 of file image.cpp.

356 {
357  drawVertLine(x,ys,ye,colIndex,mask);
358  int i;
359  for (i=0;i<6;i++)
360  {
361  int h=i>>1;
362  drawHorzLine(ys+i,x-h,x+h,colIndex,0xffffffff);
363  }
364 }
void drawHorzLine(int y, int xs, int xe, uchar colIndex, uint mask)
Definition: image.cpp:325
void drawVertLine(int x, int ys, int ye, uchar colIndex, uint mask)
Definition: image.cpp:346
list x
Definition: train.py:276
static constexpr double ys
Definition: Units.h:103
void Image::drawVertLine ( int  x,
int  ys,
int  ye,
uchar  colIndex,
uint  mask 
)

Definition at line 346 of file image.cpp.

347 {
348  int y,i=0;
349  for (y=ys;y<=ye;y++,i++)
350  {
351  if (mask&(1<<(i&0x1f))) setPixel(x,y,colIndex);
352  }
353 }
void setPixel(int x, int y, uchar val)
Definition: image.cpp:250
list x
Definition: train.py:276
static constexpr double ys
Definition: Units.h:103
void Image::fillRect ( int  x,
int  y,
int  width,
int  height,
uchar  colIndex,
uint  mask 
)

Definition at line 374 of file image.cpp.

375 {
376  int xp,yp,xi,yi;
377  for (yp=y,yi=0;yp<y+lheight;yp++,yi++)
378  for (xp=x,xi=0;xp<x+lwidth;xp++,xi++)
379  if (mask&(1<<((xi+yi)&0x1f)))
380  setPixel(xp,yp,colIndex);
381 }
void setPixel(int x, int y, uchar val)
Definition: image.cpp:250
list x
Definition: train.py:276
uchar* Image::getData ( ) const
inline

Definition at line 44 of file image.h.

44 { return data; }
uchar * data
Definition: image.h:50
uint Image::getHeight ( ) const
inline

Definition at line 43 of file image.h.

43 { return height; }
int height
Definition: image.h:49
uchar Image::getPixel ( int  x,
int  y 
) const

Definition at line 256 of file image.cpp.

257 {
258  if (x>=0 && x<width && y>=0 && y<height)
259  return data[y*width+x];
260  else
261  return 0;
262 }
int height
Definition: image.h:49
int width
Definition: image.h:48
uchar * data
Definition: image.h:50
list x
Definition: train.py:276
uint Image::getWidth ( ) const
inline

Definition at line 42 of file image.h.

42 { return width; }
int width
Definition: image.h:48
bool Image::save ( const char *  fileName,
int  mode = 0 
)

Definition at line 383 of file image.cpp.

384 {
385 #if 0
386  GifEncoder gifenc(data,
387  mode==0 ? palette : palette2,
388  width,height,
389  mode==0 ? 3 : 4,
390  0);
392  if (file.open(IO_WriteOnly))
393  {
394  gifenc.writeGIF(file);
395  return TRUE;
396  }
397  else
398  {
399  return FALSE;
400  }
401 #endif
402  static bool useTransparency = Config_getBool("FORMULA_TRANSPARENT");
403  uchar* buffer;
404  size_t bufferSize;
406  LodePNG_Encoder_init(&encoder);
407  int numCols = mode==0 ? 8 : 16;
408  Color *pPal = mode==0 ? palette :
409  useTransparency ? palette2 :
410  palette3 ;
411  int i;
412  for (i=0;i<numCols;i++,pPal++)
413  {
415  pPal->red,pPal->green,pPal->blue,pPal->alpha);
416  }
417  encoder.infoPng.color.colorType = 3;
418  encoder.infoRaw.color.colorType = 3;
419  LodePNG_encode(&encoder, &buffer, &bufferSize, data, width, height);
420  LodePNG_saveFile(buffer, bufferSize, fileName);
421  free(buffer);
422  LodePNG_Encoder_cleanup(&encoder);
423  return TRUE;
424 }
unsigned colorType
Definition: lodepng.h:127
int height
Definition: image.h:49
LodePNG_InfoRaw infoRaw
Definition: lodepng.h:342
#define IO_WriteOnly
Definition: qiodevice.h:62
LodePNG_InfoColor color
Definition: lodepng.h:225
Byte blue
Definition: image.cpp:32
Byte red
Definition: image.cpp:30
const bool FALSE
Definition: qglobal.h:370
void LodePNG_Encoder_init(LodePNG_Encoder *encoder)
Definition: lodepng.cpp:4076
int width
Definition: image.h:48
Byte green
Definition: image.cpp:31
Definition: image.cpp:28
void LodePNG_encode(LodePNG_Encoder *encoder, unsigned char **out, size_t *outsize, const unsigned char *image, unsigned w, unsigned h)
Definition: lodepng.cpp:3910
unsigned char uchar
Definition: nybbler.cc:11
unsigned LodePNG_InfoColor_addPalette(LodePNG_InfoColor *info, unsigned char r, unsigned char g, unsigned char b, unsigned char a)
Definition: lodepng.cpp:2046
fileName
Definition: dumpTree.py:9
void LodePNG_Encoder_cleanup(LodePNG_Encoder *encoder)
Definition: lodepng.cpp:4084
LodePNG_InfoColor color
Definition: lodepng.h:266
static Color palette3[]
Definition: image.cpp:189
static Color palette2[]
Definition: image.cpp:169
uchar * data
Definition: image.h:50
#define Config_getBool(val)
Definition: config.cpp:664
unsigned LodePNG_saveFile(const unsigned char *buffer, size_t buffersize, const char *filename)
Definition: lodepng.cpp:4141
The QFile class is an I/O device that operates on files.
Definition: qfile.h:50
LodePNG_InfoPng infoPng
Definition: lodepng.h:341
Byte alpha
Definition: image.cpp:33
static Color palette[]
Definition: image.cpp:156
static QFile::EncoderFn encoder
Definition: qfile.cpp:470
const bool TRUE
Definition: qglobal.h:371
void Image::setPixel ( int  x,
int  y,
uchar  val 
)

Definition at line 250 of file image.cpp.

251 {
252  if (x>=0 && x<width && y>=0 && y<height)
253  data[y*width+x] = val;
254 }
int height
Definition: image.h:49
int width
Definition: image.h:48
uchar * data
Definition: image.h:50
list x
Definition: train.py:276
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.

265 {
266  if (c>=' ')
267  {
268  int xf,yf,ci=c-' ';
269  int rowOffset=0;
270  int cw = charWidth[ci];
271  int cp = charPos[ci];
272  for (yf=0;yf<charHeight;yf++)
273  {
274  unsigned short bitPattern=0;
275  int bitsLeft=cw;
276  int byteOffset = rowOffset+(cp>>3);
277  int bitOffset = cp&7;
278  // get the bit pattern for row yf of the character from the font data
279  while (bitsLeft>0)
280  {
281  int bits=8-bitOffset;
282  if (bits>bitsLeft) bits=bitsLeft;
283  bitPattern<<=bits;
284  bitPattern|=((fontRaw[byteOffset]<<bitOffset)&0xff)>>(8-bits);
285  bitsLeft-=bits;
286  bitOffset=0;
287  byteOffset++;
288  }
289  int mask=1<<(cw-1);
290  // draw character row yf
291  for (xf=0;xf<cw;xf++)
292  {
293  setPixel(x+xf,y+yf,(bitPattern&mask) ? fg : getPixel(x+xf,y+yf));
294  mask>>=1;
295  }
296  rowOffset+=charSetWidth;
297  }
298  }
299 }
unsigned char fontRaw[charSetWidth *charHeight]
Definition: image.cpp:73
unsigned short charPos[numChars]
Definition: image.cpp:40
void setPixel(int x, int y, uchar val)
Definition: image.cpp:250
unsigned char charWidth[numChars]
Definition: image.cpp:56
const int charHeight
Definition: image.cpp:37
const int charSetWidth
Definition: image.cpp:36
list x
Definition: train.py:276
uchar getPixel(int x, int y) const
Definition: image.cpp:256
void Image::writeString ( int  x,
int  y,
const char *  s,
uchar  fg 
)

Definition at line 301 of file image.cpp.

302 {
303  if (s)
304  {
305  char c;
306  while ((c=*s++))
307  {
308  writeChar(x,y,c,fg);
309  x+=charWidth[c-' '];
310  }
311  }
312 }
void writeChar(int x, int y, char c, uchar fg)
Definition: image.cpp:264
unsigned char charWidth[numChars]
Definition: image.cpp:56
list x
Definition: train.py:276
static QCString * s
Definition: config.cpp:1042

Friends And Related Function Documentation

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

Definition at line 314 of file image.cpp.

315 {
316  int w=0;
317  if (s)
318  {
319  char c;
320  while ((c=*s++)) w+=charWidth[c-' '];
321  }
322  return w;
323 }
unsigned char charWidth[numChars]
Definition: image.cpp:56
static QCString * s
Definition: config.cpp:1042

Member Data Documentation

uchar* Image::data
private

Definition at line 50 of file image.h.

int Image::height
private

Definition at line 49 of file image.h.

int Image::width
private

Definition at line 48 of file image.h.


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