VB改变图片大小的函数

小歆13年前软件源码04162
   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        

相关文章

交错式ADC的基础知识【PDF】

交错式ADC的基础知识【PDF】

PDF下载地址:         小歆网盘:交错式ADC的基础知识(219.47 KB) 作者:ADI美国工程...

制作win7+ubuntu +winPE+CDlinux多系统启动U盘

制作前期准备工作 1.需要软件 grub4dos(http://sourceforge.net/projects/grub4dos/files/)...

抓包工具smsniff2.0汉化版

抓包工具smsniff2.0汉化版

抓包工具smsniff2.0汉化版 ! d5 @& i7 R7 v3 J% F+ Z ( P2 D: j0 W5 o* a# ^/ N! B 0 U9...

H桥电路01.jpg

H桥驱动电路原理

一、H桥驱动电路     图4.12中所示为一个典型的直流电机控制电路。电路得名于“H桥驱动电路”是因为它的形状酷似字母H。4个三极管组成H的4条垂直腿,而电机就...

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

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

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

VB获取网页中的验证码

VB获取网页中的验证码 函数代码: Public Function GetImg(WebBrowser, Img, sxz) '参数 'WebBrowser:等获取验...

发表评论    

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