Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-swt-dev] SWT ImageData -- How to obtain number of channels



Hi, all:

I'm wondering how I can obtain the number of channels for a loaded image, using SWT technology.

Let's have a look at the following website first.
[url="" href="http://www.eclipse.org/articles/Article-SWT-images/graphics-resources.html#ImageData">http://www.eclipse.org/articles/Article-SWT-images/graphics-resources.html#ImageData] http://www.eclipse.org/articles/Article-SWT-images/graphics- resources.html#ImageData[/url]

By using 
[code]
ImageData ideaImageData = new ImageData(
    getClass().getResourceAsStream("Idea.jpg"));[/code]

we loaded an image and stored in [code]ImageData ideaImageDat[/code]

In Eclipse' documentation at
[url="" href="http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/overview-summary.html">http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/overview-summary.html] http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/reference/api/overview-summary.html[/url]

Nothing can be found to tell "number of image channels", in the class "ImageData".

What I would like to find is something like a function getNbOfChannels();

If the loaded image "idea.jpg" is a color image, then, the function returns 3
If it is a gray image, then, the function returns 1.


Can anybody help to give me a hand ?

Cheers
JIA Pei






--
Welcome to Vision Open
http://www.visionopen.com

Back to the top