Tag: 图像

iOS Objective-C图像文件名称/path在模拟器和设备之间的不同行为

我有一个应用程序包中包含一个图像文件(我的意思是该文件被拖入XCode,并出现在“其他来源”),我使用的代码如下: [[NSBundle mainBundle] pathForResource:@"Auto" ofType:@"jpg"] 获得图像的path。 我发现在设备(iPod Touch)上运行时,名称区分大小写,所以如果文件是“Auto”,并使用“AUTO”,返回的poath是“file://(null)”。 但是在模拟器上,如果我使用“自动”,它和我使用“自动”一样。 我在想,模拟器在设备行为上有如此明显的差异,这是一个错误。 那些更有经验的用户是否认为这是事实,我应该向苹果公司报告? 谢谢。

如何使用writeToFile将图像保存在文档目录中?

// directoryPath is a URL from another VC @IBAction func saveButtonTapped(sender: AnyObject) { let directoryPath = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)[0] as NSURL let urlString : NSURL = directoryPath.URLByAppendingPathComponent("Image1.png") print("Image path : \(urlString)") if !NSFileManager.defaultManager().fileExistsAtPath(directoryPath.absoluteString) { UIImageJPEGRepresentation(self.image, 1.0)!.writeToFile(urlString.absoluteString, atomically: true) displayImageAdded.text = "Image Added Successfully" } else { displayImageAdded.text = "Image Not Added" print("image \(image))") } } […]

如何在iOS中将图像转换为二进制格式?

我正在一个项目,我需要上传图像到我的服务器。 我想将我的图像的二进制数据存储到数据库中的BLOB数据types字段。 所以我需要将我的图像转换成二进制格式。 这样它可以保存在服务器数据库上。 那么如何将图像转换为二进制格式? 请指教。

如何在存在的图像上添加水印

我发现一些代码如下: UIGraphicsBeginImageContext(CGSizeMake(320, 480)); // This is where we resize captured image [(UIImage *)[info objectForKey:UIImagePickerControllerOriginalImage] drawInRect:CGRectMake(0, 0, 320, 480)]; // And add the watermark on top of it [[UIImage imageNamed:@"Watermark.png"] drawAtPoint:CGPointMake(0, 0) blendMode:kCGBlendModeNormal alpha:WATERMARK_ALPHA]; // Save the results directly to the image view property imageView.image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); 但我不确定这是否是最好的方法。

使用Swift中的多部分表单数据iOS上传图像

我有一个与多部分forms上传图像的问题 这里是我从这个答案使用的代码 var request = NSMutableURLRequest(URL: url!) request.HTTPMethod = "POST" var boundary = generateBoundaryString() request.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type") var body = NSMutableData() if self.img.image != nil { var imageData = UIImagePNGRepresentation(self.img.image) if imageData != nil { body.appendString("–\(boundary)\r\n") body.appendString("Content-Disposition: form-data; name=\"image\"; filename=\"image.png\"\r\n") body.appendString("Content-Type: image/png\r\n\r\n") body.appendData(imageData!) body.appendString("\r\n") } } body.appendString("–\(boundary)–\r\n") request.setValue("\(body.length)", forHTTPHeaderField:"Content-Length") request.HTTPBody = body 然后我使用NSURLSession来应用请求 服务器说,我没有select图像上传,我只想现在上传图像 […]

上传PHP后修复iOS图片方向

有没有一种方式来旋转图片只有当从iOS上传后没有正确定位的PHP? 有些照片旋转了90度,而其他照片则正确上传。

UIImage种植中心广场

所以这是我迄今为止所做的。 我正在使用从相机捕获的UIImage,并可以在横向上裁剪中心广场。 出于某种原因,这不会像预期的那样转换成肖像模式。 我会发布我的代码和日志只是为了参考。 码: CGRect squareRect = CGRectMake(offsetX, offsetY, newWidth, newHeight); CGImageRef imageRef = CGImageCreateWithImageInRect([image CGImage], squareRect); image = [UIImage imageWithCGImage:imageRef scale:1 orientation:image.imageOrientation]; 肖像结果(不是正方形): original image size: {1536, 2048}, with orientation: 3 squareRect: {{0, 256}, {1536, 1536}} new image size: {1280, 1536}, with orientation: 3 <— not expected 景观结果(平方): original image size: {2048, 1536}, […]

在ios中将图像转换为卡通

在ios中是否有任何filter可以将图像转换为卡通形象,就像上面的图片一样?

iOS:如何在界面生成器中使用自定义包中的图像?

我有一个捆绑,我把图像放在里面。 内容是: MyBundle.bundle/images/picture1.png MyBundle.bundle/images/picture2.png 我将MyBundle.bundle拖到我的项目中。 现在我可以在Interface Builder中看到这些图像,甚至可以使用它们。 但是,当我运行该应用程序,我没有看到图像。 怎么了? 谢谢,

在iOS中的另一个图像覆盖图像

我在iOS应用程序中显示来自YouTube的缩略图图像。 点击后,将转到youtube。 我需要将播放button叠加到这些图像上。 什么可能是最直接的方式呢? 另外,图像被远程加载到桌子上,所以性能是一个很大的考虑因素