开发者

Iphone app: Resize a png by getting Height and Width from user

Ive an image with particular resolution appearing on Iphone screen. I need to resiz开发者_运维知识库e that image by getting info. as an alert from user(Width and height). Cud anyone help me with block of code for this????


WARNING: code typed in answer box, not tested. It's pretty close, though.

NSSize newSize = [self getSizeFromUser];  // you have to write this part.
CGRect theRect = CGRectMake (0, 0, newSize.width, newSize.height);

// Put image into new context
UIGraphicsBeginImageContext (newSize);
    [theImage drawInRect: theRect];
    //get the image from the context
    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
    [[compositeImage retain] autorelease];
UIGraphicsEndImageContext();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