안녕하십니까~!!! 오늘도 앱 개발에 열중인 초보 개발자 입니다!!!!
gif 관련 앱을 만들어 볼려고 하고 있습니다.
아래의 코드로 만들어 지긴 하는데 딜레이가 정해져 있어 많은 어려움을 겪고 있습니다 ㅜ
e.setDelay(500); 이 부분이 딜레이를 설정하는것 같습니다...(확실히는 모르겟습니다만....)
근데 제가 이 딜레이 부분을 e.setDelay(x);로 두고 이 x 값을 seekbar를 통해 변경하고 싶습니다 ㅜ (혹은 editbox루요...ㅜ)
seekbar 혹은 editbox로 조절 가능하게 하는 법 혹시 아시는 고수분 계시면 저에게 한줄기 빛을 내려 주십시오!!!!
귀찮으시 겠지만 간절히 부탁 드립니다 ㅜ
------------------------------------------------------------------------------------------------------------------------
protected void makeGIF() {
mProgressDialog = new ProgressDialog(this);
mProgressDialog.setTitle("Making your GIF");
mProgressDialog.setIndeterminate(false);
mProgressDialog.setMax(100);
mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
mProgressDialog.show();
GIFEncodeTask task = new GIFEncodeTask();
task.execute("");
}
private class GIFEncodeTask extends AsyncTask<String, Integer, String> {
@Override
protected String doInBackground(String... arg0) {
AnimatedGifEncoder e = new AnimatedGifEncoder();
try {
e.start(new FileOutputStream(new File(IMG_DIR, "output.gif")));
} catch (FileNotFoundException e1) {
throw new RuntimeException(e1);
}
e.setDelay(500);
File[] files = IMG_DIR.listFiles();
int c = 0;
for (File f : files) {
c += 1;
publishProgress((int) ((float) c / files.length * 100f));
if (f.getName().contains(".jpg")) {
Log.d("D", f.getName());
BitmapFactory.Options bmOptions = new BitmapFactory.Options();
bmOptions.inJustDecodeBounds = true;
BitmapFactory.decodeFile(f.getAbsolutePath(), bmOptions);
int photoW = bmOptions.outWidth;
int photoH = bmOptions.outHeight;
int targetW = 20;
int targetH = targetW * photoH / photoW;
int scaleFactor = photoW / targetW;
// Decode the image file into a Bitmap sized to fill the
// View
bmOptions.inJustDecodeBounds = false;
bmOptions.inSampleSize = scaleFactor;
bmOptions.inPurgeable = true;
Bitmap bitmap = BitmapFactory.decodeFile(
f.getAbsolutePath(), bmOptions);
e.addFrame(BitmapFactory.decodeFile(f.getAbsolutePath()));
}
}
e.finish();
publishProgress(-1);
return null;
}