Results 1 to 2 of 2

Thread: [SOLVED] QImage setPixel alpha issue

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2007
    Location
    Paris
    Posts
    459
    Thanks
    98
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5

    Default [SOLVED] QImage setPixel alpha issue

    Hi,

    I'm replacing pixels in a QImage using that code :

    Qt Code:
    1. for (int i = 0; i < height; i++)
    2. {
    3. for (int j = 0; j < width; j++)
    4. {
    5. int alpha = qAlpha(image.pixel(j, i));
    6. if (alpha > 0)
    7. {
    8. image.setPixel(j, i,
    9. qRgba(color.red(),
    10. color.green(),
    11. color.blue(),
    12. alpha));
    13. }
    14. }
    15. }
    16.  
    17. q->QPixmap::operator=(QPixmap::fromImage(image));
    To copy to clipboard, switch view to plain text mode 

    My image file is a PNG file.

    For some reason, everytime I replace a "transparent" pixel. The pixel goes black instead of the choosen color. Plain pixels are replaced fine.

    Any idea ?
    Last edited by bunjee; 19th September 2008 at 15:57.

Similar Threads

  1. QImage Issue
    By vishal.chauhan in forum Qt Programming
    Replies: 5
    Last Post: 5th February 2007, 04:29

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.