8/8/2019 Mini Curso iPhone
1/60
Development of Computer Graphics and
Digital Image Processing on the iPhone
Luciano Fagundes([email protected])
Rafael Santos([email protected])
domingo, 22 de agosto de 2010
mailto:[email protected]:[email protected]:[email protected]:[email protected]:[email protected]8/8/2019 Mini Curso iPhone
2/60
Agenda
Motivation iOS Devices Dev Basics
From Concept to the App Store
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
3/60
Agenda
Motivation
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
4/60
Motivation
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
5/60
Motivation
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
6/60
Motivation
Multi-purpouse device
Wide Community (Millions of iOS
devices world-wide) Easy to Deploy !!! (App Store)
Apps can and are changing the World (Size of the Market) See Gigaom
Infograph
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
7/60
Motivation
Old WAP-based Mobile Phones
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
8/60
iOS Devices
iPhone iPad iPod Touch
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
9/60
iOS Devices
iPhone iPad iPod Touch
Camera +Phone +
WiFi + 3G
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
10/60
iOS Devices
iPhone iPad iPod Touch
Camera +Phone +
WiFi + 3G
WiFi + 3G
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
11/60
iOS Devices
iPhone iPad iPod Touch
Camera +Phone +
WiFi + 3G
WiFi + 3G WiFi
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
12/60
iPhone
Tech Benchmark
Engadgetdomingo, 22 de agosto de 2010
http://www.engadget.com/2010/06/07/iphone-4-vs-the-smartphone-elite-evo-4g-n8-pre-plus-and-hd2/http://www.engadget.com/2010/06/07/iphone-4-vs-the-smartphone-elite-evo-4g-n8-pre-plus-and-hd2/8/8/2019 Mini Curso iPhone
13/60
iPhone4/iPad
Tech Benchmark
PCMagazine
The iPad's graphics capabilities comefrom a PowerVR SGX GPU, similar tothe one found in the iPhone 3GS andiPod Touch. If the iPad is using the samePowerVR SGX 535 as in the 3GS, it canrender about 28 million polygons/ second ...
domingo, 22 de agosto de 2010
http://www.pcmag.com/article2/0,2817,2362040,00.asphttp://www.pcmag.com/article2/0,2817,2362040,00.asphttp://www.pcmag.com/article2/0,2817,2362040,00.asp8/8/2019 Mini Curso iPhone
14/60
IPhone 3GS vs 3G
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
15/60
IPhone 3GS vs 3G
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
16/60
iPhone4 vs 3Gs
Early benchmarks of the iPhone 4 show it
to be 31% faster than the iPhone 3GSaccording to the Geekbench 2 app....
Macrumors
domingo, 22 de agosto de 2010
http://www.macrumors.com/2010/06/23/iphone-4-is-faster-than-3gs-and-slower-than-ipad-in-early-benchmarks/http://www.macrumors.com/2010/06/23/iphone-4-is-faster-than-3gs-and-slower-than-ipad-in-early-benchmarks/http://www.macrumors.com/2010/06/23/iphone-4-is-faster-than-3gs-and-slower-than-ipad-in-early-benchmarks/http://www.macrumors.com/2010/06/23/iphone-4-is-faster-than-3gs-and-slower-than-ipad-in-early-benchmarks/http://appshopper.com/utilities/geekbench-2http://appshopper.com/utilities/geekbench-28/8/2019 Mini Curso iPhone
17/60
iPhone4 vs 3Gs
Early benchmarks of the iPhone 4 show it
to be 31% faster than the iPhone 3GSaccording to the Geekbench 2 app....
Macrumors
Brings iPhone4 performance to ~36Million Polygons/sec
domingo, 22 de agosto de 2010
http://www.macrumors.com/2010/06/23/iphone-4-is-faster-than-3gs-and-slower-than-ipad-in-early-benchmarks/http://www.macrumors.com/2010/06/23/iphone-4-is-faster-than-3gs-and-slower-than-ipad-in-early-benchmarks/http://www.macrumors.com/2010/06/23/iphone-4-is-faster-than-3gs-and-slower-than-ipad-in-early-benchmarks/http://www.macrumors.com/2010/06/23/iphone-4-is-faster-than-3gs-and-slower-than-ipad-in-early-benchmarks/http://appshopper.com/utilities/geekbench-2http://appshopper.com/utilities/geekbench-28/8/2019 Mini Curso iPhone
18/60 Agenda
Dev BasicsMotivation iOS Devices
From Concept to the App Store
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
19/60 Agenda
Dev Basics
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
20/60
Dev Basics
What would you need to start Building Native Apps??
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
21/60
Dev Basics
What would you need to start Building Native Apps??
MacOS Device
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
22/60
Dev Basics
What would you need to start Building Native Apps??
MacOS Device iPhoneDev Center
domingo, 22 de agosto de 2010
http://developer.apple.com/iphone/index.actionhttp://developer.apple.com/iphone/index.actionhttp://developer.apple.com/iphone/index.actionhttp://developer.apple.com/iphone/index.action8/8/2019 Mini Curso iPhone
23/60
8/8/2019 Mini Curso iPhone
24/60
Dev Basics
Objective C
It is a superclass of ANSI C
It brings Object Orientation totraditional ANSI C
It is NOT C++ Objective C++ works with C++
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
25/60
Dev Basics
Objective C requires Header Files(*.h) and Implementation Files (*.m)
Objective C++ requires Header Files(*.h) and Implementation Files(*.mm)
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
26/60
Dev Basics
A header le from HelloWorld Project:
//// HelloWorldViewController.h
// HelloWorld//// Created by Luciano Fagundes on 19/08/10.// Copyright Pessoal 2010. All rights reserved.//
#import
@interface HelloWorldViewController : UIViewController {
}
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
27/60
Dev Basics
#import"HelloWorldViewController.h"
@implementation HelloWorldViewController
- ( id )initWithNibName:( NSString *) nibNameOrNil bundle:(NSBundle*) nibBundleOrNil {
return self;
}- ( void )loadView {}
- ( void )viewDidLoad {[super viewDidLoad];
}
- ( void )didReceiveMemoryWarning {!
[superdidReceiveMemoryWarning];!}
- ( void )viewDidUnload {
}
- ( void )dealloc {[super dealloc];
}
@enddomingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
28/60
Dev Basics
-( id )initWithNibName:(NSString *) nibName
bundle:(NSBundle *) nibBundleOrNil {return self;
}
Object Method in Objective C
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
29/60
Dev Basics
-
In Java it would be :
public
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
30/60
8/8/2019 Mini Curso iPhone
31/60
Dev Basics
initWithNibName :bundle :
In Java it would be :
initWithNibNameBundle
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
32/60
Dev Basics
(NSString *)nibName(NSBundle *)nibBundle
In Java it would be :
(String nibName, Bundle nibBundle)
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
33/60
Dev Basics
{
return self;}
In Java it would be :
{return self
}domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
34/60
Dev Basics
Sending a Message to an Object
[receiver doSomething][receiver doThis:this andDoThat:that]
In Java it would be :receiver.doSomething()receiver.DoThisAndDoThat(this,that)
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
35/60
Agenda
Dev BasicsMotivation iOS Devices
From Concept to the App Store
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
36/60
Agenda
From Concept to the App Store
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
37/60
Demo 1:XCode
Interface Builder
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
38/60
Agenda
Dev BasicsMotivation iOS Devices
From Concept to the App Store
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
39/60
App Store
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
40/60
App StoreCreate an Account on the IPhone Developer Program
Build you AppDownload XCode
Develop / Test
Download your Digital Certicate
Sign your App
Distribution Access iTune Connect
Enter all the marketing material for your App, including : MultipleLanguages, price, description, snapshots, target countries, etc
Submit App to Apple for Approval
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
41/60
App StoreMaintenance
Monitor your Sales Reports from the entire World cia iTunesConnect ( https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa )
Monitor your App reviews (Customer feedback) for the several
different countriesFix Bugs / Evolve the App
Submit updated App to Apple and start all over
GET RICH !!
You will get 70% of the price you have set for your App Another way would be launching free Apps monetized by
Advertisement (iAd, Admob and others)
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
42/60
App Store Advantages:
World Wide Exposure Very Hot Market for independent
developers
Very quick product cycle Up to the second user feedback
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
43/60
App Store
Risks:
Brutal Competition (Fast andFlexible) Apps can fade among the others Consumer has total control of the
market; very easy to discard andprovide a bad review for your App
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
44/60
Image Processing With Quartz
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
45/60
Showing Images
UIImageView * imgView =
[[UIImageView alloc ] initWithFrame ( 10,10,100,100 )]];UIImage * img =[[UIImage alloc ] initWithURL: ];
imgView.image = img;[img release
];
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
46/60
Acquiring ImagesUIImagePickerController *ipc =
[[UIImagePickerController alloc] init];
// Get images from the photo library.ipc.delegate = self;ipc.sourceType =
UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:ipc animated:YES];
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
47/60
Receiving Image-(void) imagePickerController:
(UIImagePickerController *)pickerdidFinishPickingMediaWithInfo:
(NSDictionary *)info {[self displayImage:[info objectForKey:
@"UIImagePickerControllerOriginalImage"]];[self dismissModalViewControllerAnimated:
YES];[picker release];
}
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
48/60
Receiving Image-(void) imagePickerController:
(UIImagePickerController *)pickerdidFinishPickingMediaWithInfo:
(NSDictionary *)info {
[self displayImage:[info objectForKey:@"UIImagePickerControllerOriginalImage"]];
[self dismissModalViewControllerAnimated:
YES];[picker release];
} -(void) imagePickerControllerDidCancel:
(UIImagePickerController *)picker;domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
49/60
8/8/2019 Mini Curso iPhone
50/60
Drawing //Manually creates a a Graphical Context
int pixelsWide = workArea.size.width;int pixelsHigh = workArea.size.height;
CGContextRef ctx=NULL;CGColorSpaceRef colorSpace;void* bitmapData;int bitmapByteCount;
int bitmapBytesPerRow;// find dimension of the image regardingits bytesbitmapBytesPerRow =(pixelsWide*4);
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
51/60
Drawing //RGBA !!bitmapByteCount =(bitmapBytesPerRow*pixelsHigh);
//Allocate image buffer
bitmapData=malloc(bitmapByteCount);if(bitmapData==NULL){
fprintf (stderr,"Memorynotallocated!");return NULL;
}
//create RGB color spacecolorSpace=
CGColorSpaceCreateDeviceRGB();domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
52/60
Drawing
//Create a Ghraphic Context with thejust created buffer
ctx=CGBitmapContextCreate(bitmapData,pixelsWide,pixelsHigh,
8,//bitspercomponenttipliedLast);
bitmapBytesPerRow,colorSpace,kCGImageAlphaPremultipliedlast);
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
53/60
Drawing // Returns NULLif Context creation failedif(ctx==NULL){ //5
free(bitmapData);} //release color space because it is nolonger needed
CGColorSpaceRelease(colorSpace);
! //Clear drawing area !CGContextClearRect(ctx, workArea);
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
54/60
Drawing // Create a sample array of values !! NSMutableArray * dataSet =[[NSMutableArray alloc] init];
[dataSet addObject:[NSNumbernumberWithInt:10]];
[dataSet addObject:[NSNumbernumberWithInt:15]];
![dataSet addObject:[NSNumbernumberWithInt:30]];
![dataSet addObject:[NSNumbernumberWithInt:5]]; ![dataSet addObject:[NSNumber
numberWithInt:18]];
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
55/60
Drawing ! // Create an array of colors for eachpie slice
NSMutableArray * colors =
[[NSMutableArray alloc] init];[colors addObject:[UIColor blueColor]];[colors addObject:[UIColor greenColor]];[colors addObject:[UIColor redColor]];[colors addObject:[UIColor grayColor]];[colors addObject:[UIColor whiteColor]];
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
56/60
Drawing // sum all values in the arrayfloat total = 0;for ( NSNumber * iTmp in dataSet ){
total+=[iTmp intValue];
}// Plots the Pie Chartfloat startDegree = 0;float endDegree = 0;float radius = workArea.size.width/2;
//Plot Itemsint item;CGContextSetStrokeColorWithColor(ctx,
[UIColor blackColor].CGColor );domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
57/60
Drawing for(inti=0;i
8/8/2019 Mini Curso iPhone
58/60
Drawing // Create image to be returned from the// Graphical Context
CGImageRef img =CGBitmapContextCreateImage(ctx);
UIImage * ret = [UIImageimageWithCGImage:img]
// Free up all remaining memoryfree(CGBitmapContextGetData(ctx));CGContextRelease(ctx);CGImageRelease(img);return ret;
}
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
59/60
Exporting to PhotoLibrary
UIImageWriteToSavedPhotosAlbum([imageView image], nil,nil,nil);
domingo, 22 de agosto de 2010
8/8/2019 Mini Curso iPhone
60/60
Case of Study Demo 2:
Sample CG Apps