我正在尝试基于 Objective-C 中较小的 PNG 以编程方式创建一个大的 PNG。较小的 PNG 是我用作水印的徽标。我想将较小的PNG放在大PNG的右下角。大 PNG 应该是源视频的大小并且具有透明背景。
我在 C# 中有这个工作,但不能完全弄清楚如何在 Objective-C 中工作。我想我应该使用 Image I/O 库。
Bitmap bm;
int shortestSide;
if (videoWidth > videoHeight)
shortestSide = videoHeight;
else
shortestSide = videoWidth;
var logoDimension = (int)(shortestSide * 0.05);
Image logo;
if (logoDimension <= 16)
logo = Resources.watermark_16x16;
else if (logoDimension <= 24)
logo = Resources.watermark_24x24;
else if (logoDimension <= 36)
logo = Resources.watermark_36x36;
else if (logoDimension <= 48)
logo = Resources.watermark_48x48;
else if (logoDimension <= 54)
logo = Resources.watermark_54x54;
else
logo = Resources.watermark_64x64;
var logoPoint = new Point(videoWidth - logo.Width * 2, videoHeight - logo.Height * 2);
var image = new Bitmap(videoWidth, videoHeight, PixelFormat.Format32bppArgb);
using (var g = Graphics.FromImage(image))
{
g.DrawImageUnscaled(logo, logoPoint);
}
bm = image;
bm.Save(watermarkPath, ImageFormat.Png);
谢谢!