R
R
Riateche2011-07-19 18:47:52
Qt
Riateche, 2011-07-19 18:47:52

Building and displaying a large image in Qt

My program builds an image with complex rules and then displays it in a QScrollArea. Now I do it like this:

  1. Create a QImage
  2. Filling with QImage::setPixel
  3. Add my widget (inherited from QWidget) and show it in QScrollArea
  4. Override paintEvent and use QPainter::drawImage to draw the visible area at the desired scale

By the way, is this the normal way or is there an easier way?

The problem is that QImage stores data in memory, and I might have very large images that won't fit in memory. We need an analogue of QImage, which stores data on disk. How can this be organized?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
Horse, 2011-07-19
@Riateche

Qt itself, as far as I understand, assumes that you will not draw a widget in QScrollArea, but inherit it from QAbstractScrollArea.
Regarding the display, there are 2 options:
1. Calculate on the go, it is very desirable with a video card. In this case, you do not need to store anything and there will be no problems with scrolling.
2. Calculate the image, break it into several segments (for example, 10,000 x 10,000 pixels). When rendering, load 1-4 necessary fragments and actually draw them.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question