很簡單的方法,貌似沒有。這個需要自己寫很多代碼:
為湟源等地區(qū)用戶提供了全套網(wǎng)頁設計制作服務,及湟源網(wǎng)站建設行業(yè)解決方案。主營業(yè)務為成都網(wǎng)站制作、做網(wǎng)站、湟源網(wǎng)站設計,以傳統(tǒng)方式定制建設網(wǎng)站,并提供域名空間備案等一條龍服務,秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務。我們深信只要達到每一位用戶的要求,就會得到認可,從而選擇與我們長期合作。這樣,我們也可以走得更遠!
用一個ListView控件。
判斷滾動條當前所顯示的圖片集合,獲取它們的物理路徑。
用Bitmap.FromImage方法把這些圖片讀出來,
然后獲取縮略圖,
把縮略圖用Graphics.DrawImage()繪制出來。
我可以提供Bitmap如何獲取縮略圖的方法:
'''?summary必須創(chuàng)建一個委托并將對此委托的引用作為獲取縮略圖?callback?參數(shù)傳遞,但不使用此委托。/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("讀取數(shù)據(jù)庫失敗!");///顯示錯誤信息
}
//刪除所有記錄
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);
//獲取圖片數(shù)據(jù)
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]; //按文件的大小在堆上申請一塊內(nèi)存
if (f.Read(pBuffer, nSize) 0 ) //把文件讀到pBuffer(堆上申請一塊內(nèi)存)
{ // +----------------------------------------------
BYTE *pBuf = pBuffer; ///下面這一大段是把pBuffer里的數(shù)據(jù)放到庫中
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("圖片數(shù)據(jù)")-AppendChunk(varBLOB);
}
delete [] pBuffer; //刪掉堆上申請的那一塊內(nèi)存
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、假設你要循環(huán)切換4張圖片,你可以添加如下代碼即可實現(xiàn):
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代碼,可以給你參考