qTox  Version: nightly | Commit: bc751c8e1cac455f9690654fcfe0f560d2d7dfdd
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Attributes | Static Private Attributes | List of all members
Identicon Class Reference

#include <identicon.h>

Collaboration diagram for Identicon:
Collaboration graph

Public Member Functions

 Identicon (const QByteArray &data)
 Creates an Identicon, that visualizes a hash in graphical form. More...
 
QImage toImage (int scaleFactor=1)
 Writes the Identicon to a QImage. More...
 

Static Public Member Functions

static float bytesToColor (QByteArray bytes)
 Converts a series of IDENTICON_COLOR_BYTES bytes to a value in the range 0.0..1.0. More...
 

Static Public Attributes

static constexpr int IDENTICON_ROWS = 5
 
static constexpr int IDENTICON_COLOR_BYTES = 6
 

Private Attributes

uint8_t identiconColors [IDENTICON_ROWS][ACTIVE_COLS]
 
QColor colors [COLORS]
 

Static Private Attributes

static constexpr int COLORS = 2
 
static constexpr int ACTIVE_COLS = (IDENTICON_ROWS + 1) / 2
 
static constexpr int HASH_MIN_LEN
 

Detailed Description

Definition at line 25 of file identicon.h.

Constructor & Destructor Documentation

◆ Identicon()

Identicon::Identicon ( const QByteArray &  data)

Creates an Identicon, that visualizes a hash in graphical form.

Parameters
dataData to visualize

Definition at line 63 of file identicon.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ bytesToColor()

float Identicon::bytesToColor ( QByteArray  bytes)
static

Converts a series of IDENTICON_COLOR_BYTES bytes to a value in the range 0.0..1.0.

Parameters
bytesBytes to convert to a color
Returns
Value in the range of 0.0..1.0

Definition at line 95 of file identicon.cpp.

Here is the caller graph for this function:

◆ toImage()

QImage Identicon::toImage ( int  scaleFactor = 1)

Writes the Identicon to a QImage.

Parameters
scaleFactorthe image will be a square with scaleFactor * IDENTICON_ROWS pixels, must be >= 1
Returns
a QImage with the identicon

Definition at line 121 of file identicon.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ ACTIVE_COLS

Identicon::ACTIVE_COLS = (IDENTICON_ROWS + 1) / 2
staticconstexprprivate

Width from the center to the outside, for 5 columns it's 3, 6 -> 3, 7 -> 4

Definition at line 38 of file identicon.h.

◆ COLORS

Identicon::COLORS = 2
staticconstexprprivate

Number of colors to use for the identicon

Definition at line 37 of file identicon.h.

◆ colors

QColor Identicon::colors[COLORS]
private

Definition at line 43 of file identicon.h.

◆ HASH_MIN_LEN

Identicon::HASH_MIN_LEN
staticconstexprprivate
Initial value:

Min length of the hash in bytes, 7 bytes control the color, the rest controls the pixel placement

Definition at line 39 of file identicon.h.

◆ IDENTICON_COLOR_BYTES

Identicon::IDENTICON_COLOR_BYTES = 6
staticconstexpr

Specifies how many bytes should define the foreground color must be smaller than 8, else there'll be overflows

Definition at line 34 of file identicon.h.

◆ IDENTICON_ROWS

Identicon::IDENTICON_ROWS = 5
staticconstexpr

Specifies how many rows of blocks the identicon should have

Definition at line 33 of file identicon.h.

◆ identiconColors

uint8_t Identicon::identiconColors[IDENTICON_ROWS][ACTIVE_COLS]
private

Definition at line 42 of file identicon.h.


The documentation for this class was generated from the following files:
Identicon::IDENTICON_ROWS
static constexpr int IDENTICON_ROWS
Definition: identicon.h:33
Identicon::COLORS
static constexpr int COLORS
Definition: identicon.h:37
Identicon::ACTIVE_COLS
static constexpr int ACTIVE_COLS
Definition: identicon.h:38
Identicon::IDENTICON_COLOR_BYTES
static constexpr int IDENTICON_COLOR_BYTES
Definition: identicon.h:34