Page 2 of 2 FirstFirst 12
Results 21 to 35 of 35

Thread: How to threading data in app?

  1. #21
    Join Date
    Oct 2013
    Location
    VietNam
    Posts
    41
    Thanks
    3
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Windows Android

    Default Re: How to threading data in app?

    Quote Originally Posted by wysota View Post
    How is the gradient implemented?
    Qt Code:
    1. gradient: Gradient {
    2. id: id0
    3. GradientStop {
    4. position: 0.0
    5. id: id1
    6. SequentialAnimation on color {
    7. id: update1
    8. loops: Animation.Infinite
    9. ColorAnimation { from: "red"; to: "magenta"; duration: 1000}
    10. ColorAnimation { from: "magenta"; to: "blue"; duration: 1000}
    11. ColorAnimation { from: "blue"; to: "cyan"; duration: 1000}
    12. ColorAnimation { from: "cyan"; to: "lime"; duration: 1000}
    13. ColorAnimation { from: "lime"; to: "yellow"; duration: 1000}
    14. ColorAnimation { from: "yellow"; to: "red"; duration: 1000}
    15. }
    16. }
    17. GradientStop {
    18. position: 1
    19. id: id2
    20. SequentialAnimation on color {
    21. id: update2
    22. loops: Animation.Infinite
    23. ColorAnimation { from: "yellow"; to: "red"; duration: 1000}
    24. ColorAnimation { from: "red"; to: "magenta"; duration: 1000}
    25. ColorAnimation { from: "magenta"; to: "blue"; duration: 1000}
    26. ColorAnimation { from: "blue"; to: "cyan"; duration: 1000}
    27. ColorAnimation { from: "cyan"; to: "lime"; duration: 1000}
    28. ColorAnimation { from: "lime"; to: "yellow"; duration: 1000}
    29. }
    30.  
    31. }
    To copy to clipboard, switch view to plain text mode 
    This is one example. I have get color pixel of screen another effect.

  2. #22
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #23
    Join Date
    Oct 2013
    Location
    VietNam
    Posts
    41
    Thanks
    3
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Windows Android

    Default Re: How to threading data in app?

    Quote Originally Posted by wysota View Post
    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

    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.
    Last edited by tanthinh1510; 2nd April 2015 at 10:11.

  4. #24
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #25
    Join Date
    Oct 2013
    Location
    VietNam
    Posts
    41
    Thanks
    3
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Windows Android

    Default Re: How to threading data in app?

    Quote Originally Posted by wysota View Post
    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
    Qt Code:
    1. HWND name = FindWindow(NULL,L"Lighting Player");
    2. HDC dc = GetDC(name);
    3. COLORREF color = GetPixel(dc, _x, _y );
    To copy to clipboard, switch view to plain text mode 
    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?

  6. #26
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to threading data in app?

    Quote Originally Posted by tanthinh1510 View Post
    it can get a large number of pixels in a small period of time?
    I bet it can.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #27
    Join Date
    Oct 2013
    Location
    VietNam
    Posts
    41
    Thanks
    3
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Windows Android

    Default Re: How to threading data in app?

    Quote Originally Posted by wysota View Post
    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"?

  8. #28
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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.
    Last edited by wysota; 3rd April 2015 at 11:07.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #29
    Join Date
    Oct 2013
    Location
    VietNam
    Posts
    41
    Thanks
    3
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Windows Android

    Default Re: How to threading data in app?

    Quote Originally Posted by wysota View Post
    QQuickWindow::setRenderTarget() (make sure you understand the warning in the docs) and optionally you can see if QQuickWindow::grabWindow() is fast enough for you.
    I used QQuickWindow::grabWindow() and my code
    Qt Code:
    1. void getScreen::getpixel(int _x, int _y)
    2. {
    3. QQuickWindow screen;
    4. QImage imageScreen = screen.grabWindow();
    5. COLORREF color = imageScreen.pixel(_x,_y);
    6. int _red = GetRValue(color);
    7. int _green = GetGValue(color);
    8. int _blue = GetBValue(color);
    9. QColor c1;
    10. c1.setRgb(_red, _green, _blue);
    11. qDebug() << c1.name();
    12. }
    To copy to clipboard, switch view to plain text mode 
    result is
    Qt Code:
    1. QQuickWindow::grabWindow: scene graph already in use
    2. QImage::pixel: coordinate (39,72) out of range
    To copy to clipboard, switch view to plain text mode 
    I don't know warning
    Warning: This function can only be called from the GUI thread

  10. #30
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #31
    Join Date
    Oct 2013
    Location
    VietNam
    Posts
    41
    Thanks
    3
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Windows Android

    Default Re: How to threading data in app?

    Quote Originally Posted by wysota View Post
    Where are you calling this function?
    I call when I click in rectangle
    Qt Code:
    1. Rectangle {
    2. width: 360
    3. height: 360
    4. MouseArea {
    5. anchors.fill: parent
    6. onClicked: {
    7. _getScreen.getpixel(mouse.x,mouse.y)
    8. }
    9. }
    10. }
    To copy to clipboard, switch view to plain text mode 

  12. #32
    Join Date
    Oct 2013
    Location
    VietNam
    Posts
    41
    Thanks
    3
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Windows Android

    Default 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?

  13. #33
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to threading data in app?

    Render the scene to an FBO
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  14. #34
    Join Date
    Oct 2013
    Location
    VietNam
    Posts
    41
    Thanks
    3
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Windows Android

    Default Re: How to threading data in app?

    Quote Originally Posted by wysota View Post
    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.

  15. #35
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to threading data in app?

    Did you try using setRenderTarget as advised?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Threading with rsh and rcp
    By jaxrpc in forum Newbie
    Replies: 2
    Last Post: 4th June 2010, 12:50
  2. Threading...?
    By sekatsim in forum Qt Programming
    Replies: 12
    Last Post: 10th June 2008, 02:14
  3. Qt Threading
    By avh in forum Newbie
    Replies: 7
    Last Post: 30th May 2008, 21:20
  4. I'm failing with Threading
    By thomaspu in forum Qt Programming
    Replies: 2
    Last Post: 11th January 2008, 20:40
  5. Sub-Threading
    By TheGrimace in forum Qt Programming
    Replies: 4
    Last Post: 7th June 2007, 17:38

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.