Doxygen
Loading...
Searching...
No Matches
Image Class Reference

Class representing a bitmap image generated by doxygen. More...

#include <src/image.h>

Classes

struct  Private
 

Public Member Functions

 Image (uint32_t w, uint32_t h)
 
 ~Image ()
 
void setPixel (uint32_t x, uint32_t y, uint8_t val)
 
uint8_t getPixel (uint32_t x, uint32_t y) const
 
void writeChar (uint32_t x, uint32_t y, char c, uint8_t fg)
 
void writeString (uint32_t x, uint32_t y, const QCString &s, uint8_t fg)
 
void drawHorzLine (uint32_t y, uint32_t xs, uint32_t xe, uint8_t colIndex, uint32_t mask)
 
void drawHorzArrow (uint32_t y, uint32_t xs, uint32_t xe, uint8_t colIndex, uint32_t mask)
 
void drawVertLine (uint32_t x, uint32_t ys, uint32_t ye, uint8_t colIndex, uint32_t mask)
 
void drawVertArrow (uint32_t x, uint32_t ys, uint32_t ye, uint8_t colIndex, uint32_t mask)
 
void drawRect (uint32_t x, uint32_t y, uint32_t width, uint32_t height, uint8_t colIndex, uint32_t mask)
 
void fillRect (uint32_t x, uint32_t y, uint32_t width, uint32_t height, uint8_t colIndex, uint32_t mask)
 
bool save (const QCString &fileName)
 
uint32_t width () const
 
uint32_t height () const
 

Static Public Member Functions

static uint32_t stringLength (const QCString &s)
 

Private Attributes

std::unique_ptr< Privatep
 

Friends

uint32_t stringLength (const QCString &s)
 

Detailed Description

Class representing a bitmap image generated by doxygen.

Definition at line 26 of file image.h.

Constructor & Destructor Documentation

◆ Image()

Image::Image ( uint32_t w,
uint32_t h )

Definition at line 174 of file image.cpp.

174 : p(std::make_unique<Private>())
175{
176 int hue = Config_getInt(HTML_COLORSTYLE_HUE);
177 int sat = Config_getInt(HTML_COLORSTYLE_SAT);
178 int gamma = Config_getInt(HTML_COLORSTYLE_GAMMA);
179
180 double red1=0.0 ,green1=0.0 ,blue1=0.0;
181 double red2=0.0, green2=0.0, blue2=0.0;
182
183 ColoredImage::hsl2rgb(hue/360.0, // hue
184 sat/255.0, // saturation
185 pow(235/255.0,gamma/100.0), // luma (gamma corrected)
186 &red1,&green1,&blue1
187 );
188
189 ColoredImage::hsl2rgb(hue/360.0, // hue
190 sat/255.0, // saturation
191 pow(138/255.0,gamma/100.0), // luma (gamma corrected)
192 &red2,&green2,&blue2
193 );
194
195 p->palette[2].red = static_cast<Byte>(red1 * 255.0);
196 p->palette[2].green = static_cast<Byte>(green1 * 255.0);
197 p->palette[2].blue = static_cast<Byte>(blue1 * 255.0);
198
199 p->palette[3].red = static_cast<Byte>(red2 * 255.0);
200 p->palette[3].green = static_cast<Byte>(green2 * 255.0);
201 p->palette[3].blue = static_cast<Byte>(blue2 * 255.0);
202
203 p->data.resize(w*h);
204 p->width = w;
205 p->height = h;
206}
static void hsl2rgb(double h, double s, double l, double *pRed, double *pGreen, double *pBlue)
Definition image.cpp:368
std::unique_ptr< Private > p
Definition image.h:51
#define Config_getInt(name)
Definition config.h:34
unsigned char Byte
Definition image.cpp:23

References Config_getInt, ColoredImage::hsl2rgb(), and p.

Referenced by ~Image().

◆ ~Image()

Image::~Image ( )
default

References height(), Image(), and width().

Member Function Documentation

◆ drawHorzArrow()

void Image::drawHorzArrow ( uint32_t y,
uint32_t xs,
uint32_t xe,
uint8_t colIndex,
uint32_t mask )

Definition at line 299 of file image.cpp.

300{
301 drawHorzLine(y,xs,xe,colIndex,mask);
302 for (uint32_t i=0;i<6;i++)
303 {
304 uint32_t h=i>>1;
305 drawVertLine(xe-i,y-h,y+h,colIndex,0xffffffff);
306 }
307}
void drawVertLine(uint32_t x, uint32_t ys, uint32_t ye, uint8_t colIndex, uint32_t mask)
Definition image.cpp:309
void drawHorzLine(uint32_t y, uint32_t xs, uint32_t xe, uint8_t colIndex, uint32_t mask)
Definition image.cpp:289

