Yasic / ParticleTextView

一个用粒子动画显示文字的 Android 自定义 View
1.32k stars 197 forks source link

Do you know how can I convert ParticleTextView object into GIF? #11

Open keval-gangani opened 6 years ago

keval-gangani commented 6 years ago

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(); } }

particletext