如何在VB中实现更改分辨率?

 我来答
百度网友d8f3578
2008-02-29 · TA获得超过652个赞
知道小有建树答主
回答量:100
采纳率:0%
帮助的人:117万
展开全部
Private Sub Command1_Click()
Dim red As Integer
Dim green As Integer
Dim blue As Integer
Dim c1, c2 As Long
Dim i, j As Integer
For i = 1 To Picture1.Width - 2 Step 4
For j = 1 To Picture1.Height - 2 Step 4
c1 = Picture1.Point(i, j)
red = c1 And &HFF
green = (c1 And 62580) / 256
blue = (c1 And &HFF0000) / 65536
'颜色处理
Picture2.PSet (i, j), RGB(red, green, blue)
Picture2.PSet (i, j + 1), RGB(red, green, blue)
Picture2.PSet (i, j + 2), RGB(red, green, blue)
Picture2.PSet (i, j + 3), RGB(red, green, blue)

Picture2.PSet (i + 1, j), RGB(red, green, blue)
Picture2.PSet (i + 1, j + 1), RGB(red, green, blue)
Picture2.PSet (i + 1, j + 2), RGB(red, green, blue)
Picture2.PSet (i + 1, j + 3), RGB(red, green, blue)

Picture2.PSet (i + 2, j), RGB(red, green, blue)
Picture2.PSet (i + 2, j + 1), RGB(red, green, blue)
Picture2.PSet (i + 2, j + 2), RGB(red, green, blue)
Picture2.PSet (i + 2, j + 3), RGB(red, green, blue)

Picture2.PSet (i + 3, j), RGB(red, green, blue)
Picture2.PSet (i + 3, j + 1), RGB(red, green, blue)
Picture2.PSet (i + 3, j + 2), RGB(red, green, blue)
Picture2.PSet (i + 3, j + 3), RGB(red, green, blue)
Next
Next

End Sub

Private Sub Form_Load()
With Form1
.Caption = "降低分辨率"
.Height = 4800
.Left = 0
.Top = 0
.Width = 6000
.ScaleMode = 3 'Pixel
End With
With Command1
.Caption = "降低分辨率"
.Height = 40
.Left = 20
.Top = 250
.Width = 100
.Visible = True

End With
With Picture1
.AutoRedraw = True
.AutoSize = True
.Height = 220
.Left = 20
.ScaleMode = 3 'Pixel
.Top = 20
.Width = 200
End With
With Picture2
.AutoRedraw = True
.AutoSize = True
.Height = 220
.Left = 200
.ScaleMode = 3 'Pixel
.Top = 20
.Width = 180
End With
Picture1.Picture = LoadPicture(App.Path + "\xxx.bmp")
End Sub
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
百度网友6452b3628
2008-02-29 · TA获得超过1.7万个赞
知道大有可为答主
回答量:4881
采纳率:0%
帮助的人:5352万
展开全部
'这是我收集到的一个代码,主要是api ChangeDisplaySettings的应用
Option Explicit

Public oldwidth As Integer, oldheight As Integer, oldcolor As Integer, oldfreq As Long
Private Declare Function ChangeDisplaySettings Lib "user32.dll" Alias "ChangeDisplaySettingsA" (ByRef lpDevMode As DEVMODE, ByVal dwFlags As Long) As Long
Private Declare Function EnumDisplaySettings Lib "user32.dll" Alias "EnumDisplaySettingsA" (ByVal lpszDeviceName As String, ByVal iModeNum As Long, ByRef lpDevMode As DEVMODE) As Long
Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long
Private Const ENUM_CURRENT_SETTINGS = 1
Private Const BITSPIXEL = 12

Const DM_PELSHEIGHT As Long = &H100000
Const DM_PELSWIDTH As Long = &H80000
Const DM_BITSPERPEL As Long = &H40000
Const DM_DISPLAYFREQUENCY As Long = &H400000

Const CCHDEVICENAME As Long = 32
Const CCHFORMNAME As Long = 32
Const CDS_TEST = &H4
Const GDC_FREQ = 116

Private Type DEVMODE
dmDeviceName As String * CCHDEVICENAME
dmSpecVersion As Integer
dmDriverVersion As Integer
dmSize As Integer
dmDriverExtra As Integer
dmFields As Long
dmOrientation As Integer
dmPaperSize As Integer
dmPaperLength As Integer
dmPaperWidth As Integer
dmScale As Integer
dmCopies As Integer
dmDefaultSource As Integer
dmPrintQuality As Integer
dmColor As Integer
dmDuplex As Integer
dmYResolution As Integer
dmTTOption As Integer
dmCollate As Integer
dmFormName As String * CCHFORMNAME
dmUnusedPadding As Integer
dmBitsPerPel As Integer
dmPelsWidth As Long
dmPelsHeight As Long
dmDisplayFlags As Long
dmDisplayFrequency As Long
End Type
Private Sub Form_Activate()
'获得现实参数以便恢复
oldwidth = GetDisplayWidth
oldheight = GetDisplayHeight
getcolor
getfreq

Call initscreen
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
'按esc卸载窗体
If KeyAscii = 27 Then
Unload Me
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
'卸载时恢复原设定
restscreen
End Sub
Public Sub initscreen()
Dim nwidth As Long, nheight As Long, ncolor As Integer, nfreq As Long
nwidth = 800: nheight = 600: ncolor = 16: nfreq = 85
Call SetDisplaymode(nwidth, nheight, ncolor, nfreq)
End Sub
Public Sub restscreen()
Dim nwidth As Long, nheight As Long, ncolor As Integer, nfreq As Long
nwidth = oldwidth: nheight = oldheight: ncolor = oldcolor: nfreq = oldfreq
Call SetDisplaymode(nwidth, nheight, ncolor, nfreq)
End Sub
Public Function SetDisplaymode(LngWidth As Long, LngHeight As Long, IntColor As Integer, LngFrequency As Long) As Long
Dim newDevmode As DEVMODE
Dim lngP As Long
EnumDisplaySettings 0&, 0&, newDevmode
With newDevmode
.dmFields = DM_PELSHEIGHT Or DM_PELSWIDTH Or DM_BITSPERPEL Or DM_DISPLAYFREQUENCY
.dmPelsWidth = LngWidth
.dmPelsHeight = LngHeight
.dmBitsPerPel = IntColor
.dmDisplayFrequency = LngFrequency
End With
SetDisplaymode = ChangeDisplaySettings(newDevmode, CDS_TEST)
End Function
Public Function GetDisplayWidth() As Integer
On Error Resume Next
GetDisplayWidth = Screen.Width \ Screen.TwipsPerPixelX
End Function
Public Function GetDisplayHeight() As Integer
On Error Resume Next
GetDisplayHeight = Screen.Height \ Screen.TwipsPerPixelY
End Function
Public Function getfreq() As Integer
On Error Resume Next
oldfreq = GetDeviceCaps(Me.hdc, GDC_FREQ)
End Function
Public Sub getcolor()
On Error Resume Next
oldcolor = Format$(GetDeviceCaps(hdc, BITSPIXEL))
End Sub
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
手机用户98588
2008-02-29
知道答主
回答量:10
采纳率:0%
帮助的人:0
展开全部
Baidu,Google 应有尽有
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式