Sample 6 - Filled rectangles and color manipulation

Filled rectangles, color manipulation

rectangle.vbs


Dim im
Set im = CreateObject("ActiveImage.Images.1")
im.CreateImage 170,1200
im.SetColor 255,255,255
im.Fill 0,0
im.SetFont 3 ' Tiny
x = 0
y = 0
d = 8

Dim c(5)
c(0) = 0
c(1) = 63
c(2) = 127
c(3) = 191
c(4) = 255


For r = 0 to 4
For g = 0 to 4
For b = 0 to 4

y = y + d
im.SetColor c(r),c(g),c(b)
im.DrawFilledRectangle x, y, x + 170, y + d
im.SetColor 255 - c(r), 255 - c(g), 255 - c(b)
im.DrawText x,y, "Red = " & im.GetPixelRed(x,y) & " Green = " & im.GetPixelGreen(x,y) & " Blue = " & im.GetPixelBlue(x,y)
next
next
next

im.WriteToFile "C:\rectangle.png"
im.SetImageType 1
im.SetJpegQuality 100
im.WriteToFile "C:\rectangle.jpg"
im.DestroyImage
Set im = Nothing


rectangle.jpg rectangle.png
Picture 1. rectangle.jpg (size - 250 Kb) Picture 2. rectangle.png (size - 27 Kb)

If you have any questions or bug reports, write to active.image@tonec.com for technical support.