Xcode UIImageJPEG表示和蹩脚图像

Xcode UIImageJPEG表示和蹩脚图像,xcode,image,uiimagejpegrepresentation,Xcode,Image,Uiimagejpegrepresentation,在尝试之后,我能够将从相机拍摄的图像上传到我的Web服务器 但我不明白的是,为什么图像质量差,分辨率低,颜色很少。有没有办法获得更好的质量 这是我的密码: NSURL *url = [NSURL URLWithString:@"http://localhost"]; AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url]; NSData *imageData = UIImageJPEGRepr

在尝试之后,我能够将从相机拍摄的图像上传到我的Web服务器

但我不明白的是,为什么图像质量差,分辨率低,颜色很少。有没有办法获得更好的质量

这是我的密码:

NSURL *url = [NSURL URLWithString:@"http://localhost"];

    AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url];

    NSData *imageData = UIImageJPEGRepresentation(image, 0.9);

    NSMutableURLRequest *request = [httpClient multipartFormRequestWithMethod:@"POST" path:@"/upload.php" parameters:nil constructingBodyWithBlock: ^(id <AFMultipartFormData>formData) {
        [formData appendPartWithFileData:imageData name:@"file" fileName:@"temp.jpeg" mimeType:@"image/jpeg"];
    }];

    AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];

    [operation setUploadProgressBlock:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) {
        NSLog(@"Sent %lld of %lld bytes", totalBytesWritten, totalBytesExpectedToWrite);
    }];

    [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject)
    {
        NSString *response = [operation responseString];
        NSLog(@"response: [%@]",response);
        //[MBProgressHUD hideHUDForView:self.view animated:YES];
    }
    failure:^(AFHTTPRequestOperation *operation, NSError *error)
    {
        //[MBProgressHUD hideHUDForView:self.view animated:YES];
        if([operation.response statusCode] == 403)
        {
            NSLog(@"Upload Failed");
            return;
        }
        NSLog(@"error: %@", [operation error]);

    }];


    [operation start];
NSURL*url=[NSURL URLWithString:@”http://localhost"];
AFHTTPClient*httpClient=[[AFHTTPClient alloc]initWithBaseURL:url];
NSData*imageData=UIIMAGEJPEG表示法(图像,0.9);
NSMutableURLRequest*request=[httpClient multipartFormRequestWithMethod:@“POST”路径:@“/upload.php”参数:nil constructingBodyWithBlock:^(id formData){
[formData appendPartWithFileData:imageData名称:@“file”文件名:@“temp.jpeg”mimeType:@“image/jpeg”];
}];
AFHTTPRequestOperation*操作=[[AFHTTPRequestOperation alloc]initWithRequest:request];
[操作设置LoadProgressBlock:^(NSUTEGER字节写入、long long TotalBytesWrite、long long totalBytesExpectedToWrite){
NSLog(@“已发送%lld个字节,共%lld个字节”,TotalBytesWrite,totalBytesExpectedToWrite);
}];
[操作setCompletionBlockWithSuccess:^(AFHTTPRequestOperation*操作,id响应对象)
{
NSString*response=[operation responseString];
NSLog(@“响应:[%@]”,响应);
//[MBProgressHUD hideHUDForView:self.view动画:是];
}
失败:^(AFHTTPRequestOperation*操作,NSError*错误)
{
//[MBProgressHUD hideHUDForView:self.view动画:是];
如果([operation.response statusCode]==403)
{
NSLog(@“上传失败”);
返回;
}
NSLog(@“错误:%@,[操作错误]);
}];
[操作启动];

谢谢瑞吉斯,对不起,伙计们,为了在我的Web服务器上工作,我使用realVnc。RealVnc的设置设置为低分辨率!!!我确实更改了设置以获得更好的解决方案,现在问题解决了

您需要与原始图像进行一些比较,以了解质量下降的原因。UIImageJPEG表示与原始UIImage相比如何?服务器上的版本与UIImageJPEG表示相比如何?除了视觉比较外,还可以查看它们的像素尺寸和文件大小。