Re: How to threading data in app?
Quote:
Originally Posted by
wysota
How is the gradient implemented?
Code:
gradient: Gradient {
id: id0
GradientStop {
position: 0.0
id: id1
SequentialAnimation on color {
id: update1
loops: Animation.Infinite
ColorAnimation { from: "red"; to: "magenta"; duration: 1000}
ColorAnimation { from: "magenta"; to: "blue"; duration: 1000}
ColorAnimation { from: "blue"; to: "cyan"; duration: 1000}
ColorAnimation { from: "cyan"; to: "lime"; duration: 1000}
ColorAnimation { from: "lime"; to: "yellow"; duration: 1000}
ColorAnimation { from: "yellow"; to: "red"; duration: 1000}
}
}
GradientStop {
position: 1
id: id2
SequentialAnimation on color {
id: update2
loops: Animation.Infinite
ColorAnimation { from: "yellow"; to: "red"; duration: 1000}
ColorAnimation { from: "red"; to: "magenta"; duration: 1000}
ColorAnimation { from: "magenta"; to: "blue"; duration: 1000}
ColorAnimation { from: "blue"; to: "cyan"; duration: 1000}
ColorAnimation { from: "cyan"; to: "lime"; duration: 1000}
ColorAnimation { from: "lime"; to: "yellow"; duration: 1000}
}
}
This is one example. I have get color pixel of screen another effect.
Re: How to threading data in app?
It seems quite easy to calculate the color from such definition. You know the starting color, the ending color and the percentage of the gradient you are currently in.
Re: How to threading data in app?
Quote:
Originally Posted by
wysota
It seems quite easy to calculate the color from such definition. You know the starting color, the ending color and the percentage of the gradient you are currently in.
Yes! I can calculate gradient the color from the starting color and ending color. But random effect, I can't calculate color.
As this video
https://www.youtube.com/watch?v=vL7p-IsObj4
So I want get color of screen
Added after 15 minutes:
My problem is when I put <150 object to get color pixel of screen, it work ok. But when I put 500 - 1000 object, it's shaking shock
I need get color all object in 30 millisecond or less but 30 milisecond not enough to calculate all the object in list.
So I think threading data.
Re: How to threading data in app?
Then do as I told you in the beginning -- render the scene to an FBO, convert that to a QImage and use QImage::pixel() to get the color.
Re: How to threading data in app?
Quote:
Originally Posted by
wysota
Then do as I told you in the beginning -- render the scene to an FBO, convert that to a
QImage and use
QImage::pixel() to get the color.
it can get a large number of pixels in a small period of time?
I have to get color by function
Code:
HWND name = FindWindow(NULL,L"Lighting Player");
HDC dc = GetDC(name);
COLORREF color = GetPixel(dc, _x, _y );
But it but 30 millisecond not enough to calculate large object
I don't know what is "render the scene to an FBO"? Can you explain more?
Re: How to threading data in app?
Quote:
Originally Posted by
tanthinh1510
it can get a large number of pixels in a small period of time?
I bet it can.
Re: How to threading data in app?
Quote:
Originally Posted by
wysota
Then do as I told you in the beginning -- render the scene to an FBO, convert that to a
QImage and use
QImage::pixel() to get the color.
Can you for me example "render the scene to an FBO"?
Re: How to threading data in app?
QQuickWindow::setRenderTarget() (make sure you understand the warning in the docs) and optionally you can see if QQuickWindow::grabWindow() is fast enough for you.
Re: How to threading data in app?
Quote:
Originally Posted by
wysota
I used QQuickWindow::grabWindow() and my code
Code:
void getScreen::getpixel(int _x, int _y)
{
QQuickWindow screen;
QImage imageScreen
= screen.
grabWindow();
COLORREF color = imageScreen.pixel(_x,_y);
int _red = GetRValue(color);
int _green = GetGValue(color);
int _blue = GetBValue(color);
c1.setRgb(_red, _green, _blue);
qDebug() << c1.name();
}
result is
Code:
QQuickWindow::grabWindow: scene graph already in use
QImage::pixel: coordinate
(39,
72) out of range
I don't know warning
Quote:
Warning: This function can only be called from the GUI thread
Re: How to threading data in app?
Where are you calling this function? What is COLORREF? How in God's name am I supposed to make anything out of the code you post?
Re: How to threading data in app?
Quote:
Originally Posted by
wysota
Where are you calling this function?
I call when I click in rectangle
Code:
Rectangle {
width: 360
height: 360
MouseArea {
anchors.fill: parent
onClicked: {
_getScreen.getpixel(mouse.x,mouse.y)
}
}
}
Re: How to threading data in app?
Thanks wysota!
I used QQuickWindow::grabWindow() and it work ok. However when I minimize app, it do not work. How to it work when minimize app?
Re: How to threading data in app?
Render the scene to an FBO :)
Re: How to threading data in app?
Quote:
Originally Posted by
wysota
Render the scene to an FBO :)
I'm trying used it but I can't find document or example about it. Maybe a don't understand about it.
Re: How to threading data in app?
Did you try using setRenderTarget as advised?