Lecture 5 Graphics Erick Pranata. » Graphics Overview » About GDI+ » Getting Started.

Slides:



Advertisements
Similar presentations
Computer Graphics Prof. Muhammad Saeed Dept. of Computer Science & IT Federal Urdu University of Arts, Sciences and Technology.
Advertisements

Nov 2005 MSc Slide 1 - Another Example of a Structural Pattern Alternative way of adding Functionality to an existing class (alternative to a derived class)
CHAPTER 20 CREATING SVG GRAPHICS. LEARNING OBJECTIVES How to embed a graphic stored within a.SVG file in an HTML page How to use the and tag pair to specify.
Chapter 9 Color, Sound and Graphics
COMPUTER PROGRAMMING I Objective 8.03 Apply Animation and Graphic Methods in a Windows Form (4%)
Graphics and Multimedia Session 13 Mata kuliah: M0874 – Programming II Tahun: 2010.
Foundation Level Course
Using MS Paint by A. Satariano Launching MS Paint Click on the Start Button Move the mouse up to the Programs Folder. Then move the mouse up to the Accessories.
Računarska grafika GDI+ (Graphics Device Interface Plus)
User Interface Programming in C#: Graphics
Chapter 13 Graphics, Animation, Sound, and Drag-and-Drop Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved. McGraw-Hill.
1 L38 Graphics and Java 2D™ (3). 2 OBJECTIVES In this chapter you will learn:  To understand graphics contexts and graphics objects.  To understand.
 2006 Pearson Education, Inc. All rights reserved Graphics and Multimedia.
Graphics and Multimedia. Outline Introduction Graphics Contexts and Graphics Objects Color Control.
Graphics and Multimedia. Outline Drawing Polygons and Polylines Advanced Graphics Capabilities.
GDI+ getting started. GDI+  Class-based API for C/C++  Windows Graphics Device Interface (GDI)  Device-independent applications  Services 1)2D vector.
Java Review Structure of a graphics program. Computer Graphics and User Interfaces Java is Object-Oriented A program uses objects to model the solution.
Računarska grafika GDI+ (Graphics Device Interface Plus)
Graphics and Multimedia. Introduction The language contains many sophisticated drawing capabilities as part of namespace System.Drawing and the other.
Graphics Images – PictureBox control Drawing graphics - Graphics object Multimedia controls PictureBox control Image property – select image Choose how.
Computer Graphics Prof. Muhammad Saeed. Drawing and Transformation of Figures in C# August 1,
1 Chapter 26 D&D – Graphics Outline 26.1 Introduction 26.3 Graphics Contexts and Graphics Objects 26.4 Color Control 26.5 Font Control 26.6 Drawing Lines,
Software Engineering1 The.NET Framework and the CLI 2D Graphics with GDI+ Visual Studio.NET 2008.
Lecture Set 13 Drawing Mouse and Keyboard Events Part A - Drawing.
Computer Programming and Basic Software Engineering 9 Building Graphical User Interface A Brief Introduction to GDI+ S.R.G. Fraser, Pro Visual C++/CLI.
CST238 Week 5 Questions / Concerns? Announcements – HW#1 due (Project ideas) – Check-off Take Home lab#4 Recap New topics – Drawing Coming up: – GUI Bloopers.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 26 – CheckWriter Application Introducing Graphics.
1 Windows Graphics. 2 Objectives You will be able to Use the Windows GDI+ to draw arbitrary figures and text on a Windows form. Add a handler for the.
Computer Graphics Lecture 1 July 11, Computer Graphics What do you think of? The term “computer graphics” is a blanket term used to refer to the.
Object Oriented Programming Graphics and Multimedia Dr. Mike Spann
C# Programming Lecture 4 “GDI+” PGL01/CSP/2006.
Graphics and Multimedia Part #2
COM148X1 Interactive Programming Lecture 6. Topics Today Generate Random Numbers Graphics Animation.
Chapter 15 Graphics and Java 2D™ Java How to Program, 8/e (C) 2010 Pearson Education, Inc. All rights reserved.
Lecture Set 13 Drawing Mouse and Keyboard Events Part B – Mouse and Keyboard Events.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved CheckWriter Application Introducing Graphics and Printing.
Chapter2: Drawing a Window. Drawing with the GDI.
GDI+ 1. Objectives 2 GDI+ class  Create and render Graphic  Display information on the computer screen, printer 3.
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. Chapter 13 Graphics, Animation, Sound and Drag-and-Drop.
Računarska grafika GDI+ (Graphics Device Interface Plus)
1 Graphic Device Interface (GDI). 2 Class Form A Form is a representation of any window displayed in your application. The Form class can be used to create.
Ray Konopka Developing Custom.NET Components DevCon Course No: 3118.
Graphics and Multimedia. OUTLINE Font Control Drawing Lines, Rectangles and Ovals Drawing Arcs Drawing a General Path.
Images Part 11 dbg. 2 Images The form and several controls can display a number of different types of image files in the BackgroundImage Property. These.
Windows Programming C# Software Development. Overview  DLLs / PInvoke  DirectX .NET Component Library  Custom Controls  Event Model (in C++)  GUI.
 2002 Prentice Hall. All rights reserved. 1 Outline Mouse Event Handling Keyboard Event Handling Graphical User Interface Concepts:
