UIImageのトリミング
::::::
//サムネイルの作成
UIImage *image = [UIImage imageNamed:@"gazou.png"];
float w = image.size.width;
float h = image.size.height;
CGRect rect;
if (h <= w) {
//横長の場合
float x = w / 2 - h / 2;
float y = 0;
rect = CGRectMake(x, y, h, h);
} else {
//縦長の場合
float x = 0;
float y = h / 2 - w / 2;
rect = CGRectMake(x, y, w, w);
}
CGImageRef cgImage = CGImageCreateWithImageInRect(image.CGImage, rect);
UIImage *thumbnailImage = [UIImage imageWithCGImage:cgImage];
::::::
参考サイト
http://ameblo.jp/dokugakumono/entry-10852012897.html
::::::
//サムネイルの作成
UIImage *image = [UIImage imageNamed:@"gazou.png"];
float w = image.size.width;
float h = image.size.height;
CGRect rect;
if (h <= w) {
//横長の場合
float x = w / 2 - h / 2;
float y = 0;
rect = CGRectMake(x, y, h, h);
} else {
//縦長の場合
float x = 0;
float y = h / 2 - w / 2;
rect = CGRectMake(x, y, w, w);
}
CGImageRef cgImage = CGImageCreateWithImageInRect(image.CGImage, rect);
UIImage *thumbnailImage = [UIImage imageWithCGImage:cgImage];
::::::
参考サイト
http://ameblo.jp/dokugakumono/entry-10852012897.html