Unity3D读取Ios中的动态UIImage图片
2013-03-08 16:47
399 查看
extern "C" { const char* _GetImage() { NSLog(@"I am in Begin"); UIImage *myUIImage = [UIImage imageNamed:@"Test.jpg"]; NSData *imageData = UIImagePNGRepresentation(myUIImage); NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"Test.jpg"]; //Add the file name NSLog(@"filePath %@",filePath); [imageData writeToFile:filePath atomically:YES]; return MakeStringCopy([filePath UTF8String]); } } [DllImport ("__Internal")] private static extern String _GetImage(); public Texture2D texture2D; void Start () { texture2D = new Texture2D (200, 200); imagePath = GetImage(); byte[] imageBytes = File.ReadAllBytes(imagePath); texture2D.LoadImage(imageBytes); } void OnGUI () { GUI.Button (new Rect(20,20,100,100),texture2D); } public static String GetImage() { if (Application.platform != RuntimePlatform.OSXEditor) { return _GetImage(); } else { return @"Hello"; } }
相关文章推荐
- Unity3D读取Ios中的动态UIImage图片内容!!!!
- unity3d读取图片文件绘制在UIImage上
- iOS读取图片数据的两种方法:UIImageJPEG和UIImagePNG
- iOS 【读取图片数据 UIImageJPEGRepresentation和UIImagePNGRepresentation】
- [Unity3D][Vuforia][IOS]vuforia在unity3d中添加自己的动态模型,识别自己的图片,添加GUI,播放视频
- [unity基础教程]关于Unity3D中Resources动态加载NGUI图片的方法!
- Silverlight:动态读取图片或者视频
- ios 获取UIImage图片的像素尺寸
- iOS:UIimageView切换图片渐入渐出的动画
- 关于Unity3D中Resources动态加载NGUI图片的方法!!!
- ios学习--结合UIImageView实现图片的移动和缩放
- iOS NSMutableDictionary中UIImage的存储和读取
- ios UIImageView异步加载网络图片2
- Unity3D移动平台动态读取外部文件全解析
- Unity3D(一)——移动平台动态读取外部文件全解析
- [IOS OpenCV]摄像头采集图片用 CreateIplImageFromUIImage 转换后图像被旋转、变形解决方案
- 【酷熊科技】工作积累 ----------- Unity3D 读取 图片
- 自定义动态数量图片显示视图(UIImageView)
- IOS 播放动态Gif图片
- ios 获取uiimage图片原始大小的方法