Resources & Bitmaps Adding clip art to your application.
(PART III) Graphics and Multimedia 16/02/1437 Lect6 CT
GDI +. Graphics class's methods System.Drawing Graphics Objects.
IS502:M ULTIMEDIA D ESIGN FOR I NFORMATION S YSTEM D IGITAL S TILL I MAGES Presenter Name: Mahmood A.Moneim Supervised By: Prof. Hesham A.Hefny Winter.
Georgia Institute of Technology Drawing in Java – part 2 Dr Usman Saeed Assistant Professor Faculty of Computing and Information Technology North Jeddah.
10/20/2005week71 Graphics, mouse and mouse motion events, KeyEvent Agenda Classes in AWT for graphics Example java programs –Graphics –Mouse events –Mouse.
(PART II) Graphics and Multimedia. Font Control Font s  After a Font is created, its properties cannot be modified  Programmers must create a new Font.
(PART II) Graphics and Multimedia 11/02/1437 Lect6 (Part 2)
Csharp ile Grafik.
Graphics and Multimedia
Lines, Curves, and Area Fill
Graphics.
Graphics and Multimedia
Graphics and Multimedia
Drawing Mouse and Keyboard Events Part A - Drawing
ThS. Nguyễn Hà Giang Khoa CNTT - Hutech
CASE Tools Graphical User Interface Programming Using C#
Graphics and Multimedia
Repetition and Multiple Forms
Graphics and Multimedia
Chapter 12 Graphics in Windows and the Web
CPT 450 Computer Graphics 3rd Lecture.
Lines, Curves and Area Fills
Presentation transcript:

Lecture 5 Graphics Erick Pranata

» Graphics Overview » About GDI+ » Getting Started

» Successor of Graphic Device Interface » Responsible for displaying information on screens and printers » Namespaces: ˃System.Drawing ˃System.Drawing.Drawing2D ˃System.Drawing.Imaging ˃System.Drawing.Text ˃System.Drawing.Printing

» Two-dimensional (2-D) vector graphics ˃Lines, curves, etc. ˃Specified by set of points in coordinate system » Imaging ˃Bitmap » Typography

» Graphics Class ˃DrawLine receives a Pen object ˃FillRectangle receives a LinearGradientBrush object ˃Font and StringFormat ˃Rectangle, Point, Size ˃BitmapData

» Graphics Overview » About GDI+ » Getting Started

» Lines » Rectangles » Ellipses » Arcs » Polygons » Cardinal Splines » Bezier Splines

myGraphics.DrawRectangle( myPen, 20, 10, 100, 50 );

