public class GalleryFileActivity extends Activity {
public static int mDegreeY = 0;
public static int mDegreeX = 0;
public static int mDegreeplu = 0;
public static int mDegreemin = 0;
int a = 0;
Animation animation;
int btncnt = 0;
int result;
HorizontalScrollView mLLayout;
ArrayList<String> items = new ArrayList<String>();
private GalleryViewPager mViewPager;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.gall_file_main);
mLLayout = (HorizontalScrollView) findViewById(R.id.scrollviewer);
animation = AnimationUtils.loadAnimation(getApplicationContext(),
R.anim.rotate);
String[] urls = null;
Intent intent = getIntent();
items = intent.getStringArrayListExtra("urls");
FilePagerAdapter pagerAdapter = new FilePagerAdapter(this, items);
a = pagerAdapter.getCount();
pagerAdapter.setOnItemChangeListener(new OnItemChangeListener() {
@Override
public void onItemChange(int currentPosition) {
Toast.makeText(GalleryFileActivity.this,
"Current item is " + currentPosition,
Toast.LENGTH_SHORT).show();
Log.i("filt", "전체 사진 수 : " + String.valueOf(a));
}
});
mViewPager = (GalleryViewPager) findViewById(R.id.viewer);
mViewPager.setOffscreenPageLimit(3);
mViewPager.setAdapter(pagerAdapter);
}
public void copy(InputStream in, File dst) throws IOException {
OutputStream out = new FileOutputStream(dst);
// Transfer bytes from in to out
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();
}
public void clickHandler(View _v) {
switch (_v.getId()) {
case R.id.btnRotate:
result = mLLayout.getVisibility();
btncnt++;
// mDegreeplu= mDegreeplu+90;
/*
* Intent i = new Intent(getApplicationContext(),
* GalleryFilter.class); // i.putStringArrayListExtra("urls",
* items); startActivity(i);
*/
GalleryFilterItem thumbInfo = new GalleryFilterItem();
thumbInfo.setpos(mDegreeplu);
TouchImageView touch = new TouchImageView(getBaseContext());
GalleryViewPager galleryContainer = ((GalleryViewPager) mViewPager);
Log.i("gallt","비트맵값받나?"+String.valueOf(galleryContainer.mCurrentView.getBitmap()));
galleryContainer.mCurrentView.imgResize(galleryContainer.mCurrentView.getBitmap());
// galleryContainer.mCurrentView.gallro(mDegreeplu);
// galleryContainer.mCurrentView.getImageProcess(galleryContainer.,
// nRotate, viewW, viewH, view);
if (result == View.GONE) {
mLLayout.setVisibility(View.VISIBLE); // 화면에서 제외
} else {
mLLayout.setVisibility(View.GONE); // 화면에서 제외
}
// 화면에서 보이기 }
Log.i("gallt", "btnRotate result 값" + result);
Log.i("gallt", "btnRotate Degree 값" + mDegreeplu);
break;
case R.id.btnFilter:
Log.i("gallt", "btnfilter");
break;
case R.id.rotate_Y:
mDegreeY = mDegreeY + 180;
GalleryViewPager galleryContainery = ((GalleryViewPager) mViewPager);
galleryContainery.mCurrentView.gallroY(mDegreeY);
Log.i("gallt", "Y 180도회전!!");
break;
case R.id.rotate_X:
mDegreeX = mDegreeX + 180;
GalleryViewPager galleryContainerx = ((GalleryViewPager) mViewPager);
galleryContainerx.mCurrentView.gallroX(mDegreeX);
Log.i("gallt", "Y 180도회전!!");
break;
case R.id.rotate_plu:
mDegreeplu = mDegreeplu + 90;
GalleryViewPager galleryContainerplu = ((GalleryViewPager) mViewPager);
galleryContainerplu.mCurrentView.gallro(mDegreeplu);
// galleryContainerplu.startAnimation(animation);
Log.i("gallt", "Y 180도회전!!");
break;
case R.id.rotate_min:
mDegreeplu = mDegreeplu - 90;
GalleryViewPager galleryContainermin = ((GalleryViewPager) mViewPager);
galleryContainermin.mCurrentView.gallro(mDegreeplu);
Log.i("gallt", " 180도회전!!");
break;
}
}
}
요기가 이미지띄워주는부분입니다
package com.truba.touchgallery.TouchView;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.util.AttributeSet;
import android.util.Log;
import java.io.File;
import java.io.FileInputStream;
import com.example.androidimagefilterdemo.GalleryFilterItem;
import com.truba.touchgallery.TouchView.InputStreamWrapper.InputStreamProgressListener;
public class FileTouchImageView extends UrlTouchImageView {
public FileTouchImageView(Context ctx) {
super(ctx);
}
public FileTouchImageView(Context ctx, AttributeSet attrs) {
super(ctx, attrs);
}
public void setUrl(String imagePath) {
new ImageLoadTask().execute(imagePath);
}
// No caching load
public class ImageLoadTask extends UrlTouchImageView.ImageLoadTask {
@Override
protected Bitmap doInBackground(String... strings) {
String path = strings[0];
Bitmap bm = null;
BitmapFactory.Options option = new BitmapFactory.Options();
option.inSampleSize = 5;
try {
File file = new File(path);
FileInputStream fis = new FileInputStream(file);
InputStreamWrapper bis = new InputStreamWrapper(fis, 8192,
file.length());
bis.setProgressListener(new InputStreamProgressListener() {
@Override
public void onProgress(float progressValue,
long bytesLoaded, long bytesTotal) {
publishProgress((int) (progressValue * 100));
}
});
Matrix matrix = new Matrix();
bm = BitmapFactory.decodeStream(bis, null, option);
if (bm.getHeight() < bm.getWidth()) {
matrix.preRotate(90, 0, 0);
bm = Bitmap.createBitmap(bm, 0, 0, bm.getWidth(),
bm.getHeight(), matrix, false);
}
bis.close();
} catch (Exception e) {
e.printStackTrace();
}
return bm;
}
전혀 감을 잡지 못하고있씁니다.