References drawHorzLine(), and drawVertLine().

Referenced by TreeDiagram::drawConnectors().

◆ drawHorzLine()

void Image::drawHorzLine ( uint32_t y,
uint32_t xs,
uint32_t xe,
uint8_t colIndex,
uint32_t mask )

Definition at line 289 of file image.cpp.

290{
291 uint32_t i=0,j=0;
292 for (uint32_t x=xs;x<=xe;x++,j++)
293 {
294 if (j&1) i++;
295 if (mask&(1<<(i&0x1f))) setPixel(x,y,colIndex);
296 }
297}
void setPixel(uint32_t x, uint32_t y, uint8_t val)
Definition image.cpp:213

References setPixel().

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

◆ drawRect()

void Image::drawRect ( uint32_t x,
uint32_t y,
uint32_t width,
uint32_t height,
uint8_t colIndex,
uint32_t mask )

Definition at line 328 of file image.cpp.

329{
330 drawHorzLine(y,x,x+w-1,colIndex,mask);
331 drawHorzLine(y+h-1,x,x+w-1,colIndex,mask);
332 drawVertLine(x,y,y+h-1,colIndex,mask);
333 drawVertLine(x+w-1,y,y+h-1,colIndex,mask);
334}

References drawHorzLine(), and drawVertLine().

Referenced by writeBitmapBox().

◆ drawVertArrow()

void Image::drawVertArrow ( uint32_t x,
uint32_t ys,
uint32_t ye,
uint8_t colIndex,
uint32_t mask )

Definition at line 318 of file image.cpp.

319{
320 drawVertLine(x,ys,ye,colIndex,mask);
321 for (uint32_t i=0;i<6;i++)
322 {
323 uint32_t h=i>>1;
324 drawHorzLine(ys+i,x-h,x+h,colIndex,0xffffffff);
325 }
326}

References drawHorzLine(), and drawVertLine().

Referenced by TreeDiagram::drawConnectors().

◆ drawVertLine()

void Image::drawVertLine ( uint32_t x,
uint32_t ys,
uint32_t ye,
uint8_t colIndex,
uint32_t mask )

Definition at line 309 of file image.cpp.

310{
311 uint32_t i=0;
312 for (uint32_t y=ys;y<=ye;y++,i++)
313 {
314 if (mask&(1<<(i&0x1f))) setPixel(x,y,colIndex);
315 }
316}

References setPixel().

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

◆ fillRect()

void Image::fillRect ( uint32_t x,
uint32_t y,
uint32_t width,
uint32_t height,
uint8_t colIndex,
uint32_t mask )

Definition at line 336 of file image.cpp.

337{
338 for (uint32_t yp=y,yi=0;yp<y+height;yp++,yi++)
339 for (uint32_t xp=x,xi=0;xp<x+width;xp++,xi++)
340 if (mask&(1<<((xi+yi)&0x1f)))
341 setPixel(xp,yp,colIndex);
342 else
343 setPixel(xp,yp,8);
344}
uint32_t width() const
Definition image.cpp:208
uint32_t height() const
Definition image.cpp:209

References height(), setPixel(), and width().

Referenced by writeBitmapBox().

◆ getPixel()

uint8_t Image::getPixel ( uint32_t x,
uint32_t y ) const

Definition at line 218 of file image.cpp.

219{
220 return (x<p->width && y<p->height) ? p->data[y*p->width+x] : 0;
221}

References height(), p, and width().

Referenced by writeChar().

◆ height()

uint32_t Image::height ( ) const

Definition at line 209 of file image.cpp.

209{ return p->height; }

References p.

Referenced by TreeDiagram::drawBoxes(), TreeDiagram::drawConnectors(), fillRect(), getPixel(), setPixel(), and ~Image().

◆ save()

bool Image::save ( const QCString & fileName)

Definition at line 346 of file image.cpp.

