Results 1 to 10 of 10

Thread: Image Converting and color problem

  1. #1
    Join Date
    Oct 2009
    Posts
    30
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Image Converting and color problem

    Hi all,

    I have an image and convert 32 bit to 8 bit. I convert this image from photoshop and photoshop is success convert but i convert to image so change color. For example;



    Code is;

    Qt Code:
    1. void image::convertimage(QString pathAddress,QString imageName)
    2. {
    3. QImage img = QImage(pathAddress + imageName);
    4.  
    5. img = img.convertToFormat(QImage::Format_Indexed8,Qt::ThresholdDither|Qt::AutoColor);
    6. img.save("D:\\image\\out\\"+ imageName, "png", 100);
    7. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Image Converting and color problem

    You can try to specify your own color table by using this version of convertToFormat(), if the default color table doesn't fit your needs.
    See also:
    http://doc.trolltech.com/4.4/qimage....l-manipulation
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

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

    electronicboy (2nd November 2009)

  4. #3
    Join Date
    Oct 2009
    Posts
    30
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Image Converting and color problem

    Allright it's great. How can I find the used color from image?

  5. #4
    Join Date
    Oct 2009
    Posts
    30
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Image Converting and color problem

    Hi all,

    I don't found function for used color. And I think I seek all pixel and find unique color. How can I get pixel color fast?

  6. #5
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Image Converting and color problem

    I am sorry, but I don't quite understand, can you restate the question?

    In general though, if the Qt supplied function is not good enough for your case, you can do the conversion your self, by iterating through the image - read the QImage documentation on how to access each pixel and how to set pixel values.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  7. #6
    Join Date
    Oct 2009
    Posts
    30
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Image Converting and color problem

    hi @high_flyer,

    I want to find the colors in the image. is there any function for this. if there is not a function for this how can i inspect the colors pixel by pixel.

    Thanks

  8. #7
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Image Converting and color problem

    Yes there is a method for it - READ the QImage DOCUMENTATION!!
    http://doc.trolltech.com/4.4/qimage....l-manipulation
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  9. #8
    Join Date
    Oct 2009
    Posts
    30
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Image Converting and color problem

    I read and I don't see getPixel :S

    "To alter or add a color to an image's color table, use the setColor () function."

    But I want to pixel color
    Last edited by electronicboy; 3rd November 2009 at 10:30.

  10. #9
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Image Converting and color problem

    reading doesn't mean to look for the function names YOU think are used, but to read the WHOLE class documentation, then you will know how and what you can do with the class!
    http://doc.trolltech.com/4.4/qimage.html#pixel-2
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  11. #10
    Join Date
    Oct 2009
    Posts
    30
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Image Converting and color problem

    I forgot to tell I read again and I see pixel function. Also my english is not good. And I am a C#.net developer. I don't use .net. I write the programe in .net and i wrote again in qt. I'm trying to learn qt. Thanks for your's approach and supports.
    Last edited by electronicboy; 3rd November 2009 at 11:31.

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.