Suppose I have image canvas or previously loaded image which supports transparency (gif/png). What are the steps to implement changing transparency for the image, but not for the whole image, but only a part of it? I undestand I should use CGContext, but i'm lacking the details.
假设我有图像画布或以前加载的图像,它支持透明度(gif / png)。实现更改图像透明度的步骤是什么,但不是整个图像,而只是部分图像的一部分?我不明白我应该使用CGContext,但我缺乏细节。
1 个解决方案
#1
1) create a memory buffer
1)创建一个内存缓冲区
2) cast it into a CGContext
with alpha by using CGBitmapContextCreate
2)使用CGBitmapContextCreate将其转换为带有alpha的CGContext
3) draw your image into it with CGContextDrawImage
3)使用CGContextDrawImage将图像绘制到其中
4) modify the mask via the buffer you created in step 1.
4)通过在步骤1中创建的缓冲区修改掩码。
5) $$$
#1
1) create a memory buffer
1)创建一个内存缓冲区
2) cast it into a CGContext
with alpha by using CGBitmapContextCreate
2)使用CGBitmapContextCreate将其转换为带有alpha的CGContext
3) draw your image into it with CGContextDrawImage
3)使用CGContextDrawImage将图像绘制到其中
4) modify the mask via the buffer you created in step 1.
4)通过在步骤1中创建的缓冲区修改掩码。
5) $$$