Class representing a bitmap image colored based on hue/sat/gamma settings.
More...
#include <src/image.h>
|
| ColoredImage (uint32_t width, uint32_t height, const uint8_t *greyLevels, const uint8_t *alphaLevels, int saturation, int hue, int gamma) |
|
| ~ColoredImage () |
|
bool | save (const QCString &fileName) |
|
|
static void | hsl2rgb (double h, double s, double l, double *pRed, double *pGreen, double *pBlue) |
|
Class representing a bitmap image colored based on hue/sat/gamma settings.
Definition at line 55 of file image.h.
◆ ColoredImage()
ColoredImage::ColoredImage |
( |
uint32_t | width, |
|
|
uint32_t | height, |
|
|
const uint8_t * | greyLevels, |
|
|
const uint8_t * | alphaLevels, |
|
|
int | saturation, |
|
|
int | hue, |
|
|
int | gamma ) |
Definition at line 432 of file image.cpp.
434 :
p(std::make_unique<Private>())
435{
436 p->hasAlpha = alphaLevels!=
nullptr;
439 p->data.resize(width*height*4);
440 for (uint32_t i=0;i<width*height;i++)
441 {
442 double red=0.0, green=0.0, blue=0.0;
444 saturation/255.0,
445 pow(greyLevels[i]/255.0,gamma/100.0),
446 &red,&green,&blue);
447 Byte r =
static_cast<Byte>(red *255.0);
448 Byte g =
static_cast<Byte>(green*255.0);
449 Byte b =
static_cast<Byte>(blue *255.0);
450 Byte a = alphaLevels ? alphaLevels[i] : 255;
455 }
456}
static void hsl2rgb(double h, double s, double l, double *pRed, double *pGreen, double *pBlue)
std::unique_ptr< Private > p
References hsl2rgb(), and p.
Referenced by ~ColoredImage().
◆ ~ColoredImage()
ColoredImage::~ColoredImage |
( |
| ) |
|
|
default |
◆ hsl2rgb()
void ColoredImage::hsl2rgb |
( |
double | h, |
|
|
double | s, |
|
|
double | l, |
|
|
double * | pRed, |
|
|
double * | pGreen, |
|
|
double * | pBlue ) |
|
static |
Definition at line 368 of file image.cpp.
370{
371 double r = l;
372 double g = l;
373 double b = l;
374 double v = (l <= 0.5) ? (l * (1.0 + s)) : (l + s - l * s);
375 if (v > 0)
376 {
377 double m = l + l - v;
378 double sv = ( v - m ) / v;
379 h *= 6.0;
380 int sextant = static_cast<int>(h);
381 double fract = h - sextant;
382 double vsf = v * sv * fract;
383 double mid1 = m + vsf;
384 double mid2 = v - vsf;
385 switch (sextant)
386 {
387 case 0:
388 r = v;
389 g = mid1;
390 b = m;
391 break;
392 case 1:
393 r = mid2;
394 g = v;
395 b = m;
396 break;
397 case 2:
398 r = m;
399 g = v;
400 b = mid1;
401 break;
402 case 3:
403 r = m;
404 g = mid2;
405 b = v;
406 break;
407 case 4:
408 r = mid1;
409 g = m;
410 b = v;
411 break;
412 case 5:
413 r = v;
414 g = m;
415 b = mid2;
416 break;
417 }
418 }
419 *pRed = r;
420 *pGreen = g;
421 *pBlue = b;
422}
Referenced by ColoredImage(), getDirectoryBackgroundColor(), Image::Image(), and replaceColorMarkers().
◆ save()
bool ColoredImage::save |
( |
const QCString & | fileName | ) |
|
Definition at line 460 of file image.cpp.
461{
462 uint8_t *buffer = nullptr;
463 size_t bufferSize = 0;
464 LodePNG_Encoder encoder;
465 LodePNG_Encoder_init(&encoder);
466 encoder.infoPng.color.colorType =
p->hasAlpha ? 6 : 2;
467 encoder.infoRaw.color.colorType = 6;
468 LodePNG_encode(&encoder, &buffer, &bufferSize, &
p->data[0],
p->width,
p->height);
469 LodePNG_saveFile(buffer, bufferSize, fileName.
data());
470 LodePNG_Encoder_cleanup(&encoder);
471 free(buffer);
473}
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
References QCString::data(), p, and TRUE.
Referenced by writeColoredImgData().
std::unique_ptr<Private> ColoredImage::p |
|
private |
The documentation for this class was generated from the following files: