ios printing with a predefined size

I make an app that have to printing image. I need to print image with a predefined size.

For example I have some image 50 x 50 px I want to resize it to some new size pixel that after printing I get image with size 5 x 5 cm.

Please see an attachment:

Thanks for help!

Answers


Hey i have used below code for resize the image in my app

Set the size according you want

  UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[result objectForKey:@"pic"]]]];
        // Resize, crop the image to make sure it is square and renders
        // well on Retina display
        float ratio;
        float delta;
        float px = 100; // Double the pixels of the UIImageView (to render on Retina)
        CGPoint offset;
        CGSize size = image.size;
        if (size.width > size.height) {
            ratio = px / size.width;
            delta = (ratio*size.width - ratio*size.height);
            offset = CGPointMake(delta/2, 0);
        } else {
            ratio = px / size.height;
            delta = (ratio*size.height - ratio*size.width);
            offset = CGPointMake(0, delta/2);
        }
        CGRect clipRect = CGRectMake(-offset.x, -offset.y,
                                     (ratio * size.width) + delta,
                                     (ratio * size.height) + delta);
        UIGraphicsBeginImageContext(CGSizeMake(px, px));
        UIRectClip(clipRect);
        [image drawInRect:clipRect];
        UIImage *imgThumb = UIGraphicsGetImageFromCurrentImageContext();

        UIGraphicsEndImageContext();
        [img setImage:imgThumb];

Need Your Help

HtmlAgilityPack get contents in a comments line

html dom get comments

I want get content value in a comment line string:

ArrayAdapter only shows last added thumbnail picture in list view

java android listview android-arrayadapter

In my app, I have a listView which shows employees, every item has it's own name, email and a thumbnail. everything works fine but the thumbnails. My ArrayAdapter, instead of showing all the employ...