[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform.swt] Preserve transparency ico->png
|
- From: ryeager@xxxxxxxxx (Robert Yeager)
- Date: Mon, 13 Oct 2008 00:10:10 +0000 (UTC)
- Newsgroups: eclipse.platform.swt
- Organization: Eclipse
- User-agent: NewsPortal/0.36 (http://florian-amrhein.de/newsportal)
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