VB改变图片大小的函数

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

规划小歆工作室Android刷机包制作...

小歆工作室Android刷机包制作        《小歆工作室Android刷机包》基于MIUI安卓系统修改更新的一款ROM刷机包,此版本规...

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

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

VIP会员试用抵价券发放活动

VIP会员试用抵价券发放活动    为了让广大网友更多的体验小歆工作室的各项服务 从2013年3月30日开启截止至2013年5月31日...

u808_01.png

中兴U808 官方深度精简版 全局透明美化稳定流畅 可长期使用

中兴U808是我个人非常喜欢的一款机型。本ROM是基于官方4.0.3制作,在保证官方原汁原味的基础上,添加了三星风格,删除了大部分没有实际用途的软件,释放更多系统内存从而达到让系统分配更多内存供主固件...

VB中LostFocus、GotFocus事件的改进

---- VB中有一个LostFocus事件和一个GotFocus事件,看名字似乎是当当前窗口失去焦点或得到焦点时触发的事件。但在实际应用时却发现当这个窗口和Win...

阻焊剂分类及阻焊剂配方和使用方法

阻焊层,顾名思义,就是防止焊接的一层。它一般是绿色或者其它颜色,覆盖在布有铜线上面的那层薄膜,它起绝缘,还有防止焊锡附着在不需要焊接的一些铜线上。当然,它也在一定程度上保护布线层。 &...

发表评论    

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