home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 6 / mastvb6.iso / ch_code / ch13 / copypix / copypixform.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-04-28  |  3.2 KB  |  100 lines

  1. VERSION 5.00
  2. Begin VB.Form CopyPixForm 
  3.    Caption         =   "Pixel Copy"
  4.    ClientHeight    =   6390
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   6615
  8.    LinkTopic       =   "Form1"
  9.    PaletteMode     =   1  'UseZOrder
  10.    ScaleHeight     =   6390
  11.    ScaleWidth      =   6615
  12.    StartUpPosition =   3  'Windows Default
  13.    Begin VB.CommandButton Command2 
  14.       Caption         =   "Copy API"
  15.       BeginProperty Font 
  16.          Name            =   "Verdana"
  17.          Size            =   9.75
  18.          Charset         =   0
  19.          Weight          =   400
  20.          Underline       =   0   'False
  21.          Italic          =   0   'False
  22.          Strikethrough   =   0   'False
  23.       EndProperty
  24.       Height          =   375
  25.       Left            =   4680
  26.       TabIndex        =   3
  27.       Top             =   5880
  28.       Width           =   1815
  29.    End
  30.    Begin VB.PictureBox Picture2 
  31.       Height          =   3015
  32.       Left            =   120
  33.       ScaleHeight     =   197
  34.       ScaleMode       =   3  'Pixel
  35.       ScaleWidth      =   285
  36.       TabIndex        =   2
  37.       Top             =   3240
  38.       Width           =   4335
  39.    End
  40.    Begin VB.CommandButton Command1 
  41.       Caption         =   "Copy VB"
  42.       BeginProperty Font 
  43.          Name            =   "Verdana"
  44.          Size            =   9.75
  45.          Charset         =   0
  46.          Weight          =   400
  47.          Underline       =   0   'False
  48.          Italic          =   0   'False
  49.          Strikethrough   =   0   'False
  50.       EndProperty
  51.       Height          =   375
  52.       Left            =   4680
  53.       TabIndex        =   1
  54.       Top             =   5280
  55.       Width           =   1815
  56.    End
  57.    Begin VB.PictureBox Picture1 
  58.       Height          =   3015
  59.       Left            =   120
  60.       Picture         =   "CopyPixForm.frx":0000
  61.       ScaleHeight     =   197
  62.       ScaleMode       =   3  'Pixel
  63.       ScaleWidth      =   285
  64.       TabIndex        =   0
  65.       Top             =   120
  66.       Width           =   4335
  67.    End
  68. Attribute VB_Name = "CopyPixForm"
  69. Attribute VB_GlobalNameSpace = False
  70. Attribute VB_Creatable = False
  71. Attribute VB_PredeclaredId = True
  72. Attribute VB_Exposed = False
  73. Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
  74. Private Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
  75. Private Declare Function GetNearestColor Lib "gdi32" (ByVal hdc As Long, ByVal crColor As Long) As Long
  76. Private Sub Command1_Click()
  77. Dim i As Integer, j As Integer
  78. Dim clrValue As Long
  79.     Picture2.Cls
  80.     For i = 0 To Picture1.ScaleWidth - 1
  81.         For j = 0 To Picture1.ScaleHeight - 1
  82.             clrValue = Picture1.Point(i, j)
  83.             Picture2.PSet (i, j), clrValue
  84.         Next
  85.         'DoEvents
  86.     Next
  87. End Sub
  88. Private Sub Command2_Click()
  89. Dim i As Integer, j As Integer
  90. Dim clrValue As Long
  91.     For i = 0 To Picture1.ScaleWidth - 1
  92.         For j = 0 To Picture1.ScaleHeight - 1
  93.             SetPixel Picture2.hdc, i, j, GetPixel(Picture1.hdc, i, j)
  94.         Next
  95.     Next
  96. End Sub
  97. Private Sub Form_Load()
  98. Picture2.Picture = Picture1.Picture
  99. End Sub
  100.