[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Preserve transparency ico->png

Hi, I want to convert an image from ICO to PNG w/ SWT and preserve the transparency. I have the following code, but the images end up with a black background:


import org.apache.commons.httpclient.Header; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpState; import org.apache.commons.httpclient.SimpleHttpConnectionManager; import org.apache.commons.httpclient.methods.*; import org.eclipse.swt.*; import org.eclipse.swt.graphics.*;

try
{
SimpleHttpConnectionManager connectionManager = new SimpleHttpConnectionManager();


HttpClient httpClient = new HttpClient(connectionManager);

GetMethod get = new GetMethod("http://www.qrowd.com/favicon.ico";);
get.setFollowRedirects(true);
get.setRequestHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows 2000)");

httpClient.executeMethod(get);


ImageData imagedata = new ImageData(get.getResponseBodyAsStream());
ImageLoader imageLoader = new ImageLoader();
imageLoader.data = new ImageData[] {imagedata};
			    	    	
imageLoader.save("output.png", SWT.IMAGE_PNG);
}
catch (Exception e)
{
System.out.println(e.toString());
}


I've done all the Googling I could do, but couldn't find a solution. Any help would be much appreciated.


Thanks,

Robert