본문 바로가기

Size

[Android] 이미지 크기 알아보는 방법 /** Get Bitmap's Width **/ public static int getBitmapOfWidth( String fileName ){ try { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeFile(fileName, options); return options.outWidth; } catch(Exception e) { return 0; } } /** Get Bitmap's height **/ public static int getBitmapOfHeight( String fileName ){ try { BitmapFactory.Opt.. 더보기
[Android] !!! FAILED BINDER TRANSACTION !!! 안드로이드에서 Material Design을 계속 밀어줌으로써,Activity 간의 이동을 할 때 Bitmap을 넘겨주고자 하는 일이 많아졌다. Intent에 Bitmap을 put 시킬 때, 안드로이드에서는 이미지 크기가 40KB 로 제한되어 있다.따라서 40KB 이상의 Bitmap을 넣을 경우!!! 아래와 같은 Log를 볼 수 있다. !!! FAILED BINDER TRANSACTION !!! 그럼.. 이미지의 크기를 낮춰야 할까??? 그럼 이미지가 깨지게 되는데.. 어떻하지??이벤트 마다 이미지를 다시 로딩 해야 하나??? 화면을 넘어가서 로딩 할까?? 그럼 화면에서 정상적인 동작이 이뤄지지 않을 수도 있다.(예를 들어 모션은 들어 갔는데 이미지는 아직 로딩이 안되는 상태에서 이미지를 구할려고 한다면.. 더보기
[Android] Make CustomView (TextView, OnMeasure) CustomView를 만들어 보고자 합니다.하고자 하는 것은 TextView Background 에 기본적으로 RoundRect 가 그려지도록 할 예정입니다. 여기서 필요한 기술이 두가지 입니다. 1. Background를 어떻게 그리지??2. CustomeView의 크기를 어떻게 조절하지??? 모든것을 설명해 드릴 수 없지만, 개발하는데 유용할 만한 내용은 될것이라 생각 됩니다. 먼저, Background에 이미지를 넣을때 아래와 같은 방법을 많이 씁니다. (전..그랬음.._) - FrameLayout으로 감싼 후, Background로 활용할 이미지를 ImageView에 먼저 그린 후 그 다음으로 위에 표현하고자 하는 View를 올린다. 단점 ) View의 크기가 고정 되어 있지 않으면 (예를 들어 .. 더보기
[Android] 화면 전체 사이즈 구하기 아래 함수를 호출 한다.public Point getScreenSize(Activity activity) { Display display = activity.getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); return size; } 위 상태에서 width : size.x height : size.y 값을 이용하면 된다. Library나 예제 소스에 간혹 아래와 같이 호출을 하는데 int screenHeight = parentLayout.getRootView() .getHeight();위와 같은 방법을 쓰면 최신 버전에서 전혀 다른 값이 나올 수 있다.예를 들어 제가 Nexus4 로 테스트 해본 .. 더보기
[Android] ImageView 사이즈 ViewTreeObserver vto = image1.getViewTreeObserver(); vto.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { public boolean onPreDraw() { image1.getViewTreeObserver().removeOnPreDrawListener(this); Log.e(getClass().getName(),"imageView size : Height: " + image1.getMeasuredHeight() + " Width: " + image1.getMeasuredWidth()); return true; } }); 위 방법을 통하면 ImageVIew 사이즈를 구할수있다. 더보기
[ Android ] Camera 캡쳐된 화면 보여주기. 이번에 Camera 연동 부분이 있어 조사를 좀 했습니다.조사 해본 결과 첫번째 캡쳐된 이미지를 가져오는 방법이 mCamera.setPreviewCallback(new Camera.PreviewCallback() {public void onPreviewFrame(byte[] data, Camera camera) {Camera.Parameters params = mCamera.getParameters(); int w = params.getPreviewSize().width; int h = params.getPreviewSize().height; int format = params.getPreviewFormat(); YuvImage image = new YuvImage(data, format, w, h, n.. 더보기