1 / 13

Contents

Contents. 학습목표. Canvas 와 Paint 객체를 통해 화면에 원하는 도형을 그리고 속성을 변경하는 기본적인 방법에 대해 소개한다 . 토스트로 메시지를 출력하는 방법과 스피커를 통해 소리를 출력하는 방법에 대해서도 알아본다 . 학습내용. 캔버스 그리기 객체 쉐이더 그외 출력. 5.2.1. Bitmap. 비트맵을 사용하려면 res/ drawable 폴더에 복사 ( 탐색기에서 마우스로 드래그 ) Resources 객체를 얻을때 뷰의 메서드 호출

oneida
Download Presentation

Contents

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Contents 학습목표 • Canvas와 Paint 객체를 통해 화면에 원하는 도형을 그리고 속성을 변경하는 기본적인 방법에 대해 소개한다. • 토스트로 메시지를 출력하는 방법과 스피커를 통해 소리를 출력하는 방법에 대해서도 알아본다. 학습내용 • 캔버스 • 그리기 객체 • 쉐이더 • 그외 출력

  2. 5.2.1. Bitmap • 비트맵을 사용하려면 res/drawable폴더에 복사(탐색기에서 마우스로 드래그) • Resources 객체를 얻을때뷰의메서드 호출 • Resources View.getResources () • Resources.getDrawable (int id) 메서드로읽어들인다. • BitmapDrawable은 미트맵을 래핑하는 클래스이며 비트맵의 여러 가지 속성을 정의. • 비트맵 하나를 읽기 위해서는 다음을 연속적으로 호출 • Resources r=getResources(); // 리소스 관리자 얻음 • BitmapDrawablebd=(BitmapDrawable)r.getDrawable(ID);//비트맵드로블 읽음 • Bitmap bit=bd.getBitmap(); // 비트맵 추출 • 위 세줄과 동일한 코드 • Bitmap bit = BitmapFactory.decodeResource(getResources(), ID);

  3. 5.2.1. Bitmap • 리소스로부터 로드한 비트맵 화면 출력 • src영역을 dst에 출력 src가 null이면 전체 출력,src와 dst크기에 따라 확대 또는 축소 • public void drawBitmap (Bitmap bitmap, float left, float top, Paint paint) • public void drawBitmap (Bitmap bitmap,Rectsrc, Rectdst, Paint paint) • public void drawBitmap (Bitmap bitmap,Rectsrc, RectFdst, , Paint paint) • public void drawBitmap (Bitmap bitmap, Matrix matrix, , Paint paint) • public void drawBitmap (int[] colors, int offset, int stride, int x, int y, • int width, int height, booleanhasAlpha, Paint paint) • 코드에서 비트맵을 생성할 때는 다음 메서드를 호출한다. • static Bitmap createBitmap (int width, int height, Bitmap.Configconfig)

  4. 5.2.1. Bitmap 오프스크린 비트맵 : 캔버스에 그리는 그림은 메모리에 그려질 뿐 화면에 나오지 않음. drawBitmap으로 화면에 나옴.

  5. 5.2.2. 텍스트 • FreeType공개 라이브러리 : 안드로이드 텍스트 출력 기능 제공하며 최신 폰트를 지원하며 글꼴 관리에 대한 거의 모든 기능 제공 • - 지정한 좌표에 문자열 전체를 다 출력한다. void drawText (String text, float x, float y, Paint paint) - 지정한 좌표에 문자열 일부를 출력한다. void drawText (String text, int start, int end, float x, float y, Paint paint) void drawText (char[] text, int index, int count, float x, float y, Paint paint) void drawTextOnPath (String text, Path path, float hOffset, float vOffset, Paint paint)

  6. 5.2.2. 텍스트 • 텍스트의 여러가지속성을 변경하는 Paint의메서드들은다음과 같다. void setTextAlign (Paint.Align align) //정렬 void setTextSize (float textSize) //크기 Typeface setTypeface (Typeface typeface) //타입 void setUnderlineText (booleanunderlineText) //밑줄 void setStrikeThruText (booleanstrikeThruText) //취소선 void setSubpixelText (booleansubpixelText)//서브픽셀 void setTextSkewX (float skewX) //글자의 기울기 void setTextScaleX (float scaleX) //장평

  7. 5.2.2. 텍스트

  8. 5.2.2. 텍스트 • 글자의 모양을 결정하는 가장 중요한 정보는 타입페이스이다. • 타입페이스란 : 바탕, 굴림, 궁서 등 고유의 글꼴에 대한 이름 • 페이스를 변경할 때 Paint의 Typeface 메서드를 사용하며 메서드의 인수로 Typeface 객체를 전달한다. • Typeface는 별도 생성자가 없으므로 정적 메서드로 생선해야 한다. • static Typeface create (Typeface family, int style) • static Typeface create (String familyName, int style) • 페이스 이름과 스타일은 인수로 전달한다.

  9. 5.2.2. 텍스트

  10. 5.2.2. 텍스트 커스텀 폰트 사용 : 적당한 폰트를 프로젝트의 assets폴더로 복사를 한다.

  11. 5.2.3. Path • 패스(Path)는 직선, 곡선, 다각형 등의 도형 궤적 정보를 가지는 그래픽 객체. • Path는 다방면으로 활용성이 높은 객체이다. • 곡선을 직접 그리는 메서드가 없어 패스에 곡선 정보를 생성 후 패스를 출력 하여 사용. • 패스를 따라 흐르는 텍스트 출력 가능. • moveTo(float x, float y) • lineTo(float x, float y) • addCircle(float x, float y, float radius, Path.Direction dir) • addRect(RectFrect, Path.Direction dir) • quadTo(float x1, float y1, float x2, float y2) • cubicTo(float x1, float y1, float x2, float y2, float x3, float y3)

  12. 5.2.3. Path

More Related