-
Notifications
You must be signed in to change notification settings - Fork 33
/
AppDelegate_iPad.mm
131 lines (102 loc) · 3.94 KB
/
AppDelegate_iPad.mm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
//
// AppDelegate_iPad.m
// ImageConversion
//
// Created by Paul Solt on 9/22/10.
// Copyright 2010 RIT. All rights reserved.
//
#import "AppDelegate_iPad.h"
#import "ImageHelper.h"
#import "GraphicsCommon.h"
@implementation AppDelegate_iPad
@synthesize window;
#pragma mark -
#pragma mark Application lifecycle
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
//
// UIImage *image = [UIImage imageNamed:@"Icon4.png"];
// int width = image.size.width;
// int height = image.size.height;
//
// // Create a bitmap
// unsigned char *bitmap = [ImageHelper convertUIImageToBitmapRGBA8:image];
//
// // Create a UIImage using the bitmap
// UIImage *imageCopy = [ImageHelper convertBitmapRGBA8ToUIImage:bitmap withWidth:width withHeight:height];
//
// // Cleanup
// if(bitmap) {
// free(bitmap);
// bitmap = NULL;
// }
//
// // Display the image copy on the GUI
// UIImageView *imageView = [[UIImageView alloc] initWithImage:imageCopy];
// CGPoint center = CGPointMake([UIScreen mainScreen].bounds.size.width / 2.0,
// [UIScreen mainScreen].bounds.size.height / 2.0);
// [imageView setCenter:center];
// [window addSubview:imageView];
// [imageView release];
CGPoint iconPosition = CGPointMake([UIScreen mainScreen].bounds.size.width / 2.0,
[UIScreen mainScreen].bounds.size.height / 2.0);
[self addImage:@"Icon4.png" atPosition:iconPosition];
CGPoint arrowPosition = CGPointMake([UIScreen mainScreen].bounds.size.width / 2.0,
[UIScreen mainScreen].bounds.size.height / 4.0);
[self addImage:@"ShareArrow.png" atPosition:arrowPosition];
[window makeKeyAndVisible];
return YES;
}
- (void)addImage:(NSString *)theFilename atPosition:(CGPoint)thePosition {
UIImage *image = [UIImage imageNamed:theFilename];
int width = image.size.width;
int height = image.size.height;
// Create a bitmap
unsigned char *bitmap = [ImageHelper convertUIImageToBitmapRGBA8:image];
Color3D *colorOut = new Color3D[width * height];
ConvertImageRGBA8ToColor3d(bitmap, colorOut, width, height);
// **NOTE:** Test Print the colors using a c++ code to check transparency
// for(int i = 0; i < width * height; ++i) {
// std::cout << colorOut[i] << std::endl;
// }
// Create a UIImage using the bitmap
UIImage *imageCopy = [ImageHelper convertBitmapRGBA8ToUIImage:bitmap withWidth:width withHeight:height];
// Cleanup
if(bitmap) {
free(bitmap);
bitmap = NULL;
}
// Display the image copy on the GUI
UIImageView *imageView = [[UIImageView alloc] initWithImage:imageCopy];
[imageView setCenter:thePosition];
[window addSubview:imageView];
[imageView release];
}
- (void)applicationWillResignActive:(UIApplication *)application {
/*
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
*/
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
/*
Restart any tasks that were paused (or not yet started) while the application was inactive.
*/
}
- (void)applicationWillTerminate:(UIApplication *)application {
/*
Called when the application is about to terminate.
*/
}
#pragma mark -
#pragma mark Memory management
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
/*
Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
*/
}
- (void)dealloc {
[window release];
[super dealloc];
}
@end