[C#] 纯文本查看 复制代码 using var imageB = SKBitmap.Decode("imageB.png");
using var imageA = SKBitmap.Decode("imageA.jpg");
using var pixelsB = imageB.PeekPixels();
using var pixelsA = imageA.PeekPixels();
for (int y = 0; y < imageB.Height; y++)
{
for (int x = 0; x < imageB.Width; x++)
{
var colorB = pixelsB.GetPixelColor(x, y);
var alpha = colorB.Alpha;
var colorA = pixelsA.GetPixelColor(x, y);
imageA.SetPixel(x, y, new SKColor(colorA.Red, colorA.Green, colorA.Blue, alpha));
}
}
using var stream = new FileStream("imageC.png", FileMode.Create);
imageA.Encode(SKEncodedImageFormat.Png, 100).SaveTo(stream);
不知道这样的代码能不能满足你,效率也无法保证,毕竟也是单纯的双重遍历
用的库是SkiaSharp |