现在的位置: 首页 > 综合 > 正文

图像处理模块(待补完)

2013年08月18日 ⁄ 综合 ⁄ 共 681字 ⁄ 字号 评论关闭
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.Runtime.CompilerServices

Public Module ImageHelper

    ''' <summary>
    ''' 按指定大小切割图像
    ''' </summary>
    ''' <param name="Image">要切割的Bitmap</param>
    ''' <param name="width">每个图像的宽度</param>
    ''' <param name="height">每个图像的高度</param>
    ''' <returns>返回切割后的图像枚举器</returns>
    <Extension()>
    Public Function Splite(ByVal Image As Bitmap, ByVal width As Integer, ByVal height As Integer) As IEnumerable(Of Bitmap)
        Dim list As New List(Of Bitmap)
        Dim c As Integer = Image.Width \ width
        Dim r As Integer = Image.Height \ height
        For i = 0 To r - 1
            For j = 0 To c - 1
                Dim rtg As New Rectangle(j * width, i * height, width, height)
                Dim b As Bitmap = Image.Clone(rtg, PixelFormat.Format24bppRgb)
                list.Add(b)
            Next
        Next
        Return list
    End Function

End Module

抱歉!评论已关闭.