導航:首頁 > 編程語言 > vb中圖片放大縮小代碼

vb中圖片放大縮小代碼

發布時間:2025-01-02 20:58:52

1. 求用vb編程,實現圖片的縮小和放大的程序

粗劣的做了下~最簡單的就是用image控制項 先將Image1的Stretch 屬性設置為 True
Private Sub Command1_Click()
Static a As Integer
Static b As Integer
a = a + 1
b = b + 1
Image1.Height = Image1.Height * a
Image1.Width = Image1.Width * b
End Sub

2. 求助:VB實現PICTUREBOX內圖片的放大 縮小 移動 代碼(類似ACDSEE)萬分感謝!!!

控制圖片的width(寬度)height(高度) 就可以實現了
比如放大吧
private sub max_click()
picture.width=picture.width*2
picture.height=picture.height*2
end sub
縮小的用除法就好了

移動可以試試用move方法。。。。。

3. VB中如何才能自動放大縮小圖片填充到圖片框中啊

實現代碼:

VERSION 5.00

BeginVB.FormForm1

Caption="使用PictureBox控制項實現圖像放大和縮小"

ClientHeight=5580

ClientLeft=60

ClientTop=345

ClientWidth=7935

LinkTopic="Form1"

ScaleHeight=5580

ScaleWidth=7935

StartUpPosition=3'窗口預設

BeginVB.PictureBoxPicture1

AutoRedraw=-1'True

AutoSize=-1'True

Height=3960

Left=-15

Picture="Form1.frx":0000

ScaleHeight=3900

ScaleWidth=6240

TabIndex=2

Top=15

Width=6300

End

BeginVB.CommandButtonCommand2

Caption="放大"

Height=360

Left=6540

TabIndex=1

Top=5070

Width=1140

End

BeginVB.CommandButtonCommand1

Caption="縮小"

Height=360

Left=5160

TabIndex=0

Top=5070

Width=1140

End

End

AttributeVB_Name="Form1"

AttributeVB_GlobalNameSpace=False

AttributeVB_Creatable=False

AttributeVB_PredeclaredId=True

AttributeVB_Exposed=False

DimiAsInteger

DimjAsInteger

PrivateSubCommand1_Click()

Picture1.Cls

i=i-100:j=j-100

Picture1.PaintPicturePicture1.Picture,0,0,i,j

Picture1.Width=i:Picture1.Height=j

EndSub

PrivateSubCommand2_Click()

Picture1.Cls

Picture1.Width=i:Picture1.Height=j

i=i+100:j=j+100

Picture1.PaintPicturePicture1.Picture,0,0,i,j

EndSub

PrivateSubForm_Load()

i=Picture1.Width:j=Picture1.Height

Picture1.Cls

EndSub

VB6.0通過PictureBox控制項實現圖片放大和圖片縮小功能



(3)vb中圖片放大縮小代碼擴展閱讀:

其它方法:

例子前請先下載Gdiplus.tlb,並將其放置到C:\Windows\System32中

Gdiplus.tlb下載

VisualBasiccode

使用Gdiplus.tlb,將其放到system32中,然後添加對其的引用

手動設置Form的AutoRedraw=True,ScaleMode=Pixels

OptionExplicit

DimlngGraphicsAsLong

DimlngImageHandleAsLong

DimlngTextureBrushAsLong

DimgpPAsGpStatus

DimlngPen1AsLong

DimlngTokenAsLong

PrivateSubCommand1_Click()

DimintPAsInteger

gpP=GdipCreateFromHDC(Me.hDC,lngGraphics)'創建繪圖區域設備場景

gpP=GdipLoadImageFromFile(App.Path&"\啟動.png",lngImageHandle)'讀取圖片到內存

gpP=GdipDrawImage(lngGraphics,lngImageHandle,0,0)'等大小繪制

gpP=GdipDrawImageRect(lngGraphics,lngImageHandle,200,0,300,300)'在指定的區域內繪制(放大或縮小)

gpP=GdipDrawImageRectRectI(lngGraphics,lngImageHandle,550,0,400,400,20,20,80,80,UnitPixel)'在400*400的區域內顯示圖片部分區域

