Skip to main content

The Image Class Reference

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

Declaration

class Image { ... }

Included Headers

#include <src/image.h>

Friends Index

uint32_tstringLength

Public Constructors Index

Image (uint32_t w, uint32_t h)

Public Destructor Index

~Image ()

Public Member Functions Index

voidsetPixel (uint32_t x, uint32_t y, uint8_t val)
uint8_tgetPixel (uint32_t x, uint32_t y) const
voidwriteChar (uint32_t x, uint32_t y, char c, uint8_t fg)
voidwriteString (uint32_t x, uint32_t y, const QCString &s, uint8_t fg)
voiddrawHorzLine (uint32_t y, uint32_t xs, uint32_t xe, uint8_t colIndex, uint32_t mask)
voiddrawHorzArrow (uint32_t y, uint32_t xs, uint32_t xe, uint8_t colIndex, uint32_t mask)
voiddrawVertLine (uint32_t x, uint32_t ys, uint32_t ye, uint8_t colIndex, uint32_t mask)
voiddrawVertArrow (uint32_t x, uint32_t ys, uint32_t ye, uint8_t colIndex, uint32_t mask)
voiddrawRect (uint32_t x, uint32_t y, uint32_t width, uint32_t height, uint8_t colIndex, uint32_t mask)
voidfillRect (uint32_t x, uint32_t y, uint32_t width, uint32_t height, uint8_t colIndex, uint32_t mask)
boolsave (const QCString &fileName)
uint32_twidth () const
uint32_theight () const

Private Member Attributes Index

std::unique_ptr< Private >p

Public Static Functions Index

static uint32_tstringLength (const QCString &s)

Description

Class representing a bitmap image generated by doxygen.

Definition at line 26 of file image.h.

Friends

stringLength

friend uint32_t const QCString & s

Declaration at line 44 of file image.h, definition at line 277 of file image.cpp.

277uint32_t Image::stringLength(const QCString &s)
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.

Public Constructors

Image()

Image::Image (uint32_t w, uint32_t h)

Declaration at line 29 of file image.h, definition at line 174 of file image.cpp.

174Image::Image(uint32_t w,uint32_t h) : 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}

References Config_getInt, ColoredImage::hsl2rgb and p.

Referenced by ~Image.

Public Destructor

~Image()

Image::~Image ()

Definition at line 30 of file image.h.

References height, Image and width.

Public Member Functions

drawHorzArrow()

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

Declaration at line 38 of file image.h, definition at line 299 of file image.cpp.

299void Image::drawHorzArrow(uint32_t y,uint32_t xs,uint32_t xe,uint8_t colIndex,uint32_t mask)
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}

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)

Declaration at line 37 of file image.h, definition at line 289 of file image.cpp.

289void Image::drawHorzLine(uint32_t y,uint32_t xs,uint32_t xe,uint8_t colIndex,uint32_t mask)
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}

Reference 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)

Declaration at line 41 of file image.h, definition at line 328 of file image.cpp.

328void Image::drawRect(uint32_t x,uint32_t y,uint32_t w,uint32_t h,uint8_t colIndex,uint32_t mask)
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)

Declaration at line 40 of file image.h, definition at line 318 of file image.cpp.

318void Image::drawVertArrow(uint32_t x,uint32_t ys,uint32_t ye,uint8_t colIndex,uint32_t mask)
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)

Declaration at line 39 of file image.h, definition at line 309 of file image.cpp.

309void Image::drawVertLine(uint32_t x,uint32_t ys,uint32_t ye,uint8_t colIndex,uint32_t mask)
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}

Reference 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)

Declaration at line 42 of file image.h, definition at line 336 of file image.cpp.

336void Image::fillRect(uint32_t x,uint32_t y,uint32_t width,uint32_t height,uint8_t colIndex,uint32_t mask)
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}

References height, setPixel and width.

Referenced by writeBitmapBox.

getPixel()

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

Declaration at line 34 of file image.h, definition at line 218 of file image.cpp.

218uint8_t Image::getPixel(uint32_t x,uint32_t y) const
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 ()

Declaration at line 46 of file image.h, definition at line 209 of file image.cpp.

209uint32_t Image::height() const { return p->height; }

Reference p.

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

save()

bool Image::save (const QCString & fileName)

Declaration at line 43 of file image.h, definition at line 346 of file image.cpp.

346bool Image::save(const QCString &fileName)
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}

References QCString::data, p and TRUE.

setPixel()

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

Declaration at line 33 of file image.h, definition at line 213 of file image.cpp.

213void Image::setPixel(uint32_t x,uint32_t y,uint8_t val)
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.

width()

uint32_t Image::width ()

Declaration at line 45 of file image.h, definition at line 208 of file image.cpp.

208uint32_t Image::width() const { return p->width; }

Reference p.

Referenced by fillRect, getPixel, setPixel and ~Image.

writeChar()

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

Declaration at line 35 of file image.h, definition at line 223 of file image.cpp.

223void Image::writeChar(uint32_t x,uint32_t y,char c,uint8_t fg)
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}

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)

Declaration at line 36 of file image.h, definition at line 263 of file image.cpp.

263void Image::writeString(uint32_t x,uint32_t y,const QCString &s,uint8_t fg)
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}

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

Referenced by writeBitmapBox.

Private Member Attributes

p

std::unique_ptr<Private> Image::p

Definition at line 51 of file image.h.

51 std::unique_ptr<Private> p;

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

Public Static Functions

stringLength()

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

Definition at line 47 of file image.h.


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


Generated via doxygen2docusaurus by Doxygen 1.14.0.