347{
348 uint8_t* buffer = nullptr;
349 size_t bufferSize = 0;
350 LodePNG_Encoder encoder;
351 LodePNG_Encoder_init(&encoder);
352 for (const auto &col : p->palette)
353 {
354 LodePNG_InfoColor_addPalette(&encoder.infoPng.color,
355 col.red,col.green,col.blue,col.alpha);
356 }
357 encoder.infoPng.color.colorType = 3;
358 encoder.infoRaw.color.colorType = 3;
359 LodePNG_encode(&encoder, &buffer, &bufferSize, &p->data[0], p->width, p->height);
360 LodePNG_saveFile(buffer, bufferSize, fileName.data());
361 free(buffer);
362 LodePNG_Encoder_cleanup(&encoder);
363 return TRUE;
364}
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition qcstring.h:159
#define TRUE
Definition qcstring.h:37

References QCString::data(), p, and TRUE.

◆ setPixel()

void Image::setPixel ( uint32_t x,
uint32_t y,
uint8_t val )

Definition at line 213 of file image.cpp.

214{
215 if (x<p->width && y<p->height) p->data[y*p->width+x] = val;
216}

References height(), p, and width().

Referenced by drawHorzLine(), drawVertLine(), fillRect(), and writeChar().

◆ stringLength()

static uint32_t Image::stringLength ( const QCString & s)
static

◆ width()

uint32_t Image::width ( ) const

Definition at line 208 of file image.cpp.

208{ return p->width; }

References p.

Referenced by fillRect(), getPixel(), setPixel(), and ~Image().

◆ writeChar()

void Image::writeChar ( uint32_t x,
uint32_t y,
char c,
uint8_t fg )

Definition at line 223 of file image.cpp.

224{
225 if (c>=' ')
226 {
227 uint32_t ci=c-' ';
228 uint32_t rowOffset=0;
229 uint32_t cw = charWidth[ci];
230 uint32_t cp = charPos[ci];
231 for (uint32_t yf=0;yf<charHeight;yf++)
232 {
233 unsigned short bitPattern=0;
234 uint32_t bitsLeft=cw;
235 uint32_t byteOffset = rowOffset+(cp>>3);
236 uint32_t bitOffset = cp&7;
237 // get the bit pattern for row yf of the character from the font data
238 while (bitsLeft>0)
239 {
240 uint32_t bits=8-bitOffset;
241 if (bits>bitsLeft) bits=bitsLeft;
242 bitPattern<<=bits;
243 bitPattern|=((fontRaw[byteOffset]<<bitOffset)&0xff)>>(8-bits);
244 bitsLeft-=bits;
245 bitOffset=0;
246 byteOffset++;
247 }
248 if (cw>0 && cw<32)
249 {
250 uint32_t mask=(uint32_t)1<<(cw-1);
251 // draw character row yf
252 for (uint32_t xf=0;xf<cw;xf++)
253 {
254 setPixel(x+xf,y+yf,(bitPattern&mask) ? fg : getPixel(x+xf,y+yf));
255 mask>>=1;
256 }
257 rowOffset+=charSetWidth;
258 }
259 }
260 }
261}
uint8_t getPixel(uint32_t x, uint32_t y) const
Definition image.cpp:218
const unsigned short charPos[numChars]
Definition image.cpp:38
const unsigned char charWidth[numChars]
Definition image.cpp:54
const unsigned char fontRaw[charSetWidth *charHeight]
Definition image.cpp:71
const int charHeight
Definition image.cpp:35
const int charSetWidth
Definition image.cpp:34

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

Referenced by writeString().

◆ writeString()

void Image::writeString ( uint32_t x,
uint32_t y,
const QCString & s,
uint8_t fg )

Definition at line 263 of file image.cpp.

264{
265 if (!s.isEmpty())
266 {
267 const char *ps = s.data();
268 char c = 0;
269 while ((c=*ps++))
270 {
271 writeChar(x,y,c,fg);
272 x+=charWidth[c-' '];
273 }
274 }
275}
void writeChar(uint32_t x, uint32_t y, char c, uint8_t fg)
Definition image.cpp:223
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:150

References charWidth, QCString::data(), QCString::isEmpty(), and writeChar().

Referenced by writeBitmapBox().

Friends And Related Symbol Documentation

◆ stringLength

uint32_t Image::stringLength ( const QCString & s)
friend

Definition at line 277 of file image.cpp.

278{
279 uint32_t w=0;
280 if (!s.isEmpty())
281 {
282 const char *ps = s.data();
283 char c = 0;
284 while ((c=*ps++)) w+=charWidth[c-' '];
285 }
286 return w;
287}

References charWidth, QCString::data(), and QCString::isEmpty().

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

Member Data Documentation

◆ p

std::unique_ptr<Private> Image::p
private

Definition at line 51 of file image.h.

Referenced by getPixel(), height(), Image(), save(), setPixel(), and width().


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