views:

76

answers:

1

Greetings all,

Please refer to image at : http://i48.tinypic.com/316qb78.jpg

We are developing an application to extract cell edges from MRC images from electron microscope.

MRC file format stores volumetric pixel data (http://en.wikipedia.org/wiki/Voxel) and we simply use 3D char array(char***) to load and store data (gray scale values) from a MRC file.

As shown in the image,there are 3 viewers to display XY,YZ and ZX planes respectively. Scrollbars on the top of the viewers use to change the image slice along an axis.

Here is the steps we do when user changes the scrollbar position.

1) get the new scrollbar value.(this is the selected slice)

2) for the relavant plane (YZ,XY or ZX), generate (char* slice;) array for the selected slice by reading 3D char array (char***)

3) Create a new QImage* (Format_RGB888) and set pixel values by reading 'slice' (using img->setPixel(x,y,c);)

4) This new QImage* is painted in the paintEvent() method.

We are going to execute "edge-detection" process in a seperate thread since it is an intensive process.During this process we need to draw detected curve (set of pixels) on top of above QImage*.(as a layer).This means we need to call drawPoint() methods outside the QT thread.

Is it the best wayto use QImage for this case?

What is the best way to execute QT drawing methods from another thread?

thanks in advance,

+3  A: 

From documentation about QImage:

Because QImage is a QPaintDevice subclass, QPainter can be used to draw directly onto images. When using QPainter on a QImage, the painting can be performed in another thread than the current GUI thread.

Just create QPainter on you image and draw what you need.

Kamil Klimek
Note, though, that when you draw an image to the screen, you'll only get the current state of the image... painting more on the image won't change what is shown on the screen, unless you update the widget showing the image. Luckily, signal/slot or timer will solve that pretty easily.
Caleb Huitt - cjhuitt