Does anyone know of a way to create a gfx::Image from an IntArray that is holding a byte array representation of an image (in a *.jpg format). I'm looking for something similar to the 'createImage' method of the java Toolkit, seen here: `https://docs.oracle.com/javase/7/docs/api/java/awt/Toolkit.html#createImage(byte[])`
Thanks!
SlimerDudeSun 3 Jul 2016
Hi Jay,
If you stick your data in a Buf then you could use "in memory files" like this:
Jay Herron Sun 3 Jul 2016
Hi,
Does anyone know of a way to create a gfx::Image from an IntArray that is holding a byte array representation of an image (in a *.jpg format). I'm looking for something similar to the 'createImage' method of the java Toolkit, seen here: `https://docs.oracle.com/javase/7/docs/api/java/awt/Toolkit.html#createImage(byte[])`
Thanks!
SlimerDude Sun 3 Jul 2016
Hi Jay,
If you stick your data in a
Buf
then you could use "in memory files" like this:But you'd have to build Fantom from source as "in memory files" were added after the Fantom 1.0.68 release - see this commit.
I believe at one point there was some talk of a Fantom nightly build, but that seems to have lost traction.
Otherwise you may just have to save the data as a temporary file, and re-load it... :(
(Oh, and
Bufs
are a better / more compact / more convenient way to hold binary data than Int arrays.)SlimerDude Mon 4 Jul 2016
Hi Jay,
I had another look at your problem and here's a different solution...
It creates an SWT Image from a
Buf
and does some native fwt fiddling to copy the contents into a new FantomImage
:But note your new Fantom images loose all transparency information due to this ongoing ticket.
SlimerDude Mon 4 Jul 2016
Not to be beaten, here's a solution that gets round the transparency issue:
Jay Herron Tue 5 Jul 2016
Awesome! Thanks so much for your help!