Develop
2013.04.23 16:50
[android] Canvas를 이용해 이미지 확대/축소 하기
조회 수 64145 댓글 0
캔버스를 이용해 이미지 확대/축소하는 코드
import android.app.Activity; import android.content.Context; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Rect; import android.os.Bundle; import android.view.View; import android.view.Window; public class CanvasView extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(new ImageView(this)); } public class ImageView extends View{ private Bitmap image; // 이미지 public ImageView(Context context) { super(context); setBackgroundColor(Color.WHITE); // 그림 읽어들이기 Resources r = context.getResources(); image = BitmapFactory.decodeResource(r, R.drawable.excavator); } @Override protected void onDraw(Canvas canvas) { // 원본이미지 canvas.drawBitmap(image, 0, 0, null); // 원본이미지 영역을 축소해서 그리기 int w = image.getWidth(); int h = image.getHeight(); Rect src = new Rect(0, 0, w, h); Rect dst = new Rect(0, 200, w / 2, 200 + h / 2); canvas.drawBitmap(image, src, dst, null); super.onDraw(canvas); } } }
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
781 | Etc | [link] 유용한 사이트 링크. | hooni | 2013.08.19 | 130658 |
780 | Etc |
베지어 곡선 (Bezier curve)
![]() |
hooni | 2013.08.18 | 238998 |
779 | Etc | [web] 제로보드 XE 템플릿에서 if문에 대해서 알아봅시다 | hooni | 2013.08.16 | 24748 |
778 | Develop |
아이 훌레시 작업중 ㅋㅋ
![]() |
hooni | 2013.08.09 | 0 |
777 | Develop |
[ios] 최신 UI 모음.. (나중에 정리할 것)
![]() |
hooni | 2013.08.09 | 0 |
776 | Develop | [ios] UI컨트롤러 샘플코드 | hooni | 2013.08.08 | 16490 |
775 | Develop |
[ios] libxml/tree.h file not found
![]() |
hooni | 2013.08.08 | 21281 |
774 | Develop | [ios] 소소한 팁 (Rect,Point,Path,URL 등) | hooni | 2013.08.08 | 32642 |
773 | Develop |
[ios] Background 에서 네트워크 사용
![]() |
hooni | 2013.07.22 | 13154 |
772 | Develop |
[ios] App States
![]() |
hooni | 2013.07.22 | 14532 |
771 | Etc | 영어의 12 시제 (The twelve tenses of English) | hooni | 2013.07.12 | 17291 |
770 | System/OS | [mac] 컨텍스트(Context) 메뉴 "다음으로 열기" 내용 정리 | hooni | 2013.07.10 | 20361 |