我要尋找一個很好的教程或示例代碼,這將展示如何裁剪圖像從iPhone相機拍攝使用選定區域的矩形框來裁剪圖像?
東西的
行,但你將控制角落你手指
任何提示將大大appericated,因爲我嘗試了許多方式,但沒有得到一個結果。
我要尋找一個很好的教程或示例代碼,這將展示如何裁剪圖像從iPhone相機拍攝使用選定區域的矩形框來裁剪圖像?
東西的
行,但你將控制角落你手指
任何提示將大大appericated,因爲我嘗試了許多方式,但沒有得到一個結果。
的按鈕操作的一些變化
-(IBAction) cropImage:(id) sender{
// Create rectangle that represents a cropped image
// from the middle of the existing image
float xCo,yCo;
float width=bottomCornerPoint.x-topCornerPoint.x;
float height=bottomCornerPoint.y-topCornerPoint.y;
if(width<0)
width=-width;
if(height<0)
height=-height;
if(topCornerPoint.x <bottomCornerPoint.x)
{
xCo=topCornerPoint.x;
}
else
{
xCo=bottomCornerPoint.x;
}
if(topCornerPoint.y <bottomCornerPoint.y)
{
yCo=topCornerPoint.y;
}
else {
yCo=bottomCornerPoint.y;
}
CGRect rect = CGRectMake(xCo,yCo,width,height);
// Create bitmap image from original image data,
// using rectangle to specify desired crop area
UIImage *image = [UIImage imageNamed:@"abc.png"];
CGImageRef imageRef = CGImageCreateWithImageInRect([image CGImage], rect);
UIImage *img = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);
// Create and show the new image from bitmap data
imageView = [[UIImageView alloc] initWithImage:img];
[imageView setFrame:CGRectMake(110, 600, width, height)];
imageView.image=img;
[[self view] addSubview:imageView];
[imageView release];
}
同樣的問題,誰不回答http://stackoverflow.com/questions/2754618/how-to-crop-an-image-using-rectangale-overlay -and-touch-on-iphone – Marios
你試過了什麼?你試過什麼錯? –
http://stackoverflow.com/questions/8238464/croping-an-uiimage-using-frame-to-cut我試着看這個鏈接 – Marios