Do you know how can I convert ParticleTextView object into GIF?
keval-gangani opened this issue · 0 comments
Hi Yasic,
I have been tried below logic on button click event to generate GIF from ParticleTextView object but it saves file as Jpeg. Please review below image and background coming in black color.
Can you please give some hint to save ParticleTextView object into GIF? It would be very helpful.
public void onClick(View view) {
particleTextView1.buildDrawingCache();
Bitmap image=particleTextView1.getDrawingCache();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
AnimatedGifEncoder encoder = new AnimatedGifEncoder();
encoder.start(bos);
encoder.addFrame(image);
encoder.finish();
byte[] array = bos.toByteArray();
//File output = new File( "abc.gif");
File path = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES);
File file = new File(path,"DemoPicture.gif");
path.mkdirs();
try (FileOutputStream fos = new FileOutputStream(file.getPath())) {
fos.write(array);
fos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}