COSC 4126 images - D Goforth Images, Buffering and Animation controlling full screen graphics.

Slides:



Advertisements
Similar presentations
More Java Drawing in 2D Animations with Timer. Drawing Review A simple two-dimensional coordinate system exists for each graphics context or drawing surface.
Advertisements

Raster graphics. Colour depth 01 1 bit pr pixel = 2 combinations (2 1 ): 2 bits pr pixel = 4 combinations (2 2 ): bits pr pixel = 16 combinations(2.
UID – Swing and Graphics Boriana Koleva
3.1. G RAPHICS I The use of images within games. Reflections and advice on the games proposed in the Week 2 Hand-in.
Java Applets A First Program. Applet Example /* The world’s simplest program, repeated once more in another format in an attempt to turn all of you into.
Graphics Programming UQC117S2 Semester /4. Session 3 1 Drawing in Java 2D Graphics API.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter Java Multimedia: Images, Animation, Audio.
Applets, Graphical User Interfaces, and Threads / Chapter 9 1 Applets, Graphical User Interfaces, and Threads.
Unit 071 Review of Applets Learning Outcomes oDistinguish between Java Applications and Java Applets. oWrite applet programs that can load images and play.
1 CS2200 Software Development Lecture: Simple 2-d Animation in Java A.O’Riordan, 2009 Based on two examples from K Brown (2007) and D. Brackeen (2004)
Lecture18 Java Game Programming I – An Example. Introduction We will look at the following We will look at the following Accelerated Mode GraphicsAccelerated.
A Simple Applet. Applets and applications An applet is a Java program that runs on a web page –Applets can be run from: Internet Explorer Netscape Navigator.
2.01 Understand Digital Raster Graphics
Fonts And Image. Fonts To display text, we choose a font. Recall that we are dealing with pixels in graphics programming. To choose a font, we need to.
1 Features of Java CS 3331 Fall Outline  Abstract class  Interface  Application --- animation applets.
Java2D Graphics Summary Images,. Full-Screen Exclusive Mode -Full-screen exclusive mode is a powerful feature of J2SE TM version 1.4 that allows the programmer.
Nat 4/5 - Software Design and Development – Low Level Operations - 1 National 4/5 – Computing Science Information Systems Design and Development Media.
Zinnia Bell. RAWimages are image files that have not yet processed, they contain minimally processed data from the image sensor of either a image scanner,
Guide to Programming with Python
Applets  The Applet Class  The HTML Tag F Passing Parameters to Applets.
COMP Bitmapped and Vector Graphics Pages Using Qwizdom.
Java Applets Chapter 15. Overview A Java Applet allows us to run a Java program from a web browser. Usually, just the.class file is sent to the client.
Java Programming, 3e Concepts and Techniques Chapter 2 - Part 2 Creating a Java Application and Applet.
Module Code: CU0001NI Technical Information on Digital Images Week -2.
Lecture 4 - Introduction to Computer Graphics
Threads and Multimedia Animation, Images, Sound. Animation nAnimation, displaying a sequence of frames to create the illusion of motion, is a typical.
Presentation Design: Graphics. More About Color “Bit depth” of colors -- This is based on the smallest unit of information that a computer understands.
Chapter 2 Getting Started: Drawing Figures. The Framebuffer Lecture 2 Fri, Aug 29, 2003.
Lesson 27: Introduction to the Java GUI. // helloworldbutton.java import java.awt.*; import javax.swing.*; class HelloButton{ public static void main.
PROGARMMING THROUGH JAVA Presentation on IMAGES Group No:3 Presented By: Anthony Narzary (DC2012MCA0002) Chandra Gupta Bora (DC2012MCA0009) Dipankar Saikia.
CSE 219 Computer Science III Images. HW1 Has been posted on Blackboard Making a Game of Life with limited options.
1Computer Graphics Input and Interaction Lecture 8 John Shearer Culture Lab – space 2
Copyright © 2009 Curt Hill The Picture Object Getting and displaying.
ImageJ EE4H, M.Sc Computer Vision Dr. Mike Spann
Common file formats  Lesson Objective: Understanding common file formats and their differences.  Learning Outcome:  Describe the type of files which.
J McQuillan SE204: 2004/2005: Lecture 4slide 1 The Graphics Class Used when we need to draw to the screen Two graphics classes –Graphics –Graphics2D.
Canvas and Graphics CS 21a. 9/26/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved L17: Canvas.
Digital Multimedia, 2nd edition Nigel Chapman & Jenny Chapman Chapter 3 This presentation © 2004, MacAvon Media Productions Introduction to Computer Graphics.
The Drawing program – Java Applets
Pravin Yannawar, DOCS, NMU Jalgaon Basic Java : Applets 2 Objectives of This Session Identify the need for Applets Distinguish between Applets and Applications.
Computer Images Can store color info about each pixel, but makes file BIG Compression for Web 15.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Review of Graphics in Java,
Graphic Format Factors
High Performance Java Swing Animation David Wallace Croft Presented to the Plano Java Users Group Plano, TX Copyright 2004 David Wallace Croft.
Java Programming Working with Sound and Images. Topics Learn about the paint() and repaint() methods Learn about paintComponent() method Use the drawString()
Intro to Applets. Applet Applets run within the Web browser environment Applets bring dynamic interaction and live animation to an otherwise static HTML.
Module 4- Build a Game Understanding Pictures Compression – Making things smaller.
Features of Java CS 3331 Sections and 5.5.
Chapter 16 Multimedia F Audio Files F Playing Audio F Running Audio on a Separate Thread F Displaying Images F Displaying a Sequence of Images  Using.
Practical Session 10: Animation. Animation kinds There are three basic kinds of animation: 1. Moving object 2. Changing pictures 3. Combination of 1 and.
Introduction to Images & Graphics JMA260. Objectives Images introduction Photoshop.
Creating a Java Application and Applet
Digital File Formats By Ali Aslam. JPEG JPEG Stands for Joint Photographic Experts Group. JPEG uses a lossy compression routine. Lossy compression means.
1 Perception and VR MONT 104S, Fall 2008 Lecture 20 Computer Graphics and VR.
Introduction to Applets Chapter 21. Applets An applet is a Java application that is intended to be invoked and executed through a Web browser. Click Here.
עקרונות תכנות מונחה עצמים תרגול 7: אנימציה. בשבוע שעבר  paint  Graphics  repaint.
HTTP transaction with Graphics HTML file + two graphics files.
Information Systems Design and Development Media Types Computing Science.
Chapter 14: Multimedia Audio Files Audio Files Playing Audio Playing Audio Running Audio on a Separate Thread Running Audio on a Separate Thread Displaying.
Creating an Object that can draw itself The paint method can ‘draw’ because it is passed a graphics environment as a parameter. If a class method is passed.
CPCS 391 Computer Graphics Lab One. Computer Graphics Using Java What is Computer Graphics: Computer graphics are graphics created using computers and,
Reference: What is it? A multimedia python library – Window Management – Graphics geometric shapes bitmaps (sprites) – Input Mouse Keyboard.
CPT 450 Computer Graphics 12th Lecture – Animation.
1.01 Investigate graphic types and file formats.
Raster Images CPSC 1030.
Web Design and Development
Java applets 1/3/2019.
Java Programming COMP-417 Applet
עקרונות תכנות מונחה עצמים תרגול 7: אנימציה
APPLET PROGRAMMING.
Presentation transcript:

COSC 4126 images - D Goforth Images, Buffering and Animation controlling full screen graphics

COSC 4126 images - D Goforth A screen manager class  manages the full screen display sets display parameters initializes, terminates full screen display provides access to full screen window take over display of screen to improve quality

COSC 4126 images - D Goforth Images  transparency  file formats  file input

COSC 4126 images - D Goforth Transparency  three types opaque transparent translucent

COSC 4126 images - D Goforth Opaque  every pixel displayed image

COSC 4126 images - D Goforth Transparent  every pixel displayed or not image

COSC 4126 images - D Goforth Translucent  every pixel can be partly transparent image

COSC 4126 images - D Goforth File formats  GIF – don’t use it – PNG always better  PNG any colour bit depth any transparency compression  JPEG 24 bit colour only opaque only efficient but lossy compression good for photos for screen use

COSC 4126 images - D Goforth Reading images - applets  methods in Applet class Image getImage (URL url) Image getImage (URL url, String fName)  image does not start loading till drawing of image begins

COSC 4126 images - D Goforth Reading images - applets e.g. import java.applet.*; import java.awt.*; public class ImageEG extends Applet { private Image im; public void init() { im = getImage(getDocumentBase(), ”photo.png”); } public void paint(Graphics g) { g.drawImage(im, 0, 0, this); }

COSC 4126 images - D Goforth Reading images - applications  image reader is in default toolkit: this method caches the image Image im = Toolkit.getDefaultToolkit().getImage(“photo.png”); to reload file for every display Image im = Toolkit.getDefaultToolkit().createImage(“photo.png”);  these methods work like the applet method (load with display)

COSC 4126 images - D Goforth Reading images - applications  to read an image completely: method does not return till image is loaded import javax.swing.*;... Image im = new ImageIcon(“photo.png”).getImage(); Brackeen files: ImageTest.java, ImageSpeedTest.java

COSC 4126 images - D Goforth Animation  animation = shape change + motion set of shapes (frames) are alternated in a timed sequence each shape is an Image 200 ms325 ms625 ms675 ms200 ms im1 im2im1 im3im1 one cycle, repeated

COSC 4126 images - D Goforth Animation  Animation class frames and times total time for one animation cycle current frame current time 200 ms325 ms625 ms675 ms200 ms im1 im2im1 im3im1 total time of cycle

COSC 4126 images - D Goforth Animation  store frames in a list (ArrayList) frame (AnimFrame) image plus duration ArrayList 0 im im im im ms325 ms625 ms675 ms200 ms im1 im2im1 im3im1 total time duration

COSC 4126 images - D Goforth Animation  updating the animation update current time (mod total duration) update current frame ArrayList 0 im im im im ms325 ms625 ms675 ms200 ms im1 im2im1 im3im1 total time duration

COSC 4126 images - D Goforth Animation animation loop  initialize current time from clock  while current time < end time get clock time determine elapsed time, new current time update animation(s) with elapsed time draw animations  Brackeen example AnimationTest1.java

COSC 4126 images - D Goforth Animation quality  active rendering – control painting directly (not through event queue)  double buffering (remove flicker)  synchronizing with monitor refresh rate (remove tearing) BufferStrategy class

COSC 4126 images - D Goforth Active rendering  full screen window ignores event-queue paint events fullScreen.ignoreRepaint(); then..  get graphics object for the window  paint the window  dispose the graphics object Graphics g = fullScreen.getGraphics(); draw(g); g.dispose();

COSC 4126 images - D Goforth Double buffering (eliminate flicker)  2 display buffers first is displayed while second is painted first, second swapped

COSC 4126 images - D Goforth Synchronizing with refresh (eliminate tearing)  switch buffers between refreshes, not during tear:  Brackeen example AnimationTest2.java

COSC 4126 images - D Goforth Brackeen’s ScreenManager class(1) ScreenManager  public ScreenManager()  public DisplayMode[] getCompatibleDisplayModes()  public DisplayMode findFirstCompatibleMode(DisplayMode modes[])  public DisplayMode getCurrentDisplayMode()  public boolean displayModesMatch(DisplayMode mode1, DisplayMode mode2)  public void setFullScreen(DisplayMode displayMode)

COSC 4126 images - D Goforth Brackeen’s ScreenManager class(2) ScreenManager  public JFrame getFullScreenWindow()  public int getWidth()  public int getHeight()  public Graphics2D getGraphics()  public void update()  public void restoreScreen()  public BufferedImage createCompatibleImage(int w, int h,  int transparancy)

COSC 4126 images - D Goforth Sprites: Shape change and Motion  object that moves on graphic display may change shape also  Sprite object Animation position on screen velocity get and set methods update method computes new position and Animation image

COSC 4126 images - D Goforth Sprite movement plus shape change  elapsed time et since last update ®distance moved ®x = x + et * dx ®y = y + et * dy ®Animation determines new image Brackeen code: Sprite.java SpriteTest1.java, SpriteTest2.java