-2
我试图以编程方式创建基于Objective-C中较小PNG的大型PNG。较小的PNG是我用作水印的标志。我想将较小的PNG放在大型PNG的右下角。大的PNG应该是源视频的大小并且具有透明背景。以编程方式在Objective-C中基于更小的PNG创建大型PNG
我在C#中工作,但不能完全弄清楚如何在Objective-C中工作。我想我应该使用图像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);
谢谢!
你知道任何Objective-C吗?你之前使用过Cocoa或Foundation吗?语言和框架是不同的,所以你可能不应该尝试直接移植这些代码。 – 2012-08-09 16:58:44
但你知道,Objective-C不是C#吗? – vikingosegundo 2012-08-09 17:01:29
是的,我知道Objective-C不是C#。我已经使用了好几个月。我发布了我的C#,以便人们可以看到我想要做的事情。我试图找出如何在Objective-C中完成相同的任务。 – 2012-08-09 17:07:31