Contents

■ Contents at a Glance iii

■ About the Author viii

■ About the Technical Reviewers ix

■ Acknowledgments x

■ Chapter 1: Introduction to Android Imaging 1

Image Capture Using the Built-In Camera Application 1

Returning Data from the Camera App 3

Capturing Larger Images 5

Displaying Large Images 6

Image Storage and Metadata 10

Obtaining an URI for the Image 11

Updating Our CameraActivity to Use MediaStore for Image Storage and to Associate Metadata 12

Retrieving Images Using the MediaStore 16

Creating an Image Viewing Application 18

Internal Metadata 21

Summary 21

■ Chapter 2: Building Custom Camera Applications 23

Using the Camera Class 23

Camera Permissions 24

Preview Surface 24

Implementing the Camera 25

Putting It All Together 35

Extending the Custom Camera Application 38

Building a Timer-Based Camera App 38

Building a Time-Lapse Photography App 43

Summary 45

■ Chapter 3: Image Editing and Processing 47

Selecting Images Using the Built-In Gallery Application 47

Drawing a Bitmap onto a Bitmap 52

Basic Image Scaling and Rotating 54

Enter the Matrix 55

Matrix Methods 58

Alternative to Drawing 64

Image Processing 65

ColorMatrix 65

Altering Contrast and Brightness 67

Changing Saturation 69

Image Compositing 69

Summary 78

■ Chapter 4: Graphics and Touch Events 79

Canvas Drawing 79

Bitmap Creation 79

Bitmap Configuration 80

Creating the Canvas 81

Working with Paint 82

Drawing Shapes 83

Drawing Text 87

Finger Painting 93

Touch Events 93

Drawing on Existing Images 97

Saving a Bitmap-Based Canvas Drawing 101

Summary 104

■ Chapter 5: Introduction to Audio on Android 105

Audio Playback 105

Supported Audio Formats 106

Using the Built-In Audio Player via an Intent 107

Creating a Custom Audio-Playing Application 109

MediaStore for Audio 115

Summary 123

■ Chapter 6: Background and Networked Audio 125

Background Audio Playback 125

Services 125

Local Service plus MediaPlayer 129

Controlling a MediaPlayer in a Service 132

Networked Audio 137

HTTP Audio Playback 137

Streaming Audio via HTTP 143

RTSP Audio Streaming 150

Summary 150

■ Chapter 7: Audio Capture 151

Audio Capture with an Intent 151

Custom Audio Capture 154

MediaRecorder Audio Sources 155

MediaRecorder Output Formats 155

MediaRecorder Audio Encoders 156

MediaRecorder Output and Recording 156

MediaRecorder State Machine 156

MediaRecorder Example 157

Other MediaRecorder Methods 162

Inserting Audio into the MediaStore 167

Raw Audio Recording with AudioRecord 167

Raw Audio Playback with AudioTrack 170

Raw Audio Capture and Playback Example 172

Summary 177

■ Chapter 8: Audio Synthesis and Analysis 179

Digital Audio Synthesis 179

Playing a Synthesized Sound 180

Generating Samples 182

Audio Analysis 187

Capturing Sound for Analysis 188

Visualizing Frequencies 189

Summary 193

■ Chapter 9: Introduction to Video 195

Video Playback 195

Supported Formats 195

Playback Using an Intent 196

Playback Using VideoView 197

Adding Controls with MediaController 199

Playback Using a MediaPlayer 200

Summary 210

■ Chapter 10: Advanced Video 211

MediaStore for Retrieving Video 211

Video Thumbnails from the MediaStore 212

Full MediaStore Video Example 212

Networked Video 218

Supported Network Video Types 218

Network Video Playback 221

Summary 228

■ Chapter 11: Video Capture 229

Recording Video Using an Intent 229

Adding Video Metadata 232

Custom Video Capture 235

MediaRecorder for Video 235

Full Custom Video Capture Example 246

Summary 250

■ Chapter 12: Media Consumption and Publishing Using Web Services 251

Web Services 251

HTTP Requests 252

JSON 254

Pulling Flickr Images Using JSON 257

Location 263

Pulling Flickr Images Using JSON and Location 266

REST 273

Representing Data in XML 273

SAX Parsing 274

HTTP File Uploads 278

Making an HTTP Request 278

Uploading Video to Blip.TV 280

Summary 290

Was this article helpful?

0 0

Post a comment