Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

help with images!!!  RSS feed

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a set of images in the form of byte arrays. I want to add these bytes to get a single byte array consisting of animated image. I tried doing it but I do not get the animated image back.
I have posted this question in this forum earlier but I guess I was not clear with my question. I am sorry about it.
I wanted to know if that is possible using java?

here is my code snippet
<code>
private static byte[] imagesToBlob(MagickImage magickImage)
{
byte[] blob=null,temp=null;
MagickImage[] frames=null;
try
{
if(magickImage!=null&&magickImage.isAnimatedImage())
{
int numFrames=magickImage.getNumFrames();
frames=magickImage.breakFrames();
for(int i=0;i<numFrames;i++)
{
temp=frames[i].imageToBlob(new ImageInfo());
if(i==0)
{
//blob=frames[i].imageToBlob(new ImageInfo());
blob=temp;
}
else
{
byte[] all= new byte[blob.length+temp.length];
System.arraycopy(blob, 0, all, 0, blob.length);
System.arraycopy(temp, 0, all, blob.length, temp.length);
blob=all;
}
}
}
}
catch(MagickException mex)
{
mex.printStackTrace();
}
return blob;
}

</code>
Thanks,
Samanth.
 
Java Cowboy
Sheriff
Posts: 16084
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simply concatenating the bytes of multiple images will not make an animated image. Not all image formats support animation. The GIF format does, but not by simply concatenating images.

I see you are using JMagick. Have a look at this: How to make an Animated GIF with JMagick

p.s.: Thanks for trying to use code tags, but on JavaRanch you should use square brackets, [ and ], instead of angular brackets, < and > for the code tags.
[ July 03, 2007: Message edited by: Jesper Young ]
 
Sam Venkata
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I was able to make animated images using jmagick and I resized them aswell. But I have to store the resized image on disk before I could do any other manipulation on it. Jmagick has a method called imageToBlob() bot that returns the byte[] of only the first frame and not of the whole animated image.
I have to do it in the memory and shoud not have an I/O to disk. That is the reason, I was asking if there is a way I could do it by combining the byte[]s of all the frames.
I really appreciate if somebody could help me.

Thanks,
Samanth.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!