• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Adding byte arrays

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have a set of gif images in the form of byte arrays. I want to add them into a singe byte[]. I could make an animated gif image with this byte array, using a method that I have.
I would like to know how it could be done? could some body please post a sample code?

Thanks,
Samanth.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think that multiple GIFs in a single byte[] is a valid animated GIF; in fact, I'm sure it's not.

But to combine two arrays of any type, the recipe is the same: create a new array large enough to hold all the contents, then copy each component array into the new larger array.

byte[] b1 = ...
byte[] b2 = ...
byte[] all = new byte[b1.length + b2.length];
System.arraycopy(b1, 0, all, 0, b1.length);
System.arraycopy(b2, 0, all, b1.length, b2.length);
 
Sam Venkata
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Earnest,

Thanks for your help. I was just trying for a solution that way. Now that you said it is wrong could you suggest me a way to do it?

Thanks,
Samanth.
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well now wait, you said "I could make an animated gif image with this byte array, using a method that I have." Is this true, or not? EFH is saying that the single big byte[] array is not a valid GIF format, and that's true. But if you've got a method that makes an animated GIF out of the format you describe, that's fine. The fact that the combined array is not a valid GIF in itself doesn't mean it can't be a useful step toward getting a valid animated GIF. But I don't know if your method really works, or not.
 
Sam Venkata
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Jim,
I am using Jmagick package for that. It has a method called
blobToImage() that converts a byte[] into an image I was trying to see if I could get an animated image by sending the byte[].
I was just trying to do it. That is why I asked if what I was trying to do is correct or not?
Thanks,
Samanth.
reply
    Bookmark Topic Watch Topic
  • New Topic