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.

Slides:



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

Microsoft® Small Basic
2D Graphics Drawing Things. Graphics In your GUI, you might want to draw graphics E.g. draw lines, circles, shapes, draw strings etc The Graphics class.
Graphics You draw on a Graphics object The Graphics object cannot directly be created by your code, instead one is generated when the method paintComponent.
Working with images and scenes CS 5010 Program Design Paradigms “Bootcamp” Lesson 2.5 TexPoint fonts used in EMF. Read the TexPoint manual before you delete.
Chapter 9 Color, Sound and Graphics
COMPUTER PROGRAMMING I Objective 8.03 Apply Animation and Graphic Methods in a Windows Form (4%)
Chapter 3 Creating a Business Letter with a Letterhead and Table
© by Pearson Education, Inc. All Rights Reserved. continued …
Chapter 13 Graphics, Animation, Sound, and Drag-and-Drop Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved. McGraw-Hill.
Graphics and Multimedia. Outline Introduction Graphics Contexts and Graphics Objects Color Control.
Mouse event handling Mouse events( delegates EventHandler, event arguments EventArgs) MouseEnter: raised if the mouse cursor enters the area of the control.
PictureBox, Timer, Resources. Resources An easy and effective way to add pictures (photos, graphics) to your programs Using Resources guarantees that.
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.
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,
CS324e - Elements of Graphics and Visualization Java2D Graphics.
Lecture Set 13 Drawing Mouse and Keyboard Events Part A - Drawing.
Adobe InDesign CS5 – Illustrated Unit D: Working with Graphics.
Microsoft Office 2007: Introductory 1 Word Lesson 6 Working with Graphics Computer Applications 1.
1 Chapter 9 – Additional Controls and Objects 9.1 List Boxes and Combo Boxes 9.2 Eight Additional Controls and Objects 9.3 Multiple-Form Objects 9.4 Graphics.
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.
Java Software Solutions Lewis and Loftus Chapter 7 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Graphics -- Introduction The.
Tutorial 2 Drawing Text, Adding Shapes, and Creating Symbols.
Graphics and Multimedia Part #2
BIM211 – Visual Programming Objects, Collections, and Events 1.
Introduction to Flash. Topics What is Flash? What can you do with it? Simple animation Complex interactive web application, such as an online store. Starting.
Chapter 9 - VB.Net by Schneider1 Chapter 9 – Additional Controls and Objects 9.1 List Boxes, Combo Boxes, and the File-Opening Control The List Box Control.
1 Chapter 9 – Additional Controls and Objects 9.1 List Boxes and Combo Boxes 9.2 Eight Additional Controls and Objects 9.3 Multiple-Form Programs 9.4 Graphics.
Program Design and Coding
Microsoft Visual Basic 2012 CHAPTER THREE Program Design and Coding.
Microsoft Visual Basic 2010 CHAPTER THREE Program Design and Coding.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved CheckWriter Application Introducing Graphics and Printing.
Events with Data Arguments Data Values Travel with e.
The PictureBox Control Prefix Prefix – pic Image Property PictureBox Image Property – Changes the image or file that appears inside of the PictureBox SizeMode.
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. Chapter 13 Graphics, Animation, Sound and Drag-and-Drop.
COMPUTER PROGRAMMING I SUMMER 2011 Objective 8.02 Apply Procedures to Create Picture Boxes using Images. (5%)
Chapter 5. Shape tool  Vector images  Can be resized without loss of quality  Must rasterize to work with in some cases.
More Controls and Their Properties Part 4 dbg --- TextBox, CheckBox, RadioButton, GroupBox, ToolTips,
Creating an Animated Map – Lesson 91 Creating an Animated Map Lesson 9.
Microsoft Visual Basic 2005 BASICS Lesson 3 Events and Code.
Lecture 3.1 Using Graphics with JFrame. © 2006 Pearson Addison-Wesley. All rights reserved javax.swing.JFrame - int x - int y - int width - int.
Paint Tutorial Created February 2006 Start Paint: Start>Programs>Accessories>Paint.
1 Windows Forms II Chapter RadioButton / GroupBox Controls Used to solicit a multiple choice input. Radio buttons work as a group. Selecting one.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 6A Methods (Concepts)
Basic Graphics 03/03/16 & 03/07/16 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education - Prentice Hall, 2010.
 You won’t write a single line of program code.  Instead, you’ll use visual programming techniques.  Visual Studio processes your actions (such as mouse.
Graphical User Interface Concepts - Part 1 Session 08 Mata kuliah: M0874 – Programming II Tahun: 2010.
(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.
Adobe Photoshop CS5.
Flash Interface, Commands and Functions
Adobe Flash Professional CS5 – Illustrated
Basic Graphics Chapter 5 3/19/15 Thursday Section Only
Objective 8.02 Apply Procedures to Create Picture Boxes using Images.
Computer Programming I
Graphics and Multimedia
Microsoft® Small Basic
Drawing Mouse and Keyboard Events Part A - Drawing
CASE Tools Graphical User Interface Programming Using C#
Graphics -- Introduction
Chapter Lessons Use the Macromedia Flash drawing tools
Items, Group Boxes, Check Boxes & Radio Buttons
In this chapter, you will learn the following:
Repetition and Multiple Forms
Graphics and Multimedia
Chapter 12 Graphics in Windows and the Web
Working with images and scenes
Presentation transcript:

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 images are displayed at their native size and may be tiled if necessary. Other controls, such as Buttons, can display a single copy of image at its native size.  Images

3 PictureBox Control The PictureBox control (pic prefix) is expressly designed for displaying a single image. Images with a file extension of.bmp,.gif,.jpg,.jpeg,.png,.ico can be displayed. Animated.gif s can be displayed, as well. Images may be displayed in several modes by changing the SizeMode property.

4 SizeMode Settings Normal: Image displayed from its upper left at normal size (but may not display fully). CenterImage: Image displayed with center aligned with center of the PictureBox (but may not display fully). AutoSize: Image displayed at normal size and PictureBox is resized to fit image (therefore may affect other controls on form).

5 SizeMode Settings StretchImage: Image is resized to fit the size and shape of the PictureBox but image may be distorted. Zoom: There is no distortion of Image; unused areas of PictureBox may remain because image is kept in correct proportion.  SizeMode

6 The Image Object An Image object can be used to determine the normal dimensions of an image stored in a file. Use the Height and Width properties to determine the aspect ratio of an image. This must be accomplished before setting the Height and Width Properties of a PictureBox used in the StretchImage mode—otherwise distortion will result.  AspectRatio

7 Panel A Panel control is a container. A Panel is like a GroupBox, except that it does not have a Text Property (caption). Panels can be used to organize other controls such as radio buttons, check boxes, related buttons. –Add panel to form first. –Then add other controls to panel. A Panel can be drawn upon. Use pnl prefix for a panel.

Graphics and Drawing

9 3 Step Process to Draw 1.Create a Graphics object using the CreateGraphics() method. 2.Instantiate a Pen or Brush to draw with. 3.Use some of the drawing methods of the Graphics object.

10 Graphics Object Any form or control that can create a Graphics object supports drawing. Forms, Panels, and PictureBoxes are most often used as drawing surfaces. To create a Graphics object for a Form: Graphics gr = this.CreateGraphics();

11 Drawing Coordinates The ClientSize (part of form available for controls) of a Form is available as a drawing surface. Drawing coordinates begin with 0,0 in the upper left corner, measured in pixels. The maxima of the visible drawing coordinates correspond to the ClientSize.Width (x pixels) and ClientSize.Height (y pixels).

12 The Drawing Area ClientSize.Height ClientSize.Width X = 0 pixels, Y = 0 pixels

13 Drawing and Filling Lines and “open” shapes are drawn with a Pen object. Solid and patterned shapes are filled with a Brush object. You can specify the color and width for a Pen. If you do not specify a width, the default width is one pixel. You specify the color for a Brush, and you declare what type of Brush by declaring SolidBrush, HatchBrush, etc.

14 Drawing a Line Use the DrawLine() method of the Graphics object. The arguments for this method include the pen to be used and the coordinates of the ends of the lines, expressed in pixels.  DrawLine

15 Clearing the Graphics Object Any pixels drawn on the Graphics object can be “erased” with its Clear() method. The Clear() method requires an argument to set the color of the pixels after they are cleared. Normally, the pixels are reset to the default BackColor of the form or control. gr.Clear(this.Backcolor);

16 Pen Width When you instantiate a new Pen, you are able to control both the color and line width. Pen penName = new Pen(Color.Red, 4);  CustomPens  FlexiblePen

17 DrawRectangle() Draw a rectangle by stating the Pen, the coordinates of the upper left vertex, the width and the height. Note that if height and width are equal a square will be drawn.  DrawRectangle

18 DrawEllipse() Regard an ellipse as a conic section that is inscribed within a rectangle. Again, state the Pen to be used, the starting coordinates, the width and the height of a rectangle; an ellipse will be inscribed within the rectangle. Note that if the height and width are equal a circle will be drawn.  DrawEllipse

19 FillRectangle() Use the FillRectangle() method of the Graphics object with a Brushes.color object. gr.FillRectangle(Brushes.Blue, 0,0,50,100);  FillRectangle

20 FillEllipse() Use the FillEllipse() method of the Graphics object with a Brushes.color object. gr.FillEllipse(Brushes.Red, 0,0,50,100);  FillEllipse

21 DrawString() Although it is often easiest to add text to a window using a Label, there are special situations that may call for writing directly on the Client area. DrawString() uses a number of arguments to render a string of text using an indicated size and style of a font, starting at a given set of coordinates. A Font object must be instantiated for DrawString().  DrawString

22 Centering a Shape Knowing the ClientSize Height and Width properties and the height and width of a regular drawn shape allows simple calculations to center the shape. If the desired center point and radius of a circle are known, calculating the “starting coordinates” and the width is also trivial.  CenterCircle  CenterShape