mbasaglia / Qt-Color-Widgets

Color wheel widget and dialog for Qt
147 stars 54 forks source link

Colorwheel is very cpu intensiv #14

Closed J4nsen closed 7 years ago

J4nsen commented 9 years ago

Hi, thanks for you work!

I've a small project which displays in its mainwindow just a ColorWheel. When the widget is small everything works fine. But when maximizing the application the wheel gets very unresponsive, especially when using the circle around the triangle.

I'm on Kubuntu 15.04 with Qt 5.4.1.

I've noticed that bug #3 is very similar to this. Since it is closed, I assume that this one is different.

mbasaglia commented 9 years ago

The problem is that every time the hue changes, it has to re-calculate the colors for all the pixels in the square in the middle, which might be significant work if the widget is too big.

I'll take a look and try to optimize some things.

mbasaglia commented 9 years ago

For now I've fixed this by limiting the maximum size of the image I have to render, this will slightly degrade the quality if the widget is very large but it should make it way faster.

When I have more time I'll use OpenMP to use a bit of parallelism.

J4nsen commented 9 years ago

Awesome! Works perfectly :) Thanks

J4nsen commented 9 years ago

I get a lot of warnings, when the widget is smaller:

QImage::setPixel: coordinate (0,121) out of range
QImage::setPixel: coordinate (1,121) out of range
QImage::setPixel: coordinate (2,121) out of range
[...]
QImage::setPixel: coordinate (104,121) out of range

They appear only when the triangle is rotating.

mbasaglia commented 9 years ago

Fixed that

mbasaglia commented 7 years ago

I've optimized a bit the number of reallocations for the internal image buffer, so it should be a little bit more efficient now.