Results 1 to 2 of 2

Thread: [PyQt4]C array to QImage

  1. #1
    Join Date
    Jul 2009
    Posts
    1
    Qt products
    Platforms
    Windows

    Default [PyQt4]C array to QImage

    Hi,
    I am writing an application in PyQt which draws the MandlebrotSet fractal. If i use pure python the rendering of a 500x500 matrix takes approximately 20 sec So i wrote a C DLL which does the computations for 1 sec at most and saves the data in an array(char / int / void *, whatever you like). My question is how can i transfer the data from the array to a QImage object without iterating over each pixel i.e. how can i copy the whole block of data from the array to the QImage object.
    Also, if you have better ideas for faster computation, I'll be very thankful

  2. #2
    Join Date
    Jul 2009
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: [PyQt4]C array to QImage

    Have you tried the QImage(sip.voidptr data, int width, int height, Format format) constructor? The first argument, data, should be just what you're looking for: it's a void * pointing to the beginning of your data array. Be sure to set Format correctly, so that QImage knows how to interpret your data array.

    As for faster image computations: check out the Python Image Library (PIL). It's a powerful (and fast) module for image creation / manipulation. You should get a nice performance boost if you can use PIL for some of your work.

Similar Threads

  1. Replies: 12
    Last Post: 7th September 2011, 16:37
  2. Streaming QImage (QByteArray, QDataStream, QBuffer)
    By knarz in forum Qt Programming
    Replies: 5
    Last Post: 17th January 2009, 22:05
  3. Multiple QPainters on QImage
    By fire in forum Qt Programming
    Replies: 3
    Last Post: 14th August 2008, 13:10
  4. Writing Images using QImage from 2D Array
    By kaydknight in forum Qt Programming
    Replies: 1
    Last Post: 29th December 2007, 03:06
  5. QShared
    By sabeesh in forum Qt Programming
    Replies: 11
    Last Post: 11th October 2007, 12:40

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
  •  
Qt is a trademark of The Qt Company.