Tag: uiimage

如何在KB中获取UIImage的大小?

有没有办法从一个UIImage,而不是从didFinishPickingMediaWithInfo获取该图像的KB文件大小? 所呈现的图像来自相册。 我试过下面的代码,但是这给出了以下结果: 图像的大小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 whiteColor]; panGestureRecognizer = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(beingDragged:)]; [self addGestureRecognizer:panGestureRecognizer]; // prepare image view self.imageView = [[UIImageView alloc]initWithFrame:self.bounds]; self.imageView.clipsToBounds = YES; self.imageView.contentMode = UIViewContentModeScaleAspectFill; [self addSubview:self.imageView]; NSData […]

iOS试图将图像保存到相机胶卷,但没有成功

我有一个UIImageView中的图像,并希望将其保存到设备的照片,以便它可以最终保存为壁纸。 虽然代码编译没有错误的图像不保存,我担心,当涉及到使用“UIImage”vs“UIImageView”或其他所有的东西,我做错了什么。 图像的名称是“Q115birdsfull〜iphone.png”,我的代码到目前为止是在下面。 我究竟做错了什么??? Q115birdsViewController.h #import <UIKit/UIKit.h> @interface Q115birdsViewController : UIViewController { UIImage *Q115birdsfull; } @property (nonatomic, strong) UIImage *Q115birdsfull; – (IBAction)onClickSavePhoto:(id)sender; @end Q115birdsViewController.m #import "Q115birdsViewController.h" @interface Q115birdsViewController () @end @implementation Q115birdsViewController @synthesize Q115birdsfull; – (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } […]

将UIImage编码为Base64string时,传输到服务器时不起作用

将UIImage编码为Base64string可在设备上工作,但将string传输到服务器会以某种方式破坏string,并阻止服务器成功解码图像。 关于这个问题的任何build议? // Define params params["thumbnail_base64"] = imageToBase64(blockSet.thumbnailURL) … // Convert params -> query string let postString = buildQueryString(params) // Define upload URL let uploadURL = NSURL(string: RootURL + UploadFilePath)! // Hit server let request = NSMutableURLRequest(URL: uploadURL) request.HTTPMethod = "POST" request.HTTPBody = postString.dataUsingEncoding(NSUTF8StringEncoding) … private func buildQueryString(parameters: [String:String], omitQuestionMark: Bool = false) -> String […]

如何以编程方式切片4,9,16和25片的图像

我需要一些帮助,以4,9,16和25片的方式编程图片 我将不胜感激任何帮助或想法。 谢谢

用animation从完整的UIImage中填充UIImageView的百分比

我有一个名为bigBottle的UIImageView : bigBottle.image = [UIImage imageNamed:@"fullBootle.png"]; fullBootle.png是一个装满100%的瓶子。 我需要两个步骤: 首先用百分比(让我们说50%填充)做一个图像作品 – 也就是说,一个瓶子从底部填充到一半。 animationbigBottle从瓶子下降到50%的填充效果。 我的代码如下: CGRect captureRect = CGRectMake(0,22,18,72); UIImage *captureImg; UIGraphicsBeginImageContext(captureRect.size); CGContextRef context = UIGraphicsGetCurrentContext(); [self.bigBottle.layer renderInContext:context]; captureImg = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); self.bigBottle.image = [UIImage imageWithCGImage:CGImageCreateWithImageInRect(captureImg.CGImage, captureRect)]; CGRect captureRect1 = CGRectMake(0,37,18,72); self.bigBottle.frame=CGRectMake(45, 174,18,1); CGRect newFrameOfMyView1 = CGRectMake(45,129, 18, 45); [UIView animateWithDuration:3.0f animations:^{ self.bigBottle.frame = newFrameOfMyView1; } completion:^(BOOL […]

ALAssetsLibrary图像扭曲

我正在使用下面的代码从相机胶卷加载图像。 但是当图像显示在图像视图中时,图像有时会向左旋转90度。 我怎样才能纠正这一点? 谢谢! ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset) { ALAssetRepresentation *rep = [myasset defaultRepresentation]; CGImageRef iref = [rep fullResolutionImage]; if (iref) { cell.image.image = [UIImage imageWithCGImage:iref]; } }; ALAssetsLibraryAccessFailureBlock failureblock = ^(NSError *myerror) { NSLog(@"Can't get image – %@",[myerror localizedDescription]); }; NSString *urlString = [[_alleArtikel objectAtIndex:indexPath.row] bildURL]; NSURL *asseturl = [NSURL URLWithString:urlString]; ALAssetsLibrary* assetslibrary […]

如何确定在Objective-C中图像是否为逐行JPEG(交错)

我需要在Objective-C中确定是否需要下载和显示的图像是渐进式JPEG。 我做了一些search,但没有find任何明显的方法。 你能帮我吗?

如何获取UIImage的RGBA值在特定的点击点

我正在开发一个在viewcontoller中有多个UIImageView的iPad应用程序。 每个图像都有一些透明的部分。 当用户点击图片我想testing,如果他点击的图像区域不透明,那么我想要做一些行动 search后,我已经得出结论,我必须访问图像的原始数据,并检查点用户点击的alpha值 我使用了在这里find的解决scheme,它帮助了很多。 我修改了代码,这样如果用户点击的点是透明的(alpha <1),那么prent 0就会打印1.但是,运行时结果不准确。 我有时得到0点,点击不透明和viseversa。 我认为有一个byteIndex值的问题我不确定它返回的颜色数据在点击用户点击 这是我的代码 CGPoint touchPoint; – (void)viewDidLoad { [super viewDidLoad]; [logo addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)]]; } -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [[event allTouches] anyObject]; touchPoint = [touch locationInView:self.view]; } – (void)handleSingleTap:(UITapGestureRecognizer *)recognizer { int x = touchPoint.x; int y = touchPoint.y; [self getRGBAsFromImage:img atX:x […]

使用resizeableImageWithCapInsets来平铺UIImageView:resizingMode?

我正在使用下面的代码尝试创build一个平铺的图像与帽子插图,并看到下面的图像作为模拟器中的结果。 我的源图像大小为145×83像素,并在此显示。 我究竟做错了什么? 来源图像: 结果在模拟器: 码: – (void)viewDidLoad { [super viewDidLoad]; UIImage *cloudImage = [UIImage imageNamed: @"cloud.png"]; [cloudImage resizableImageWithCapInsets: UIEdgeInsetsMake(10, 10, 10, 10) resizingMode: UIImageResizingModeTile]; UIImageView *imageView1 = [[UIImageView alloc] initWithImage: cloudImage]; [imageView1 setFrame: CGRectMake(50, 50, 100, 100)]; UIImageView *imageView2 = [[UIImageView alloc] initWithImage: cloudImage]; [imageView2 setFrame: CGRectMake(250, 50, 200, 200)]; [self.view addSubview: imageView1]; [self.view […]

CGImageCreatetesting模式不起作用(iOS)

我正在尝试为iOS 5.1设备创buildUIImagetesting模式。 目标UIImageView是320×240的大小,但我正在尝试创build一个160×120 UIImagetesting模式(未来,非testing模式图像将是这个大小)。 我想要盒子的上半部分是蓝色的,下半部分是红色的,但是看起来像是未初始化的内存会损坏图像的底部。 代码如下: int width = 160; int height = 120; unsigned int testData[width * height]; for(int k = 0; k < (width * height) / 2; k++) testData[k] = 0xFF0000FF; // BGRA (Blue) for(int k = (width * height) / 2; k < width * height; k++) testData[k] = 0x0000FFFF; // […]