PDA

View Full Version : Image Converting and color problem



electronicboy
2nd November 2009, 10:19
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;

http://img402.imageshack.us/img402/5439/colorproblem.png

Code is;



void image::convertimage(QString pathAddress,QString imageName)
{
QImage img = QImage(pathAddress + imageName);

img = img.convertToFormat(QImage::Format_Indexed8,Qt::Th resholdDither|Qt::AutoColor);
img.save("D:\\image\\out\\"+ imageName, "png", 100);
}

high_flyer
2nd November 2009, 15:24
You can try to specify your own color table by using this (http://doc.trolltech.com/4.4/qimage.html#convertToFormat-2) version of convertToFormat(), if the default color table doesn't fit your needs.
See also:
http://doc.trolltech.com/4.4/qimage.html#pixel-manipulation

electronicboy
2nd November 2009, 17:55
Allright it's great. How can I find the used color from image?

electronicboy
3rd November 2009, 09:43
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?

high_flyer
3rd November 2009, 10:55
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.

electronicboy
3rd November 2009, 11:03
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

high_flyer
3rd November 2009, 11:08
Yes there is a method for it - READ the QImage DOCUMENTATION!!
http://doc.trolltech.com/4.4/qimage.html#pixel-manipulation

electronicboy
3rd November 2009, 11:20
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

high_flyer
3rd November 2009, 11:50
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

electronicboy
3rd November 2009, 12:21
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.