I am working in iPhone application, I have tried to slice multiple part from single image but i can't get exact solution. I want single image to slice multiple part like 3x3, 4x4, 5x5, 6x6 etc... How to do this? Is it possible to do this? please help me.
Thanks in Advance
I tried this:
UIImage* whole = [UIImage imageNamed:@"1.png"];
int partId = 0;
for (int x=0; x<=300; x+=100)
{
for(int y=0; y<=300; y+=100)
{
CGImageRef cgImg = CGImageCreateWithImageInRect(whole.CGImage, CGRectMake(x, y, 100, 100));
UIImage* part = [UIImage imageWithCGImage:cgImg];
UIImageView* iv = [[UIImageView alloc] initWithImage:part];
switch (partId)
{
case 0:
img.image=iv.image;
break;
case 1:
img2.image=iv.image;
break;
case 2:
img3.image=iv.image;
break;
case 3:
img4.image=iv.image;
break;
case 4:
img5.image=iv.image;
break;
case 5:
img6.image=iv.image;
break;
case 6:
img7.image=iv.image;
break;
case 7:
img8.image=iv.image;
break;
case 8:
img9.image=iv.image;
break;
default:
break;
}
partId++;
NSLog(@"part id = %d",partId);
}
}