VB改变图片大小的函数

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

相关文章

长虹zme刷机包,目前收集到最全的ROM

从网上收集到的这些刷机包,其中只有一个“zme_zqn小米_v2.5.1.zip”的包刷过,别的都未曾尝试,感兴趣的网友请多方验证确实能刷后再刷机,否则不能开机损失就大了,刷机有风险,开刷须谨慎,再次...

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

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

C语言深度解剖 封面.jpg

[PDF]C语言深度解剖

C语言深度解剖   目录: 下载地址:        小歆网盘:C语言深度解剖(848.41 KB...

LT3083:降压DC-DC解决方案电路图

LT3083:降压DC-DC解决方案电路图

LT3083 是一款3A 低压差线性稳压器,可通过并联来增加输出电流或在表面贴装型电路板上散播热量。这款新型稳压器专为用作一个精准电流源和电压跟随器而设计,可在许多要求高电流、至零的可调节能力和不设...

嵌入式软件架构设计

模块划分 模块划分的"划"是规划的意思,意指怎样合理的将一个很大的软件划分为一系列功能独立的部分合作完成系统的需求。C语言作为一种结构化的程序设计语言,在模块的划分上主要依据功能(依功能...

软件版本号的英文代码大全

alphal 内部测试版 beta 外部测试版 demo 演示版 Enhance 增强版或者加强版 属于正式版 Free 自由版 Full version 完全版 属于正式版 sharew...

发表评论    

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