⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 本文件包含200个visual baisc实例
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "获取图片像素值"
   ClientHeight    =   3285
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5100
   Icon            =   "Form1.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   3285
   ScaleWidth      =   5100
   StartUpPosition =   1  '所有者中心
   Begin VB.PictureBox Picture1 
      BackColor       =   &H00C0C0FF&
      BorderStyle     =   0  'None
      Height          =   2310
      Left            =   1425
      Picture         =   "Form1.frx":000C
      ScaleHeight     =   2310
      ScaleWidth      =   2190
      TabIndex        =   2
      Top             =   165
      Width           =   2190
   End
   Begin VB.CommandButton Command1 
      Caption         =   "获取图片像素"
      Height          =   495
      Left            =   1020
      TabIndex        =   1
      Top             =   2655
      Width           =   1455
   End
   Begin VB.CommandButton Command2 
      Caption         =   "退出"
      Height          =   495
      Left            =   2670
      TabIndex        =   0
      Top             =   2655
      Width           =   1455
   End
   Begin VB.Label Label1 
      BackStyle       =   0  'Transparent
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00808000&
      Height          =   2250
      Left            =   855
      TabIndex        =   4
      Top             =   240
      Width           =   240
   End
   Begin VB.Label Label2 
      BackStyle       =   0  'Transparent
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00808000&
      Height          =   2250
      Left            =   3915
      TabIndex        =   3
      Top             =   240
      Width           =   240
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'API函数声明
Private Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
Private Declare Function GetBitmapBits Lib "gdi32" (ByVal hBitmap As Long, ByVal dwCount As Long, lpBits As Any) As Long
'变量数据结构的声明
Private Type BITMAP
        bmType As Long
        bmWidth As Long
        bmHeight As Long
End Type
Private Sub Form_Load()
'载入图片
  Picture1.Picture = LoadPicture(App.Path & "\back1.bmp")
'控件大小自适应图片
  Picture1.AutoSize = True
End Sub

Private Sub Command1_Click()
'定义变量
  Dim myBitmap As Long
  Dim val As Long
  Dim bmp As BITMAP
'获得pictureBox中画的句柄。
  myBitmap = Picture1.Picture.Handle
'取得BitMap的结构。
  val = GetObject(myBitmap, Len(bmp), bmp)
  'bitmap高为多少Pixels
  Label1.Caption = "图像高为 " & bmp.bmHeight & " 像素"
'BitMap宽为多少pixels
  Label2.Caption = "图像宽为 " & bmp.bmWidth & " 像素"
End Sub

Private Sub Command2_Click()
'退出程序
  End
End Sub


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -