【发布时间】:2012-03-25 20:59:15
【问题描述】:
我正在尝试编写一个实用程序类,该类允许自动调整平铺图像的大小。假设有一个 srcBitmap,我从中复制一个由 Rectangle srcRegion 给出的区域。然后我想将该区域粘贴(明智的像素信息)到另一个名为 Bitmap destBitmap 的图像中,在目标区域 Rectangle destRegion 中。 我知道如何从源中获取区域并将其放入 Bitmap 对象中,但我还没有找到如何将 Bitmap 对象实际粘贴到某个区域中的另一个更大的 Bitmap 对象中。
有没有快速的方法来做到这一点? (没有 GDI,也没有深入研究位图的字节数组)。这是应该阐明我的目标的sn-p
private static void CopyRegionIntoImage(Bitmap srcBitmap, Rectangle srcRegion, Bitmap destBitmap, Rectangle destRegion)
{
// get the required region from the destination
Bitmap region = Copy(srcBitmap, srcRegion);
}
【问题讨论】:
-
您已经将 GDI+ 与 Bitmap 类一起使用。
-
谢谢!我猜.Net 4.0 框架在这个库周围有包装器。不知道,C# 和 dotNet 不是我的生计。
标签: c# image image-processing bitmapimage