Krita Source Code Documentation
Loading...
Searching...
No Matches
gimp_bump_map.h File Reference
#include <QtGlobal>
#include "kis_types.h"

Go to the source code of this file.

Classes

struct  bumpmap_vals_t
 

Enumerations

enum  BumpmapType { LINEAR = 0 , SPHERICAL , SINUSOIDAL }
 

Functions

void KRITAIMAGE_EXPORT bumpmap (KisPixelSelectionSP device, const QRect &selectionRect, const bumpmap_vals_t &bmvals)
 

Enumeration Type Documentation

◆ BumpmapType

Enumerator
LINEAR 
SPHERICAL 
SINUSOIDAL 

Definition at line 21 of file gimp_bump_map.h.

22{
23 LINEAR = 0,
26};
@ SINUSOIDAL
@ LINEAR
@ SPHERICAL

Function Documentation

◆ bumpmap()

void KRITAIMAGE_EXPORT bumpmap ( KisPixelSelectionSP device,
const QRect & selectionRect,
const bumpmap_vals_t & bmvals )

Definition at line 64 of file gimp_bump_map.cpp.

67{
70
71 bumpmap_params_t params;
72 bumpmap_init_params (&params, bmvals);
73
74 const QRect dataRect = kisGrowRect(selectionRect, 1);
75
76 const int dataRowSize = dataRect.width() * sizeof(quint8);
77 const int selectionRowSize = selectionRect.width() * sizeof(quint8);
78 QScopedArrayPointer<quint8> dstRow(new quint8[selectionRowSize]);
79
80 std::unique_ptr<quint8[]> bmRow1(new quint8[dataRowSize]);
81 std::unique_ptr<quint8[]> bmRow2(new quint8[dataRowSize]);
82 std::unique_ptr<quint8[]> bmRow3(new quint8[dataRowSize]);
83
84 device->readBytes(bmRow1.get(), dataRect.left(), dataRect.top(), dataRect.width(), 1);
85 device->readBytes(bmRow2.get(), dataRect.left(), dataRect.top() + 1, dataRect.width(), 1);
86 device->readBytes(bmRow3.get(), dataRect.left(), dataRect.top() + 2, dataRect.width(), 1);
87
88 convertRow(bmRow1.get(), dataRect.width(), params.lut);
89 convertRow(bmRow2.get(), dataRect.width(), params.lut);
90 convertRow(bmRow3.get(), dataRect.width(), params.lut);
91
92 for (int row = selectionRect.top();
93 row < selectionRect.top() + selectionRect.height(); row++) {
94
95 bumpmap_row (bmvals, dstRow.data(), selectionRect.width(),
96 bmRow1.get() + 1, bmRow2.get() + 1, bmRow3.get() + 1,
97 &params);
98
99 device->writeBytes(dstRow.data(), selectionRect.left(), row, selectionRect.width(), 1);
100
101 bmRow1.swap(bmRow2);
102 bmRow2.swap(bmRow3);
103
104 device->readBytes(bmRow3.get(), dataRect.left(), row + 1, dataRect.width(), 1);
105 convertRow(bmRow3.get(), dataRect.width(), params.lut);
106 }
107}
void readBytes(quint8 *data, qint32 x, qint32 y, qint32 w, qint32 h) const
void writeBytes(const quint8 *data, qint32 x, qint32 y, qint32 w, qint32 h)
void bumpmap_init_params(bumpmap_params_t *params, const bumpmap_vals_t &bmvals)
void bumpmap_row(const bumpmap_vals_t &bmvals, guchar *dest, gint width, const guchar *bm_row1, const guchar *bm_row2, const guchar *bm_row3, bumpmap_params_t *params)
void convertRow(quint8 *data, int width, const quint8 *lut)
#define KIS_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:75
T kisGrowRect(const T &rect, U offset)
Definition kis_global.h:186

References bumpmap_init_params(), bumpmap_row(), convertRow(), KIS_ASSERT_RECOVER_RETURN, kisGrowRect(), bumpmap_params_t::lut, KisPaintDevice::readBytes(), KisPaintDevice::writeBytes(), bumpmap_vals_t::xofs, and bumpmap_vals_t::yofs.