VB改变图片大小的函数

小歆14年前软件源码05192
   Public Function ResizePicture(ByVal sourceImage As Bitmap, _
                ByVal newSize As Size) As Bitmap '调整图片大小(图片源,新尺寸)

        Dim Result_image As New Bitmap(sourceImage, newSize.Width, newSize.Height)
        Dim Gr As Graphics

        Gr = Graphics.FromImage(Result_image)
        Gr.DrawImage(Result_image, 0, 0, newSize.Width, newSize.Height)
        Gr.Save()

        Return Result_image
    End Function

    Public Function CropBitmap(ByVal inputBmp As Bitmap, _
                ByVal cropRectangle As Rectangle) As Bitmap '裁剪位图(输出,矩形)
        '创建一个新的位图对象根据输入的
        Dim newBmp As New Bitmap(cropRectangle.Width, _
                 cropRectangle.Height, _
                 System.Drawing.Imaging.PixelFormat.Format24bppRgb) 'Graphics.FromImage 
                                                'doesn't like Indexed pixel format

        '创建一个图形对象,并将其附加的位图
        Dim newBmpGraphics As Graphics = Graphics.FromImage(newBmp)

        '对输入图像中裁剪矩形绘制的部分
        '图形对象
        newBmpGraphics.DrawImage(inputBmp, _
              New Rectangle(0, 0, cropRectangle.Width, cropRectangle.Height), _
                cropRectangle, _
                GraphicsUnit.Pixel)

        'Return the bitmap
        newBmpGraphics.Dispose()

        'newBmp will have a RawFormat of MemoryBmp because it was created
        'from scratch instead of being based on inputBmp.  Since it is inconvenient
        'for the returned version of a bitmap to be of a different format, now convert
        'the scaled bitmap to the format of the source bitmap
        Return newBmp
    End Function        

相关文章

[DOC]全国计算机二级C语言(完整复习资料)

National Computer Rank Examination 全国计算机等级考试 (2012年9月串讲...

[微软官方]USB2.0提速补丁(x86x64) 官方版

[微软官方]USB2.0提速补丁(x86x64) 官方版

免费为USB2.0设备提速补丁USB2.0提速补丁(x86x64) 官方版 USB2.0提速补丁是一款HotFix热修复补丁,并没有作为常规补丁随系统自动更新,所以我们可以自己来手动下载安装。...

[转]windows7系统启动顺序详解

你对电脑的启动过程了解吗?我将详细讲述自己的学习操作系统以来对操作系统的理解。当然只是windows系统的启动问题,不管你是维修电脑,服务器 维护,各...

红色警戒2修改大师V2.80正式版

红色警戒2修改大师V2.80正式版

今天,我给大家分享一个软件,是关于红色警戒破解的,我已经用它很久了,而它与其他人的辅助不一样,功能更加全面,操作更简单,尤其是它的那个可以联机用的功能,废话不多说,直接上图!7 ~: K: v6 k+...

字模提取软件截图.jpg

[Horse][字模提取][V2.2]

字模提取V2.2   下载地址:字模提取V2.2.zip...

Android开发宝典之 Android程序员入门

Android开发宝典之 Android程序员入门

简介 Android作为一个系统,是一个运行在Linux2.6核心上的JAVA基础的操作系统。系统是非常轻量型的而且全特性。本文介绍了Android开发的基本知识,很实用。 目录...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。