Convert Image from BMP to GIF [message #466989] |
Fri, 20 January 2006 16:09 |
Eclipse User |
|
|
|
Originally posted by: mowens72.gmail.com
I have an SWT canvas that I can save without any problems to BMP and
Jpeg. Is it possible to save it as a GIF?
Or, does anyone have a code example that will convert an SWT Image to
transparent GIF? Thanks!
Mike O.
|
|
|
|
Re: Convert Image from BMP to GIF [message #467161 is a reply to message #467028] |
Wed, 25 January 2006 21:29 |
Eclipse User |
|
|
|
Originally posted by: mowens72.gmail.com
I just figured this out with some trial and error. In case anyone else
is interested, this is how I took an SWT image from a canvas and turned
it into a PNG with alpha transparency:
Convert the SWT image to AWT (found a code snippet online)
Get the pixels from the AWT image
If the pixel is white (or whatever color you want to be transparent)
perform a 0x00 >> pixel, else do pixel << 0x00 to store in a new one
dimensional array
Use AWT Component's createImage function get a new AWT image
Save the AWT using Jimi with the PNGEncoder
Veronika Irvine wrote:
> The following snippet saves an animated gif - your case will be simpler but
> similar:
>
> http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/org. eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet194 .java
>
> "Mike Owens" <mowens72@gmail.com> wrote in message
> news:dqr1vk$4as$1@utils.eclipse.org...
>
>>I have an SWT canvas that I can save without any problems to BMP and Jpeg.
>>Is it possible to save it as a GIF?
>>
>>Or, does anyone have a code example that will convert an SWT Image to
>>transparent GIF? Thanks!
>>
>>Mike O.
>
>
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.03627 seconds