CHAP 8. 고급 그래픽과 O PEN GL. © 2012 생능출판사 All rights reserved C ANVAS 클래스와 P AINT 클래스.

Slides:



Advertisements
Similar presentations
5-3. 세이더 천안천일고등학교 류빈 1.Canvas 와 Paint 객체를 통해 화면에 원하는 도형을 그리고 속성을 변경하는 기본적인 방법에 대해 소개 한다. 2. 토스트로 메시지를 출력하는 방법과 스피커를 통해 소리를 출력하는 방법에.
Advertisements

Graphics with Canvas, SurfaceView, and multitouch processing (panning and multitouch zoom) GraphicsWithCanvas_2012.pptx.
© 2004 Pearson Addison-Wesley. All rights reserved2-1 Introduction to Graphics The last few sections of each chapter of the textbook focus on graphics.
Basic 2D Graphics in Android. Android Graphics Programming There are many ways to do graphics programming in Android – 2D vs. 3D – static vs. dynamic.
 In inheritance the child (subclass) chooses its parent (superclass)  Remember - only public or “protected” methods and variables are inherited  Should.
My own View Android development Maarten Pennings 2011 oct 14.
Crash Course in Android Development. 2 Content  Installing the ADT  Hardware and OS requirements  Java  ADT Bundle  Eclipse Project Setup  Drawing.
2D Graphics: Part 1. Android Graphics Libraries 2D Graphics –custom 2D graphics library in packages android.graphics android.graphics.drawable android.graphics.drawable.shapes.
Custom Views, Drawing, Styles, Themes, ViewProperties, Animations, oh my!
Basic Drawing Techniques
2D Graphics: Part 2.
4 출 력.
1 Identifiers  Identifiers are the words a programmer uses in a program  An identifier can be made up of letters, digits, the underscore character (
Programming Concepts. Derive a new class from Activity of the framework Prepare the data beforehand, e.g., vertices, colours, normal vectors, texture.
6-2 2D Graphics CSNB544 Mobile Application Development Thanks to Utexas Austin.
Android Activities 1. What are Android Activities? Activities are like windows in an Android application An application can have any number of activities.
8. Notification과 Alarm.
C# Programming Lecture 4 “GDI+” PGL01/CSP/2006.
Package org.androidtown.database.query; import android.app.Activity; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase;
로봇 모니터링 2/2 UNIT 21 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Broadcasting Service 2.
Android Accessing GPS Ken Nguyen Clayton State University 2012.
CHAP 10. 고급 위젯. © 2012 생능출판사 All rights reserved 어댑터 뷰 어댑터 뷰 (AdapterView) 는 배열이나 파일, 데이터 베이스에 저장된 데이터를 화면에 표시할 때 유용한 뷰.
로봇 전화번호부 4/4 UNIT 12 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 뷰 홀더 패턴을 사용할 수 있다. 토스트를 사용할 수 있다. 클릭 이벤트를 처리할 수 있다. 2.
Android Programming-Activity Lecture 4. Activity Inside java folder Public class MainActivity extends ActionBarActivity(Ctrl + Click will give you the.
Android Graphics Library. Color Android colors are represented with four numbers, one each for alpha, red, green, and blue (ARGB). Each component can.
로봇 모니터링 1/2 UNIT 20 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Message Queue Handler 2.
Activity 생명주기 UNIT 13 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Logcat 액티비티 생명주기를 설명할 수 있다. 현재 상태를 저장할 수 있다. 2.
5-1. 캔버스 천안천일고등학교 류빈 1.Canvas 와 Paint 객체를 통해 화면에 원하는 도형을 그리고 속성을 변경하는 기본적인 방법에 대해 소개 한다. 2. 토스트로 메시지를 출력하는 방법과 스피커를 통해 소리를 출력하는 방법에.
Custom Widget 1 UNIT 26 로봇 SW 콘텐츠 교육원 조용수. 캔버스 public void drawColor(int color) 2 public class ControllerView extends View { public ControllerView(Context.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Introduction to Android (Part.
Ch3. 캔버스 활용 3-2 도형으로 안드로이드 캐릭터 만들기.
데이터 저장 & Fragment UNIT 28 로봇 SW 콘텐츠 교육원 조용수. 데이터 저장 & Fragment SharedPreference 로 데이터 저장 Fragment 의 이해 2.
Announcements Homework #2 will be posted after class due Thursday Feb 7, 1:30pm you may work with one other person No office hours tonight (sorry!) I will.
Cosc 5/4730 Android drawing. Screen support Android is the OS and is used a many different hardware created by different vendors. – Screen size For simplicity,
CHAP 8. 그래픽.
네트워크 전송 1/2 UNIT 29 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Android Network 통신 2.
영상 획득 영상 저장 카메라 파라메터 커스텀 이미지
Android Application Lifecycle and Menus
아주대학교 LifecareScienceLAB Android Seminar 3 rd class Android Software Development 2011/05/04 – p.m. 06:00 – 팔달관 409 호 아주대학교.
로봇을 조종하자 1/5 UNIT 14 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 터치 이벤트를 처리할 수 있다. 2.
Custom Widget 2 UNIT 27 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Custom Widget –Canvas 를 이용하여 Custom Widget 을 만든다. 2.
CHAP 14. 프로세스와 스레드. © 2012 생능출판사 All rights reserved 다중 스레딩 하나의 애플리케이션이 동시에 여러 가지 작업을 하 는 것 이들 작업은 스레드 (thread) 라고 불린다.
Print Row Function void PrintRow(float x[ ][4],int i) { int j; for(j=0;j
1 Drawing C Sc 335 Object-Oriented Programming and Design Rick Mercer.
Android Alert Dialog. Alert Dialog Place Button to open the dialog. public class MainActivity extends ActionBarActivity { private static Button button_sbm;
CHAP 6. 이벤트 처리. © 2012 생능출판사 All rights reserved 폴링과 이벤트 구동 방식.
1 Visual C 영상처리 프로그램 (MDI) BMP 파일 불러오기 이미지 픽셀 다루기.
Basic 2D Graphics in Android. Android Graphics Programming There are many ways to do graphics programming in Android – 2D vs. 3D – static vs. dynamic.
© 2012 생능출판사 All rights reserved CHAP 8. 그래픽. © 2012 생능출판사 All rights reserved 안드로이드에서의 2 차원 그래픽 사용 방법 1) XML 파일로 그래픽이나 애니메이션을 정의한다. 그리는 작업은 안드로이드 시스템이.
David Sutton 2D GRAPHICS IN ANDROID. INTRODUCTION AND OUTLINE  In this week’s session we will create a simple Kaleidoscope application. Topics that will.
C Sc 335 Object-Oriented Programming and Design Rick Mercer
JAVA ACCESS MODIFIERS. Access Modifiers Access modifiers control which classes may use a feature. A classes features are: - The class itself - Its member.
CHAP 8. 그래픽. © 2012 생능출판사 All rights reserved 안드로이드에서의 그래픽 XML 파일로 그래픽이나 애니메이션을 정의한다. 그 리는 작업은 안드로이드 시스템이 담당한다. onDraw() 메소드 안에 draw...() 와 같은 메소드를 호.
2D Graphics: Part 1.
Android Application 2D Graphics cs.
UNIT 11 로봇 전화번호부 3/4 로봇 SW 콘텐츠 교육원 조용수.
GUI Programming Fundamentals
CS499 – Mobile Application Development
2D Graphics: Part 2.
Android Programming Lecture 6
null, true, and false are also reserved.
Graphics with Canvas.
CMPE419 Mobile Application Development
UNIT 08 그림책 만들기 2/2 로봇 SW 콘텐츠 교육원 조용수.
Code Animation Examples
JavaScript Reserved Words
Mobile Computing With Android ACST 4550 Android Database Storage
滑動 建國科技大學 資管系 饒瑞佶.
ארועים ומאזינים android.
CIS 470 Mobile App Development
Presentation transcript:

CHAP 8. 고급 그래픽과 O PEN GL

© 2012 생능출판사 All rights reserved C ANVAS 클래스와 P AINT 클래스

© 2012 생능출판사 All rights reserved 그래디언트 연속하여 변화되는 색상 선형 그래디언트 원형 그래디언트 비트맵 그래디언트

© 2012 생능출판사 All rights reserved 선형 그래디언트 예제 (1/3)... class MyView extends View { public MyView(Context context) { super(context); } public void onDraw(Canvas canvas) { Paint paint = new Paint(); paint.setShader(new LinearGradient(0, 0, 100, 0, Color.WHITE, Color.BLUE, TileMode.CLAMP)); canvas.drawRect(0, 0, 300, 50, paint); canvas.drawText("CLAMP", 0, 70, paint); paint.setShader(new LinearGradient(0, 0, 100, 0, Color.WHITE, Color.BLUE, TileMode.MIRROR));

© 2012 생능출판사 All rights reserved 선형 그래디언트 예제 (2/3) canvas.drawRect(0, 70, 300, 120, paint); canvas.drawText("MIRROR", 0, 140, paint); paint.setShader(new LinearGradient(0, 0, 100, 0, Color.WHITE, Color.BLUE, TileMode.REPEAT)); canvas.drawRect(0, 140, 300, 190, paint); canvas.drawText("REPEAT", 0, 210, paint); int[] colors = { Color.WHITE, Color.RED, Color.BLUE }; float[] positions = { 0.0f, 0.8f, 1.0f }; paint.setShader(new LinearGradient(0, 0, 320, 0, colors, null, TileMode.CLAMP)); canvas.drawRect(0, 210, 300, 260, paint); canvas.drawText("colors[]", 0, 280, paint); paint.setShader(new LinearGradient(0, 0, 320, 0, colors, positions, TileMode.CLAMP)); canvas.drawRect(0, 280, 300, 330, paint); canvas.drawText("colors[] 와 positions[]", 0, 350, paint); }

© 2012 생능출판사 All rights reserved 선형 그래디언트 예제 (3/3) public class GradientTest extends Activity { /** Called when the activity is first created. public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(new MyView(this)); }

© 2012 생능출판사 All rights reserved 원형 그래디언트

© 2012 생능출판사 All rights reserved 원형 그래디언트 예제 public void onDraw(Canvas canvas) { Paint paint = new Paint(); paint.setShader(new RadialGradient(100, 100, 50, Color.RED, Color.YELLOW, TileMode.CLAMP)); canvas.drawCircle(100, 100, 50, paint); paint.setShader(new RadialGradient(250, 100, 50, Color.YELLOW, Color.RED, TileMode.CLAMP)); canvas.drawCircle(250, 100, 50, paint); paint.setShader(new SweepGradient(100, 250, Color.RED, Color.YELLOW)); canvas.drawCircle(100, 250, 50, paint); paint.setShader(new SweepGradient(250, 250, Color.YELLOW, Color.RED)); canvas.drawCircle(250, 250, 50, paint); }

© 2012 생능출판사 All rights reserved 비트맴 그래디언트 class MyView extends View { public MyView(Context context) { super(context); } public void onDraw(Canvas canvas) { Paint paint = new Paint(); Bitmap bitmap = BitmapFactory.decodeResource(getContext().getResources(), R.drawable.bitmap); paint.setShader(new BitmapShader(bitmap, TileMode.REPEAT, TileMode.REPEAT)); canvas.drawRect(0, 0, this.getMeasuredWidth(), this.getMeasuredHeight(), paint); }

© 2012 생능출판사 All rights reserved 트랜스퍼 모드 이미지와 이미지를 겹쳐서 화면에 그리는 경우에 어 떤 연산을 할 것인지를 정의

© 2012 생능출판사 All rights reserved class MyView extends View { private static final int W = 80; private static final int H = 80; private static final int ROW_MAX = 4; // 한 행의 샘플 개수 private Bitmap mSrcB; private Bitmap mDstB; // 비트맵을 생성한다. Bitmap makeDst(int w, int h) { Bitmap bm = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(bm); Paint p = new Paint(Paint.ANTI_ALIAS_FLAG); p.setColor(0xFFFFCC44); c.drawOval(new RectF(0, 0, w * 3 / 4, h * 3 / 4), p); return bm; } // 비트맵을 생성한다. Bitmap makeSrc(int w, int h) { Bitmap bm = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(bm); Paint p = new Paint(Paint.ANTI_ALIAS_FLAG); p.setColor(0xFF66AAFF); c.drawRect(w / 3, h / 3, w * 19 / 20, h * 19 / 20, p); return bm; } 트랜스퍼 모드 예제

© 2012 생능출판사 All rights protected void onDraw(Canvas canvas) { canvas.drawColor(Color.WHITE); Paint paint = new Paint(); // paint.setFilterBitmap(false); paint.setXfermode(null); canvas.drawBitmap(mDstB, 0, 100, paint); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_OVER)); canvas.drawBitmap(mSrcB, 0, 100, paint); } … 트랜스퍼 모드 예제

© 2012 생능출판사 All rights reserved 2 차원 변환 평행 이동, 신축, 회전과 같은 기본 변환 뿐만 아니 라 밀림 변환 (skew transformation) 과 같은 추가적 인 변환도 가능

© 2012 생능출판사 All rights reserved 회전

© 2012 생능출판사 All rights reserved 신축

© 2012 생능출판사 All rights reserved 영상처리 영상의 각 픽셀 값에 변화를 주는 것이다. 영상처리의 예 영상을 흐리게 하거나 영상을 선명하게 하는 것 영상에서 에지 (edge) 를 추출하는 것

© 2012 생능출판사 All rights reserved 마스크 필터 픽셀 (pixel) 을 중심으로 마스크를 씌워서 연산을 한 후에 연산의 결과값으로 픽셀값을 변경하는 것 블러 마스크 필터 엠보스 마스크 필터

© 2012 생능출판사 All rights reserved

엠보스 마스크 필터

© 2012 생능출판사 All rights reserved O PEN GL 1.1 버전과 2.0 버전을 지원

© 2012 생능출판사 All rights reserved O PEN GL ES 그래픽을 위한 액티비티 생성 하기

© 2012 생능출판사 All rights reserved M Y GLS URFACE V IEW 클래스 작성

© 2012 생능출판사 All rights reserved R ENDERER 클래스 작성

© 2012 생능출판사 All rights reserved 삼각형 정의

© 2012 생능출판사 All rights reserved 삼각형 그리기

© 2012 생능출판사 All rights reserved 삼각형에 컬러 정보 추가

© 2012 생능출판사 All rights reserved 삼각형 회전