Home > Software engineering >  VB images about o RBG one component of the sum of values in a range.
VB images about o RBG one component of the sum of values in a range.

Time:10-09

DIB is utilized to extract the image pixels in a colout array, is implemented,
R=colout (2, x, y)
G=colout (1, x, y)
B=colout (0, x, y)
For example I asked (2, 4) to (7, 9) within the scope of the sum of r component, algorithm is how to write

CodePudding user response:

(2, 4) (7, 9) is a diagonal matrix

CodePudding user response:

Public Sub Mosaic ()
Dim r As Long
Dim g As Long
Dim w As Long
Dim h As Long

W=Text1. Text
H=Text2. Text
Row=Int (Picture1. ScaleWidth/w)
Lin=Int (Picture1. ScaleHeight/h)
Rl=Picture1. ScaleWidth Mod h
Ll=Picture1. ScaleHeight Mod w
For y=0 To Step (Lin - 1) * h h
For x=0 To Step (row 1) * w w
For k=x To w - 1
For j=y To h - 1
R=ColOut (2, k, j)
G=ColOut (1, k, j)
B=ColOut (0, k, j)
Next j
Next k
For k=x To w - 1
For j=y To h - 1
ColOut (2, k, j)=r/(w * h)
ColOut (1, k, j)=g/(w * h)
ColOut (0, k, j)=b/(w * h)
Next j
Next k
Picture2. Refresh
Next x

If rl & lt;> 0 Then
Xl=Picture1. ScaleWidth - rl
For k=x To xl - 1
For j=y To h - 1
R=ColOut (2, k, j)
G=ColOut (1, k, j)
B=ColOut (0, k, j)
Next j
Next k
For k=x To xl - 1
For j=y To h - 1

ColOut (2, k, j)=r/(xl * h)
ColOut (1, k, j)=g/(xl * h)
ColOut (0, k, j)=b/(xl * h)
Next k
Next j
Picture2. Refresh
End the If
Next y


If ll & lt;> 0 Then
Yl=Picture. ScaleHeight - ll
For x=0 To Step (row 1) * w w
For k=x To w - 1
For j=y To yl - 1
R=ColOut (2, k, j)
G=ColOut (1, k, j)
B=ColOut (0, k, j)
Next j
Next k
For k=x To w - 1
For j=y To yl - 1

ColOut (2, k, j)=r/w * yl)
ColOut (1, k, j)=g/(w * yl)
ColOut (0, k, j)=b/(w * yl)
Next k
Next j
Picture2. Refresh
End the If
Next x

If rl & lt;> 0 Then
Xl=Picture1. ScaleWidth - rl
Yl=Picture. ScaleHeight - ll
For k=x To xl - 1
For j=y To yl - 1
R=ColOut (2, k, j)
G=ColOut (1, k, j)
B=ColOut (0, k, j)
Next j
Next k
For k=x To xl - 1
For j=y To yl - 1

ColOut (2, k, j)=r/(xl * yl)
ColOut (1, k, j)=g/(xl * yl)
ColOut (0, k, j)=b/(xl * yl)
Next k
Next j
Picture2. Refresh
End the If
End the If
End Sub
This short program where went wrong

CodePudding user response:


Public Sub Mosaic ()
Dim r As Long
Dim g As Long
Dim w As Long
Dim h As Long

W=Text1. Text
H=Text2. Text
The row=Int (Picture1. ScaleWidth/w) 'Mosaic column number 1
Lin=Int (Picture1. ScaleHeight/h) 'Mosaic line number 1
Rl=Picture1. ScaleWidth Mod h 'remaining pieces of the number of columns in
Ll=Picture1. ScaleHeight Mod w 'remaining pieces of the number of rows in the
For y=0 To Step (Lin - 1) * h h
For x=0 To Step (row 1) * w w
For k=x To w - 1
For j=y To h - 1
R=ColOut (2, k, j)
G=ColOut (1, k, j)
B=ColOut (0, k, j)
Next j
Next k
For k=x To w - 1
For j=y To h - 1
ColOut (2, k, j)=r/(w * h)
ColOut (1, k, j)=g/(w * h)
ColOut (0, k, j)=b/(w * h)
Next j
Next k
Picture2. Refresh
Next x

If rl & lt;> 0 Then
Xl=Picture1. ScaleWidth - rl
For k=x To xl - 1
For j=y To h - 1
R=ColOut (2, k, j)
G=ColOut (1, k, j)
B=ColOut (0, k, j)
Next j
Next k
For k=x To xl - 1
For j=y To h - 1

ColOut (2, k, j)=r/(xl * h)
ColOut (1, k, j)=g/(xl * h)
ColOut (0, k, j)=b/(xl * h)
Next k
Next j
Picture2. Refresh
End the If
Next y


If ll & lt;> 0 Then
Yl=Picture. ScaleHeight - ll
For x=0 To Step (row 1) * w w
For k=x To w - 1
For j=y To yl - 1
R=ColOut (2, k, j)
G=ColOut (1, k, j)
B=ColOut (0, k, j)
Next j
Next k
For k=x To w - 1
For j=y To yl - 1

ColOut (2, k, j)=r/w * yl)
ColOut (1, k, j)=g/(w * yl)
ColOut (0, k, j)=b/(w * yl)
Next k
Next j
Picture2. Refresh
End the If
Next x

If rl & lt;> 0 Then
Xl=Picture1. ScaleWidth - rl
Yl=Picture. ScaleHeight - ll
For k=x To xl - 1
For j=y To yl - 1
R=ColOut (2, k, j)
G=ColOut (1, k, j)
B=ColOut (0, k, j)
Next j
Next k
For k=x To xl - 1
For j=y To yl - 1

ColOut (2, k, j)=r/(xl * yl)
ColOut (1, k, j)=g/(xl * yl)
ColOut (0, k, j)=b/(xl * yl)
Next k
Next j
Picture2. Refresh
End the If
End the If
End Sub
Something wrong












  •  Tags:  
  • API
  • Related