切片图像成砖切片、图像

2023-09-02 23:58:52 作者:终是许了伤悲淡了流年

由于加载位图对象。我想这个图像切片成256×256砖,每砖保存作为一个JPG文件。

Given a loaded Bitmap object. I want to slice up this image into 256x256 tiles and save out each tile as a jpg file.

您可能会认为这是一个Silverlight的Deep Zoom排序的任务,你是对的。

You may think this as a Silverlight Deep Zoom sort task and you'd be right.

我有使用WPF一个解决方案,但我想preFER,将工作在.NET 2.0框架的解决方案。 GDI +是不是什么地方我花任何的时间。

I've got a solution using WPF but I would prefer a solution that would work in the .NET 2.0 framework. GDI+ is not somewhere I've spent any amount of time.

任何人都知道我怎么能去呢?我似乎无法找到一个创建从一个指定的矩形排序方法的位图。我会感到惊讶,如果不存在,但也许我看不到树木,不见森林。

Anyone know how I could go about this? I can't seem to find a "Create Bitmap from a specified rectangle sort of method". I'd be surprised if one doesn't exist but perhaps I can't see the wood for the trees.

推荐答案

您可以使用 Bitmap.Clone(矩形的PixelFormat)裁剪出一源图像的256×256区域。这在.NET 2.0。

You can use Bitmap.Clone(Rectangle, PixelFormat) to crop out a 256x256 region of a source image. This works in .NET 2.0.