• Post Reply Bookmark Topic Watch Topic
  • New Topic

help with images!!!  RSS feed

 
Sam Venkata
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.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!