Doxygen
ColoredImage类 参考

Class representing a bitmap image colored based on hue/sat/gamma settings. 更多...

#include <image.h>

Public 成员函数

 ColoredImage (uint width, uint height, const uchar *greyLevels, const uchar *alphaLevels, int saturation, int hue, int gamma)
 
 ~ColoredImage ()
 
bool save (const QCString &fileName)
 

静态 Public 成员函数

static void hsl2rgb (double h, double s, double l, double *pRed, double *pGreen, double *pBlue)
 

Private 属性

uint m_width
 
uint m_height
 
ucharm_data
 
bool m_hasAlpha
 

详细描述

Class representing a bitmap image colored based on hue/sat/gamma settings.

在文件 image.h56 行定义.

构造及析构函数说明

◆ ColoredImage()

ColoredImage::ColoredImage ( uint  width,
uint  height,
const uchar greyLevels,
const uchar alphaLevels,
int  saturation,
int  hue,
int  gamma 
)

在文件 image.cpp476 行定义.

479 {
480  m_hasAlpha = alphaLevels!=0;
481  m_width = width;
482  m_height = height;
483  m_data = (uchar*)malloc(width*height*4);
484  uint i;
485  for (i=0;i<width*height;i++)
486  {
487  uchar r,g,b,a;
488  double red,green,blue;
489  hsl2rgb(hue/360.0, // hue
490  saturation/255.0, // saturation
491  pow(greyLevels[i]/255.0,gamma/100.0), // luma (gamma corrected)
492  &red,&green,&blue);
493  r = (int)(red *255.0);
494  g = (int)(green*255.0);
495  b = (int)(blue *255.0);
496  a = alphaLevels ? alphaLevels[i] : 255;
497  m_data[i*4+0]=r;
498  m_data[i*4+1]=g;
499  m_data[i*4+2]=b;
500  m_data[i*4+3]=a;
501  }
502 }

引用了 hsl2rgb(), m_data, m_hasAlpha, m_height , 以及 m_width.

◆ ~ColoredImage()

ColoredImage::~ColoredImage ( )

在文件 image.cpp504 行定义.

505 {
506  free(m_data);
507 }

引用了 m_data.

成员函数说明

◆ hsl2rgb()

void ColoredImage::hsl2rgb ( double  h,
double  s,
double  l,
double *  pRed,
double *  pGreen,
double *  pBlue 
)
static

在文件 image.cpp412 行定义.

414 {
415  double v;
416  double r,g,b;
417 
418  r = l; // default to gray
419  g = l;
420  b = l;
421  v = (l <= 0.5) ? (l * (1.0 + s)) : (l + s - l * s);
422  if (v > 0)
423  {
424  double m;
425  double sv;
426  int sextant;
427  double fract, vsf, mid1, mid2;
428 
429  m = l + l - v;
430  sv = (v - m ) / v;
431  h *= 6.0;
432  sextant = (int)h;
433  fract = h - sextant;
434  vsf = v * sv * fract;
435  mid1 = m + vsf;
436  mid2 = v - vsf;
437  switch (sextant)
438  {
439  case 0:
440  r = v;
441  g = mid1;
442  b = m;
443  break;
444  case 1:
445  r = mid2;
446  g = v;
447  b = m;
448  break;
449  case 2:
450  r = m;
451  g = v;
452  b = mid1;
453  break;
454  case 3:
455  r = m;
456  g = mid2;
457  b = v;
458  break;
459  case 4:
460  r = mid1;
461  g = m;
462  b = v;
463  break;
464  case 5:
465  r = v;
466  g = m;
467  b = mid2;
468  break;
469  }
470  }
471  *pRed = r;
472  *pGreen = g;
473  *pBlue = b;
474 }

被这些函数引用 ColoredImage(), getDirectoryBackgroundColor(), Image::Image() , 以及 replaceColorMarkers().

◆ save()

bool ColoredImage::save ( const QCString fileName)

在文件 image.cpp509 行定义.

510 {
511  uchar *buffer;
512  size_t bufferSize;
513  LodePNG_Encoder encoder;
514  LodePNG_Encoder_init(&encoder);
515  encoder.infoPng.color.colorType = m_hasAlpha ? 6 : 2; // 2=RGB 24 bit, 6=RGBA 32 bit
516  encoder.infoRaw.color.colorType = 6; // 6=RGBA 32 bit
517  LodePNG_encode(&encoder, &buffer, &bufferSize, m_data, m_width, m_height);
518  LodePNG_saveFile(buffer, bufferSize, fileName.data());
519  LodePNG_Encoder_cleanup(&encoder);
520  free(buffer);
521  return TRUE;
522 }

引用了 QCString::data(), m_data, m_hasAlpha, m_height, m_width , 以及 TRUE.

被这些函数引用 writeColoredImgData().

类成员变量说明

◆ m_data

uchar* ColoredImage::m_data
private

在文件 image.h69 行定义.

被这些函数引用 ColoredImage(), save() , 以及 ~ColoredImage().

◆ m_hasAlpha

bool ColoredImage::m_hasAlpha
private

在文件 image.h70 行定义.

被这些函数引用 ColoredImage() , 以及 save().

◆ m_height

uint ColoredImage::m_height
private

在文件 image.h68 行定义.

被这些函数引用 ColoredImage() , 以及 save().

◆ m_width

uint ColoredImage::m_width
private

在文件 image.h67 行定义.

被这些函数引用 ColoredImage() , 以及 save().


该类的文档由以下文件生成:
ColoredImage::hsl2rgb
static void hsl2rgb(double h, double s, double l, double *pRed, double *pGreen, double *pBlue)
Definition: image.cpp:412
ColoredImage::m_width
uint m_width
Definition: image.h:67
ColoredImage::m_height
uint m_height
Definition: image.h:68
ColoredImage::m_hasAlpha
bool m_hasAlpha
Definition: image.h:70
uint
unsigned uint
Definition: qcstring.h:40
uchar
unsigned char uchar
Definition: qcstring.h:38
ColoredImage::m_data
uchar * m_data
Definition: image.h:69
TRUE
#define TRUE
Definition: qcstring.h:36
QCString::data
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:153