annotate layer/Colour3DPlotRenderer.cpp @ 1088:c520f90bbf2e spectrogram-minor-refactor

One FFT model per spectrogram (again!) - but we do still need a magnitude range per view, as views could be showing different regions
author Chris Cannam
date Tue, 05 Jul 2016 08:58:28 +0100
parents db976e9f385a
children c8c747783110
rev   line source
Chris@1071 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@1071 2
Chris@1071 3 /*
Chris@1071 4 Sonic Visualiser
Chris@1071 5 An audio file viewer and annotation editor.
Chris@1071 6 Centre for Digital Music, Queen Mary, University of London.
Chris@1071 7 This file copyright 2006-2016 Chris Cannam and QMUL.
Chris@1071 8
Chris@1071 9 This program is free software; you can redistribute it and/or
Chris@1071 10 modify it under the terms of the GNU General Public License as
Chris@1071 11 published by the Free Software Foundation; either version 2 of the
Chris@1071 12 License, or (at your option) any later version. See the file
Chris@1071 13 COPYING included with this distribution for more information.
Chris@1071 14 */
Chris@1071 15
Chris@1071 16 #include "Colour3DPlotRenderer.h"
Chris@1074 17 #include "RenderTimer.h"
Chris@1071 18
Chris@1075 19 #include "data/model/DenseThreeDimensionalModel.h"
Chris@1075 20 #include "data/model/Dense3DModelPeakCache.h"
Chris@1075 21 #include "data/model/FFTModel.h"
Chris@1075 22
Chris@1077 23 #include "LayerGeometryProvider.h"
Chris@1082 24 #include "VerticalBinLayer.h"
Chris@1075 25
Chris@1079 26 #include <vector>
Chris@1079 27
Chris@1079 28 using namespace std;
Chris@1079 29
Chris@1073 30 Colour3DPlotRenderer::RenderResult
Chris@1076 31 Colour3DPlotRenderer::render(QPainter &paint, QRect rect)
Chris@1076 32 {
Chris@1076 33 return render(paint, rect, false);
Chris@1076 34 }
Chris@1076 35
Chris@1076 36 Colour3DPlotRenderer::RenderResult
Chris@1076 37 Colour3DPlotRenderer::renderTimeConstrained(QPainter &paint, QRect rect)
Chris@1076 38 {
Chris@1076 39 return render(paint, rect, true);
Chris@1076 40 }
Chris@1076 41
Chris@1076 42 Colour3DPlotRenderer::RenderResult
Chris@1076 43 Colour3DPlotRenderer::render(QPainter &paint, QRect rect, bool timeConstrained)
Chris@1073 44 {
Chris@1075 45 LayerGeometryProvider *v = m_sources.geometryProvider;
Chris@1075 46 if (!v) {
Chris@1075 47 throw std::logic_error("no LayerGeometryProvider provided");
Chris@1075 48 }
Chris@1075 49
Chris@1079 50 sv_frame_t startFrame = v->getStartFrame();
Chris@1079 51
Chris@1079 52 int x0 = v->getXForViewX(rect.x());
Chris@1079 53 int x1 = v->getXForViewX(rect.x() + rect.width());
Chris@1079 54 if (x0 < 0) x0 = 0;
Chris@1079 55 if (x1 > v->getPaintWidth()) x1 = v->getPaintWidth();
Chris@1079 56
Chris@1079 57 m_cache.resize(v->getPaintSize());
Chris@1079 58 m_cache.setZoomLevel(v->getZoomLevel());
Chris@1079 59
Chris@1079 60 if (m_cache.isValid()) { // some part of the cache is valid
Chris@1079 61
Chris@1079 62 if (v->getXForFrame(m_cache.getStartFrame()) ==
Chris@1079 63 v->getXForFrame(startFrame) &&
Chris@1079 64 m_cache.getValidLeft() <= x0 &&
Chris@1079 65 m_cache.getValidRight() >= x1) {
Chris@1079 66
Chris@1079 67 // cache is valid for the complete requested area
Chris@1079 68 paint.drawImage(rect, m_cache.getImage(), rect);
Chris@1079 69 return { rect, {} };
Chris@1079 70
Chris@1079 71 } else {
Chris@1079 72 // cache doesn't begin at the right frame or doesn't
Chris@1079 73 // contain the complete view, but might be scrollable or
Chris@1079 74 // partially usable
Chris@1079 75 m_cache.scrollTo(startFrame);
Chris@1079 76
Chris@1079 77 // if we are not time-constrained, then we want to paint
Chris@1081 78 // the whole area in one go; we don't return a partial
Chris@1081 79 // paint. To avoid providing the more complex logic to
Chris@1081 80 // handle painting discontiguous areas, if the only valid
Chris@1079 81 // part of cache is in the middle, just make the whole
Chris@1079 82 // thing invalid and start again.
Chris@1079 83 if (!timeConstrained) {
Chris@1079 84 if (m_cache.getValidLeft() > x0 &&
Chris@1079 85 m_cache.getValidRight() < x1) {
Chris@1079 86 m_cache.invalidate();
Chris@1079 87 }
Chris@1079 88 }
Chris@1079 89 }
Chris@1075 90 }
Chris@1075 91
Chris@1079 92 bool rightToLeft = false;
Chris@1079 93
Chris@1079 94 if (!m_cache.isValid() && timeConstrained) {
Chris@1081 95 // When rendering the whole area, in a context where we might
Chris@1081 96 // not be able to complete the work, start from somewhere near
Chris@1081 97 // the middle so that the region of interest appears first
Chris@1079 98
Chris@1079 99 //!!! (perhaps we should avoid doing this if past repaints
Chris@1079 100 //!!! have been fast enough to do the whole in one shot)
Chris@1079 101 if (x0 == 0 && x1 == v->getPaintWidth()) {
Chris@1079 102 x0 = int(x1 * 0.3);
Chris@1079 103 }
Chris@1079 104 }
Chris@1079 105
Chris@1079 106 if (m_cache.isValid()) {
Chris@1079 107 // When rendering only a part of the cache, we need to make
Chris@1079 108 // sure that the part we're rendering is adjacent to (or
Chris@1079 109 // overlapping) a valid area of cache, if we have one. The
Chris@1079 110 // alternative is to ditch the valid area of cache and render
Chris@1079 111 // only the requested area, but that's risky because this can
Chris@1079 112 // happen when just waving the pointer over a small part of
Chris@1079 113 // the view -- if we lose the partly-built cache every time
Chris@1079 114 // the user does that, we'll never finish building it.
Chris@1079 115 int left = x0;
Chris@1079 116 int width = x1 - x0;
Chris@1079 117 bool isLeftOfValidArea = false;
Chris@1079 118 m_cache.adjustToTouchValidArea(left, width, isLeftOfValidArea);
Chris@1079 119 x0 = left;
Chris@1079 120 x1 = x0 + width;
Chris@1079 121
Chris@1079 122 // That call also told us whether we should be painting
Chris@1079 123 // sub-regions of our target region in right-to-left order in
Chris@1079 124 // order to ensure contiguity
Chris@1079 125 rightToLeft = isLeftOfValidArea;
Chris@1079 126 }
Chris@1075 127
Chris@1080 128 renderToCache(x0, x1 - x0, rightToLeft, timeConstrained);
Chris@1079 129
Chris@1079 130 QRect pr = rect & m_cache.getValidArea();
Chris@1079 131 paint.drawImage(pr.x(), pr.y(), m_cache.getImage(),
Chris@1079 132 pr.x(), pr.y(), pr.width(), pr.height());
Chris@1079 133
Chris@1079 134 if (!timeConstrained && (pr != rect)) {
Chris@1079 135 //!!! on a first cut, there is a risk that this will happen
Chris@1079 136 //!!! when we are at start/end of model -- trap, report, and
Chris@1079 137 //!!! then fix
Chris@1079 138 throw std::logic_error("internal error: failed to render entire requested rect even when not time-constrained");
Chris@1079 139 }
Chris@1079 140
Chris@1079 141 return { pr, {} };
Chris@1079 142
Chris@1073 143 //!!! todo: timing/incomplete paint
Chris@1073 144
Chris@1073 145 //!!! todo: peak frequency style
Chris@1073 146
Chris@1073 147 //!!! todo: transparent style from Colour3DPlot
Chris@1074 148
Chris@1074 149 //!!! todo: bin boundary alignment when in BinResolution
Chris@1074 150
Chris@1079 151 //!!! todo: view magnitudes / normalise visible area
Chris@1079 152
Chris@1079 153 //!!! todo: alter documentation for view mag stuff (cached paints
Chris@1079 154 //!!! do not update MagnitudeRange)
Chris@1079 155
Chris@1079 156 //!!! todo, here or in caller: illuminateLocalFeatures
Chris@1079 157
Chris@1079 158 //!!! fft model scaling?
Chris@1079 159
Chris@1079 160 //!!! should we own the Dense3DModelPeakCache here? or should it persist
Chris@1073 161 }
Chris@1073 162
Chris@1080 163 void
Chris@1080 164 Colour3DPlotRenderer::renderToCache(int x0, int repaintWidth,
Chris@1080 165 bool rightToLeft, bool timeConstrained)
Chris@1079 166 {
Chris@1079 167 // Draw to the draw buffer, and then scale-copy from there.
Chris@1079 168
Chris@1079 169 DenseThreeDimensionalModel *model = m_sources.source;
Chris@1079 170 if (!model || !model->isOK() || !model->isReady()) {
Chris@1079 171 throw std::logic_error("no source model provided, or model not ready");
Chris@1079 172 }
Chris@1079 173
Chris@1079 174 LayerGeometryProvider *v = m_sources.geometryProvider; // already checked
Chris@1079 175
Chris@1079 176 // The draw buffer contains a fragment at either our pixel
Chris@1079 177 // resolution (if there is more than one time-bin per pixel) or
Chris@1079 178 // time-bin resolution (if a time-bin spans more than one pixel).
Chris@1079 179 // We need to ensure that it starts and ends at points where a
Chris@1079 180 // time-bin boundary occurs at an exact pixel boundary, and with a
Chris@1079 181 // certain amount of overlap across existing pixels so that we can
Chris@1079 182 // scale and draw from it without smoothing errors at the edges.
Chris@1079 183
Chris@1079 184 // If (getFrameForX(x) / increment) * increment ==
Chris@1079 185 // getFrameForX(x), then x is a time-bin boundary. We want two
Chris@1079 186 // such boundaries at either side of the draw buffer -- one which
Chris@1079 187 // we draw up to, and one which we subsequently crop at.
Chris@1079 188
Chris@1079 189 bool bufferIsBinResolution = false;
Chris@1079 190 int binResolution = model->getResolution();
Chris@1079 191 int zoomLevel = v->getZoomLevel();
Chris@1079 192 if (binResolution > zoomLevel) bufferIsBinResolution = true;
Chris@1079 193
Chris@1079 194 sv_frame_t leftBoundaryFrame = -1, leftCropFrame = -1;
Chris@1079 195 sv_frame_t rightBoundaryFrame = -1, rightCropFrame = -1;
Chris@1079 196
Chris@1079 197 int drawWidth;
Chris@1079 198
Chris@1079 199 if (bufferIsBinResolution) {
Chris@1079 200 for (int x = x0; ; --x) {
Chris@1079 201 sv_frame_t f = v->getFrameForX(x);
Chris@1079 202 if ((f / binResolution) * binResolution == f) {
Chris@1079 203 if (leftCropFrame == -1) leftCropFrame = f;
Chris@1079 204 else if (x < x0 - 2) {
Chris@1079 205 leftBoundaryFrame = f;
Chris@1079 206 break;
Chris@1079 207 }
Chris@1079 208 }
Chris@1079 209 }
Chris@1079 210 for (int x = x0 + repaintWidth; ; ++x) {
Chris@1079 211 sv_frame_t f = v->getFrameForX(x);
Chris@1079 212 if ((f / binResolution) * binResolution == f) {
Chris@1079 213 if (rightCropFrame == -1) rightCropFrame = f;
Chris@1079 214 else if (x > x0 + repaintWidth + 2) {
Chris@1079 215 rightBoundaryFrame = f;
Chris@1079 216 break;
Chris@1079 217 }
Chris@1079 218 }
Chris@1079 219 }
Chris@1079 220 drawWidth = int((rightBoundaryFrame - leftBoundaryFrame) / binResolution);
Chris@1079 221 } else {
Chris@1079 222 drawWidth = repaintWidth;
Chris@1079 223 }
Chris@1079 224
Chris@1079 225 // We always paint the full height. Smaller heights can be used
Chris@1079 226 // when painting direct from cache (outside this function), but we
Chris@1079 227 // want to ensure the cache is coherent without having to worry
Chris@1079 228 // about vertical matching of required and valid areas as well as
Chris@1079 229 // horizontal. That's why this function didn't take any y/height
Chris@1079 230 // parameters.
Chris@1079 231 int h = v->getPaintHeight();
Chris@1079 232
Chris@1079 233 clearDrawBuffer(drawWidth, h);
Chris@1079 234
Chris@1079 235 vector<int> binforx(drawWidth);
Chris@1079 236 vector<double> binfory(h);
Chris@1079 237
Chris@1079 238 bool usePeaksCache = false;
Chris@1079 239 int binsPerPeak = 1;
Chris@1079 240
Chris@1079 241 if (bufferIsBinResolution) {
Chris@1080 242
Chris@1079 243 for (int x = 0; x < drawWidth; ++x) {
Chris@1079 244 binforx[x] = int(leftBoundaryFrame / binResolution) + x;
Chris@1079 245 }
Chris@1080 246
Chris@1080 247 // calculating boundaries later will be too fiddly for partial
Chris@1080 248 // paints, and painting should be fast anyway when this is the
Chris@1080 249 // case because it means we're well zoomed in
Chris@1080 250 timeConstrained = false;
Chris@1080 251
Chris@1079 252 } else {
Chris@1079 253 for (int x = 0; x < drawWidth; ++x) {
Chris@1079 254 sv_frame_t f0 = v->getFrameForX(x);
Chris@1079 255 double s0 = double(f0 - model->getStartFrame()) / binResolution;
Chris@1079 256 binforx[x] = int(s0 + 0.0001);
Chris@1079 257 }
Chris@1079 258
Chris@1079 259 if (m_sources.peaks) { // peaks cache exists
Chris@1079 260
Chris@1079 261 binsPerPeak = m_sources.peaks->getColumnsPerPeak();
Chris@1079 262 usePeaksCache = (binResolution * binsPerPeak) < zoomLevel;
Chris@1079 263
Chris@1079 264 if (m_params.colourScale.getScale() ==
Chris@1079 265 ColourScale::PhaseColourScale) {
Chris@1079 266 usePeaksCache = false;
Chris@1079 267 }
Chris@1079 268 }
Chris@1079 269 }
Chris@1082 270
Chris@1080 271 for (int y = 0; y < h; ++y) {
Chris@1082 272 binfory[y] =
Chris@1082 273 m_sources.verticalBinLayer->getBinForY(m_sources.geometryProvider, y);
Chris@1080 274 }
Chris@1079 275
Chris@1083 276 int attainedWidth = renderDrawBuffer(repaintWidth,
Chris@1080 277 h,
Chris@1080 278 binforx,
Chris@1080 279 binfory,
Chris@1080 280 usePeaksCache,
Chris@1080 281 rightToLeft,
Chris@1080 282 timeConstrained);
Chris@1083 283
Chris@1083 284 //!!! now scale-copy to cache
Chris@1084 285
Chris@1084 286 if (attainedWidth == 0) return;
Chris@1084 287
Chris@1084 288 int paintedLeft = x0;
Chris@1084 289 if (rightToLeft) {
Chris@1084 290 paintedLeft += (repaintWidth - attainedWidth);
Chris@1084 291 }
Chris@1084 292
Chris@1084 293 if (bufferIsBinResolution) {
Chris@1084 294
Chris@1084 295 int scaledLeft = v->getXForFrame(leftBoundaryFrame);
Chris@1084 296 int scaledRight = v->getXForFrame(rightBoundaryFrame);
Chris@1084 297
Chris@1084 298 QImage scaled = m_drawBuffer.scaled
Chris@1084 299 (scaledRight - scaledLeft, h,
Chris@1084 300 Qt::IgnoreAspectRatio, (m_params.interpolate ?
Chris@1084 301 Qt::SmoothTransformation :
Chris@1084 302 Qt::FastTransformation));
Chris@1084 303
Chris@1084 304 int scaledLeftCrop = v->getXForFrame(leftCropFrame);
Chris@1084 305 int scaledRightCrop = v->getXForFrame(rightCropFrame);
Chris@1084 306
Chris@1084 307 int targetLeft = scaledLeftCrop;
Chris@1084 308 if (targetLeft < 0) {
Chris@1084 309 targetLeft = 0;
Chris@1084 310 }
Chris@1084 311
Chris@1084 312 int targetWidth = scaledRightCrop - targetLeft;
Chris@1084 313 if (targetLeft + targetWidth > m_cache.getSize().width()) {
Chris@1084 314 targetWidth = m_cache.getSize().width() - targetLeft;
Chris@1084 315 }
Chris@1084 316
Chris@1084 317 int sourceLeft = targetLeft - scaledLeft;
Chris@1084 318 if (sourceLeft < 0) {
Chris@1084 319 sourceLeft = 0;
Chris@1084 320 }
Chris@1084 321
Chris@1084 322 int sourceWidth = targetWidth;
Chris@1084 323
Chris@1084 324 if (targetWidth > 0) {
Chris@1084 325 m_cache.drawImage(targetLeft, targetWidth,
Chris@1084 326 scaled,
Chris@1084 327 sourceLeft, sourceWidth);
Chris@1084 328 }
Chris@1084 329
Chris@1084 330 } else {
Chris@1084 331
Chris@1084 332 m_cache.drawImage(paintedLeft, attainedWidth,
Chris@1084 333 m_drawBuffer,
Chris@1084 334 paintedLeft - x0, attainedWidth);
Chris@1084 335 }
Chris@1079 336 }
Chris@1083 337
Chris@1083 338
Chris@1083 339 int
Chris@1083 340 Colour3DPlotRenderer::renderDrawBuffer(int w, int h,
Chris@1083 341 const vector<int> &binforx,
Chris@1083 342 const vector<double> &binfory,
Chris@1083 343 bool usePeaksCache,
Chris@1083 344 bool rightToLeft,
Chris@1083 345 bool timeConstrained)
Chris@1083 346 {
Chris@1083 347 // Callers must have checked that the appropriate subset of
Chris@1083 348 // Sources data members are set for the supplied flags (e.g. that
Chris@1083 349 // peaks model exists if usePeaksCache)
Chris@1083 350
Chris@1083 351 RenderTimer timer(timeConstrained ?
Chris@1083 352 RenderTimer::FastRender :
Chris@1083 353 RenderTimer::NoTimeout);
Chris@1083 354
Chris@1083 355 int minbin = int(binfory[0] + 0.0001);
Chris@1083 356 int maxbin = int(binfory[h-1]);
Chris@1083 357 if (minbin < 0) minbin = 0;
Chris@1083 358 if (maxbin < 0) maxbin = minbin+1;
Chris@1083 359
Chris@1083 360 int divisor = 1;
Chris@1083 361 DenseThreeDimensionalModel *sourceModel = m_sources.source;
Chris@1083 362 if (usePeaksCache) {
Chris@1083 363 divisor = m_sources.peaks->getColumnsPerPeak();
Chris@1083 364 sourceModel = m_sources.peaks;
Chris@1083 365 }
Chris@1083 366
Chris@1083 367 int psx = -1;
Chris@1083 368
Chris@1083 369 int start = 0;
Chris@1083 370 int finish = w;
Chris@1083 371 int step = 1;
Chris@1083 372
Chris@1083 373 if (rightToLeft) {
Chris@1083 374 start = w-1;
Chris@1083 375 finish = -1;
Chris@1083 376 step = -1;
Chris@1083 377 }
Chris@1083 378
Chris@1083 379 int columnCount = 0;
Chris@1083 380
Chris@1083 381 vector<float> preparedColumn;
Chris@1083 382
Chris@1083 383 for (int x = start; x != finish; x += step) {
Chris@1083 384
Chris@1083 385 // x is the on-canvas pixel coord; sx (later) will be the
Chris@1083 386 // source column index
Chris@1083 387
Chris@1083 388 ++columnCount;
Chris@1083 389
Chris@1083 390 if (binforx[x] < 0) continue;
Chris@1083 391
Chris@1083 392 int sx0 = binforx[x] / divisor;
Chris@1083 393 int sx1 = sx0;
Chris@1083 394 if (x+1 < w) sx1 = binforx[x+1] / divisor;
Chris@1083 395 if (sx0 < 0) sx0 = sx1 - 1;
Chris@1083 396 if (sx0 < 0) continue;
Chris@1083 397 if (sx1 <= sx0) sx1 = sx0 + 1;
Chris@1083 398
Chris@1083 399 vector<float> pixelPeakColumn;
Chris@1083 400
Chris@1083 401 for (int sx = sx0; sx < sx1; ++sx) {
Chris@1083 402
Chris@1083 403 #ifdef DEBUG_SPECTROGRAM_REPAINT
Chris@1083 404 // cerr << "sx = " << sx << endl;
Chris@1083 405 #endif
Chris@1083 406
Chris@1083 407 if (sx < 0 || sx >= sourceModel->getWidth()) {
Chris@1083 408 continue;
Chris@1083 409 }
Chris@1083 410
Chris@1083 411 if (sx != psx) {
Chris@1083 412
Chris@1083 413 // order:
Chris@1083 414 // get column -> scale -> record extents ->
Chris@1083 415 // normalise -> peak pick -> apply display gain ->
Chris@1083 416 // distribute/interpolate
Chris@1083 417
Chris@1083 418 ColumnOp::Column fullColumn = sourceModel->getColumn(sx);
Chris@1083 419 ColumnOp::Column column =
Chris@1083 420 vector<float>(fullColumn.data() + minbin,
Chris@1083 421 fullColumn.data() + maxbin + 1);
Chris@1083 422
Chris@1083 423 //!!! fft scale if (m_colourScale != PhaseColourScale) {
Chris@1083 424 // column = ColumnOp::fftScale(column, m_fftSize);
Chris@1083 425 // }
Chris@1083 426
Chris@1083 427 //!!! extents recordColumnExtents(column,
Chris@1083 428 // sx,
Chris@1083 429 // overallMag,
Chris@1083 430 // overallMagChanged);
Chris@1083 431
Chris@1083 432 // if (m_colourScale != PhaseColourScale) {
Chris@1083 433 column = ColumnOp::normalize(column, m_params.normalization);
Chris@1083 434 // }
Chris@1083 435
Chris@1083 436 if (m_params.binDisplay == PeakBins) {
Chris@1083 437 column = ColumnOp::peakPick(column);
Chris@1083 438 }
Chris@1083 439
Chris@1083 440 preparedColumn =
Chris@1083 441 ColumnOp::distribute(column, //!!! gain? ColumnOp::applyGain(column, m_gain),
Chris@1083 442 h,
Chris@1083 443 binfory,
Chris@1083 444 minbin,
Chris@1083 445 m_params.interpolate);
Chris@1083 446
Chris@1083 447 psx = sx;
Chris@1083 448 }
Chris@1083 449
Chris@1083 450 if (sx == sx0) {
Chris@1083 451 pixelPeakColumn = preparedColumn;
Chris@1083 452 } else {
Chris@1083 453 for (int i = 0; in_range_for(pixelPeakColumn, i); ++i) {
Chris@1083 454 pixelPeakColumn[i] = std::max(pixelPeakColumn[i],
Chris@1083 455 preparedColumn[i]);
Chris@1083 456 }
Chris@1083 457 }
Chris@1083 458 }
Chris@1083 459
Chris@1083 460 if (!pixelPeakColumn.empty()) {
Chris@1083 461 for (int y = 0; y < h; ++y) {
Chris@1083 462 m_drawBuffer.setPixel
Chris@1083 463 (x,
Chris@1083 464 h-y-1,
Chris@1083 465 m_params.colourScale.getPixel(pixelPeakColumn[y]));
Chris@1083 466 }
Chris@1083 467 }
Chris@1083 468
Chris@1083 469 double fractionComplete = double(columnCount) / double(w);
Chris@1083 470 if (timer.outOfTime(fractionComplete)) {
Chris@1083 471 return columnCount;
Chris@1083 472 }
Chris@1083 473 }
Chris@1083 474
Chris@1083 475 return columnCount;
Chris@1083 476 }
Chris@1083 477
Chris@1079 478 void
Chris@1079 479 Colour3DPlotRenderer::clearDrawBuffer(int w, int h)
Chris@1079 480 {
Chris@1079 481 if (m_drawBuffer.width() < w || m_drawBuffer.height() != h) {
Chris@1079 482
Chris@1079 483 m_drawBuffer = QImage(w, h, QImage::Format_Indexed8);
Chris@1079 484
Chris@1079 485 for (int pixel = 0; pixel < 256; ++pixel) {
Chris@1079 486 //!!! todo: colour rotation (here 0)
Chris@1079 487 m_drawBuffer.setColor
Chris@1079 488 ((unsigned char)pixel,
Chris@1079 489 m_params.colourScale.getColourForPixel(pixel, 0).rgb());
Chris@1079 490 }
Chris@1079 491 }
Chris@1079 492
Chris@1079 493 m_drawBuffer.fill(0);
Chris@1079 494 }
Chris@1079 495
Chris@1079 496