Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Image transparency problem - easy, I think
Image transparency problem - easy, I think [message #462744] Tue, 18 October 2005 14:10 Go to next message
Mark Victory is currently offline Mark Victory
Messages: 133
Registered: July 2009
Senior Member
I am using a suggestion that someone had on this board for copying an image
(.gif) to a new file.

Here's the code:

private void moveImage(Image image, String fileName)
{
//New image loader
ImageLoader imageSaver = new ImageLoader();

//image has been loaded from a .gif fi.e
ImageData idata = image.getImageData();

//Set the old image data into the loader and
imageSaver.data = new ImageData[]{idata};

//save as the new image.
imageSaver.save(path+File.separator+fileName+".gif",
SWT.IMAGE_JPEG);
}

The problem is that the background of the new image is black rather than
transparent.
I saw the information about the transparency bit but apparently, I'm not
smart enough to understand it. :-)

Any help would be appreciated.

Thanks,
Mark
Re: Image transparency problem - easy, I think - Still need help [message #462746 is a reply to message #462744] Tue, 18 October 2005 14:33 Go to previous messageGo to next message
Mark Victory is currently offline Mark Victory
Messages: 133
Registered: July 2009
Senior Member
I realized that I typed SWT.IMAGE_JPEG rather than SWT.IMAGE_GIF.
Thought I'd be all set.

However, now I get an error that the "depth is unsupported" on the
imageSaver.save( ) call. When I debug, the depth is 32. The image is a 256
color gif.

Now any ideas?

Thanks,
Mark

"Mark Victory" <mvictory@us.ibm.com> wrote in message
news:dj3dqh$m4b$1@news.eclipse.org...
>I am using a suggestion that someone had on this board for copying an image
>(.gif) to a new file.
>
> Here's the code:
>
> private void moveImage(Image image, String fileName)
> {
> //New image loader
> ImageLoader imageSaver = new ImageLoader();
>
> //image has been loaded from a .gif fi.e
> ImageData idata = image.getImageData();
>
> //Set the old image data into the loader and
> imageSaver.data = new ImageData[]{idata};
>
> //save as the new image.
> imageSaver.save(path+File.separator+fileName+".gif",
> SWT.IMAGE_JPEG);
> }
>
> The problem is that the background of the new image is black rather than
> transparent.
> I saw the information about the transparency bit but apparently, I'm not
> smart enough to understand it. :-)
>
> Any help would be appreciated.
>
> Thanks,
> Mark
>
Re: Image transparency problem - easy, I think - Still need help [message #462750 is a reply to message #462746] Tue, 18 October 2005 17:10 Go to previous message
Mark Victory is currently offline Mark Victory
Messages: 133
Registered: July 2009
Senior Member
I got it working.

It appears that there is a difference in the ImageData extracted from a
loaded image as opposed
to creating the ImageData from an input stream even if the source .GIF file
is the same.

Thanks,
Mark


"Mark Victory" <mvictory@us.ibm.com> wrote in message
news:dj3f5n$o0u$1@news.eclipse.org...
>I realized that I typed SWT.IMAGE_JPEG rather than SWT.IMAGE_GIF.
> Thought I'd be all set.
>
> However, now I get an error that the "depth is unsupported" on the
> imageSaver.save( ) call. When I debug, the depth is 32. The image is a
> 256 color gif.
>
> Now any ideas?
>
> Thanks,
> Mark
>
> "Mark Victory" <mvictory@us.ibm.com> wrote in message
> news:dj3dqh$m4b$1@news.eclipse.org...
>>I am using a suggestion that someone had on this board for copying an
>>image (.gif) to a new file.
>>
>> Here's the code:
>>
>> private void moveImage(Image image, String fileName)
>> {
>> //New image loader
>> ImageLoader imageSaver = new ImageLoader();
>>
>> //image has been loaded from a .gif fi.e
>> ImageData idata = image.getImageData();
>>
>> //Set the old image data into the loader and
>> imageSaver.data = new ImageData[]{idata};
>>
>> //save as the new image.
>> imageSaver.save(path+File.separator+fileName+".gif",
>> SWT.IMAGE_JPEG);
>> }
>>
>> The problem is that the background of the new image is black rather than
>> transparent.
>> I saw the information about the transparency bit but apparently, I'm not
>> smart enough to understand it. :-)
>>
>> Any help would be appreciated.
>>
>> Thanks,
>> Mark
>>
>
>
Previous Topic:Warning on SWT_AWT and OSX and a suggestion
Next Topic:Browser Resolution
Goto Forum:
  


Current Time: Mon Apr 21 00:49:52 EDT 2014

Powered by FUDForum. Page generated in 0.07848 seconds