nsdata

iOS 4 Image Oriented Incorrectly When Posted To Server

北慕城南 提交于 2019-12-08 09:58:44
问题 I am a relatively new iOS developer. I am attempting to build an app that uploads images to a server. However, when I get the image with metadata, the orientation is always off. Here is the code I am using: - (void)getJPEGFromAssetForURL:(NSURL *)url { ALAssetsLibrary* assetslibrary = [[ALAssetsLibrary alloc] init]; [assetslibrary assetForURL:url resultBlock: ^(ALAsset *myasset) { self.rep = [myasset defaultRepresentation]; NSLog(@"getJPEGFromAssetForURL: default asset representation for %@:

How to get the size of a UIImage in KB?

蓝咒 提交于 2019-12-08 09:35:00
问题 Is there a way to get the filesize in KB from a UIImage, without getting that image from didFinishPickingMediaWithInfo? The images that are presented are coming from the photo album. I tried the following code, but this gives the following result: size of image in KB: 0.000000 - (void)setImage:(UIImage *)image { _image = image; self.imageView.image = image; } - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self setupView]; self.backgroundColor = [UIColor

data from camera video returning zero

穿精又带淫゛_ 提交于 2019-12-08 08:03:23
问题 this is my code for getting a video from UIImagePickerController : - (IBAction)takeVideo:(UIButton *)sender { UIImagePickerController *picker = [[UIImagePickerController alloc] init]; picker.delegate = self; picker.allowsEditing = YES; picker.sourceType = UIImagePickerControllerSourceTypeCamera; picker.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil]; [self presentViewController:picker animated:YES completion:NULL]; } - (void)viewDidAppear:(BOOL)animated { self

Characteristic.value from Bluetooth reading in Swift

百般思念 提交于 2019-12-08 06:41:33
I'm trying to read and convert into String a reading from a BT device. <CBCharacteristic: 0x1700a2e80, UUID = 2A9D, properties = 0x20, value = <02ac08e1 07010a14 0029>, notifying = YES> Based on example I found online I did let u16 = (characteristic.value! as NSData).bytes.bindMemory(to: Int.self, capacity: characteristic.value!.count).pointee but my u16 is null, even though characteristic.value contains (lldb) dp characteristic.value! as NSData <02ac08e1 07010a14 0029> Can anyone point me in the right direction? It's not super easy. Weight Measurement You may need to write something like this

Characteristic.value from Bluetooth reading in Swift

百般思念 提交于 2019-12-08 06:37:53
问题 I'm trying to read and convert into String a reading from a BT device. <CBCharacteristic: 0x1700a2e80, UUID = 2A9D, properties = 0x20, value = <02ac08e1 07010a14 0029>, notifying = YES> Based on example I found online I did let u16 = (characteristic.value! as NSData).bytes.bindMemory(to: Int.self, capacity: characteristic.value!.count).pointee but my u16 is null, even though characteristic.value contains (lldb) dp characteristic.value! as NSData <02ac08e1 07010a14 0029> Can anyone point me in

Writing photos (and other things) to disk and getting them later in iphone

我的梦境 提交于 2019-12-08 06:21:05
问题 I'm trying to write an image to disk: NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsPath = [paths objectAtIndex:0]; NSString* savePath = [documentsPath stringByAppendingPathComponent:@"photo"]; BOOL result = [data writeToFile:savePath atomically:YES]; if(result) NSLog(@"Save of photo success!"); Then, later, I try to retrieve for a table view cell image: NSData* getPhoto = [NSData dataWithContentsOfFile:[leaf content]];

AFNetworking send image as file not as data

蓝咒 提交于 2019-12-08 05:25:09
问题 Hi server that I'm sending data is expecting image as file(jpg) not as NSData. This code works, but server can't recognize NSData as image. Any thoughts how to solve this? + (void)signupWithParameters:(NSDictionary *)parameters andUserHaveImage:(BOOL)userHaveImage andImage:(NSData *)image successBlock:(void (^) (NSDictionary *response))successHandler errorBlock:(void (^) (NSDictionary *error))errorHandler { AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; manager

iOS: Why my big files are not converted with NSData(contentsOfFile: options:)? Error Domain=NSCocaErrorDomain Code=256

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-08 05:06:37
问题 I try to convert a video with NSData, it works well with little videos or 100mb, but my big files (4.44Gb) are not sent... var video_data: NSData? do { video_data = try NSData(contentsOfFile: (videoPath), options: NSData.ReadingOptions.alwaysMapped) } catch let error as NSError { video_data = nil return } How can I put big files in NSData? Error Domain=NSCocoaErrorDomain Code=256 "Impossible d’ouvrir le fichier « D9C7DABF-4BE3-4105-8D76-AA92B1D1502E_video.notsend »." UserInfo={NSFilePath=/var

New CGIImage or CGImageRef from std::string using using base64

巧了我就是萌 提交于 2019-12-08 04:50:20
问题 everyone: I've been working on this for days. Here's a little bit of background. I'm sending an image to a server using protobuf. The image is directly from the camera, so it is not a jpeg nor a png. I found code to get the data from the UIImage using the CGImage to create a CGImageRef. See the following code: - (UIImage *)testProcessedImage:(UIImage *)processedImage { CGImageRef imageRef = processedImage.CGImage; NSData *data1 = (NSData *) CFBridgingRelease(CGDataProviderCopyData

Swift generics and CMutableVoidPointer

一曲冷凌霜 提交于 2019-12-07 18:56:39
问题 I have the following function at the moment in my generic class func writeHeader(buffer: CMutableVoidPointer) { var headerData = NSData(bytesNoCopy:buffer, length:sizeof(H)) self.fileHandle.writeData(headerData) } But as you see this is not very type safe. I tried this but it does not compile func writeHeader(buffer: CMutablePointer<H>) { var headerData = NSData(bytesNoCopy:buffer, length:sizeof(H)) self.fileHandle.writeData(headerData) } Any idea? UPDATE This is part of a generic class as