MCPcopy Create free account
hub / github.com/cpvrlab/ImagePlay / paintEvent

Method paintEvent

ImagePlay/src/IPZoomWidget.cpp:89–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87}
88
89void IPZoomWidget::paintEvent(QPaintEvent*)
90{
91 if(!_image)
92 return;
93
94 if(!_zoomUpdateMutex->tryLock())
95 return;
96
97 QPainter painter(this);
98 QBrush brush(Qt::black);
99 QColor highlightColor(Qt::red);
100
101 int cellWidth = width()/(2*_columnOffset+1);
102
103 int rectX = 0;
104 int rectY = 0;
105 for(int offsetY=-_columnOffset; offsetY <= _columnOffset; offsetY++)
106 {
107 for(int offsetX=-_columnOffset; offsetX <= _columnOffset; offsetX++)
108 {
109 uchar r = 0;
110 uchar g = 0;
111 uchar b = 0;
112
113 int nrOfPlanes = _image->getNumberOfPlanes();
114 if( _image->type() == IPL_IMAGE_COLOR)
115 {
116 //uchar test = *_image->rgb32() + (_x+offsetX)*_image->height() + (_y+offsetY);
117 r = _image->plane(0)->cp(_x+offsetX, _y+offsetY) * FACTOR_TO_UCHAR;
118 g = _image->plane(1)->cp(_x+offsetX, _y+offsetY) * FACTOR_TO_UCHAR;
119 b = _image->plane(2)->cp(_x+offsetX, _y+offsetY) * FACTOR_TO_UCHAR;
120
121 highlightColor = QColor(255-r, 255-g, 255-b);
122 }
123 else if( _image->type() == IPL_IMAGE_GRAYSCALE || _image->type() == IPL_IMAGE_BW )
124 {
125 r = g = b = _image->plane(0)->cp(_x+offsetX, _y+offsetY) * FACTOR_TO_UCHAR;
126
127 highlightColor = QColor(255, 0, 0);
128 }
129
130 else if( _image->type() == IPL_IMAGE_ORIENTED )
131 {
132 r = g = b = _image->plane(0)->cp(_x+offsetX, _y+offsetY) * FACTOR_TO_UCHAR;
133
134 highlightColor = QColor(255, 0, 0);
135 }
136
137 brush.setColor(QColor(r, g, b));
138 painter.fillRect(rectX+1, rectY+1, cellWidth-1, cellWidth-1, brush);
139
140 // center
141 if(offsetX == 0 && offsetY == 0)
142 {
143 painter.setPen(highlightColor);
144 painter.drawRect(rectX, rectY, cellWidth, cellWidth);
145 }
146

Callers

nothing calls this directly

Calls 3

planeMethod · 0.80
widthFunction · 0.50
typeMethod · 0.45

Tested by

no test coverage detected