├── .gitignore ├── GraphicsCommon.h ├── GraphicsCommon.m ├── ImageConversion-Info.plist ├── ImageConversion.xcodeproj └── project.pbxproj ├── ImageConversion_Prefix.pch ├── ImageHelper.h ├── ImageHelper.m ├── MITLicense.txt ├── README.md ├── Shared └── main.m ├── iPad ├── AppDelegate_iPad.h ├── AppDelegate_iPad.mm ├── Icon4.png ├── MainWindow_iPad.xib └── ShareArrow.png └── iPhone ├── AppDelegate_iPhone.h ├── AppDelegate_iPhone.m └── MainWindow_iPhone.xib /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | 3 | build/ 4 | 5 | *.pbxuser 6 | *.perspective 7 | *.perspectivev3 8 | 9 | *.mode1v3 10 | *.mode2v3 11 | 12 | # Xcode 13 | 14 | *.pbxuser 15 | !default.pbxuser 16 | *.mode1v3 17 | !default.mode1v3 18 | *.mode2v3 19 | !default.mode2v3 20 | *.perspectivev3 21 | !default.perspectivev3 22 | *.xcworkspace 23 | !default.xcworkspace 24 | xcuserdata 25 | -------------------------------------------------------------------------------- /GraphicsCommon.h: -------------------------------------------------------------------------------- 1 | // 2 | // GraphicsCommon.h 3 | // ImageConversion 4 | // 5 | // Created by Paul Solt on 8/24/11. 6 | // Copyright 2011 Paul Solt. All rights reserved. 7 | // 8 | 9 | //#import 10 | // 11 | //@interface GraphicsCommon : NSObject 12 | // 13 | // 14 | //@end 15 | 16 | #include 17 | #include 18 | 19 | static const int NUMBER_COLORS = 4; 20 | 21 | /** The Color3D structure is used for storing the Red, Green, Blue, and Alpha components. */ 22 | struct Color3D { 23 | 24 | Color3D() : red(0.0f), green(0.0f), blue(0.0f), alpha(1.0f) {} 25 | 26 | float red; 27 | float green; 28 | float blue; 29 | float alpha; 30 | }; // Color3D; 31 | 32 | /** Prints out a Color3D structure */ 33 | static std::ostream &operator<<(std::ostream &os, const Color3D &c) { 34 | os << "Color: (" << c.red << ", " << c.green << ", " << c.blue << ", " << c.alpha << ")"; 35 | return os; 36 | } 37 | 38 | static std::string toString(const Color3D &c) { 39 | std::ostringstream os; 40 | os << "Color: (" << c.red << ", " << c.green << ", " << c.blue << ", " << c.alpha << ")"; 41 | std::string str(os.str()); 42 | return str; 43 | } 44 | 45 | /** Converts a single color value from floating point space (0.0-1.0) to unsigned char (RGBA8) format. 46 | Red,green,blue,alpha in 0.0-1.0 space 47 | color will be in range 0-255 48 | Requires 4 component (RGBA) (unsigned char *) to be already allocated 49 | */ 50 | static inline void color3dToRGBA8(Color3D *colorIn, unsigned char *colorOut) { 51 | 52 | // Clamp the negative colors to black, it's undefined behavior otherwise. 53 | Color3D newColor = *colorIn; 54 | if(newColor.red < 0) { 55 | newColor.red = 0; 56 | } 57 | if(newColor.green < 0) { 58 | newColor.green = 0; 59 | } 60 | if(newColor.blue < 0) { 61 | newColor.blue = 0; 62 | } 63 | 64 | colorOut[0] = static_cast(newColor.red * 255); 65 | colorOut[1] = static_cast(newColor.green * 255); 66 | colorOut[2] = static_cast(newColor.blue * 255); 67 | colorOut[3] = static_cast(newColor.alpha * 255); 68 | } 69 | 70 | static inline void RGBA8ToColor3d(unsigned char *colorIn, Color3D *colorOut) { 71 | colorOut->red = static_cast(colorIn[0]) / 255.0f; 72 | colorOut->green = static_cast(colorIn[1]) / 255.0f; 73 | colorOut->blue = static_cast(colorIn[2]) / 255.0f; 74 | colorOut->alpha = static_cast(colorIn[3]) / 255.0f; 75 | } 76 | 77 | /** Converts a single color value from the colors Red, Green, Blue, Alpha in RGBA8 format to floating 78 | point format in (0.0-1.0) range. 79 | Requires the memory to be allocated for the colorOut parameter. 80 | @param red - the red component 81 | @param green - the green component 82 | @param blue - the blue component 83 | @param alpha - the alpha component 84 | @param colorOut - the floating point Color3D structure to store the conversion 85 | */ 86 | static inline void RGBA8ToColor3d(unsigned char red, unsigned char green, unsigned char blue, 87 | unsigned char alpha, Color3D *colorOut) { 88 | colorOut->red = static_cast(red) / 255.0f; 89 | colorOut->green = static_cast(green) / 255.0f; 90 | colorOut->blue = static_cast(blue) / 255.0f; 91 | colorOut->alpha = static_cast(alpha) / 255.0f; 92 | } 93 | 94 | /** Converts a Color3D image to RGBA8 (unsigned char *) given the image dimensions. The function 95 | assumes the number of bytes per pixel color is 4. The memory should be allocated before calling this 96 | method. It simply copies data from one type to the other. ImageOut should be width*height*4 97 | @param imageIn - the image that should be converted 98 | @param imageOut - the image that should be used for output 99 | @param width - the number of pixels wide 100 | @param height - the number of pixels high. 101 | */ 102 | static inline void ConvertImageColor3dToRGBA8(Color3D *imageIn, unsigned char *imageOut, int width, int height) { 103 | int length = width * height; 104 | 105 | // Need to increment unsigned char pointer by the number of colors each loop 106 | for(int i = 0, j = 0; i < length; ++i, j+=NUMBER_COLORS) { 107 | color3dToRGBA8(&imageIn[i], &imageOut[j]); 108 | } 109 | 110 | } 111 | 112 | static inline void ConvertImageRGBA8ToColor3d(unsigned char *imageIn, Color3D *imageOut, int width, int height) { 113 | int length = width * height; 114 | 115 | // Need to increment unsigned char pointer by the number of colors each loop 116 | for(int i = 0, j = 0; i < length; ++i, j+=NUMBER_COLORS) { 117 | RGBA8ToColor3d(&imageIn[j], &imageOut[i]); 118 | } 119 | } -------------------------------------------------------------------------------- /GraphicsCommon.m: -------------------------------------------------------------------------------- 1 | // 2 | // GraphicsCommon.m 3 | // ImageConversion 4 | // 5 | // Created by Paul Solt on 8/24/11. 6 | // Copyright 2011 Paul Solt. All rights reserved. 7 | // 8 | 9 | #import "GraphicsCommon.h" 10 | 11 | @implementation GraphicsCommon 12 | 13 | - (id)init 14 | { 15 | self = [super init]; 16 | if (self) { 17 | // Initialization code here. 18 | } 19 | 20 | return self; 21 | } 22 | 23 | 24 | 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /ImageConversion-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFile 12 | Icon4.png 13 | CFBundleIdentifier 14 | com.paulsolt.ImageConversion 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | NSMainNibFile 28 | MainWindow_iPad 29 | NSMainNibFile~ipad 30 | MainWindow_iPad 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /ImageConversion.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1D60589B0D05DD56006BFB54 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; }; 11 | 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; }; 12 | 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; }; 13 | 2860E328111B887F00E27156 /* AppDelegate_iPhone.m in Sources */ = {isa = PBXBuildFile; fileRef = 2860E326111B887F00E27156 /* AppDelegate_iPhone.m */; }; 14 | 2860E329111B887F00E27156 /* MainWindow_iPhone.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2860E327111B887F00E27156 /* MainWindow_iPhone.xib */; }; 15 | 2860E32E111B888700E27156 /* AppDelegate_iPad.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2860E32C111B888700E27156 /* AppDelegate_iPad.mm */; }; 16 | 2860E32F111B888700E27156 /* MainWindow_iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2860E32D111B888700E27156 /* MainWindow_iPad.xib */; }; 17 | 288765FD0DF74451002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765FC0DF74451002DB57D /* CoreGraphics.framework */; }; 18 | BD12AFAF134E31C40052742A /* MITLicense.txt in Resources */ = {isa = PBXBuildFile; fileRef = BD12AFAE134E31C40052742A /* MITLicense.txt */; }; 19 | BD3F462C124A7A5D00959DE5 /* ImageHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = BD3F462B124A7A5D00959DE5 /* ImageHelper.m */; }; 20 | BD3F4650124A852600959DE5 /* Icon4.png in Resources */ = {isa = PBXBuildFile; fileRef = BD3F464F124A852600959DE5 /* Icon4.png */; }; 21 | BD93538F14054F72009660CC /* ShareArrow.png in Resources */ = {isa = PBXBuildFile; fileRef = BD93538E14054F72009660CC /* ShareArrow.png */; }; 22 | /* End PBXBuildFile section */ 23 | 24 | /* Begin PBXFileReference section */ 25 | 1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 26 | 1D6058910D05DD3D006BFB54 /* ImageConversion.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ImageConversion.app; sourceTree = BUILT_PRODUCTS_DIR; }; 27 | 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 28 | 2860E325111B887F00E27156 /* AppDelegate_iPhone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate_iPhone.h; sourceTree = ""; }; 29 | 2860E326111B887F00E27156 /* AppDelegate_iPhone.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate_iPhone.m; sourceTree = ""; }; 30 | 2860E327111B887F00E27156 /* MainWindow_iPhone.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MainWindow_iPhone.xib; sourceTree = ""; }; 31 | 2860E32B111B888700E27156 /* AppDelegate_iPad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate_iPad.h; sourceTree = ""; }; 32 | 2860E32C111B888700E27156 /* AppDelegate_iPad.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppDelegate_iPad.mm; sourceTree = ""; }; 33 | 2860E32D111B888700E27156 /* MainWindow_iPad.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MainWindow_iPad.xib; sourceTree = ""; }; 34 | 288765FC0DF74451002DB57D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 35 | 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = Shared/main.m; sourceTree = ""; }; 36 | 32CA4F630368D1EE00C91783 /* ImageConversion_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageConversion_Prefix.pch; sourceTree = ""; }; 37 | 8D1107310486CEB800E47090 /* ImageConversion-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "ImageConversion-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = ""; }; 38 | BD12AFAE134E31C40052742A /* MITLicense.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MITLicense.txt; sourceTree = ""; }; 39 | BD3F462A124A7A5D00959DE5 /* ImageHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageHelper.h; sourceTree = ""; }; 40 | BD3F462B124A7A5D00959DE5 /* ImageHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ImageHelper.m; sourceTree = ""; }; 41 | BD3F464F124A852600959DE5 /* Icon4.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Icon4.png; sourceTree = ""; }; 42 | BD93538E14054F72009660CC /* ShareArrow.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ShareArrow.png; sourceTree = ""; }; 43 | BD9353BB140554F7009660CC /* GraphicsCommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsCommon.h; sourceTree = ""; }; 44 | /* End PBXFileReference section */ 45 | 46 | /* Begin PBXFrameworksBuildPhase section */ 47 | 1D60588F0D05DD3D006BFB54 /* Frameworks */ = { 48 | isa = PBXFrameworksBuildPhase; 49 | buildActionMask = 2147483647; 50 | files = ( 51 | 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */, 52 | 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */, 53 | 288765FD0DF74451002DB57D /* CoreGraphics.framework in Frameworks */, 54 | ); 55 | runOnlyForDeploymentPostprocessing = 0; 56 | }; 57 | /* End PBXFrameworksBuildPhase section */ 58 | 59 | /* Begin PBXGroup section */ 60 | 19C28FACFE9D520D11CA2CBB /* Products */ = { 61 | isa = PBXGroup; 62 | children = ( 63 | 1D6058910D05DD3D006BFB54 /* ImageConversion.app */, 64 | ); 65 | name = Products; 66 | sourceTree = ""; 67 | }; 68 | 2860E324111B887F00E27156 /* iPhone */ = { 69 | isa = PBXGroup; 70 | children = ( 71 | 2860E325111B887F00E27156 /* AppDelegate_iPhone.h */, 72 | 2860E326111B887F00E27156 /* AppDelegate_iPhone.m */, 73 | 2860E327111B887F00E27156 /* MainWindow_iPhone.xib */, 74 | ); 75 | path = iPhone; 76 | sourceTree = ""; 77 | }; 78 | 2860E32A111B888700E27156 /* iPad */ = { 79 | isa = PBXGroup; 80 | children = ( 81 | BD93538E14054F72009660CC /* ShareArrow.png */, 82 | BD3F464F124A852600959DE5 /* Icon4.png */, 83 | 2860E32B111B888700E27156 /* AppDelegate_iPad.h */, 84 | 2860E32C111B888700E27156 /* AppDelegate_iPad.mm */, 85 | 2860E32D111B888700E27156 /* MainWindow_iPad.xib */, 86 | ); 87 | path = iPad; 88 | sourceTree = ""; 89 | }; 90 | 28EEBF621118D79A00187D67 /* Shared */ = { 91 | isa = PBXGroup; 92 | children = ( 93 | 8D1107310486CEB800E47090 /* ImageConversion-Info.plist */, 94 | BD3F462A124A7A5D00959DE5 /* ImageHelper.h */, 95 | BD3F462B124A7A5D00959DE5 /* ImageHelper.m */, 96 | BD9353BB140554F7009660CC /* GraphicsCommon.h */, 97 | ); 98 | name = Shared; 99 | sourceTree = ""; 100 | }; 101 | 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = { 102 | isa = PBXGroup; 103 | children = ( 104 | BD12AFAE134E31C40052742A /* MITLicense.txt */, 105 | 2860E32A111B888700E27156 /* iPad */, 106 | 2860E324111B887F00E27156 /* iPhone */, 107 | 28EEBF621118D79A00187D67 /* Shared */, 108 | 29B97315FDCFA39411CA2CEA /* Other Sources */, 109 | 29B97323FDCFA39411CA2CEA /* Frameworks */, 110 | 19C28FACFE9D520D11CA2CBB /* Products */, 111 | ); 112 | name = CustomTemplate; 113 | sourceTree = ""; 114 | }; 115 | 29B97315FDCFA39411CA2CEA /* Other Sources */ = { 116 | isa = PBXGroup; 117 | children = ( 118 | 32CA4F630368D1EE00C91783 /* ImageConversion_Prefix.pch */, 119 | 29B97316FDCFA39411CA2CEA /* main.m */, 120 | ); 121 | name = "Other Sources"; 122 | sourceTree = ""; 123 | }; 124 | 29B97323FDCFA39411CA2CEA /* Frameworks */ = { 125 | isa = PBXGroup; 126 | children = ( 127 | 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */, 128 | 1D30AB110D05D00D00671497 /* Foundation.framework */, 129 | 288765FC0DF74451002DB57D /* CoreGraphics.framework */, 130 | ); 131 | name = Frameworks; 132 | sourceTree = ""; 133 | }; 134 | /* End PBXGroup section */ 135 | 136 | /* Begin PBXNativeTarget section */ 137 | 1D6058900D05DD3D006BFB54 /* ImageConversion */ = { 138 | isa = PBXNativeTarget; 139 | buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "ImageConversion" */; 140 | buildPhases = ( 141 | 1D60588D0D05DD3D006BFB54 /* Resources */, 142 | 1D60588E0D05DD3D006BFB54 /* Sources */, 143 | 1D60588F0D05DD3D006BFB54 /* Frameworks */, 144 | ); 145 | buildRules = ( 146 | ); 147 | dependencies = ( 148 | ); 149 | name = ImageConversion; 150 | productName = ImageConversion; 151 | productReference = 1D6058910D05DD3D006BFB54 /* ImageConversion.app */; 152 | productType = "com.apple.product-type.application"; 153 | }; 154 | /* End PBXNativeTarget section */ 155 | 156 | /* Begin PBXProject section */ 157 | 29B97313FDCFA39411CA2CEA /* Project object */ = { 158 | isa = PBXProject; 159 | attributes = { 160 | LastUpgradeCheck = 0410; 161 | ORGANIZATIONNAME = "Paul Solt"; 162 | }; 163 | buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "ImageConversion" */; 164 | compatibilityVersion = "Xcode 3.2"; 165 | developmentRegion = English; 166 | hasScannedForEncodings = 1; 167 | knownRegions = ( 168 | English, 169 | Japanese, 170 | French, 171 | German, 172 | ); 173 | mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */; 174 | projectDirPath = ""; 175 | projectRoot = ""; 176 | targets = ( 177 | 1D6058900D05DD3D006BFB54 /* ImageConversion */, 178 | ); 179 | }; 180 | /* End PBXProject section */ 181 | 182 | /* Begin PBXResourcesBuildPhase section */ 183 | 1D60588D0D05DD3D006BFB54 /* Resources */ = { 184 | isa = PBXResourcesBuildPhase; 185 | buildActionMask = 2147483647; 186 | files = ( 187 | 2860E329111B887F00E27156 /* MainWindow_iPhone.xib in Resources */, 188 | 2860E32F111B888700E27156 /* MainWindow_iPad.xib in Resources */, 189 | BD3F4650124A852600959DE5 /* Icon4.png in Resources */, 190 | BD12AFAF134E31C40052742A /* MITLicense.txt in Resources */, 191 | BD93538F14054F72009660CC /* ShareArrow.png in Resources */, 192 | ); 193 | runOnlyForDeploymentPostprocessing = 0; 194 | }; 195 | /* End PBXResourcesBuildPhase section */ 196 | 197 | /* Begin PBXSourcesBuildPhase section */ 198 | 1D60588E0D05DD3D006BFB54 /* Sources */ = { 199 | isa = PBXSourcesBuildPhase; 200 | buildActionMask = 2147483647; 201 | files = ( 202 | 1D60589B0D05DD56006BFB54 /* main.m in Sources */, 203 | 2860E328111B887F00E27156 /* AppDelegate_iPhone.m in Sources */, 204 | 2860E32E111B888700E27156 /* AppDelegate_iPad.mm in Sources */, 205 | BD3F462C124A7A5D00959DE5 /* ImageHelper.m in Sources */, 206 | ); 207 | runOnlyForDeploymentPostprocessing = 0; 208 | }; 209 | /* End PBXSourcesBuildPhase section */ 210 | 211 | /* Begin XCBuildConfiguration section */ 212 | 1D6058940D05DD3E006BFB54 /* Debug */ = { 213 | isa = XCBuildConfiguration; 214 | buildSettings = { 215 | ALWAYS_SEARCH_USER_PATHS = NO; 216 | COPY_PHASE_STRIP = NO; 217 | GCC_DYNAMIC_NO_PIC = NO; 218 | GCC_OPTIMIZATION_LEVEL = 0; 219 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 220 | GCC_PREFIX_HEADER = ImageConversion_Prefix.pch; 221 | GCC_VERSION = com.apple.compilers.llvmgcc42; 222 | INFOPLIST_FILE = "ImageConversion-Info.plist"; 223 | IPHONEOS_DEPLOYMENT_TARGET = 3.2; 224 | PRODUCT_NAME = ImageConversion; 225 | }; 226 | name = Debug; 227 | }; 228 | 1D6058950D05DD3E006BFB54 /* Release */ = { 229 | isa = XCBuildConfiguration; 230 | buildSettings = { 231 | ALWAYS_SEARCH_USER_PATHS = NO; 232 | COPY_PHASE_STRIP = YES; 233 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 234 | GCC_PREFIX_HEADER = ImageConversion_Prefix.pch; 235 | GCC_VERSION = com.apple.compilers.llvmgcc42; 236 | INFOPLIST_FILE = "ImageConversion-Info.plist"; 237 | IPHONEOS_DEPLOYMENT_TARGET = 3.2; 238 | PRODUCT_NAME = ImageConversion; 239 | VALIDATE_PRODUCT = YES; 240 | }; 241 | name = Release; 242 | }; 243 | C01FCF4F08A954540054247B /* Debug */ = { 244 | isa = XCBuildConfiguration; 245 | buildSettings = { 246 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 247 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 248 | GCC_C_LANGUAGE_STANDARD = c99; 249 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 250 | GCC_WARN_UNUSED_VARIABLE = YES; 251 | IPHONEOS_DEPLOYMENT_TARGET = 3.2; 252 | SDKROOT = iphoneos; 253 | TARGETED_DEVICE_FAMILY = "1,2"; 254 | }; 255 | name = Debug; 256 | }; 257 | C01FCF5008A954540054247B /* Release */ = { 258 | isa = XCBuildConfiguration; 259 | buildSettings = { 260 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 261 | CODE_SIGN_IDENTITY = "iPhone Developer"; 262 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 263 | GCC_C_LANGUAGE_STANDARD = c99; 264 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 265 | GCC_WARN_UNUSED_VARIABLE = YES; 266 | IPHONEOS_DEPLOYMENT_TARGET = 3.2; 267 | OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; 268 | PROVISIONING_PROFILE = ""; 269 | SDKROOT = iphoneos; 270 | TARGETED_DEVICE_FAMILY = "1,2"; 271 | }; 272 | name = Release; 273 | }; 274 | /* End XCBuildConfiguration section */ 275 | 276 | /* Begin XCConfigurationList section */ 277 | 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "ImageConversion" */ = { 278 | isa = XCConfigurationList; 279 | buildConfigurations = ( 280 | 1D6058940D05DD3E006BFB54 /* Debug */, 281 | 1D6058950D05DD3E006BFB54 /* Release */, 282 | ); 283 | defaultConfigurationIsVisible = 0; 284 | defaultConfigurationName = Release; 285 | }; 286 | C01FCF4E08A954540054247B /* Build configuration list for PBXProject "ImageConversion" */ = { 287 | isa = XCConfigurationList; 288 | buildConfigurations = ( 289 | C01FCF4F08A954540054247B /* Debug */, 290 | C01FCF5008A954540054247B /* Release */, 291 | ); 292 | defaultConfigurationIsVisible = 0; 293 | defaultConfigurationName = Release; 294 | }; 295 | /* End XCConfigurationList section */ 296 | }; 297 | rootObject = 29B97313FDCFA39411CA2CEA /* Project object */; 298 | } 299 | -------------------------------------------------------------------------------- /ImageConversion_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'ImageConversion' target in the 'ImageConversion' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #import 8 | #endif 9 | -------------------------------------------------------------------------------- /ImageHelper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright (c) 2011 Paul Solt, PaulSolt@gmail.com 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | 26 | #import 27 | 28 | 29 | @interface ImageHelper : NSObject { 30 | 31 | } 32 | 33 | /** Converts a UIImage to RGBA8 bitmap. 34 | @param image - a UIImage to be converted 35 | @return a RGBA8 bitmap, or NULL if any memory allocation issues. Cleanup memory with free() when done. 36 | */ 37 | + (unsigned char *) convertUIImageToBitmapRGBA8:(UIImage *)image; 38 | 39 | /** A helper routine used to convert a RGBA8 to UIImage 40 | @return a new context that is owned by the caller 41 | */ 42 | + (CGContextRef) newBitmapRGBA8ContextFromImage:(CGImageRef)image; 43 | 44 | 45 | /** Converts a RGBA8 bitmap to a UIImage. 46 | @param buffer - the RGBA8 unsigned char * bitmap 47 | @param width - the number of pixels wide 48 | @param height - the number of pixels tall 49 | @return a UIImage that is autoreleased or nil if memory allocation issues 50 | */ 51 | + (UIImage *) convertBitmapRGBA8ToUIImage:(unsigned char *)buffer 52 | withWidth:(int)width 53 | withHeight:(int)height; 54 | 55 | @end 56 | 57 | -------------------------------------------------------------------------------- /ImageHelper.m: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright (c) 2011 Paul Solt, PaulSolt@gmail.com 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | 26 | #import "ImageHelper.h" 27 | 28 | 29 | @implementation ImageHelper 30 | 31 | 32 | + (unsigned char *) convertUIImageToBitmapRGBA8:(UIImage *) image { 33 | 34 | CGImageRef imageRef = image.CGImage; 35 | 36 | // Create a bitmap context to draw the uiimage into 37 | CGContextRef context = [self newBitmapRGBA8ContextFromImage:imageRef]; 38 | 39 | if(!context) { 40 | return NULL; 41 | } 42 | 43 | size_t width = CGImageGetWidth(imageRef); 44 | size_t height = CGImageGetHeight(imageRef); 45 | 46 | CGRect rect = CGRectMake(0, 0, width, height); 47 | 48 | // Draw image into the context to get the raw image data 49 | CGContextDrawImage(context, rect, imageRef); 50 | 51 | // Get a pointer to the data 52 | unsigned char *bitmapData = (unsigned char *)CGBitmapContextGetData(context); 53 | 54 | // Copy the data and release the memory (return memory allocated with new) 55 | size_t bytesPerRow = CGBitmapContextGetBytesPerRow(context); 56 | size_t bufferLength = bytesPerRow * height; 57 | 58 | unsigned char *newBitmap = NULL; 59 | 60 | if(bitmapData) { 61 | newBitmap = (unsigned char *)malloc(sizeof(unsigned char) * bytesPerRow * height); 62 | 63 | if(newBitmap) { // Copy the data 64 | for(int i = 0; i < bufferLength; ++i) { 65 | newBitmap[i] = bitmapData[i]; 66 | } 67 | } 68 | 69 | free(bitmapData); 70 | 71 | } else { 72 | NSLog(@"Error getting bitmap pixel data\n"); 73 | } 74 | 75 | CGContextRelease(context); 76 | 77 | return newBitmap; 78 | } 79 | 80 | + (CGContextRef) newBitmapRGBA8ContextFromImage:(CGImageRef) image { 81 | CGContextRef context = NULL; 82 | CGColorSpaceRef colorSpace; 83 | uint32_t *bitmapData; 84 | 85 | size_t bitsPerPixel = 32; 86 | size_t bitsPerComponent = 8; 87 | size_t bytesPerPixel = bitsPerPixel / bitsPerComponent; 88 | 89 | size_t width = CGImageGetWidth(image); 90 | size_t height = CGImageGetHeight(image); 91 | 92 | size_t bytesPerRow = width * bytesPerPixel; 93 | size_t bufferLength = bytesPerRow * height; 94 | 95 | colorSpace = CGColorSpaceCreateDeviceRGB(); 96 | 97 | if(!colorSpace) { 98 | NSLog(@"Error allocating color space RGB\n"); 99 | return NULL; 100 | } 101 | 102 | // Allocate memory for image data 103 | bitmapData = (uint32_t *)malloc(bufferLength); 104 | 105 | if(!bitmapData) { 106 | NSLog(@"Error allocating memory for bitmap\n"); 107 | CGColorSpaceRelease(colorSpace); 108 | return NULL; 109 | } 110 | 111 | //Create bitmap context 112 | context = CGBitmapContextCreate(bitmapData, 113 | width, 114 | height, 115 | bitsPerComponent, 116 | bytesPerRow, 117 | colorSpace, 118 | kCGImageAlphaPremultipliedLast); // RGBA 119 | 120 | if(!context) { 121 | free(bitmapData); 122 | NSLog(@"Bitmap context not created"); 123 | } 124 | 125 | CGColorSpaceRelease(colorSpace); 126 | 127 | return context; 128 | } 129 | 130 | + (UIImage *) convertBitmapRGBA8ToUIImage:(unsigned char *) buffer 131 | withWidth:(int) width 132 | withHeight:(int) height { 133 | 134 | 135 | size_t bufferLength = width * height * 4; 136 | CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, buffer, bufferLength, NULL); 137 | size_t bitsPerComponent = 8; 138 | size_t bitsPerPixel = 32; 139 | size_t bytesPerRow = 4 * width; 140 | 141 | CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB(); 142 | if(colorSpaceRef == NULL) { 143 | NSLog(@"Error allocating color space"); 144 | CGDataProviderRelease(provider); 145 | return nil; 146 | } 147 | CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault | kCGImageAlphaPremultipliedLast; 148 | CGColorRenderingIntent renderingIntent = kCGRenderingIntentDefault; 149 | 150 | CGImageRef iref = CGImageCreate(width, 151 | height, 152 | bitsPerComponent, 153 | bitsPerPixel, 154 | bytesPerRow, 155 | colorSpaceRef, 156 | bitmapInfo, 157 | provider, // data provider 158 | NULL, // decode 159 | YES, // should interpolate 160 | renderingIntent); 161 | 162 | uint32_t* pixels = (uint32_t*)malloc(bufferLength); 163 | 164 | if(pixels == NULL) { 165 | NSLog(@"Error: Memory not allocated for bitmap"); 166 | CGDataProviderRelease(provider); 167 | CGColorSpaceRelease(colorSpaceRef); 168 | CGImageRelease(iref); 169 | return nil; 170 | } 171 | 172 | CGContextRef context = CGBitmapContextCreate(pixels, 173 | width, 174 | height, 175 | bitsPerComponent, 176 | bytesPerRow, 177 | colorSpaceRef, 178 | bitmapInfo); 179 | 180 | if(context == NULL) { 181 | NSLog(@"Error context not created"); 182 | free(pixels); 183 | } 184 | 185 | UIImage *image = nil; 186 | if(context) { 187 | 188 | CGContextDrawImage(context, CGRectMake(0.0f, 0.0f, width, height), iref); 189 | 190 | CGImageRef imageRef = CGBitmapContextCreateImage(context); 191 | 192 | // Support both iPad 3.2 and iPhone 4 Retina displays with the correct scale 193 | if([UIImage respondsToSelector:@selector(imageWithCGImage:scale:orientation:)]) { 194 | float scale = [[UIScreen mainScreen] scale]; 195 | image = [UIImage imageWithCGImage:imageRef scale:scale orientation:UIImageOrientationUp]; 196 | } else { 197 | image = [UIImage imageWithCGImage:imageRef]; 198 | } 199 | 200 | CGImageRelease(imageRef); 201 | CGContextRelease(context); 202 | } 203 | 204 | CGColorSpaceRelease(colorSpaceRef); 205 | CGImageRelease(iref); 206 | CGDataProviderRelease(provider); 207 | 208 | if(pixels) { 209 | free(pixels); 210 | } 211 | return image; 212 | } 213 | 214 | @end 215 | -------------------------------------------------------------------------------- /MITLicense.txt: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2011 Paul Solt, PaulSolt@gmail.com 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | UIImage Conversion Sample 2 | ------------------------- 3 | Paul Solt 2010 4 | 5 | Here's a sample project and code to convert between UIImage objects and RGBA8 bitmaps. The sample project is iPhone 4/iPad 3.2 compatible. 6 | 7 | The ImageHelper works with iPhone 4 and the Retina display using the correct scale factor with high resolution images. 8 | 9 | 10 | Basic Example Usage showing the ability to convert back and forth between formats: 11 | --------------------------------------------------------------------------------- 12 | 13 | // Look at the sample project for actual usage 14 | 15 | NSString *path = (NSString*)[[NSBundle mainBundle] pathForResource:@"Icon4" ofType:@"png"]; 16 | UIImage *image = [UIImage imageWithContentsOfFile:path]; 17 | int width = image.size.width; 18 | int height = image.size.height; 19 | 20 | // Create a bitmap 21 | unsigned char *bitmap = [ImageHelper convertUIImageToBitmapRGBA8:image]; 22 | 23 | // Create a UIImage using the bitmap 24 | UIImage *imageCopy = [ImageHelper convertBitmapRGBA8ToUIImage:bitmap withWidth:width withHeight:height]; 25 | 26 | // Display the image copy on the GUI 27 | UIImageView *imageView = [[UIImageView alloc] initWithImage:imageCopy]; 28 | 29 | // Cleanup 30 | free(bitmap); 31 | -------------------------------------------------------------------------------- /Shared/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // ImageConversion 4 | // 5 | // Created by Paul Solt on 9/22/10. 6 | // Copyright 2010 Paul Solt. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) { 12 | 13 | NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; 14 | int retVal = UIApplicationMain(argc, argv, nil, nil); 15 | [pool release]; 16 | return retVal; 17 | } 18 | -------------------------------------------------------------------------------- /iPad/AppDelegate_iPad.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate_iPad.h 3 | // ImageConversion 4 | // 5 | // Created by Paul Solt on 9/22/10. 6 | // Copyright 2010 RIT. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate_iPad : NSObject { 12 | UIWindow *window; 13 | } 14 | 15 | @property (nonatomic, retain) IBOutlet UIWindow *window; 16 | 17 | 18 | // Adds an image to an imageview on the window 19 | - (void)addImage:(NSString *)theFilename atPosition:(CGPoint)thePosition; 20 | 21 | @end 22 | 23 | -------------------------------------------------------------------------------- /iPad/AppDelegate_iPad.mm: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate_iPad.m 3 | // ImageConversion 4 | // 5 | // Created by Paul Solt on 9/22/10. 6 | // Copyright 2010 RIT. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate_iPad.h" 10 | #import "ImageHelper.h" 11 | #import "GraphicsCommon.h" 12 | 13 | @implementation AppDelegate_iPad 14 | 15 | @synthesize window; 16 | 17 | 18 | #pragma mark - 19 | #pragma mark Application lifecycle 20 | 21 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 22 | 23 | // Override point for customization after application launch. 24 | // 25 | // UIImage *image = [UIImage imageNamed:@"Icon4.png"]; 26 | // int width = image.size.width; 27 | // int height = image.size.height; 28 | // 29 | // // Create a bitmap 30 | // unsigned char *bitmap = [ImageHelper convertUIImageToBitmapRGBA8:image]; 31 | // 32 | // // Create a UIImage using the bitmap 33 | // UIImage *imageCopy = [ImageHelper convertBitmapRGBA8ToUIImage:bitmap withWidth:width withHeight:height]; 34 | // 35 | // // Cleanup 36 | // if(bitmap) { 37 | // free(bitmap); 38 | // bitmap = NULL; 39 | // } 40 | // 41 | // // Display the image copy on the GUI 42 | // UIImageView *imageView = [[UIImageView alloc] initWithImage:imageCopy]; 43 | // CGPoint center = CGPointMake([UIScreen mainScreen].bounds.size.width / 2.0, 44 | // [UIScreen mainScreen].bounds.size.height / 2.0); 45 | // [imageView setCenter:center]; 46 | // [window addSubview:imageView]; 47 | // [imageView release]; 48 | CGPoint iconPosition = CGPointMake([UIScreen mainScreen].bounds.size.width / 2.0, 49 | [UIScreen mainScreen].bounds.size.height / 2.0); 50 | [self addImage:@"Icon4.png" atPosition:iconPosition]; 51 | 52 | CGPoint arrowPosition = CGPointMake([UIScreen mainScreen].bounds.size.width / 2.0, 53 | [UIScreen mainScreen].bounds.size.height / 4.0); 54 | [self addImage:@"ShareArrow.png" atPosition:arrowPosition]; 55 | 56 | [window makeKeyAndVisible]; 57 | 58 | return YES; 59 | } 60 | 61 | - (void)addImage:(NSString *)theFilename atPosition:(CGPoint)thePosition { 62 | UIImage *image = [UIImage imageNamed:theFilename]; 63 | int width = image.size.width; 64 | int height = image.size.height; 65 | 66 | // Create a bitmap 67 | unsigned char *bitmap = [ImageHelper convertUIImageToBitmapRGBA8:image]; 68 | Color3D *colorOut = new Color3D[width * height]; 69 | ConvertImageRGBA8ToColor3d(bitmap, colorOut, width, height); 70 | 71 | // **NOTE:** Test Print the colors using a c++ code to check transparency 72 | // for(int i = 0; i < width * height; ++i) { 73 | // std::cout << colorOut[i] << std::endl; 74 | // } 75 | 76 | // Create a UIImage using the bitmap 77 | UIImage *imageCopy = [ImageHelper convertBitmapRGBA8ToUIImage:bitmap withWidth:width withHeight:height]; 78 | 79 | // Cleanup 80 | if(bitmap) { 81 | free(bitmap); 82 | bitmap = NULL; 83 | } 84 | 85 | // Display the image copy on the GUI 86 | UIImageView *imageView = [[UIImageView alloc] initWithImage:imageCopy]; 87 | [imageView setCenter:thePosition]; 88 | [window addSubview:imageView]; 89 | [imageView release]; 90 | } 91 | 92 | 93 | - (void)applicationWillResignActive:(UIApplication *)application { 94 | /* 95 | 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. 96 | 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. 97 | */ 98 | } 99 | 100 | 101 | - (void)applicationDidBecomeActive:(UIApplication *)application { 102 | /* 103 | Restart any tasks that were paused (or not yet started) while the application was inactive. 104 | */ 105 | } 106 | 107 | 108 | - (void)applicationWillTerminate:(UIApplication *)application { 109 | /* 110 | Called when the application is about to terminate. 111 | */ 112 | } 113 | 114 | 115 | #pragma mark - 116 | #pragma mark Memory management 117 | 118 | - (void)applicationDidReceiveMemoryWarning:(UIApplication *)application { 119 | /* 120 | Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later. 121 | */ 122 | } 123 | 124 | 125 | - (void)dealloc { 126 | [window release]; 127 | [super dealloc]; 128 | } 129 | 130 | 131 | @end 132 | -------------------------------------------------------------------------------- /iPad/Icon4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulSolt/UIImage-Conversion/cc7c5e10763d650ae16a8e3d8736e486e597cdc8/iPad/Icon4.png -------------------------------------------------------------------------------- /iPad/MainWindow_iPad.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1024 5 | 10F569 6 | 804 7 | 1038.29 8 | 461.00 9 | 10 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 11 | 123 12 | 13 | 14 | YES 15 | 16 | 17 | YES 18 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 19 | 20 | 21 | YES 22 | 23 | YES 24 | 25 | 26 | YES 27 | 28 | 29 | 30 | YES 31 | 32 | IBFilesOwner 33 | IBIPadFramework 34 | 35 | 36 | IBFirstResponder 37 | IBIPadFramework 38 | 39 | 40 | 41 | 292 42 | {768, 1024} 43 | 44 | 1 45 | MSAxIDEAA 46 | 47 | NO 48 | NO 49 | 50 | 2 51 | 52 | IBIPadFramework 53 | YES 54 | 55 | 56 | IBIPadFramework 57 | 58 | 59 | 60 | 61 | YES 62 | 63 | 64 | window 65 | 66 | 67 | 68 | 7 69 | 70 | 71 | 72 | delegate 73 | 74 | 75 | 76 | 8 77 | 78 | 79 | 80 | 81 | YES 82 | 83 | 0 84 | 85 | 86 | 87 | 88 | 89 | -1 90 | 91 | 92 | File's Owner 93 | 94 | 95 | -2 96 | 97 | 98 | 99 | 100 | 2 101 | 102 | 103 | YES 104 | 105 | 106 | 107 | 108 | 6 109 | 110 | 111 | App Delegate iPad 112 | 113 | 114 | 115 | 116 | YES 117 | 118 | YES 119 | -1.CustomClassName 120 | -2.CustomClassName 121 | 2.IBEditorWindowLastContentRect 122 | 2.IBPluginDependency 123 | 6.CustomClassName 124 | 6.IBPluginDependency 125 | 126 | 127 | YES 128 | UIApplication 129 | UIResponder 130 | {{903, 55}, {768, 1024}} 131 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 132 | AppDelegate_iPad 133 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 134 | 135 | 136 | 137 | YES 138 | 139 | 140 | YES 141 | 142 | 143 | 144 | 145 | YES 146 | 147 | 148 | YES 149 | 150 | 151 | 152 | 9 153 | 154 | 155 | 156 | YES 157 | 158 | AppDelegate_iPad 159 | NSObject 160 | 161 | window 162 | UIWindow 163 | 164 | 165 | window 166 | 167 | window 168 | UIWindow 169 | 170 | 171 | 172 | IBProjectSource 173 | iPad/AppDelegate_iPad.h 174 | 175 | 176 | 177 | 178 | YES 179 | 180 | NSObject 181 | 182 | IBFrameworkSource 183 | Foundation.framework/Headers/NSError.h 184 | 185 | 186 | 187 | NSObject 188 | 189 | IBFrameworkSource 190 | Foundation.framework/Headers/NSFileManager.h 191 | 192 | 193 | 194 | NSObject 195 | 196 | IBFrameworkSource 197 | Foundation.framework/Headers/NSKeyValueCoding.h 198 | 199 | 200 | 201 | NSObject 202 | 203 | IBFrameworkSource 204 | Foundation.framework/Headers/NSKeyValueObserving.h 205 | 206 | 207 | 208 | NSObject 209 | 210 | IBFrameworkSource 211 | Foundation.framework/Headers/NSKeyedArchiver.h 212 | 213 | 214 | 215 | NSObject 216 | 217 | IBFrameworkSource 218 | Foundation.framework/Headers/NSObject.h 219 | 220 | 221 | 222 | NSObject 223 | 224 | IBFrameworkSource 225 | Foundation.framework/Headers/NSRunLoop.h 226 | 227 | 228 | 229 | NSObject 230 | 231 | IBFrameworkSource 232 | Foundation.framework/Headers/NSThread.h 233 | 234 | 235 | 236 | NSObject 237 | 238 | IBFrameworkSource 239 | Foundation.framework/Headers/NSURL.h 240 | 241 | 242 | 243 | NSObject 244 | 245 | IBFrameworkSource 246 | Foundation.framework/Headers/NSURLConnection.h 247 | 248 | 249 | 250 | NSObject 251 | 252 | IBFrameworkSource 253 | UIKit.framework/Headers/UIAccessibility.h 254 | 255 | 256 | 257 | NSObject 258 | 259 | IBFrameworkSource 260 | UIKit.framework/Headers/UINibLoading.h 261 | 262 | 263 | 264 | NSObject 265 | 266 | IBFrameworkSource 267 | UIKit.framework/Headers/UIResponder.h 268 | 269 | 270 | 271 | UIApplication 272 | UIResponder 273 | 274 | IBFrameworkSource 275 | UIKit.framework/Headers/UIApplication.h 276 | 277 | 278 | 279 | UIResponder 280 | NSObject 281 | 282 | 283 | 284 | UISearchBar 285 | UIView 286 | 287 | IBFrameworkSource 288 | UIKit.framework/Headers/UISearchBar.h 289 | 290 | 291 | 292 | UISearchDisplayController 293 | NSObject 294 | 295 | IBFrameworkSource 296 | UIKit.framework/Headers/UISearchDisplayController.h 297 | 298 | 299 | 300 | UIView 301 | 302 | IBFrameworkSource 303 | UIKit.framework/Headers/UITextField.h 304 | 305 | 306 | 307 | UIView 308 | UIResponder 309 | 310 | IBFrameworkSource 311 | UIKit.framework/Headers/UIView.h 312 | 313 | 314 | 315 | UIViewController 316 | 317 | IBFrameworkSource 318 | UIKit.framework/Headers/UINavigationController.h 319 | 320 | 321 | 322 | UIViewController 323 | 324 | IBFrameworkSource 325 | UIKit.framework/Headers/UIPopoverController.h 326 | 327 | 328 | 329 | UIViewController 330 | 331 | IBFrameworkSource 332 | UIKit.framework/Headers/UISplitViewController.h 333 | 334 | 335 | 336 | UIViewController 337 | 338 | IBFrameworkSource 339 | UIKit.framework/Headers/UITabBarController.h 340 | 341 | 342 | 343 | UIViewController 344 | UIResponder 345 | 346 | IBFrameworkSource 347 | UIKit.framework/Headers/UIViewController.h 348 | 349 | 350 | 351 | UIWindow 352 | UIView 353 | 354 | IBFrameworkSource 355 | UIKit.framework/Headers/UIWindow.h 356 | 357 | 358 | 359 | 360 | 0 361 | IBIPadFramework 362 | 363 | com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS 364 | 365 | 366 | 367 | com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 368 | 369 | 370 | YES 371 | ../ImageConversion.xcodeproj 372 | 3 373 | 123 374 | 375 | 376 | -------------------------------------------------------------------------------- /iPad/ShareArrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulSolt/UIImage-Conversion/cc7c5e10763d650ae16a8e3d8736e486e597cdc8/iPad/ShareArrow.png -------------------------------------------------------------------------------- /iPhone/AppDelegate_iPhone.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate_iPhone.h 3 | // ImageConversion 4 | // 5 | // Created by Paul Solt on 9/22/10. 6 | // Copyright 2010 RIT. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate_iPhone : NSObject { 12 | UIWindow *window; 13 | } 14 | 15 | @property (nonatomic, retain) IBOutlet UIWindow *window; 16 | 17 | @end 18 | 19 | -------------------------------------------------------------------------------- /iPhone/AppDelegate_iPhone.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate_iPhone.m 3 | // ImageConversion 4 | // 5 | // Created by Paul Solt on 9/22/10. 6 | // Copyright 2010 RIT. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate_iPhone.h" 10 | 11 | @implementation AppDelegate_iPhone 12 | 13 | @synthesize window; 14 | 15 | 16 | #pragma mark - 17 | #pragma mark Application lifecycle 18 | 19 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 20 | 21 | // Override point for customization after application launch. 22 | 23 | [window makeKeyAndVisible]; 24 | 25 | return YES; 26 | } 27 | 28 | 29 | - (void)applicationWillResignActive:(UIApplication *)application { 30 | /* 31 | 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. 32 | 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. 33 | */ 34 | } 35 | 36 | 37 | - (void)applicationDidEnterBackground:(UIApplication *)application { 38 | /* 39 | Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 40 | If your application supports background execution, called instead of applicationWillTerminate: when the user quits. 41 | */ 42 | } 43 | 44 | 45 | - (void)applicationWillEnterForeground:(UIApplication *)application { 46 | /* 47 | Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background. 48 | */ 49 | } 50 | 51 | 52 | - (void)applicationDidBecomeActive:(UIApplication *)application { 53 | /* 54 | Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 55 | */ 56 | } 57 | 58 | 59 | - (void)applicationWillTerminate:(UIApplication *)application { 60 | /* 61 | Called when the application is about to terminate. 62 | See also applicationDidEnterBackground:. 63 | */ 64 | } 65 | 66 | 67 | #pragma mark - 68 | #pragma mark Memory management 69 | 70 | - (void)applicationDidReceiveMemoryWarning:(UIApplication *)application { 71 | /* 72 | Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later. 73 | */ 74 | } 75 | 76 | 77 | - (void)dealloc { 78 | [window release]; 79 | [super dealloc]; 80 | } 81 | 82 | 83 | @end 84 | -------------------------------------------------------------------------------- /iPhone/MainWindow_iPhone.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1024 5 | 10D573 6 | 782 7 | 1038.29 8 | 460.00 9 | 10 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 11 | 105 12 | 13 | 14 | YES 15 | 16 | 17 | 18 | YES 19 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 20 | 21 | 22 | YES 23 | 24 | YES 25 | 26 | 27 | YES 28 | 29 | 30 | 31 | YES 32 | 33 | IBFilesOwner 34 | IBCocoaTouchFramework 35 | 36 | 37 | IBFirstResponder 38 | IBCocoaTouchFramework 39 | 40 | 41 | IBCocoaTouchFramework 42 | 43 | 44 | 45 | 1316 46 | 47 | {320, 480} 48 | 49 | 50 | 1 51 | MSAxIDEAA 52 | 53 | NO 54 | NO 55 | 56 | IBCocoaTouchFramework 57 | YES 58 | 59 | 60 | 61 | 62 | YES 63 | 64 | 65 | delegate 66 | 67 | 68 | 69 | 5 70 | 71 | 72 | 73 | window 74 | 75 | 76 | 77 | 6 78 | 79 | 80 | 81 | 82 | YES 83 | 84 | 0 85 | 86 | 87 | 88 | 89 | 90 | 2 91 | 92 | 93 | YES 94 | 95 | 96 | 97 | 98 | -1 99 | 100 | 101 | File's Owner 102 | 103 | 104 | 4 105 | 106 | 107 | App Delegate 108 | 109 | 110 | -2 111 | 112 | 113 | 114 | 115 | 116 | 117 | YES 118 | 119 | YES 120 | -1.CustomClassName 121 | -2.CustomClassName 122 | 2.IBAttributePlaceholdersKey 123 | 2.IBEditorWindowLastContentRect 124 | 2.IBPluginDependency 125 | 2.UIWindow.visibleAtLaunch 126 | 4.CustomClassName 127 | 4.IBPluginDependency 128 | 129 | 130 | YES 131 | UIApplication 132 | UIResponder 133 | 134 | YES 135 | 136 | 137 | YES 138 | 139 | 140 | {{520, 376}, {320, 480}} 141 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 142 | 143 | AppDelegate_iPhone 144 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 145 | 146 | 147 | 148 | YES 149 | 150 | 151 | YES 152 | 153 | 154 | 155 | 156 | YES 157 | 158 | 159 | YES 160 | 161 | 162 | 163 | 8 164 | 165 | 166 | 167 | YES 168 | 169 | AppDelegate_iPhone 170 | NSObject 171 | 172 | window 173 | UIWindow 174 | 175 | 176 | IBProjectSource 177 | iPhone/AppDelegate_iPhone.h 178 | 179 | 180 | 181 | 182 | YES 183 | 184 | NSObject 185 | 186 | IBFrameworkSource 187 | Foundation.framework/Headers/NSError.h 188 | 189 | 190 | 191 | NSObject 192 | 193 | IBFrameworkSource 194 | Foundation.framework/Headers/NSFileManager.h 195 | 196 | 197 | 198 | NSObject 199 | 200 | IBFrameworkSource 201 | Foundation.framework/Headers/NSKeyValueCoding.h 202 | 203 | 204 | 205 | NSObject 206 | 207 | IBFrameworkSource 208 | Foundation.framework/Headers/NSKeyValueObserving.h 209 | 210 | 211 | 212 | NSObject 213 | 214 | IBFrameworkSource 215 | Foundation.framework/Headers/NSKeyedArchiver.h 216 | 217 | 218 | 219 | NSObject 220 | 221 | IBFrameworkSource 222 | Foundation.framework/Headers/NSObject.h 223 | 224 | 225 | 226 | NSObject 227 | 228 | IBFrameworkSource 229 | Foundation.framework/Headers/NSRunLoop.h 230 | 231 | 232 | 233 | NSObject 234 | 235 | IBFrameworkSource 236 | Foundation.framework/Headers/NSThread.h 237 | 238 | 239 | 240 | NSObject 241 | 242 | IBFrameworkSource 243 | Foundation.framework/Headers/NSURL.h 244 | 245 | 246 | 247 | NSObject 248 | 249 | IBFrameworkSource 250 | Foundation.framework/Headers/NSURLConnection.h 251 | 252 | 253 | 254 | NSObject 255 | 256 | IBFrameworkSource 257 | UIKit.framework/Headers/UIAccessibility.h 258 | 259 | 260 | 261 | NSObject 262 | 263 | IBFrameworkSource 264 | UIKit.framework/Headers/UINibLoading.h 265 | 266 | 267 | 268 | NSObject 269 | 270 | IBFrameworkSource 271 | UIKit.framework/Headers/UIResponder.h 272 | 273 | 274 | 275 | UIApplication 276 | UIResponder 277 | 278 | IBFrameworkSource 279 | UIKit.framework/Headers/UIApplication.h 280 | 281 | 282 | 283 | UIResponder 284 | NSObject 285 | 286 | 287 | 288 | UIView 289 | 290 | IBFrameworkSource 291 | UIKit.framework/Headers/UITextField.h 292 | 293 | 294 | 295 | UIView 296 | UIResponder 297 | 298 | IBFrameworkSource 299 | UIKit.framework/Headers/UIView.h 300 | 301 | 302 | 303 | UIWindow 304 | UIView 305 | 306 | IBFrameworkSource 307 | UIKit.framework/Headers/UIWindow.h 308 | 309 | 310 | 311 | 312 | 0 313 | IBCocoaTouchFramework 314 | 315 | com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS 316 | 317 | 318 | 319 | com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 320 | 321 | 322 | YES 323 | ../ImageConversion.xcodeproj 324 | 3 325 | 105 326 | 327 | 328 | --------------------------------------------------------------------------------