重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
很简单的方法,貌似没有。这个需要自己写很多代码:
为湟源等地区用户提供了全套网页设计制作服务,及湟源网站建设行业解决方案。主营业务为成都网站制作、做网站、湟源网站设计,以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。我们深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!
用一个ListView控件。
判断滚动条当前所显示的图片集合,获取它们的物理路径。
用Bitmap.FromImage方法把这些图片读出来,
然后获取缩略图,
把缩略图用Graphics.DrawImage()绘制出来。
我可以提供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
‘ 导入图片按钮
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
FolderBrowserDialog1.Description = "选择图片文件夹导入图片"
FolderBrowserDialog1.ShowDialog()
path = FolderBrowserDialog1.SelectedPath()
If path = "" Then Return
strSrcFile = Dir(path "\*.tif")
PictureBox1.Image = Image.FromFile(path "\" strSrcFile)
dirFiles.Add(path "\" strSrcFile)
FileNames.Add(strSrcFile)
Do
strSrcFile = Dir()
dirFiles.Add(path "\" strSrcFile)
If (strSrcFile IsNot Nothing) Then
FileNames.Add(strSrcFile)
End If
Loop Until Len(strSrcFile) = 0
End Sub
’ 上一张图片(我做的按钮,鼠标左键的话原理也是一样 的,你放到鼠标左键事件中就可以了)
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click '向前
If path "" Then
If (saveDirFiles.Count = 0) Then
Return
End If
MyPos = 0
PictureBox1.Image = Image.FromFile(saveDirFiles(saveDirFiles.Count - 1).ToString())
dirFiles.Insert(0, saveDirFiles(saveDirFiles.Count - 1).ToString())
saveDirFiles.RemoveAt(saveDirFiles.Count - 1)
End If
End Sub
’ 下一张图片
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click '向后
If path "" Then
If (dirFiles.Count = 0) Then
Return
End If
MyPos = 0
Dim iCurrentPos As Integer = 0
Try
PictureBox1.Image = Image.FromFile(dirFiles(iCurrentPos + 1).ToString())
Catch ex As Exception
MsgBox("已翻至图片的最后一页")
Return
End Try
saveDirFiles.Add(dirFiles(iCurrentPos))
dirFiles.RemoveAt(iCurrentPos)
End sub
void CGridImageDlg::OnSave()
{
try
{
pRecordset.CreateInstance("ADODB.Recordset");
pRecordset-Open("SELECT * FROM 基本信息图片",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText);
}
catch(_com_error e)///捕捉异常
{
AfxMessageBox("读取数据库失败!");///显示错误信息
}
//删除所有记录
while (!pRecordset-adoEOF)
{
pRecordset-Delete(adAffectCurrent);///删除当前记录
pRecordset-MoveNext();
}
int m_Rcount = 1;
while (m_Rcount m_GridCtrl.GetRowCount())
{
pRecordset-AddNew();
if(m_GridCtrl.GetItemText(m_Rcount,0)!="")
pRecordset-Fields-GetItem(_variant_t("图片编号"))-Value=_bstr_t(m_GridCtrl.GetItemText(m_Rcount,0));
if(m_GridCtrl.GetItemText(m_Rcount,1)!="")
pRecordset-Fields-GetItem(_variant_t("桥梁编号"))-Value=_bstr_t(m_GridCtrl.GetItemText(m_Rcount,1));
//获得文件名
CString m_sname;
m_sname.Format("%s",m_GridCtrl.GetItemText(m_Rcount,2));
//获取扩展名
CString m_sExt;
m_sExt.Format("%s%s",_T("."),m_GridCtrl.GetItemText(m_Rcount,4));
//获得主程序的路径
CString sPath;
GetModuleFileName(NULL,sPath.GetBufferSetLength (MAX_PATH+1),MAX_PATH);
sPath.ReleaseBuffer ();
int nPos;
nPos=sPath.ReverseFind ('\\');
sPath=sPath.Left (nPos);
//获取图片数据
CFile f;
CString FilePathName;
FilePathName.Format("%s%s%s%s",sPath,_T("\\临时图片\\"),m_sname,m_sExt); //文件名和后缀名
CFileException e;
if(f.Open(FilePathName, CFile::modeRead | CFile::typeBinary, e)) //打开了一个文件
{
int nSize = f.GetLength(); //先得到文件长度
BYTE * pBuffer = new BYTE [nSize]; //按文件的大小在堆上申请一块内存
if (f.Read(pBuffer, nSize) 0 ) //把文件读到pBuffer(堆上申请一块内存)
{ // +----------------------------------------------
BYTE *pBuf = pBuffer; ///下面这一大段是把pBuffer里的数据放到库中
VARIANT varBLOB;
SAFEARRAY *psa;
SAFEARRAYBOUND rgsabound[1];
if(pBuf)
{
rgsabound[0].lLbound = 0;
rgsabound[0].cElements = nSize;
psa = SafeArrayCreate(VT_UI1, 1, rgsabound);
for (long i = 0; i (long)nSize; i++)
SafeArrayPutElement (psa, i, pBuf++);
varBLOB.vt = VT_ARRAY | VT_UI1;
varBLOB.parray = psa;
pRecordset-GetFields()-GetItem("图片数据")-AppendChunk(varBLOB);
}
delete [] pBuffer; //删掉堆上申请的那一块内存
pBuf=0; //以防二次乱用
f.Close();
}
}
if(m_GridCtrl.GetItemText(m_Rcount,3)!="")
pRecordset-Fields-GetItem(_variant_t("图片类别名称"))-Value=_bstr_t(m_GridCtrl.GetItemText(m_Rcount,3));
if(m_GridCtrl.GetItemText(m_Rcount,4)!="")
pRecordset-Fields-GetItem(_variant_t("图片后缀"))-Value=_bstr_t(m_GridCtrl.GetItemText(m_Rcount,4));
if(m_GridCtrl.GetItemText(m_Rcount,5)!="")
pRecordset-Fields-GetItem(_variant_t("拍摄日期"))-Value=_bstr_t(m_GridCtrl.GetItemText(m_Rcount,5));
if(m_GridCtrl.GetItemText(m_Rcount,6)!="")
pRecordset-Fields-GetItem(_variant_t("图片描述"))-Value=_bstr_t(m_GridCtrl.GetItemText(m_Rcount,6));
m_Rcount++;
pRecordset-Update();
}
}
Dim i As Integer
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
i = i + 1
If i 3 Then Timer1.Enabled = False : Exit Sub
PictureBox1.ImageLocation = "z:\" i ".png"
End Sub
vb.net 怎么来回切换图片?1、添加控件Picturebox1和控件Timer1,将Timer1的Interval属性改为1000(即1秒),Enabled属性改为True
2、假设你要循环切换4张图片,你可以添加如下代码即可实现:
Dim a As Integer = 0
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If a = 4 Then
a = 0
Else
a = a + 1
End If
If a = 0 Then Me.PictureBox1.Image = Image.FromFile("1.jpg")
If a = 1 Then Me.PictureBox1.Image = Image.FromFile("2.jpg")
If a = 2 Then Me.PictureBox1.Image = Image.FromFile("3.jpg")
If a = 3 Then Me.PictureBox1.Image = Image.FromFile("4.jpg")
End Sub
用GDI
先建一个6400*4800的Image 类的位图图像 作为GDI画板
然后用Drawimage方法,加载小图像,并按坐标位置画进去
然后保存成文件
我有一个相似功能的VB.net代码,可以给你参考