首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UIImageJPEGRepresentation和垃圾图像

UIImageJPEGRepresentation和垃圾图像
EN

Stack Overflow用户
提问于 2013-01-23 06:17:51
回答 1查看 567关注 0票数 0

经过尝试,我能够上传一张从相机拍摄的图像到我的网络服务器上。

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

下面是我的代码:

代码语言:javascript
复制
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];

谢谢Regis

EN

回答 1

Stack Overflow用户

发布于 2013-01-23 23:30:32

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14469097

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档