private void PrintGraphDrawing(float now, float target, int id) {
Bitmap bit = BitmapFactory.decodeResource(getResources(), R.drawable.graph_bg);// 뒤에깔 배경
Bitmap bitnow =
BitmapFactory.decodeResource(getResources(), R.drawable.graph__s);//배경앞에 깔릴 이미지
Bitmap targetbit = BitmapFactory.decodeResource(getResources(), R.drawable.graph_g);// 배경앞에 깔릴 다른 이미지
Rect src = new Rect();
Rect dst = new Rect();
int w = bit.getWidth();
int h = bit.getHeight();
int destx = 0;
int desty = 0;
Bitmap rounder = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_555);
Canvas nowCanvas = new Canvas(rounder);
src.top = 0;
src.left = 0;
src.right = w;
src.bottom = h;
dst.top = desty;
dst.left = destx;
dst.right = destx + w;
dst.bottom = desty + h;
nowCanvas.drawBitmap(bit, src, dst, null);
w = targetbit.getWidth();
h = targetbit.getHeight();
Canvas targetCanvas = new Canvas(rounder);
Path mPath = new Path(); // 각도 주는 클래스
BitmapDrawable targetDraw = new BitmapDrawable(mContext.getResources(), targetbit);
targetDraw.setBounds(0, 0, w, h);
targetCanvas.translate(0, 0);
mPath.reset();
RectF oval = new RectF(0, 0, w, h); // 원그리는 클래스
mPath.moveTo(w / 2, h / 2);
mPath.arcTo(oval, 90, target);
targetCanvas.clipPath(mPath);
targetDraw.draw(targetCanvas);
w = bitnow.getWidth();
h = bitnow.getHeight();
BitmapDrawable nowDraw = new BitmapDrawable(mContext.getResources(), bitnow);
nowDraw.setBounds(0, 0, w, h);
nowCanvas.translate(0, 0);
mPath.reset();
oval = new RectF(0, 0, w, h);
mPath.moveTo(w / 2, h / 2);
mPath.arcTo(oval, 90, now);
nowCanvas.clipPath(mPath);
nowDraw.draw(nowCanvas);
ImageView imgV = (ImageView) mView.findViewById(id);
imgV.ImageBitmap(rounder);
}
'프로그램 > Android' 카테고리의 다른 글
안드로이드 Download Manager (0) | 2016.09.07 |
---|---|
java.lang.UnsatisfiedLinkError 와 안드로이드 라이브러리 추가 등등... (0) | 2016.06.22 |
Google Marker 안에 이미지 넣기 (0) | 2016.06.09 |
String.xml 포맷팅 및 필요한 사항들.... (0) | 2016.02.19 |
Dialog에서 백버튼 클릭시 and 키보드 제어 (0) | 2016.02.19 |