gpt4 book ai didi

iphone - 绘制具有透明度的图像

转载 作者:行者123 更新时间:2023-11-28 17:40:24 24 4
gpt4 key购买 nike

我有几个 png,我在 beginGraphicsContextWithOptions 中相互叠加以形成单个图像。但是,我想绘制其中一些具有透明度的图像。请问我该怎么做?

最佳答案

下面是如何使用透明度叠加图像:

NSString* file1 = "your images file path";

NSRect largerect = NSRectMake(10,10,300,300);

NSString* file2 = "your images file path";

NSString* file3 = "your images file path";

NSString* file4 = "your images file path";

NSImage* img1 = [[NSImage alloc] initWithContentsOfFile:file1];

NSImage* img2 = [[NSImage alloc] initWithContentsOfFile:file1];

NSImage* img3 = [[NSImage alloc] initWithContentsOfFile:file1];

NSImage* img4 = [[NSImage alloc] initWithContentsOfFile:file1];

//the fraction parameter is just how transparent you want it so 1.0 is opaque and 0.0 you will not see the image

[image1 drawInRect: largeRect
fromRect: NSZeroRect
operation: NSCompositeSourceOver
fraction: 0.8];

[image2 drawInRect: largeRect
fromRect: NSZeroRect
operation: NSCompositeSourceOver
fraction: 0.6];

[image1 drawInRect: smallRect1
fromRect: NSZeroRect
operation: NSCompositeSourceOver
fraction: 0.40];

[image2 drawInRect: smallRect2
fromRect: NSZeroRect
operation: NSCompositeSourceOver
fraction: 0.40];

关于iphone - 绘制具有透明度的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8373808/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com