Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] SWT getImageData().type always -1


If you care about the type of file an Image was read from, you need to read it into an ImageData first, and then create your Image from that.
(as opposed to reading directly from file into an Image). Image class does not retain information about where the Image originally came from. Only ImageData class does that.

        ImageData data = "" ImageData("C:\\graphic.bmp");
        Image image = new Image(device, data);
        // At this point, data.type will be SWT.IMAGE_BMP
        // and image.getImageData().type will be -1 (SWT.IMAGE_UNDEFINED)

See org.eclipse.swt.examples.imageanalyzer.ImageAnalyzer (available in the eclipse examples zip on the eclipse download page) for an example that reads from file into an ImageData and then gets the Image from the ImageData.

Carolyn



Philipp Schneider <eclipse-swt-dev@xxxxxxxxxxxxxxxxxxxxxxxxxx>
Sent by: platform-swt-dev-admin@xxxxxxxxxxx

11/23/2004 06:50 PM

Please respond to
platform-swt-dev

To
platform-swt-dev@xxxxxxxxxxx
cc
Subject
[platform-swt-dev] SWT getImageData().type always -1





Hello.

I am using SWT to do a project for college.
The method getImageData().type from Image Object will ALWAYS return -1.
If I load a Image Object from a byte[] or from a File it is always -1. I
can see jpeg and gif, but type is always -1.
Is that a bug, or am I stupid ? :-)
Is there another way to find out what type a image it is?

thanks
Phil

_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/platform-swt-dev


Back to the top