» Line ˃ myGraphics.DrawLine(myPen, 4, 2, 12, 6); ˃ Point myStartPoint = new Point(4, 2); Point myEndPoint = new Point(12, 6); myGraphics.DrawLine( myPen, myStartPoint, myEndPoint ); » Pen ˃ Pen myPen = new Pen(Color.Blue, 2); myGraphics.DrawLine( myPen, 0, 0, 60, 30 ); ˃ myPen.DashStyle = DashStyle.Dash; ˃StartCap and EndCap: +Square, Rounded, triangular, or custom shape

» Rectangle ˃ myGraphics.DrawRectangle( myPen, 100, 50, 80, 40 ); ˃ Rectangle myRectangle = new Rectangle(100, 50, 80, 40); myGraphics.DrawRectangle( myPen, myRectangle );

» Ellipse ˃ myGraphics.DrawEllipse(myPen, 100, 50, 80, 40); ˃ Rectangle myRectangle = new Rectangle(100, 50, 80, 40); myGraphics.DrawEllipse(myPen, myRectangle); » Arc ˃ myGraphics.DrawArc(myPen, 100, 50, 140, 70, 30, 180);

» Point[] myPointArray = { new Point(0, 0), new Point(50, 30), new Point(30, 60) }; myGraphics.DrawPolygon( myPen, myPointArray );

» myGraphics.DrawCurve(myPen, myPointArray, 1.5f);

» Spesified by four points: ˃Two end points ˃Two control points: act as magnets » myGraphics.DrawBezier(myPen, 0, 0, 40, 20, 80, 150, 100, 10);

» Combining vector graphics » Example: ˃ GraphicsPath myGraphicsPath = new GraphicsPath(); myGraphicsPath.AddLine(0, 0, 30, 20); myGraphicsPath.AddEllipse(20, 20, 20, 40); myGraphicsPath.AddBezier(30, 60, 70, 60, 50, 30, 100, 10); myGraphics.DrawPath(myPen, myGraphicsPath);

» Solid Brush ˃ SolidBrush mySolidBrush = new SolidBrush(Color.Red); myGraphics.FillEllipse( mySolidBrush, 0, 0, 60, 40 ); » Hatch Brush ˃ HatchBrush myHatchBrush = new HatchBrush( HatchStyle.Vertical, Color.Blue, Color.Green );

» Texture Brush ˃ Image myImage = Image.FromFile( "MyTexture.bmp“ ); TextureBrush myTextureBrush = new TextureBrush(myImage); » Gradient Brush ˃ LinearGradientBrush myLinearGradientBrush = new LinearGradientBrush( myRectangle, Color.Blue, Color.Green, LinearGradientMode.Horizontal );

» myGraphics.FillRegion( mySolidBrush, myRegion);

» myGraphics.Clip = myRegion; myGraphics.DrawLine( myPen, 0, 0, 200, 200);

» myGraphics.SmoothingMode = SmoothingMode.AntiAlias;

» Graphics Overview » About GDI+ » Getting Started

» PaintEventArgs from Paint event ˃ private void Form1_Paint( object sender, System.Windows.Forms.PaintEventArgs pe ) { Graphics g = pe.Graphics; } » CreateGraphics of a component ˃ Graphics g = this.CreateGraphics(); » Create a Graphics object from an Image ˃ Bitmap myBitmap = new Bitmap("myPic.bmp"); Graphics g = Graphics.FromImage(myBitmap);

» Pen » Brush » Font » Color Do not forget to dispose them after use

» Use Invalidate() method ˃ this.Invalidate()

» string drawString = "Sample Text"; » Font drawFont = new Font("Arial", 16); » SolidBrush drawBrush = new SolidBrush(Color.Black); » StringFormat drawFormat = new StringFormat(); » myGraphics.DrawString( drawString, drawFont, drawBrush, 150, 50, drawFormat);

» MouseClick » MouseDoubleClick » MouseDown » MouseEnter » MouseHover » MouseLeave » MouseMove » MouseUp

» Graphics and Drawing in Windows Forms, us/library/a36fascx(v=vs.110).aspxhttp://msdn.microsoft.com/en- us/library/a36fascx(v=vs.110).aspx