ASP Painter
Home
Home
Samples
Samples
Purchase
Purchase
Download
Download
Documentation
Documentation


ASPPainter::Matrix::Matrix.vbs

							
'============================================================
'Sample Matrix.vbs

'Using this sample it is possible to change values of each color channel.


' You can apply linear transformations (rotation, scaling, and the like) to color
' vectors by multiplying by a 4x4 matrix. However, you cannot use a 4x4 matrix
' to perform a translation (nonlinear). If you add a dummy fifth coordinate (for example,
' the number 1) to each of the color vectors, you can use a 5x5 matrix to apply any
' combination of linear transformations and translations. A transformation consisting
' of a linear transformation followed by a translation is called an affine transformation.
' A 5x5 matrix that represents an affine transformation is called a homogeneous matrix
' for a 4-space transformation. The element in the fifth row and fifth column of a 5x5
' homogeneous matrix must be 1, and all of the other entries in the fifth column.


' The following sample shows how to change alpha channel value for the whole image to blend
' with another image. Two images are created initially, then alpha channel value of the
' second image is reduced by a half (matrix value with index (4,4)), and images are blended.
' On the output image you can see that the first line can be seen through the second line. '============================================================
Dim im
Dim mc(5,5)


Set im = CreateObject("ASPPainter.Pictures.1")
im.SetBKColor 255,255,255,0
im.Create 200,100
im.SetColor 255,255,0,255
im.SetLineWidth 5
im.DrawLine 0,0,200,100
im.SetFormat 0
im.SaveToFile "C:\matrix.png"

For i = 1 to 5
For j = 1 to 5
mc(i,j) = 0.0
next
next
For j = 1 to 5
mc(j,j) = CInt(1)
next

mc(4,4) = 0.5

im.SetImageIndex 1
im.SetBKColor 255,255,255,0
im.Create 200,100

im.SetColor 0,255,0,255
im.SetLineWidth 10
im.DrawLine 0,100,200,0
im.SaveToFile "C:\matrix1.png"

'im.SetImageIndex
'im.BlendImage 0,1,0,0,0,0,200,100
'im.SaveToFile "C:\matrix2.png"

im.SetColorMatrix mc
im.DrawColorMatrix 0,1,0,0,0,0,200,100 ,200,100

im.SetFormat 0
im.SetImageIndex 0
im.SaveToFile "C:\matrix3.png"
im.DestroyALL
Set im = Nothing
Picture 1. matrix.png Picture 2. matrix2.png Picture 3. matrix3.png

More samples:

Arc, Beziers, Circle, Ellipse, Line, Pie, Rectangle, Unclosed polygon

See also:

SetHTMLColor, SetBKColor, Create, SetColor , SetLineWidth , DrawArc , DrawFilledRectangle , DrawBezier , DrawCircle , DrawFilledCircle , DrawEllipse , DrawFilledEllipse , DrawRectangle , DrawUnclosedPolygon , SaveToFile , DestroyALL



home samples purchase documentation download