Results 1 to 2 of 2

Thread: Paint to pixmap directly

  1. #1
    Join Date
    Feb 2008
    Posts
    157
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Paint to pixmap directly

    Currently I create an QImage first and pass that to a pixmap. This is done with this code:
    Qt Code:
    1. QImage QRgbMatrix::toImage()
    2. {
    3. QImage image = QImage(m_size_x, m_size_y, QImage::Format_RGB32);
    4.  
    5. int r, g, b; r = g = b = 0;
    6. for ( int y = 0; y < m_size_y; y++ )
    7. {
    8. QRgb *line = (QRgb *)image.scanLine(y) ;
    9. for ( int x = 0; x < m_size_x; x++ )
    10. {
    11. int pos = ArrPos(x,y);
    12.  
    13. r = d->red[pos];
    14. g = d->green[pos];
    15. b = d->blue[pos];
    16.  
    17. *line++ = qRgb(r, g, b);
    18.  
    19. }
    20. }
    21. return image;
    22. }
    23.  
    24. QPixmap QRgbMatrix::toPixmap()
    25. {
    26. return QPixmap::fromImage(toImage());
    27. }
    To copy to clipboard, switch view to plain text mode 

    Now my question is, if it would be possible to create a pixmap image without creating an QImage first.
    My main concern about the QImage step is the time required for the conversions.

  2. #2
    Join Date
    Feb 2008
    Posts
    157
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Paint to pixmap directly

    I finished my application to work with the camera it shall images of. I experience a total time for the image creation (ToImage() function) of 200 ms (release) for a 5 MP image. Is there a general possibility to speed up this code?

Similar Threads

  1. QPainter::begin: Cannot paint on a null pixmap
    By sabeesh in forum Qt Programming
    Replies: 5
    Last Post: 27th July 2010, 18:03
  2. Set QHash and QMap value directly
    By wirasto in forum Qt Programming
    Replies: 2
    Last Post: 17th December 2009, 19:21
  3. How do I paint directly ina QGraphcicsView?
    By extrakun in forum Qt Programming
    Replies: 3
    Last Post: 13th July 2009, 09:12
  4. Paint XP radio button to pixmap
    By Ben.Hines in forum Qt Programming
    Replies: 2
    Last Post: 26th April 2006, 21:15
  5. How to paint a selection rectangle on a pixmap?
    By SkripT in forum Qt Programming
    Replies: 6
    Last Post: 8th January 2006, 19:52

Tags for this Thread

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.