Search Results

Search found 779 results on 32 pages for 'uiimage'.

Page 3/32 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Do we need to release an UIImage object even not allocated memory?

    - by Madan Mohan
    Hi Guys, I added an image to button UIImage* deleteImage = [UIImage imageNamed:@"Delete.png"]; CGRect imageFrame=CGRectMake(-4,-4, 310, 55); [btn setFrame:imageFrame]; btn.backgroundColor=[UIColor clearColor]; [btn setBackgroundImage:deleteImage forState:UIControlStateNormal]; [btn setTitle:@"Delete" forState:UIControlStateNormal]; [btn addTarget:self action:@selector(editDeleteAction) forControlEvents:UIControlEventTouchUpInside]; [elementView addSubview:btn]; [deleteImage release];// do we need to release the image here If I release here its working fine but in object allocations no.of image count is increasing.

    Read the article

  • XCode Build Parse Error 'Unexpected @ in Program'

    - by Grymjack
    I'm following a tutorial for creating an animation using Xcode Version 4.5.2 in Mountain Lion 10.8.2. When trying to build the code below, I get a Parse Error Unexpected '@' in program showing up for the 'hopAnimation=' line. While searching, I have found examples that build simple animations in a different way, but nothing that seems to address this particular problem. I'm a noob to XCode programming and if anyone could help me correct the syntax, I would highly appreciate it. I would also like to thank all the contributors to stackflow for making this such a valuable resource. Searching for the answers to most of my prior questions always seemed to have you guys at the top of the results list. ViewController.m - (void)viewDidLoad { // load all the frames of our animation into an array NSArray *hopAnimation; hopAnimation=[[NSArray alloc] arrayWithObjects: [UIImage imageNamed:@”frame-1.png”], [UIImage imageNamed:@”frame-2.png”], [UIImage imageNamed:@”frame-3.png”], [UIImage imageNamed:@”frame-4.png”], [UIImage imageNamed:@”frame-5.png”], [UIImage imageNamed:@”frame-6.png”], [UIImage imageNamed:@”frame-7.png”], [UIImage imageNamed:@”frame-8.png”], [UIImage imageNamed:@”frame-9.png”], [UIImage imageNamed:@”frame-10.png”], [UIImage imageNamed:@”frame-11.png”], [UIImage imageNamed:@”frame-12.png”], [UIImage imageNamed:@”frame-13.png”], [UIImage imageNamed:@”frame-14.png”], [UIImage imageNamed:@”frame-15.png”], [UIImage imageNamed:@”frame-16.png”], [UIImage imageNamed:@”frame-17.png”], [UIImage imageNamed:@”frame-18.png”], [UIImage imageNamed:@”frame-19.png”], [UIImage imageNamed:@”frame-20.png”],nil]; self.bunnyView1.animationImages=hopAnimation; self.bunnyView2.animationImages=hopAnimation; self.bunnyView3.animationImages=hopAnimation; self.bunnyView4.animationImages=hopAnimation; self.bunnyView5.animationImages=hopAnimation; self.bunnyView1.animationDuration=1; self.bunnyView2.animationDuration=1; self.bunnyView3.animationDuration=1; self.bunnyView4.animationDuration=1; self.bunnyView5.animationDuration=1; [super viewDidLoad]; }

    Read the article

  • How do you populate a UIImage view with ASIHTTPRequest given @2x?

    - by Jonathan Page
    I've been trying to load images from a url using ASIHTTPRequest but I always come up with a blank UIImage. I think it might have something to do with iOS automatically choosing the @2x named version of images or vica versa. [ASIHTTPRequest setDefaultCache:[ASIDownloadCache sharedCache]]; NSString *url_string = [NSString stringWithFormat:@"http://173.246.100.185/%@", [eventDictionary objectForKey:kEventDescriptionImageURLKey]]; NSURL *url = [NSURL URLWithString:url_string]; __block ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url]; [request setDownloadCache:[ASIDownloadCache sharedCache]]; [request setCachePolicy:ASIAskServerIfModifiedCachePolicy|ASIFallbackToCacheIfLoadFailsCachePolicy]; [request setCacheStoragePolicy:ASICachePermanentlyCacheStoragePolicy]; [request setSecondsToCache:86400]; [request setDelegate:self]; [request setCompletionBlock:^{ NSLog(@"Successful Update"); [self makeAssignment]; }]; [request setFailedBlock:^{ NSError *error = [request error]; NSLog(@"%@", [error localizedDescription]); UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Update Failed" message:[error localizedDescription] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; [alert release]; }]; [request startAsynchronous]; NSLog(@"%@", url_string); The makeAssignment method is below. NSString *url_string = [NSString stringWithFormat:@"http://173.246.100.185/%@", [eventDictionary objectForKey:kEventDescriptionImageURLKey]]; NSURL *url = [NSURL URLWithString:url_string]; downloadedImage = [[UIImage alloc] initWithContentsOfFile:[[ASIDownloadCache sharedCache] pathToCachedResponseDataForURL:url]]; NSLog(@"%@", downloadedImage); NSLog(@"%@", [[ASIDownloadCache sharedCache] pathToCachedResponseDataForURL:url]); Nothing I do, including naming images @2x on the server or providing both versions, gets it to load. Any ideas? Has anyone done this before? When I load them locally (from within the package) I don't have any issues. Thanks!

    Read the article

  • what is the proper way to set a UIImageView with a UIImage?

    - by RexOnRoids
    I have a UIImageView that starts off with an image (loading.png) specified in IB. When my app starts, a new image is downloaded from the internet to replace the existing one. I do the following to replace the image: if(object.imageView.image != nil){ [object.imageView.image release]; object.imageView.image = nil; } object.imageView.image = [UIImage imageNamed:@"downloadedimage.png"]; Is this the right way to re-set an image? I am getting EXC_BAD_ACCESS when doing so.

    Read the article

  • iOS - pass UIImage to shader as texture

    - by martin pilch
    I am trying to pass UIImage to GLSL shader. The fragment shader is: varying highp vec2 textureCoordinate; uniform sampler2D inputImageTexture; uniform sampler2D inputImageTexture2; void main() { highp vec4 color = texture2D(inputImageTexture, textureCoordinate); highp vec4 color2 = texture2D(inputImageTexture2, textureCoordinate); gl_FragColor = color * color2; } What I want to do is send images from camera and do multiply blend with texture. When I just send data from camera, everything is fine. So problem should be with sending another texture to shader. I am doing it this way: - (void)setTexture:(UIImage*)image forUniform:(NSString*)uniform { CGSize sizeOfImage = [image size]; CGFloat scaleOfImage = [image scale]; CGSize pixelSizeOfImage = CGSizeMake(scaleOfImage * sizeOfImage.width, scaleOfImage * sizeOfImage.height); //create context GLubyte * spriteData = (GLubyte *)malloc(pixelSizeOfImage.width * pixelSizeOfImage.height * 4 * sizeof(GLubyte)); CGContextRef spriteContext = CGBitmapContextCreate(spriteData, pixelSizeOfImage.width, pixelSizeOfImage.height, 8, pixelSizeOfImage.width * 4, CGImageGetColorSpace(image.CGImage), kCGImageAlphaPremultipliedLast); //draw image into context CGContextDrawImage(spriteContext, CGRectMake(0.0, 0.0, pixelSizeOfImage.width, pixelSizeOfImage.height), image.CGImage); //get uniform of texture GLuint uniformIndex = glGetUniformLocation(__programPointer, [uniform UTF8String]); //generate texture GLuint textureIndex; glGenTextures(1, &textureIndex); glBindTexture(GL_TEXTURE_2D, textureIndex); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); //create texture glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, pixelSizeOfImage.width, pixelSizeOfImage.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, spriteData); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, textureIndex); //"send" to shader glUniform1i(uniformIndex, 1); free(spriteData); CGContextRelease(spriteContext); } Uniform for texture is fine, glGetUniformLocation function do not returns -1. The texture is PNG file of resolution 2000x2000 pixels. PROBLEM: When the texture is passed to shader, I have got "black screen". Maybe problem are parameters of the CGContext or parameters of the function glTexImage2D Thank you

    Read the article

  • How to save an animated image to iPhone's photos album?

    - by OpenThread
    I created an animated image, and it animates properly in an UIImageView: - (void)viewDidLoad { [super viewDidLoad]; UIImage *image1 = [UIImage imageNamed:@"apress_logo"]; UIImage *image2 = [UIImage imageNamed:@"Icon"]; UIImage *animationImage = [UIImage animatedImageWithImages:[NSArray arrayWithObjects:image1, image2, nil] duration:0.5]; UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)]; imageView.image = animationImage; [self.view addSubview:imageView]; } But if saved to photos album, it couldn't animate agian: UIImageWriteToSavedPhotosAlbum(animationImage, self, @selector(imageSavedToPhotosAlbum:didFinishSavingWithError:contextInfo:), nil); So is there any solution to save an animated image to photos album? Special thanks!

    Read the article

  • Rendering UIImage/CGImage into CGPDFContext results in... blankness!

    - by quixoto
    Hi all, I'm trying to take an image that I have in a image object and render into a Core Graphics PDF context-- happens to be on an iPhone but this question surely applies equally to desktop Quartz. This UIImage is a simple color-on-white image at about 600x800 resolution. If I (say) turn it into a PNG file, that file looks exactly as expected-- so the data is OK. Here's what I'm doing to generate the PDF: NSMutableData * outputData = [[NSMutableData alloc] init]; CGDataConsumerRef dataConsumer = CGDataConsumerCreateWithCFData((CFMutableDataRef)outputData); CFMutableDictionaryRef attrDictionary = NULL; attrDictionary = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); CFDictionarySetValue(attrDictionary, kCGPDFContextTitle, @"My Awesome Document"); CGContextRef pdfContext = CGPDFContextCreate(dataConsumer, NULL, attrDictionary); CFRelease(dataConsumer); CFRelease(attrDictionary); CGImageRef pageImage = [myUIImage CGImage]; CGPDFContextBeginPage(pdfContext, NULL); CGContextDrawImage(pdfContext, CGRectMake(0, 0, [myUIImage size].width, [myUIImage size].height), pageImage); CGPDFContextEndPage(pdfContext); CGContextRelease(pdfContext); Resulting PDF, which ends up in outputData, seems like a valid PDF file (opens correctly, document title is present in metadata), but it consists of precisely one blank page. What am I doing wrong? Thanks.

    Read the article

  • merging UIImagePickerController image with cameraOverlayView

    - by GameDev
    Im really in the need for some help and advice. Spent the last week on this and have now just become frustrated as i cant get it to work! Basically, im trying to merge two images into one image to display/save. First the user picks an image from album, it goes to edit image screen where user can move and scale the image. On this screen is an overlay image (320x480) for the person to align there eyes in. Once aligned I want to save this image (edited and overlay) into one and pass the image onto my next screen. It works fine when the image is filling the edit/crop box, but when the image is widescreen with top and bottom not filling the box, then when i save the image the coords of the overlay dont get saved correctly! Heres my code, ive tried various ways of doing this but have failed at every attempt :( - (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { // Access the cropped image from info dictionary UIImage *image = [info objectForKey:@"UIImagePickerControllerEditedImage"]; // Combine image with overlay before saving!! image = [self addOverlayToImage:image]; overlayGraphicView.image = nil; // Take the picture image to the post picture view controller postPictureView = [[PostPictureViewController alloc] init:image Company:companyName withLink:buyButtonLink]; [picker pushViewController:postPictureView animated:YES]; [picker release],picker = nil; } The problem is that the image picked (originalImage) could be of any height, my overlayImage is however always 320x480, its almost all transparent with just two eye images in center which i want to save over the original images eyes! - (UIImage*) addOverlayToImage:(UIImage*)originalImage { CGRect cgRect =[[UIScreen mainScreen] bounds]; CGSize size = cgRect.size; UIGraphicsBeginImageContext(size); [originalImage drawInRect:CGRectMake(0, 0, size.width, size.height)]; UIImage* overlayImage = [UIImage imageNamed:overlayGraphicName]; [(UIImage *)overlayImage drawInRect:CGRectMake(0, 0, size.width, size.height)]; UIImage *finalImage = UIGraphicsGetImageFromCurrentImageContext(); [finalImage retain]; UIGraphicsEndImageContext(); return finalImage; } I wish there was just an easy way to take a screenshot of whatever is in the edit crop box :( Please if someone could help me with this ASAP as I need to finish this in 1-2 days time! Thank you. EDIT:- I should also mention that with this I get the correct center of the screen and placement of the overlay on my next screen: [(UIImage *)overlayImage drawInRect:CGRectMake(0, 0, size.width, size.height)]; However, I am unable to work out the correct position of the main image especially as the height is different for every image if not fullscreen! I tried this to center it into the correct position but it doesnt work: [originalImage drawInRect:CGRectMake(0,(size.height/2 - originalImage.size.height/2), originalImage.size.width, originalImage.size.height)];

    Read the article

  • Memory allocation and release for UIImage in iPhone?

    - by rkbang
    Hello all, I am using following code in iPhone to get smaller cropped image as follows: - (UIImage*) getSmallImage:(UIImage*) img { CGSize size = img.size; CGFloat ratio = 0; if (size.width < size.height) { ratio = 36 / size.width; } else { ratio = 36 / size.height; } CGRect rect = CGRectMake(0.0, 0.0, ratio * size.width, ratio * size.height); UIGraphicsBeginImageContext(rect.size); [img drawInRect:rect]; UIImage *tempImg = [UIGraphicsGetImageFromCurrentImageContext() retain]; UIGraphicsEndImageContext(); return [tempImg autorelease]; } - (UIImage*)imageByCropping:(UIImage *)imageToCrop toRect:(CGRect)rect { //create a context to do our clipping in UIGraphicsBeginImageContext(rect.size); CGContextRef currentContext = UIGraphicsGetCurrentContext(); //create a rect with the size we want to crop the image to //the X and Y here are zero so we start at the beginning of our //newly created context CGFloat X = (imageToCrop.size.width - rect.size.width)/2; CGFloat Y = (imageToCrop.size.height - rect.size.height)/2; CGRect clippedRect = CGRectMake(X, Y, rect.size.width, rect.size.height); //CGContextClipToRect( currentContext, clippedRect); //create a rect equivalent to the full size of the image //offset the rect by the X and Y we want to start the crop //from in order to cut off anything before them CGRect drawRect = CGRectMake(0, 0, imageToCrop.size.width, imageToCrop.size.height); CGContextTranslateCTM(currentContext, 0.0, drawRect.size.height); CGContextScaleCTM(currentContext, 1.0, -1.0); //draw the image to our clipped context using our offset rect //CGContextDrawImage(currentContext, drawRect, imageToCrop.CGImage); CGImageRef tmp = CGImageCreateWithImageInRect(imageToCrop.CGImage, clippedRect); //pull the image from our cropped context UIImage *cropped = [UIImage imageWithCGImage:tmp];//UIGraphicsGetImageFromCurrentImageContext(); CGImageRelease(tmp); //pop the context to get back to the default UIGraphicsEndImageContext(); //Note: this is autoreleased*/ return cropped; } I am using following line of code in cellForRowAtIndexPath to update the image of the cell: cell.img.image = [self imageByCropping:[self getSmallImage:[UIImage imageNamed:@"goal_image.png"]] toRect:CGRectMake(0, 0, 36, 36)]; Now when I add this table view and pop it from navigation controller, I see a memory hike.I see no leaks but memory keeps climbing. Please note that the images changes for each row and I am creating the controller using lazy initialization that is I create or alloc it whenever I need it. I saw on internet many people facing the same issue, but very rare good solutions. I have multiple views using the same way and I see almost memory raised to 4MB within 20-25 view transitions. What is the good solution to resolve this issue. tnx.

    Read the article

  • UIImage couldn't load some png picture.

    - by www.ruu.cc
    I Use the following code to load png image: UIImage *imageBack1 = [UIImage imageNamed:@"Bar1.png"]; UIImage *imageBack2 = [UIImage imageNamed:@"Bar2.png"]; imageBack1 work right when imageBack2's value is nil, Bar1.png and Bar2.png are located at the same place,but why Bar2.png couldn't be load?

    Read the article

  • When to release the UIImage ?

    - by ragnarius
    I use the following code to draw a subimage UIImage* subIm = getSubImage( large, rect ); [subIm drawInRect:self.bounds]; where getSubImage is defined as follows UIImage* getSubImage(UIImage* uim, CGRect rc){ CGImageRef imref = CGImageCreateWithImageInRect(uim.CGImage, rc); UIImage* sub = [UIImage imageWithCGImage:imref]; CGImageRelease(imref); NSLog(@"subimage retainCount=%d", [sub retainCount]); // is 1 return sub; }//getSubImage Is the code correct? Is it safe to "CGImageRelease" imref? Has sub "CGImageRetained" imref? Should I release subIm (I get an error if I do)? Is subIm contained in the autorelease-pool, and , if so, how do I know this? In general, can one check if an object is contained in the autorelease pool (for debugging purpose)?

    Read the article

  • (iphone) am I creating a leak when creating a new image from an image?

    - by Eugene
    Hi, I have following code as UIImage+Scale.h category. -(UIImage*)scaleToSize:(CGSize)size { UIGraphicsBeginImageContext(size); [self drawInRect:CGRectMake(0, 0, size.width, size.height)]; // is this scaledImage auto-released? UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return scaledImage; } I use image obtained as above and use it as following. UIImage* image = [[UIImage alloc] initWithData: myData]; image = [image scaleToSize: size]; <- wouldn't this code create a leak since image(before scaling) is lost somewhere? i guess above codes work fine if image was first created with auto-release. But if image was created using 'alloc', it would create a leak in my short knowledge. How should I change scaleToSize: to guard against it? Thank you

    Read the article

  • UIImageView is clipping a pixel of the bottom of my UIImage...?

    - by akaii
    I'm not sure what might be causing this, but UIImageView occasionally clips off about a pixel or 2 from the bottom of some square/rectangular UIImages I'm using as subviews for UITableViewCells. These UIImageViews are well within the borders of the cell, so it shouldn't be due to cliptobounds. There seems to be no consistency or pattern to which images are being clipped, nor when they're clipped, other than that it only happens to (or is only noticable in) square/rectangular icons, and only ones that are parented to UITableViewCells (or their subclasses). I'm having trouble reproducing the problem consistently, which is why I haven't posted any code this time. Has anyone encountered something similar to this before? I've encountered a similar bug that involved floating point values for origin/size being interpreted weirdly... but that doesn't seem to be the cause of this particular problem. I don't need a specific solution at this point, I'm just making sure I haven't missed any well-known bugs or documented problems that involve UIImageView.

    Read the article

  • UIImage cropping on user selected rectangle in iphone?

    - by Rajendra Bhole
    Hi, I developing an small application in which i want to crop the UIImage captured by imagePickerControllerSourceTypeOfCamera. The UIImage should crop by user selected crop area or cropped rectangle. That means first user capture the image from the camera.Then on captured image the user selected an rectangle having color gray.That image(image data) should crop from that gray colored rectangle. My under develop code is as follows. -(IBAction) getPhoto:(id)sender { UIImagePickerController* imagePickerController = [[UIImagePickerController alloc] init]; imagePickerController.delegate = self; if((UIButton *) sender == btnphotoAlbum) { imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; } else { imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera; } imagePickerController.allowsImageEditing = YES; //imagePickerController.toolbar.barStyle =UIBarStyleBlackOpaque; //UIToolbar *toolBar=[[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 20, 320)]; //imagePickerController. [self presentModalViewController:imagePickerController animated:YES]; } (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo { UIImage *selectedImage = image; UIImage *originalImage = [editingInfo objectForKey:@"UIImagePickerControllerOriginalImage"]; NSValue *cropRect = [editingInfo objectForKey:UIImagePickerControllerCropRect]; CGRect theRect = [cropRect CGRectValue]; //captureImage.image =[info objectForKey:@"UIImagePickerControllerOriginalImage"]; [picker dismissModalViewControllerAnimated:YES]; } How i crop the image?

    Read the article

  • Increase performance on iphone at pdf rendering

    - by burki
    Hi! I have a UITableView, and in every cell there's displayed a UIImage created from a pdf. But now the performance is very bad. Here's my code I use to generate the UIImage from the PDF. Creating CGPDFDocumentRef and UIImageView (in cellForRowAtIndexPath method): ... CFURLRef pdfURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), (CFStringRef)formula.icon, NULL, NULL); CGPDFDocumentRef documentRef = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL); CFRelease(pdfURL); UIImageView *imageView = [[UIImageView alloc] initWithImage:[self imageFromPDFWithDocumentRef:documentRef]]; ... Generate UIImage: - (UIImage *)imageFromPDFWithDocumentRef:(CGPDFDocumentRef)documentRef { CGPDFPageRef pageRef = CGPDFDocumentGetPage(documentRef, 1); CGRect pageRect = CGPDFPageGetBoxRect(pageRef, kCGPDFCropBox); UIGraphicsBeginImageContext(pageRect.size); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextTranslateCTM(context, CGRectGetMinX(pageRect),CGRectGetMaxY(pageRect)); CGContextScaleCTM(context, 1, -1); CGContextTranslateCTM(context, -(pageRect.origin.x), -(pageRect.origin.y)); CGContextDrawPDFPage(context, pageRef); UIImage *finalImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return finalImage; } What can I do to increas the speed and keep the memory low?

    Read the article

  • Using UIImageView for a flipbook anim on iphone

    - by Joey
    I'm using UIImageView to run a flipbook anim like this: mIntroAnimFrame = [[UIImageView alloc] initWithFrame:CGRectMake( 0, 0, 480, 320); mIntroAnimFrame.image = [UIImage imageNamed:@"frame0000.tif"]; Basically, when determine it is time, I flip the image by just calling: mIntroAnimFrame.image = [UIImage imageNamed:@"frame0000.tif"]; again with the right frame. Should I be doing this differently? Are repeated calls to set the image this way possibly bogging down main memory, or does each call essentially free the previous UIImage because nothing else references it? I suspect the latter is true. Also, is there an easy way to preload the images? The anim seems to slow down at times. Should I simply load all the images into a dummy UIImage array so they are preloaded, then refer to it when I want to show it with mIntroAnimFrame.image = mPreloadedArray[i]; ?

    Read the article

  • UIImageView dimensions not what I set in IB

    - by Brenden
    I set a UIImageView to 70x70 pixels. In the actual view they look 70px high and 30 wide. This is when there is no source UIImage set and with a background color so I can see it's layout. However, when I do set a UIImage to it the layout does not change, remains portrait. Is there something I am overlooking that affects the layout dimensions of a UIImage or UIImageView? Thanks.

    Read the article

  • iPhone SDK: Can a UIButton with custom images display the title?

    - by Harkonian
    If I create a custom UIButton with images for UIControlState normal and UIControlStateSelected, am I still supposed to be able to display the title for the button? Currently I can't. This is how I create my button: UIImage *moveButtonImage = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"button_move_inactive" ofType:@"png"] ]; UIImage *moveButtonSelectedImage = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"button_move_pressed" ofType:@"png"] ]; self.moveButton = [UIButton buttonWithType:UIButtonTypeCustom]; [self.moveButton setImage : moveButtonImage forState : UIControlStateNormal]; [self.moveButton setImage : moveButtonSelectedImage forState : UIControlStateSelected]; [self.moveButton setTitle:@"Test" forState:UIControlStateNormal]; The button title never displays in this case and I'm forced to create my own label to display on the button, which seems like a hacky way of doing things. Maybe I'm doing something wrong here?

    Read the article

  • Objective C: Using UIImage for Stroking

    - by SeongHo
    I am trying to apply a texture for my brush but i'm really having a hard time figuring how it is done. Here's the image of my output. I used an UIImage that just follows the touch on the screen but when i swipe it faster the result is on the right side "W", and on the left side that's the result when i swipe it slow. i tried using the CGContextMoveToPoint and CGContextAddLineToPoint i don't know how apply the texture. Is it possible to use UIImage for the stroke texture? Here's my code UIImage * brushImageTexture = [UIImage imageNamed:@"brushImage.png"]; [brushImagetexture drawAtPoint:CGPointMake(touchCurrentPosition.x, touchVurrentPosition.y) blendMode:blendMode alpha:1.0f];

    Read the article

  • coloring the clickable part of an image in iphone

    - by iphonecool
    Dear All, I'm assigned with new task for detecting the boundaries of an uiimage.That is, i want detect the boundary of an uiimage for coloring the particular part of an uiimage(for,part by part coloring). My Task is, I'm selecting the particular color among no.of colors and click on the particular part of the image the selectable part want to color.For that what should i do to achieve this. Please explain me how can i do this..what are the methods are used to achieve this. Thanks & Regards Renuga

    Read the article

  • UIImage rounded corners

    - by catlan
    I try to get rounded corners on a UIImage, what I read so far, the easiest way is to use a mask images. For this I used code from TheElements iPhone Example and some image resize code I found. My problem is that resizedImage is always nil and I don't find the error... - (UIImage *)imageByScalingProportionallyToSize:(CGSize)targetSize { CGSize imageSize = [self size]; float width = imageSize.width; float height = imageSize.height; // scaleFactor will be the fraction that we'll // use to adjust the size. For example, if we shrink // an image by half, scaleFactor will be 0.5. the // scaledWidth and scaledHeight will be the original, // multiplied by the scaleFactor. // // IMPORTANT: the "targetHeight" is the size of the space // we're drawing into. The "scaledHeight" is the height that // the image actually is drawn at, once we take into // account the ideal of maintaining proportions float scaleFactor = 0.0; float scaledWidth = targetSize.width; float scaledHeight = targetSize.height; CGPoint thumbnailPoint = CGPointMake(0,0); // since not all images are square, we want to scale // proportionately. To do this, we find the longest // edge and use that as a guide. if ( CGSizeEqualToSize(imageSize, targetSize) == NO ) { // use the longeset edge as a guide. if the // image is wider than tall, we'll figure out // the scale factor by dividing it by the // intended width. Otherwise, we'll use the // height. float widthFactor = targetSize.width / width; float heightFactor = targetSize.height / height; if ( widthFactor < heightFactor ) scaleFactor = widthFactor; else scaleFactor = heightFactor; // ex: 500 * 0.5 = 250 (newWidth) scaledWidth = width * scaleFactor; scaledHeight = height * scaleFactor; // center the thumbnail in the frame. if // wider than tall, we need to adjust the // vertical drawing point (y axis) if ( widthFactor < heightFactor ) thumbnailPoint.y = (targetSize.height - scaledHeight) * 0.5; else if ( widthFactor > heightFactor ) thumbnailPoint.x = (targetSize.width - scaledWidth) * 0.5; } CGContextRef mainViewContentContext; CGColorSpaceRef colorSpace; colorSpace = CGColorSpaceCreateDeviceRGB(); // create a bitmap graphics context the size of the image mainViewContentContext = CGBitmapContextCreate (NULL, targetSize.width, targetSize.height, 8, 0, colorSpace, kCGImageAlphaPremultipliedLast); // free the rgb colorspace CGColorSpaceRelease(colorSpace); if (mainViewContentContext==NULL) return NULL; //CGContextSetFillColorWithColor(mainViewContentContext, [[UIColor whiteColor] CGColor]); //CGContextFillRect(mainViewContentContext, CGRectMake(0, 0, targetSize.width, targetSize.height)); CGContextDrawImage(mainViewContentContext, CGRectMake(thumbnailPoint.x, thumbnailPoint.y, scaledWidth, scaledHeight), self.CGImage); // Create CGImageRef of the main view bitmap content, and then // release that bitmap context CGImageRef mainViewContentBitmapContext = CGBitmapContextCreateImage(mainViewContentContext); CGContextRelease(mainViewContentContext); CGImageRef maskImage = [[UIImage imageNamed:@"Mask.png"] CGImage]; CGImageRef resizedImage = CGImageCreateWithMask(mainViewContentBitmapContext, maskImage); CGImageRelease(mainViewContentBitmapContext); // convert the finished resized image to a UIImage UIImage *theImage = [UIImage imageWithCGImage:resizedImage]; // image is retained by the property setting above, so we can // release the original CGImageRelease(resizedImage); // return the image return theImage; }

    Read the article

  • UIImage rounded corners

    - by catlan
    I try to get rounded corners on a UIImage, what I read so far, the easiest way is to use a mask images. For this I used code from TheElements iPhone Example and some image resize code I found. My problem is that resizedImage is always nil and I don't find the error... - (UIImage *)imageByScalingProportionallyToSize:(CGSize)targetSize { CGSize imageSize = [self size]; float width = imageSize.width; float height = imageSize.height; // scaleFactor will be the fraction that we'll // use to adjust the size. For example, if we shrink // an image by half, scaleFactor will be 0.5. the // scaledWidth and scaledHeight will be the original, // multiplied by the scaleFactor. // // IMPORTANT: the "targetHeight" is the size of the space // we're drawing into. The "scaledHeight" is the height that // the image actually is drawn at, once we take into // account the ideal of maintaining proportions float scaleFactor = 0.0; float scaledWidth = targetSize.width; float scaledHeight = targetSize.height; CGPoint thumbnailPoint = CGPointMake(0,0); // since not all images are square, we want to scale // proportionately. To do this, we find the longest // edge and use that as a guide. if ( CGSizeEqualToSize(imageSize, targetSize) == NO ) { // use the longeset edge as a guide. if the // image is wider than tall, we'll figure out // the scale factor by dividing it by the // intended width. Otherwise, we'll use the // height. float widthFactor = targetSize.width / width; float heightFactor = targetSize.height / height; if ( widthFactor < heightFactor ) scaleFactor = widthFactor; else scaleFactor = heightFactor; // ex: 500 * 0.5 = 250 (newWidth) scaledWidth = width * scaleFactor; scaledHeight = height * scaleFactor; // center the thumbnail in the frame. if // wider than tall, we need to adjust the // vertical drawing point (y axis) if ( widthFactor < heightFactor ) thumbnailPoint.y = (targetSize.height - scaledHeight) * 0.5; else if ( widthFactor > heightFactor ) thumbnailPoint.x = (targetSize.width - scaledWidth) * 0.5; } CGContextRef mainViewContentContext; CGColorSpaceRef colorSpace; colorSpace = CGColorSpaceCreateDeviceRGB(); // create a bitmap graphics context the size of the image mainViewContentContext = CGBitmapContextCreate (NULL, targetSize.width, targetSize.height, 8, 0, colorSpace, kCGImageAlphaPremultipliedLast); // free the rgb colorspace CGColorSpaceRelease(colorSpace); if (mainViewContentContext==NULL) return NULL; //CGContextSetFillColorWithColor(mainViewContentContext, [[UIColor whiteColor] CGColor]); //CGContextFillRect(mainViewContentContext, CGRectMake(0, 0, targetSize.width, targetSize.height)); CGContextDrawImage(mainViewContentContext, CGRectMake(thumbnailPoint.x, thumbnailPoint.y, scaledWidth, scaledHeight), self.CGImage); // Create CGImageRef of the main view bitmap content, and then // release that bitmap context CGImageRef mainViewContentBitmapContext = CGBitmapContextCreateImage(mainViewContentContext); CGContextRelease(mainViewContentContext); CGImageRef maskImage = [[UIImage imageNamed:@"Mask.png"] CGImage]; CGImageRef resizedImage = CGImageCreateWithMask(mainViewContentBitmapContext, maskImage); CGImageRelease(mainViewContentBitmapContext); // convert the finished resized image to a UIImage UIImage *theImage = [UIImage imageWithCGImage:resizedImage]; // image is retained by the property setting above, so we can // release the original CGImageRelease(resizedImage); // return the image return theImage; }

    Read the article

  • Resize and saving an image to disk in Monotouch

    - by Chris S
    I'm trying to resize an image loaded from disk - a JPG or PNG (I don't know the format when I load it) - and then save it back to disk. I've got the following code which I've tried to port from objective-c, however I've got stuck on the last parts. Original Objective-C. This may not be the best way of achieving what I want to do - any solution is fine for me. int width = 100; int height = 100; using (UIImage image = UIImage.FromFile(filePath)) { CGImage cgimage = image.CGImage; CGImageAlphaInfo alphaInfo = cgimage.AlphaInfo; if (alphaInfo == CGImageAlphaInfo.None) alphaInfo = CGImageAlphaInfo.NoneSkipLast; CGBitmapContext context = new CGBitmapContext(IntPtr.Zero, width, height, cgimage.BitsPerComponent, 4 * width, cgimage.ColorSpace, alphaInfo); context.DrawImage(new RectangleF(0, 0, width, height), cgimage); /* Not sure how to convert this part: CGImageRef ref = CGBitmapContextCreateImage(bitmap); UIImage* result = [UIImage imageWithCGImage:ref]; CGContextRelease(bitmap); // ok if NULL CGImageRelease(ref); */ }

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >