vb.net图片缩略图 vb缩小图片

vb.net中 , 如何像下图一样,用很简单的办法,导入1000张图片 。很简单的方法vb.net图片缩略图,貌似没有 。这个需要自己写很多代码:
用一个ListView控件 。
判断滚动条当前所显示的图片集合,获取它们的物理路径 。
用Bitmap.FromImage方法把这些图片读出来,
然后获取缩略图 ,
把缩略图用Graphics.DrawImage()绘制出来 。
vb.net图片缩略图我可以提供Bitmap如何获取缩略图的方法:
''' summary必须创建一个委托并将对此委托的引用作为获取缩略图 callback 参数传递,但不使用此委托 。/summary
Public Function ThumbnailCallback() As Boolean
Return False
End Function
''' summary返回Image,表示图像指定 宽 和 高 的缩略图 。/summary
Public Function 获取缩略图(位图 As Bitmap, 宽 As Integer, 高 As Integer) As Image
Dim myCallback As New Image.GetThumbnailImageAbort(ThumbnailCallback)
Return 位图.GetThumbnailImage(宽, 高, myCallback, IntPtr.Zero)
End Function
vb.net中怎么实现图片缩小和放大Pegasus的ImagXpress 8.0控件,支持各种格式文件的加载 。控件封装了右键局部区域放大的功能,要实现图片的缩放,把AutoResize属性设置为PegasusImaging.WinForms.ImagXpress8.AutoResizeType.CropImage,修改 ZoomFactor的值就可以了 。
如何正确掌握VB.NET操作缩放图像在VB.NET操作缩放图像中的显示和保存缩放图像 , 用到Image和Graphics类 , 在VSDotNet2K3下面Reference里自动添加了引用System.Drawing , 直接用就行 。
实现VB.NET操作缩放图像代码如下:DimimgAsImageImage=Image.FromFile
(D:\Image\tstImage.jpg)
''tstImage是原先的图片DimgrfxAsGraphics=Me
.CreateGraphics
grfx.DrawImage(img,0,0,img.Width*
3,img.Height*3)''在Form里显示
DimimgnewAsNewSystem.Drawing.Bitmap
(img,img.Height*3,img.Width*3)
''新建一个放大的图片
imgnew.Save(D:\Image\tstNewImage.jpg,
System.Drawing.Imaging.ImageFormat.Jpeg)
''保存放大后图片
你可以建一个Form,然后在Form里拖进一个Button , 把上面的代码放在Button_Click事件里面源码天空
,执行就行了 。
对上面VB.NET操作缩放图像代码的解释:
1.要获取Graphics对象只能从某一事件的参数中获取或者使用窗体和控件对象的CreateGraphics方法来获取-----上面代码使用Me.CreateGraphics来引用这个对象 。
2.加载一个图片用Image类的FromFile或者FromStream方法
3.用DrawImage来显示一个图片,该方法有30多个重载方法,可以查MSDN了解细节 。
4.保存时的一个问题:我们必须先建一个对象,用于存缩放图像 。
vb.net 如何放大和缩小图片Sub 图片缩放()
Dim SngPer As Single = 1 '放大或缩小的比例 放大2倍时SngPer=2,缩小3倍时 SngPer=1/3
Dim PicOld As Image = Image.FromFile("原图片路径")
Dim PicNew As New System.Drawing.Bitmap(PicOld, PicOld.Width * SngPer, PicOld.Height * SngPer)
PicNew.Save("新图片路径", Drawing.Imaging.ImageFormat.Jpeg)
End Sub
asp.net如何实现 图片压缩(vb.net)'''''''''''''''tosmallimg.aspx''
%@ Page Language="VB" AutoEventWireup="false" CodeFile="tosmallpic.aspx.vb" Inherits="tosmallpic" %
%@ OutputCache Duration="86400" VaryByParam="*" %
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""
html xmlns=""
head runat="server"
title无标题页/title
/head
body
form id="form1" runat="server"
div
/div
/form
/body
/html
'''''''''''''''tosmallimg.aspx.vb''
Imports System.Drawing, System.Drawing.Imaging, System.Drawing.Drawing2D
Partial Class tosmallpic
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim width As Int16 = CInt(My.Request.QueryString("width"))
Dim height As Int16 = CInt(My.Request.QueryString("height"))
Dim url As String = My.Request.QueryString("url")
If Not System.IO.File.Exists(Server.MapPath(url)) Then
Response.Redirect("img/default.jpg")
Response.End()
End If
Dim img As Image = Image.FromFile(Server.MapPath(url))
If width = 0 And height0 Then
width = height * img.Width / img.Height
ElseIf height = 0 Then
height = width * img.Height / img.Width
End If
If widthimg.Width Then Response.Redirect(url)
Dim bmp As New Bitmap(width, height)
Dim gr As Graphics = Graphics.FromImage(bmp)
gr.Clear(Color.Transparent)
'gr.SmoothingMode = SmoothingMode.AntiAlias
Dim rct As New Rectangle(0, 0, width, height)
gr.DrawImage(img, New Rectangle(0, 0, width, height), New Rectangle(0, 0, img.Width, img.Height), GraphicsUnit.Pixel)
Response.Clear()
Response.ContentType = "image/jpeg"
bmp.Save(Response.OutputStream, ImageFormat.Jpeg)
End Sub
End Class
介绍下我的blog
asp.net(vb)创建缩略图你可以在VB中先生成:
用两个图片框:
第一个用于加载原始图片(AutoSize属性设置为True)
第二个用于生成缩略图的,大小调整成你的缩略图的大小(设置AutoRedraw属性为True)
用如下方法,可以生成缩略图(不过是bmp格式的,如果你要用别的格式,可以用工具批量转换一下
Private
Sub
Command1_Click()
Picture2.PaintPicture
Picture1.Picture,
0,
0,
Picture2.ScaleWidth,
Picture2.ScaleHeight
SavePicture
Picture2.Image,
"C:\a.bmp"
End
Sub
【vb.net图片缩略图 vb缩小图片】vb.net图片缩略图的介绍就聊到这里吧 , 感谢你花时间阅读本站内容,更多关于vb缩小图片、vb.net图片缩略图的信息别忘了在本站进行查找喔 。

    推荐阅读