gpP=GdipCreateTexture(lngImageHandle,WrapModeTile,lngTextureBrush)'設置一定排列方式的刷子平鋪方式

gpP=GdipFillRectangle(lngGraphics,lngTextureBrush,0,300,400,300)'在指定區域內按指定的格式繪制圖片

IflngGraphics<>

IflngImageHandle<>

IflngTextureBrush<>

Me.Refresh

EndSub

PrivateSubForm_Load()

DimbolPAsBoolean

WithMe

.Caption="GDIPlus範例"

.Width=960*15

.Height=720*15

.Left=(Screen.Width-.Width)*0.5

.Top=(Screen.Height-.Height)*0.5

EndWith

GpInput.GdiplusVersion=1

IflngToken=0ThenbolP=(GdiplusStartup(lngToken,GpInput)=Ok)

EndSub

4. 在VB中,如何實現圖片的等比例放大或縮小

給你一個我原來做過的實例吧。imgPreview 為Image對象。

Private Type PreviewSize
sngLeft As Single
sngTop As Single
sngWidth As Single
sngHeight As Single
intZoon As Integer
End Type

Private muPreviewSize As PreviewSize
Private Const cmChangeSize = 1.2

'// 縮小
Private Sub Command1_Click()
With muPreviewSize
.intZoon = .intZoon - 1
.sngHeight = .sngHeight / cmChangeSize
.sngWidth = .sngWidth / cmChangeSize

imgPreview.Stretch = True
imgPreview.Move .sngLeft, .sngTop, .sngWidth, .sngHeight

'// 如果已經縮小了9倍則縮小按鈕不可用
If .intZoon < -9 Then
Command1.Enabled = False
Command2.Enabled = True
Else
Command2.Enabled = True
End If
End With
End Sub

'// 放大
Private Sub Command2_Click()
With muPreviewSize
.intZoon = .intZoon + 1
.sngHeight = .sngHeight * cmChangeSize
.sngWidth = .sngWidth * cmChangeSize

imgPreview.Stretch = True
imgPreview.Move .sngLeft, .sngTop, .sngWidth, .sngHeight

'// 如果已經放大了9倍則放大按鈕不可用
If .intZoon > 9 Then
Command2.Enabled = False
Command1.Enabled = True
Else
Command1.Enabled = True
End If
End With
End Sub

Private Sub Form_Load()
With muPreviewSize
.intZoon = 0
'// + 0.5 為Image的邊框
.sngHeight = imgPreview.Height + 0.5
.sngWidth = imgPreview.Width + 0.5
.sngLeft = imgPreview.Left
.sngTop = imgPreview.Top
End With
End Sub

5. vb 如何放大或縮小圖片,用Picture控制項

用 PictureBox 肯定是可以的,但我猜想你只是想顯示一下而已,那為什麼不用 Image 控制項呢?
嘗試一下 Image 控制項的 Stretch 屬性吧。

閱讀全文

與vb中圖片放大縮小代碼相關的資料

熱點內容
司法考試哪個網站好 瀏覽:469
android搜索功能代碼 瀏覽:437
文件名如何沒有文字 瀏覽:601
吃雞地圖資源包文件路徑 瀏覽:267
cad文件轉移手機 瀏覽:733
指定區域網內文件delphi 瀏覽:638
蘋果5s充電介面維修 瀏覽:913
建行app怎麼老是信息填寫錯誤 瀏覽:832
羅技g903切換配置文件 瀏覽:649
游戲的數據在哪個英文文件夾 瀏覽:435
編程一般學什麼專業課 瀏覽:394
不屬於資料庫系統的主要組成部分 瀏覽:797
jdl是什麼網路詞 瀏覽:247
優酷的緩存視頻文件夾 瀏覽:842
jsp頁面獲取地址欄參數 瀏覽:893
怎麼帶小度app聽酷狗音樂的歌 瀏覽:17
icleanerpro白蘋果 瀏覽:786
2016年1024客戶端安卓 瀏覽:136
win7連接不了網路列印機共享的列印機 瀏覽:214
為啥電腦發文件是rtf格式 瀏覽:927

友情鏈接