34 const QRect& applyRect,
41 if (progressUpdater) progressUpdater->
setProgress(0);
46 if (userChosenHeightChannel ==
"FAIL") {
54 if (userChosenHeightChannel == channel->
name()) {
55 m_heightChannel = channel;
59 if (!m_heightChannel) {
60 m_heightChannel = channels.first();
64 QRect inputArea = applyRect;
65 QRect outputArea = applyRect;
66 if (m_usenormalmap==
false) {
67 inputArea.adjust(-1, -1, 1, 1);
76 if (progressUpdater) progressUpdater->
setProgress(1);
81 const quint8 BYTE_DEPTH_OF_BUMPMAP = 2;
82 const quint8 CHANNEL_COUNT_OF_BUMPMAP = 4;
83 const quint32 pixelsOfInputArea = abs(inputArea.width() * inputArea.height());
84 const quint32 pixelsOfOutputArea = abs(outputArea.width() * outputArea.height());
85 const quint8 pixelSize = BYTE_DEPTH_OF_BUMPMAP * CHANNEL_COUNT_OF_BUMPMAP;
86 const quint32 bytesToFillBumpmapArea = pixelsOfOutputArea * pixelSize;
88 quint8 *bumpmapDataPointer =
bumpmap.data();
93 if (progressUpdater) progressUpdater->
setProgress(2);
104 quint32 curPixel = 0;
110 if (m_usenormalmap==
false) {
111 for (qint32 srcRow = 0; srcRow < inputArea.height(); ++srcRow) {
114 tileRenderer.
realheightmap[curPixel] = toDoubleFuncPtr[ki](data, channels[ki]->pos());
120 if (progressUpdater) progressUpdater->
setProgress(50);
122 const int tileHeightMinus1 = inputArea.height() - 1;
123 const int tileWidthMinus1 = inputArea.width() - 1;
126 for (
int y = 1; y < tileHeightMinus1; ++y) {
127 for (
int x = 1; x < tileWidthMinus1; ++x) {
128 posup = (y + 1) * inputArea.width() + x;
129 posdown = (y - 1) * inputArea.width() + x;
130 posleft = y * inputArea.width() + x - 1;
131 posright = y * inputArea.width() + x + 1;
134 memcpy(bumpmapDataPointer,
138 bumpmapDataPointer += pixelSize;
142 for (qint32 srcRow = 0; srcRow < inputArea.height(); ++srcRow) {
145 tileRenderer.
realheightmap[curPixel] = toDoubleFuncPtr[ki](data, channels[ki]->pos());
146 QVector <float> current_pixel_values(4);
150 memcpy(bumpmapDataPointer,
156 bumpmapDataPointer += pixelSize;
166 if (progressUpdater) progressUpdater->
setProgress(90);
169 bumpmapPaintDevice->
writeBytes(
bumpmap.data(), outputArea.x(), outputArea.y(), outputArea.width(), outputArea.height());
172 copier.
bitBlt(outputArea.x(), outputArea.y(), bumpmapPaintDevice,
173 outputArea.x(), outputArea.y(), outputArea.width(), outputArea.height());
177 if (progressUpdater) progressUpdater->
setProgress(100);