UIImage by selecting part of another UIImage

后端 未结 1 1101
被撕碎了的回忆
被撕碎了的回忆 2021-01-07 01:41

I have an UIImage and a CGPoint which tells me in what direction I should move it to create another image. The backgrou

相关标签:
1条回答
  • 2021-01-07 02:06

    You can use CGImageCreateWithImageInRect(). You can get a CGImage from a UIImage with the property of the same name.

    Basically what you end up doing is apply masks to the existing image to extract the portions you need. Like so -

    enter image description here

    myImageArea = CGRectMake(xOrigin, yOrigin, myWidth, myHeight);//newImage
    mySubimage  = CGImageCreateWithImageInRect(oldImage, myImageArea);
    myRect      = CGRectMake(0, 0, myWidth*2, myHeight*2);
    CGContextDrawImage(context, myRect, mySubimage);
    

    This post gives a good idea of how to use this property.

    0 讨论(0)
提交回复
热议问题