Results 1 to 3 of 3

Thread: QPainter doing a distortion in drawed pixmap

  1. #1
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Unhappy QPainter doing a distortion in drawed pixmap

    Hello!

    I'm facing a strange problem with QPainter::drawPixmap usage. To use my debug situation, I downloaded a common-random bitmap (.bmp) from the web into my PC and put it in a subdirectory. If I call QPixmap::drawPixmap with a unaltered QPixmap created with the bitmap's file, it is drawed correctly on screen.

    The problem is that I need to do some edittings on it and for that I'm using GIMP (I'm working in Linux). So, if I do such edittings (and, in accordance to my tests, actually any edit at all with GIMP) and then I try to print the image again using the same code, I get a blue-unchanged image instead o.O

    Here is a print screen comparing the changed file with the original one:

    asdasda.png

    And here a print of the two files in the system folder, in the same order:

    ddddd.png

    At least visually one can see that is not GIMP who is distorting the image (and I actually found no reason for believing so).



    I'm glad for any help in trying to solve this problem!

    Momergil


    ------
    Edit: Now I did other tests and I'm beginning to think that it's GIMP fault (while I don't have here any other image editor for linux to do the final checking and don't know which to download). Here are two other images comparing what I got and what Qt shows:

    A.png

    And in the directory:

    B.png

    The most interesting here is the last files, when I just opened the image in GIMP and clicked int File->Overwrite (without any edit) and this was enough for QPainter to draw the pixmap with that "blue color effect" :/
    Last edited by Momergil; 11th July 2014 at 19:27.
    May the Lord be with you. Always.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QPainter doing a distortion in drawed pixmap

    Since we do not have the original BMP file, your code, or any idea what you are doing in Gimp, it is difficult to say.

    It looks like the blue and red channels have been swapped. It also looks like you are fiddling with an alpha channel and this might cause a problem with BMP handling in Qt. If you convert to PNG then you might find the image works better.

  3. #3
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QPainter doing a distortion in drawed pixmap

    Quote Originally Posted by ChrisW67 View Post
    Since we do not have the original BMP file, your code, or any idea what you are doing in Gimp, it is difficult to say.
    Well, actually I didn't post any of this since there is no special thing about what I did. I mean, regarding the image in Gimp, as I sad, it was enough to just open the bitmap and save it again without any real change in the image that the problem would already arise. Regarding the code, once again no special thing here; only load the pixmap with the file path and use QPainter::drawPixmap on it inside a paint event.

    Quote Originally Posted by ChrisW67 View Post
    If you convert to PNG then you might find the image works better.
    Well you're correct about that (I was avoiding PNG conversion because this project is not mine since its birth and it seems a convention that only bitmap images should be used); if I use a PNG image, then the blue effect doesn't appear anymore, but the real effect I want to implement (rounded corners) don't appear (I mean, I put the rounded corners but the image shown in the app is with squared corners as the original)

    So I'll try another way of doing the round corners.

    Thanks,

    Momergil


    EDIT: Btw, isn't there a way to do this rounded corners effect on Qt?
    EDIT 2: Well actually there is a small "non-normality" that is actually causing the problem:

    Qt Code:
    1. #define SET_PIXMAP(_s) QPixmap::fromImage(QPixmap(_s).toImage().convertToFormat(QImage::Format_RGB16))
    To copy to clipboard, switch view to plain text mode 

    I use such define where I load the QPixmap in order to force a RGB16 image since the hardware used in this project only supports such RGB configuration. If this is set, the rounded corners don't appear.
    Last edited by Momergil; 14th July 2014 at 14:12.
    May the Lord be with you. Always.

Similar Threads

  1. QPainter over Pixmap problem
    By seany in forum Qt Programming
    Replies: 3
    Last Post: 16th June 2013, 20:18
  2. Replies: 1
    Last Post: 27th April 2012, 16:01
  3. QPainter::begin: Cannot paint on a null pixmap
    By sabeesh in forum Qt Programming
    Replies: 5
    Last Post: 27th July 2010, 19:03
  4. QPainter ouside of paintEvent with a pixmap
    By bitChanger in forum Qt Programming
    Replies: 10
    Last Post: 22nd March 2006, 20:45

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.