Results 1 to 6 of 6

Thread: QImage, PNG ad Transparency

  1. #1
    Join Date
    May 2011
    Posts
    2
    Qt products
    Qt4

    Default QImage, PNG ad Transparency

    Hi!

    I'm new to the forum and quite new to the Qt Programming.

    I've a problem with QImage.
    I need to draw an image (.png) with transparency.
    I've serched and read a lot of thread on this forum, but I did'nt found any solution.

    This is the code I used to load the image:

    Qt Code:
    1. imm=QImage(53,48,QImage::Format_ARGB32_Premultiplied);
    2. immGL=QImage(53,48,QImage::Format_ARGB32_Premultiplied);
    3.  
    4. imm.load("image.png", "PNG");
    5. immGL = QGLWidget::convertToGLFormat(imm);
    To copy to clipboard, switch view to plain text mode 


    This is the code to draw the image:


    Qt Code:
    1. glRasterPos2i(x0,y0);
    2. glDrawPixels(w, h, GL_RGBA, GL_UNSIGNED_BYTE, immGL.bits());
    To copy to clipboard, switch view to plain text mode 


    As a result, the image is drawn with all pixel that should be transparent converted to black.

    Any solutions?

    Thanks in advance,
    Rebe
    Last edited by high_flyer; 6th May 2011 at 10:09. Reason: code tags

  2. #2
    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: QImage, PNG ad Transparency

    This is not the fault of QImage but rather of the way you use it. Either your image.png doesn't contain transparency or information about it is lost in OpenGL. And first two lines of your first code snippet can be discarded as lines #4 and #5 respectively will overwrite the objects created earlier.
    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. #3
    Join Date
    May 2011
    Posts
    2
    Qt products
    Qt4

    Default Re: QImage, PNG ad Transparency

    Ok, thanks.
    I will check OpenGL options.

  4. #4
    Join Date
    Apr 2008
    Posts
    4
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QImage, PNG ad Transparency

    Hi, I've the same issue, did you solved it?
    What did you did?

    Thanks,
    GortiZ

  5. #5
    Join Date
    May 2014
    Posts
    2
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QImage, PNG ad Transparency

    hi i am very new to QT please help me on Immage reading(raw immage) from QT using QgraphisScreen as base calss and derived method from QGLWidget ... if provide me sample code or URL Thanks in advance ....

  6. #6
    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: QImage, PNG ad Transparency

    Qt Code:
    1. QImage img("path/to/image");
    To copy to clipboard, switch view to plain text mode 
    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. QWinWidget & transparency
    By kinju in forum Qt Programming
    Replies: 1
    Last Post: 8th June 2010, 12:07
  2. Transparency over video
    By Luc4 in forum Qt Programming
    Replies: 3
    Last Post: 20th May 2010, 10:38
  3. Transparency ... Again
    By EricF in forum Qt Programming
    Replies: 4
    Last Post: 1st December 2007, 19:52
  4. Replies: 3
    Last Post: 15th March 2006, 11:44
  5. transparency
    By roms18 in forum Qt Programming
    Replies: 2
    Last Post: 16th February 2006, 19: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.