Tag: uiimage

旋转UIImage自定义程度

我正在使用下面的代码来实现这一点。 问题是当图像旋转时,图像越靠近45度,图像越大。 当图像设置为90'和倍数时,图像尺寸没有问题。 但是,当度数接近45'和倍数时,图像大小会明显缩小。 我不想改变图像大小。 我应该如何解决这个问题? – (UIImage *)imageRotatedByRadians:(CGFloat)radians img:(UIImage *)img { // calculate the size of the rotated view's containing box for our drawing space UIView *rotatedViewBox = [[UIView alloc] initWithFrame:CGRectMake(0,0,img.size.width, img.size.height)]; UIView *nonrotatedViewBox = rotatedViewBox; CGAffineTransform t = CGAffineTransformMakeRotation(radians); rotatedViewBox.transform = t; CGSize rotatedSize = rotatedViewBox.frame.size; // Create the bitmap context UIGraphicsBeginImageContext(nonrotatedViewBox.frame.size); CGContextRef […]

IOS使用SDWebImage从URL加载图像

我尝试从下面的json URL加载图像,但我得到了[cell.imageView setImageWithURL:[NSURL URLWithString:@"coffeemugDirectLink"] placeholderImage:[UIImage imageNamed:@"heart.png"]]; 错误是Expected ',' separator和Expected expression in container literal我做错了什么? 我怎样才能从JSON加载到UICollectionView我的单元格的URL? import UIKit import SDWebImage class TopratedVC: BaseViewController { @IBOutlet var collectionview: UICollectionView! @IBOutlet var Image: UIImageView! //Our web service url let URL_GET_coffeemugs:String = "http://coffeemugs.com/ios/feed.php" override func viewDidLoad() { super.viewDidLoad() addSlideMenuButton() // Do any additional setup after loading the view. //SDWebimage stuff […]

与GPUImage混合:如何控制第一个图像上的第二个图像的位置

我使用下面的代码来使用Brad Larson的GPUImage框架来混合两个图像。 有没有办法控制相对于baseImage的topImage的位置? 现在,它将topImage放在baseImage的中间。 GPUImageMultiplyBlendFilter *overlayBlendFilter = [[GPUImageMultiplyBlendFilter alloc] init]; GPUImagePicture *pic1 = [[GPUImagePicture alloc] initWithImage:baseImage]; GPUImagePicture *pic2 = [[GPUImagePicture alloc] initWithImage:topImage]; [pic1 addTarget:overlayBlendFilter]; [pic1 processImage]; [pic2 addTarget:overlayBlendFilter]; [pic2 processImage]; UIImage *blendedImage = [overlayBlendFilter imageByFilteringImage:filteredimage]; [imageView setImage:blendedImage];

在ios中的imageView中的path显示图像

我有图像path,我想在uiimageview中显示它, /用户/ WTS-新build/库/开发商/ CoreSimulator /设备/ F43C 26D2-DCFF-4764-AAF0-F6CC7BCDCF5D /数据/有限公司ntainers /数据/方面的应用中/ 8E49D340-7CAC-4031-85BF -9E5C26A1E3 7A /文档/小米ario.png 我怎样才能让图像显示?

如何捕捉self.view的特定大小

我有self.view,但我只想捕获它的300×320。 得到这个代码: UIGraphicsBeginImageContext(self.view.bounds.size); [self.view.window.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil); UIImage * imgPrintScreen = [[UIImage alloc]init]; imgPrintScreen = viewImage; 为了做到这一点,我需要改变什么? 谢谢!

从Leptonica的Pix结构创buildUIImage

我想在我的iOS应用程序中使用Leptonica库来处理图像。 有谁知道如何从Leptonica的Pix结构中的原始数据创buildUIImage : /*————————————————————————-* * Basic Pix * *————————————————————————-*/ struct Pix { l_uint32 w; /* width in pixels */ l_uint32 h; /* height in pixels */ l_uint32 d; /* depth in bits */ l_uint32 wpl; /* 32-bit words/line */ l_uint32 refcount; /* reference count (1 if no clones) */ l_int32 xres; /* image res (ppi) […]

如何只保存UIImageView不是我的照片应用程序的整个屏幕。 在Swift中

我的应用程序有一个相机部分。 它拍摄一张照片,然后在照片上加水印。 但是,当保存照片时,整个屏幕将被保存,而不仅仅是UIImageView 。 我只想要保存UIImageView 。 不是那样,而是因为button上的菜单栏不是那么大。 我只是觉得没有图片中的菜单栏会更好。 拍照之前的应用照片: 如何拍摄照片的照片保存: 这是我的代码如下。 import UIKit class Camera: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate, UITextFieldDelegate { @IBOutlet weak var cameraScreen: UIImageView! var screenView: UIImageView! @IBAction func Camera(_ sender: AnyObject) { if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.camera){ let imagePicker = UIImagePickerController() imagePicker.delegate = self imagePicker.sourceType = UIImagePickerControllerSourceType.camera; imagePicker.allowsEditing = false self.present(imagePicker, animated: true, completion: nil)}} func […]

捕获UIView的UIImage卡在DrawRect方法中

我想捕捉我的UIView的图像,但是当我调用这个方法 – (UIImage *) imageWithView:(UIView *)view { UIGraphicsBeginImageContext(view.bounds.size); [view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage * img = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return img; } 我的应用程序进入我的视图的DrawRect方法,并卡在这些行的循环 [super drawRect:rect]; [curImage drawAtPoint:CGPointMake(0, 0)]; mid1 = midPoint(previousPoint1, previousPoint2); mid2 = midPoint(currentPoint, previousPoint1); context = UIGraphicsGetCurrentContext(); [self.layer renderInContext:context]; 这是我的drawRect方法 – (void)drawRect:(CGRect)rect { [super drawRect:rect]; [curImage drawAtPoint:CGPointMake(0, 0)]; mid1 = midPoint(previousPoint1, previousPoint2); mid2 = midPoint(currentPoint, previousPoint1); […]

为什么添加一个与中心约束alignment的UIImage丢弃angular落的半径设置?

我试图把一个正方形的图像变成一个圆圈。 我正在使用这个代码来做到这一点: profilePicture2.layer.cornerRadius = profilePicture2.frame.size.height/2 profilePicture2.clipsToBounds = true 它完美的工作,直到我尝试通过添加一个“alignment中心X超级视图”约束中心图像在容器视图中。 当我添加这个约束时,我只是得到非常圆的angular而不是一个圆。 实际上,它似乎是angular落半径的一半。 因此,如果图像的高度为100,并且angular半径应该设置为50,则像半径值一样设为25。 没有其他约束已被添加到图像。 这里发生了什么?

由于内存问题,iOS应用程序在加载UIImage时崩溃

我的问题是非常相似的iOS应用程序崩溃,而UIImage加载(虚拟内存不清理) ,我有一个对象数组,每个对象有一个图片作为它的variables之一。 在上面的post中的答案似乎是,即使从数组中删除对象仍然存在。 但是,我似乎无法弄清楚他是如何解决这个问题的。 我正在使用Swift,在Objective-C中没有任何经验。 有人可以告诉我他怎么解决他的问题? 他在答案中的示例代码对我来说毫无意义。 这是我的课,其中包括图像属性: open class Cards { var name = "" var image : UIImage! var manaCost = 0 var rarity = "" var whichClass = "" var cardText = "" var tribe = "" var cardType = "" //Minion or Spell var set = "" init(name : String, image […]