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

📄 马赛克出图效果.frm

📁 Windows API函数,希望大伙有用哦
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   3930
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5250
   LinkTopic       =   "Form1"
   ScaleHeight     =   284.736
   ScaleMode       =   0  'User
   ScaleWidth      =   356.052
   Begin VB.PictureBox Picture2 
      BorderStyle     =   0  'None
      Height          =   3945
      Left            =   0
      ScaleHeight     =   263
      ScaleMode       =   0  'User
      ScaleWidth      =   179.718
      TabIndex        =   1
      Top             =   0
      Width           =   5445
      Begin VB.Timer Timer1 
         Enabled         =   0   'False
         Interval        =   5
         Left            =   750
         Top             =   2490
      End
   End
   Begin VB.PictureBox Picture1 
      AutoRedraw      =   -1  'True
      BorderStyle     =   0  'None
      Height          =   3945
      Left            =   0
      Picture         =   "马赛克出图效果.frx":0000
      ScaleHeight     =   263
      ScaleMode       =   0  'User
      ScaleWidth      =   353
      TabIndex        =   0
      Top             =   0
      Visible         =   0   'False
      Width           =   5445
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
 Dim P1 As Integer, P2 As Integer
 Dim Px As Integer, Py As Integer
 Dim A() As Integer, X() As Integer, Y() As Integer
Dim D As Integer, I As Integer
Private Sub Form_Paint()
 Dim J As Integer, K As Integer, M As Integer, N As Integer
 Dim Nx As Integer, Ny As Integer, Dx As Integer
  N = 25
  M = N * Picture1.ScaleHeight / Picture1.ScaleWidth
  D = M * N
' 调整数组大小
  ReDim A(D) As Integer, X(D) As Integer, Y(D) As Integer
' 计算图块大小
  Dx = Picture1.ScaleWidth / N
  P1 = Dx
  P2 = Dx
' 按序号生成各图块坐标,以从左到右从上到下为序
     Ny = 0
      For I = 1 To M
        Nx = 0
       For J = 1 To N
        K = K + 1
        X(K) = Nx * Dx
        Y(K) = Ny * Dx
        Nx = Nx + 1
       Next J
       Ny = Ny + 1
      Next I
' 产生随机数数组
    Randomize Timer
      For I = 1 To D
X1:
        K = Int(Rnd(1) * D) + 1
        If A(K) <> 0 Then GoTo X1
        A(K) = I
      Next I
    Picture2.Cls
    I = 1
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
 If I > D Then
' 图块显示完毕停止定时
  Timer1.Enabled = False
   Else
' 根据随机数组的值,复制图块
  Px = X(A(I))
  Py = Y(A(I))
  BitBlt Picture2.hDC, Px, Py, P1, P2, Picture1.hDC, Px, Py, &HCC0020
  I = I + 1
 End If
End Sub

⌨️ 快捷键说明

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