Initial check in of rough, experimental iPhone code. Not to be used just yet; just...
authorsrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Mon, 25 Feb 2008 21:57:48 +0000 (21:57 +0000)
committersrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Mon, 25 Feb 2008 21:57:48 +0000 (21:57 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@228 59b500cc-1b3d-0410-9834-0bbf25fbcc57

iphone/experimental/Info.plist [new file with mode: 0644]
iphone/experimental/Makefile [new file with mode: 0644]
iphone/experimental/README [new file with mode: 0644]
iphone/experimental/ZXing.m [new file with mode: 0644]
iphone/experimental/ZXingApplication.h [new file with mode: 0644]
iphone/experimental/ZXingApplication.m [new file with mode: 0644]
iphone/experimental/icon.png [new file with mode: 0644]

diff --git a/iphone/experimental/Info.plist b/iphone/experimental/Info.plist
new file mode 100644 (file)
index 0000000..47927fb
--- /dev/null
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!--
+ Copyright 2008 Google Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<plist version="1.0">
+<dict>
+       <key>CFBundleDevelopmentRegion</key>
+       <string>en</string>
+       <key>CFBundleExecutable</key>
+       <string>ZXing</string>
+       <key>CFBundleIdentifier</key>
+       <string>zxing</string>
+       <key>CFBundleInfoDictionaryVersion</key>
+       <string>0.1</string>
+       <key>CFBundleName</key>
+       <string>ZXing</string>
+       <key>CFBundlePackageType</key>
+       <string>APPL</string>
+       <key>CFBundleShortVersionString</key>
+       <string>1.0.0</string>
+       <key>CFBundleSignature</key>
+       <string>????</string>
+       <key>CFBundleVersion</key>
+       <string>1.0</string>
+</dict>
+</plist>
diff --git a/iphone/experimental/Makefile b/iphone/experimental/Makefile
new file mode 100644 (file)
index 0000000..c9957f7
--- /dev/null
@@ -0,0 +1,36 @@
+# Copyright 2008 Google Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+CC=/usr/local/bin/arm-apple-darwin-gcc -v
+LD=$(CC)
+
+CFLAGS = -L$(HEAVENLY)
+LDFLAGS = -framework CoreFoundation \
+         -framework Foundation \
+          -framework UIKit \
+          -framework CoreGraphics \
+         -framework PhotoLibrary \
+          -lobjc
+
+all:   ZXing
+
+ZXing: ZXing.o ZXingApplication.o
+       $(LD) $(LDFLAGS) -o $@ $^
+
+%.o:   %.m
+       $(CC) -c $(CFLAGS) $< -o $@
+
+clean:
+       rm -f *.o ZXing
+       rm -f ZXing.app/ZXing
diff --git a/iphone/experimental/README b/iphone/experimental/README
new file mode 100644 (file)
index 0000000..2a15126
--- /dev/null
@@ -0,0 +1,3 @@
+This is a temporary checkin of a rough shell of an iPhone application, for
+purposes of experimentation and sharing with developers. It should not be
+expected to be complete or functional, or ready for use.
diff --git a/iphone/experimental/ZXing.m b/iphone/experimental/ZXing.m
new file mode 100644 (file)
index 0000000..9ecdedb
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import <UIKit/UIKit.h>
+
+#import "ZXingApplication.h"
+
+int main(int argc, char **argv)
+{
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+    return UIApplicationMain(argc, argv, [ZXingApplication class]);
+}
diff --git a/iphone/experimental/ZXingApplication.h b/iphone/experimental/ZXingApplication.h
new file mode 100644 (file)
index 0000000..a00f844
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import <Foundation/Foundation.h>
+#import <PhotoLibrary/CameraController.h>
+#import <UIKit/UIKit.h>
+#import <UIKit/UIApplication.h>
+
+@interface ZXingApplication : UIApplication
+{
+  CameraController* cameraController;
+
+  UIWindow* mainWindow;
+
+  UIView* previewView;
+  UIView* decodeView;
+
+  UIImageView* decodeImageView;
+}
+
+- (void) decodeImage: (id) param1;
+
+- (void) cameraControllerReadyStateChanged: (id) param1;
+- (void) cameraController: (id) param1
+              tookPicture: (id) param2
+              withPreview: (id) preview
+                 jpegData: (id) param3
+          imageProperties: (id) param4;
+
+@end
diff --git a/iphone/experimental/ZXingApplication.m b/iphone/experimental/ZXingApplication.m
new file mode 100644 (file)
index 0000000..3005a0e
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import <CoreGraphics/CGGeometry.h>
+#import <CoreGraphics/CGImage.h>
+#import <Foundation/Foundation.h>
+#import <UIKit/UIPushButton.h>
+#import <UIKit/UIWindow.h>
+#import <PhotoLibrary/CameraController.h>
+#import "ZXingApplication.h"
+
+@implementation ZXingApplication
+
+- (void) applicationDidFinishLaunching: (id) param1 {
+    mainWindow = [[UIWindow alloc] initWithContentRect: [UIHardware
+        fullScreenApplicationContentRect]];
+
+    [mainWindow orderFront: self];
+    [mainWindow _setHidden: NO];
+
+    // Setup camera stuff
+    cameraController = [[CameraController alloc] init];
+    [cameraController startPreview];
+    [[CameraController sharedInstance] setDelegate: self];
+       
+    struct CGRect fullscreen_rect =
+        [UIHardware fullScreenApplicationContentRect];
+    fullscreen_rect.origin.x = 0.0f;
+    fullscreen_rect.origin.y = 0.0f;
+    fullscreen_rect.size.width = 320.0f;
+    fullscreen_rect.size.height = 480.0f;
+
+    // Setup previewView
+    previewView = [[UIView alloc] initWithFrame: fullscreen_rect];
+    [previewView addSubview: [cameraController previewView]];
+
+    UIPushButton *decode_button =
+        [[UIPushButton alloc] initWithFrame:
+                                CGRectMake(140.0f, 440.0f, 50.0f, 20.0f)];
+    [decode_button setTitle: @"Decode"];
+    [decode_button setEnabled: YES];
+    [decode_button addTarget: self action: @selector(decodeImage:)
+                   forEvents: 255];
+
+    [previewView addSubview: decode_button];
+
+    // Setup decodeView
+    decodeView = [[UIView alloc] initWithFrame: fullscreen_rect];
+    decodeImageView = [[UIImageView alloc] initWithFrame:
+                                             CGRectMake(0.0f, 0.0f,
+                                                        320.0f, 480.0f)];
+    [decodeImageView setRotationBy: 90];
+    [decodeView addSubview: decodeImageView];
+       
+    [mainWindow setContentView: previewView];
+}
+
+- (void) decodeImage: (id) param1 {
+  [cameraController capturePhoto];
+
+  [mainWindow setContentView: decodeView];
+}
+
+
+- (void) cameraControllerReadyStateChanged: (id) param1 {
+}
+
+- (void) cameraController: (id) param1
+              tookPicture: (id) param2
+              withPreview: (id) preview
+                 jpegData: (id) param3
+          imageProperties: (id) param4 {
+  [cameraController stopPreview];
+
+  CGImageRef orig_image = [preview imageRef];
+  int orig_height = CGImageGetHeight(orig_image);
+  int orig_width = CGImageGetWidth(orig_image);
+
+  [decodeImageView setImage: preview];
+  // Height and width swapped since the image comes in rotated 90 degrees.
+  [decodeImageView setFrame: CGRectMake(0.0f, 0.0f, orig_height, orig_width)];
+}
+
+@end
diff --git a/iphone/experimental/icon.png b/iphone/experimental/icon.png
new file mode 100644 (file)
index 0000000..6f97d46
Binary files /dev/null and b/iphone/experimental/icon.png differ