Results 1 to 6 of 6

Thread: Filling QPixmap from an unsigned short array? QPixmap size limitations?

  1. #1
    Join Date
    Dec 2006
    Posts
    160
    Thanks
    33
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Filling QPixmap from an unsigned short array? QPixmap size limitations?

    Hello,

    My questions are fast and simple ^^

    1a) Is there any way to fill a QPixmap from 3 unsigned shorts arrays (Each pixel has 16 bits per channel)? Of course i'm not talking of iterating on each pixel with a QPainter, doing a setPen with my 3 channels colors, and then a drawPoint on the QPixmap, since it's way too slow...

    1b) Each of my channel can have a value between 0 and 65535 (16 bits). So i'm talking about a very "fast conversion copy", changing from 16 bits in original to 8 in the QPixmap.

    1c) If the answer is clearly no, does the same question but with shorts instead of unsigned shorts have another answer? ^^

    Telling me to "change to 8 bits per channel because the human eye only perceive N colors" is not an answer for me, since it's not related to human eye but to medical images processment... 16 bits per channel i have no choice ^^

    2) Also, i have read somewhere that a QPixmap is limited in size to 2000x2000 pixels... Is it true? If yes, is there a workaround for this, knowing i'm using the QPixmap in a QGraphicsView linked to a QGraphicsScene?

    Thanks for your answers.
    Pierre.
    Last edited by hickscorp; 9th April 2007 at 00:48.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Filling QPixmap from an unsigned short array? QPixmap size limitations?

    It looks like such format isn't supported by QImage and you can create pixmaps only for data in the format for which a plugin exists.

    Maybe you can try CreateBitmap() and QPixmap::fromWinHBITMAP()?

    Another way is OpenGL.

  3. The following user says thank you to jacek for this useful post:

    hickscorp (9th April 2007)

  4. #3
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Filling QPixmap from an unsigned short array? QPixmap size limitations?

    Quote Originally Posted by hickscorp View Post
    2) Also, i have read somewhere that a QPixmap is limited in size to 2000x2000 pixels... Is it true? If yes, is there a workaround for this, knowing i'm using the QPixmap in a QGraphicsView linked to a QGraphicsScene?
    Yes, it happened to me. But the limitation is not strictly 2000x2000. On some computers was smaller.

    The workaround depends on what you are doing. I was drawing a very long raster on a widget ( sometimes 5-6000 pixels ). I solved it by splitting this one pixmap into an array of pixmaps, each 500 pixels wide ( could have been bigger, but just to be sure ). The, I painted all the pixmaps in the array next to each other, to obtain the same efect as if there was only one pixmap.

  5. The following user says thank you to marcel for this useful post:

    hickscorp (9th April 2007)

  6. #4
    Join Date
    Dec 2006
    Posts
    160
    Thanks
    33
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Filling QPixmap from an unsigned short array? QPixmap size limitations?

    Hello and thanks for replying ^^

    Jacek:
    i can't use the QPixmap::fromWinHBITMAP() method, since the application is not windows only (Photoshop runs on Mac too, and there will probably be a non-plugin version of the application in the nearby future).
    Now i see you suggest me to use OpenGL. I have a few questions about this:
    The application is aimed to be deployed on computers which have reasonable RAM and CPU... However, we can't be sure of the video card. So if i use OpenGL and the user has a "crappy" video card, what will happend?
    About using OpenGL, what do you suggest? Using two OpenGL viewports (2D), and drawing on a "texture" (My knowledge of OpenGL is very low... If you have any suggestions i will appreciate you go further in details ^^)?

    Marcel:
    Your suggestion sounds very nice, so here is a question relative to your answer:
    Let's suppose i have a 1600*1200 picture. i will split it onto 500x500 blocks as you say "to be sure". Then i'll draw those blocks on my graphic scene, but what will happend if the user zoom to the "glued" parts of the blocks? Did you try successfully this? Did some "white lines glitch" appear?

    Thanks again!
    Pierre.

  7. #5
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Filling QPixmap from an unsigned short array? QPixmap size limitations?

    As I said, I was drawing on a widget( a QAbstractButton ), so no zooming occurred in my case.

    However, using a QGraphicsView, if the integer distance between the blocks is 0 or the floating point distance is as close as possible to 0 then I tend to believe no background will show through. All I am trying to say is to make the distance between the blocks
    as small as possible ( 0 if you can ).

    I used the (500, 500) size because I had no way of knowing exactly the limitation, so this size seemed reasonable enough. BTW, the effect of large pixmaps is that they are not painted or if you try to paint inside the pixmap something Qt will crash( somewhere in QPaintEngine ).

    Regards

  8. The following user says thank you to marcel for this useful post:

    hickscorp (14th April 2007)

  9. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Filling QPixmap from an unsigned short array? QPixmap size limitations?

    Quote Originally Posted by hickscorp View Post
    i can't use the QPixmap::fromWinHBITMAP() method, since the application is not windows only
    There's also QPixmap::fromMacCGImageRef(), so you could use both. Maybe the Trolls know how to create a QPixmap with arbitrary depth?

    Quote Originally Posted by hickscorp View Post
    So if i use OpenGL and the user has a "crappy" video card, what will happend?
    You are not going to use any 3D stuff, so the only problem might be the maximum texture size.

    Although OpenGL can store textures in RGB16 and RGBA16 formats, it seems that there is no direct way to feed it with such data. Take a look at glDrawPixels() and glTexImage2D(), you might be able to draw one 16bit component at a time and with help of blending you should get original image.

  10. The following user says thank you to jacek for this useful post:

    hickscorp (14th April 2007)

Similar Threads

  1. failing to achieve desired size of a BitField structure
    By nass in forum General Programming
    Replies: 8
    Last Post: 13th February 2007, 14:29
  2. unable to save QCStrings properly in a buffer
    By nass in forum Qt Programming
    Replies: 13
    Last Post: 15th November 2006, 21:49
  3. Tiff in unsigned short
    By spawnwj in forum Qt Programming
    Replies: 14
    Last Post: 26th July 2006, 08:41
  4. How to create QPixmap from unsigned character array?
    By rashidbutt in forum Qt Programming
    Replies: 4
    Last Post: 16th May 2006, 19:25

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.