Getting and displaying

Slides:



Advertisements
Similar presentations
Adobe Flash CS4 – Illustrated Unit E: Optimizing and Publishing a Movie.
Advertisements

Graphics CS 121 Concepts of Computing II. What is a graphic? n A rectangular image. n Stored in a file of its own, or … … embedded in another data file.
File Formats By Jack Turner. Raster (Bitmap) Raster or bitmap is a dot matrix data structure, containing columns of dots and rows, of a graphics image.
TOPIC 4 INTRODUCTION TO MEDIA COMPUTATION: DIGITAL PICTURES Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach.
Image Storage Bitmapped Graphics – in which an image is represented as a collection of dots Vector Graphics – in which an image is represented as a set.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 5 Working with Images Starting Out with Games & Graphics in.
Copyright © 2009 Curt Hill The Picture Object Getting and displaying.
1 Ethics of Computing MONT 113G, Spring 2012 Session 10 HTML Tables Graphics on the Web.
Section 8.1 Create a custom theme Design a color scheme Use shared borders Section 8.2 Identify types of graphics Identify and compare graphic formats.
Information Processes and Technology Multimedia: Graphics.
Working with Images William Pegram April 1, 2013.
ManipulatingPictures-Mod6-part11 Manipulating Pictures, Arrays, and Loops part 1 Barb Ericson Georgia Institute of Technology.
Graphics & Images What File Format Do I Use?. Graphics & Images …..are visual images presented on some form of media (drawings, print, web, digital video)
FILE TYPES FOR WEB DESIGN 1 HOW SHOULD I SAVE?. GRAPHICS INTERCHANGE FORMAT (GIF) Best used for flat-color, sharp-edged art or text Clip art, logos Compression.
Raster Graphics 2.01 Investigate graphic image design.
File Types. Terms Multimedia- the integration of text, sound, video and/or animation into a document Letters, brochures, newsletters, web pages or presentations.
Editing Images for the Web. Optimization/Compression Graphics optimization is important for fast web page display.
Image File Formats By Dr. Rajeev Srivastava 1. Image File Formats Header and Image data. A typical image file format contains two fields namely Dr. Rajeev.
HTTP transaction with Graphics HTML file + two graphics files.
Resources used for marketing the product By Jamie Colclough.
Image File Formats Harrow Computer Club – Wed, 1 Dec 2010 Bob Watson MA CMath MIMA MBCS.
Copyright © Curt Hill Further Picture Manipulation Considering position.
Image Editing Vocabulary Words Pioneer Library System Norman Public Library Nancy Rimassa, Trainer Thanks to Wikipedia ( help.
WEB GRAPHICS EXPLORING COMPUTER SCIENCE - LESSON 3-4.
Digital Photography Bethany Smith Learning Technologies Bethany Smith Learning Technologies.
BITMAPPED IMAGES & VECTOR DRAWN GRAPHICS
Section 8.1 Section 8.2 Create a custom theme Design a color scheme
2.01 Understand Digital Raster Graphics
2.01 Understand Digital Raster Graphics
DIGITAL MEDIA FOUNDATIONS
Understanding Web Graphics
Exploring Computer Science - Lesson 3-4
Chapter 3 Image Files © 2013 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website,
Exploring Computer Science - Lesson 3-4
More methods, more capabilities
Pixel, Resolution, Image Size
2.01 Understand Digital Raster Graphics
Image Formats.
Chapter 3 Graphics and Image Data Representations
Sci Vis I Exam Review Unit 6 File Formats.
2.01 Investigate graphic image design.
Chapter 3 Image Files © 2017 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
Exploring Computer Science - Lesson 3-4
A computer display is made up of small squares, called pixels.
Digital Images.
Chapter 3:- Graphics Eyad Alshareef Eyad Alshareef.
LET’S LEARN ABOUT GRAPHICS!
Digital Image Formats: An Explanation
Chapter 5 Working with Images
Digital imaging.
1.01 Investigate graphic types and file formats.
Introduction to Computer Graphics
Data Representation.
Representing Images 2.6 – Data Representation.
2.01 Understand Digital Raster Graphics
Terms 1 Terms 2 Terms 3 Terms 4 Terms 5 1pt 1 pt 1 pt 1pt 1 pt 2 pt
Barb Ericson Georgia Institute of Technology April 2006
2.01 Investigate graphic image design.
Introduction to Media Computation
Other displays Saving Arrays Using fors to process
Workshop for Programming And Systems Management Teachers
2.01 Understand Digital Raster Graphics
Methods Again Parameter Passage
Multimedia System Image
2.01 Investigate graphic image design.
Lecture 4 - Introduction to Computer Graphics
2.01 Investigate graphic image design.
The beginning of media computation Followed by a demo
Creating Digital Graphics
Methods Coding in Java Copyright © Curt Hill.
Presentation transcript:

Getting and displaying The Picture Object Getting and displaying Copyright © 2009 Curt Hill

How are pictures shown? Any image displayed on a computer is a series of pixels Pixel is an abbreviation of picture elements It is a dot of a particular color and intensity Each pixel has at least three components: Red, Green, Blue All of which are in the range 0-255 Copyright © 2009 Curt Hill

How are pictures organized? Pictures are always lines of pixels The lines are horizontal The pictures are always rectangular Each line is same length Monitors are generally in the 1024 by 760 size May be higher or lower depending on age and expense Digital cameras usually make much larger images Copyright © 2009 Curt Hill

How are pictures stored? There are many formats JPEG – Joint Photograph Expert Group Usually have a .JPG extension on the file GIF – Graphic Interchange Format Owned by CompuServe PNG is the public domain alternative Bitmap – Native format for most PCs Copyright © 2009 Curt Hill

Storage Most file formats compress the image in some way Bitmaps generally the least JPGs generally the best GIFs are best for line drawings Compression may be lossless or lossy JPG is lossy but the amount of loss is a parameter to the compression process Copyright © 2009 Curt Hill

Objects We will use the Java object named Picture and a few others It will allows us to read from disk and write to disk JPGs We will not have to worry about compression and other details We will be able to access individual pixels as well as display the picture easily Copyright © 2009 Curt Hill

Constructors Pictures like all other objects need a constructor Recall there were two Turtle constructors with different parameters One took just the World object The other took an initial location and the World object We will have multiple constructors with Picture as well Copyright © 2009 Curt Hill

Picture Constructors There is a default constructor: Picture pix = new Picture(); This creates a picture object but does not initialize it The more helpful is the String constructor: Picture(String fileName); The string is the file name of the picture This could be a constant string or we could find it Copyright © 2009 Curt Hill

View The string constructor makes the object It then loads the actual picture into memory It does not display it This is done with the show method: p.show(); It creates a new window to display the picture See the example program Copyright © 2009 Curt Hill

Example public class PictureDemo1{ public static void main(String [] a){ Picture p = new Picture( “C:/intro-prog-java/mediasources/barbara.jpg"); p.show(); } Copyright © 2009 Curt Hill

What’s wrong with this picture? The problem is the constant file name Every time we run the program we get the same file What we would really like is the ability to choose any picture file on the disk We do this with FileChooser object Copyright © 2009 Curt Hill

FileChooser FileChooser is an existing object Produces a common dialog box screen that makes it easy to choose a file The static method of the object that you want is called pickAFile This returns a string This can then be given to the Picture constructor Copyright © 2009 Curt Hill

The Program Copyright © 2009 Curt Hill

Started Copyright © 2009 Curt Hill

Display Copyright © 2009 Curt Hill

Commentary The String declaration and call to FileChooser was made two lines so PowerPoint would not wrap It could be: String fileName = FileChooser.pickAFile(); Displaying pictures is that easy Copyright © 2009 Curt Hill

Now What? In order to do picture manipulation we need flow of control This includes loops and conditionals This is our next major topic (chapter 4) However, a turtle can drop a picture onto its world Copyright © 2009 Curt Hill

Turtles and Pictures A turtle can place a picture on a world with the drop method This method takes a Picture as a parameter Something like this: Turtle t = new Turtle … Picture p = new Picture … … t.drop(p); Copyright © 2009 Curt Hill

Commentary The picture is not resized If the picture is too large it will be clipped by the world The orientation of the picture matches the turtle It will be shown tilted at the same angle as the turtle Consider the following program Copyright © 2009 Curt Hill

Example program public class PictureDemo1{ public static void main(String [] a){ String fileName; fileName = FileChooser.pickAFile(); Picture p = new Picture(fileName); World w = new World(); Turtle yertle = new Turtle(w); yertle.forward(50); yertle.drop(p); yertle.turn(-50); } Copyright © 2009 Curt Hill

Display Copyright © 2009 Curt Hill

FileChooser Again FileChooser is a wrapper for the JFileChooser object Part of the standard Java package FileChooser is made to be easier to use One problem with FileChooser is that it starts at the same directory Depends on the system In Windows usually MyDocuments The directory to start in can be changed Copyright © 2009 Curt Hill

setMediaPath A method that tells FileChooser where to start Example: FileChooser.setMediaPath(“D:/intro-prog-java”); Always use forward slashes rather than backslashes Copyright © 2009 Curt Hill

Finally Next we must do a demo using Turtles After that we figure out how to access and modify pixels This is the next presentation Copyright © 2009 Curt Hill