VB改变图片大小的函数

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

相关文章

进击的巨人【特殊字体】.jpg

[字体]《进击的巨人》OP2风格特殊字体

网友制作动画《进击的巨人》OP2《自由之翼》的STAFF表使用了一种特殊字体。现在日本网友 たぬき侍 制作出了这款字体,并取名为“自由之翼体”,已于9月11日开放免费下载,商业也可免费使用。 &nb...

华为模拟电子技术讲义上下册

华为模拟电子技术讲义上下册

华为模拟电子技术讲义上下册 小歆网盘: 华为模拟电子技术讲义上下册(1.81 MB)...

Discuz附件下载权限绕过工具.png

[小歆][Discuz附件下载权限绕过工具][V1.1][2014.03.13]

Discuz附件下载权限绕过工具V1.1 本软件利用Discuz论坛的漏洞来下载论坛的附件。 【Discuz3.X的有部分好像已经失效了,自测,我刚刚测试了一个3.X论坛还是...

H桥电路01.jpg

H桥驱动电路原理

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

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

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

STM32 V3.5.0 工程模版

STM32 V3.5.0 工程模版

STM32_V3.5.0工程模版 MDK环境下利用STM32库V3.5创建工程的模板! 下载地址:STM32_V3.5.0工程模版(701.27 K...

发表评论    

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