Saturday, 21 April 2012

Send Email with Image attachment.......



-(void)yourmethodname_clicked{
        UIImagePickerController * picker = [[UIImagePickerController alloc] init];
                picker.delegate = self;
        if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])  {
                 picker.sourceType = UIImagePickerControllerSourceTypeCamera;
                 [self presentModalViewController:picker animated:YES];
        }
        else{
                 UIAlertView *altnot=[[UIAlertView alloc]initWithTitle:@"Camera Not            Available" message:@"Camera Not Available" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

                 [altnot show];
                 [altnot release];

        }
    }

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissModalViewControllerAnimated:YES];

MFMailComposeViewController *mailpicker = [[MFMailComposeViewController alloc] init];

    [mailpicker.navigationBar setTintColor:[UIColor blackColor]];
    mailpicker.mailComposeDelegate = self;

    [mailpicker setSubject:@"set your subject"]; 

    NSArray *toRecipients = [NSArray arrayWithObjects: nil];

    [mailpicker setToRecipients:toRecipients];

    UIImage *picture = [info objectForKey:@"UIImagePickerControllerOriginalImage"]];;

    NSData *imageData = UIImagePNGRepresentation(picture);
    [mailpicker addAttachmentData:imageData mimeType:@"image/png" fileName:@"set your file name"];

    NSString *emailBody = @"set your body string";
    [mailpicker setMessageBody:emailBody isHTML:YES];
    [mailpicker setSubject:@"set your subject"];
    mailpicker.title = @"Email";

    [self presentModalViewController:mailpicker animated:YES];
    [mailpicker release];
}

Monday, 5 March 2012

ImageBrightness....with simple one Method


- (UIImage *)imageNamed:(UIImage *)newimg withColor:(UIColor *)color{
    // load the image

//    NSString *name = @"badge.png";
    UIImage *img = newimg;

    // begin a new image context, to draw our colored image onto
    UIGraphicsBeginImageContext(img.size);

    // get a reference to that context we created
    CGContextRef context = UIGraphicsGetCurrentContext();

    // set the fill color
    [color setFill];

    // translate/flip the graphics context (for transforming from CG* coords to UI* coords
    CGContextTranslateCTM(context, 0, img.size.height);
    CGContextScaleCTM(context, 1.0, -1.0);

    // set the blend mode to color burn, and the original image
    CGContextSetBlendMode(context, kCGBlendModeColorBurn);
    CGRect rect = CGRectMake(0, 0, img.size.width, img.size.height);
    CGContextDrawImage(context, rect, img.CGImage);

    // set a mask that matches the shape of the image, then draw (color burn) a colored rectangle
    CGContextClipToMask(context, rect, img.CGImage);
    CGContextAddRect(context, rect);
    CGContextDrawPath(context,kCGPathFill);

    // generate a new UIImage from the graphics context we drew onto
    UIImage *coloredImg = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    //return the color-burned image
    return coloredImg;
}