ASPPainter Samples
Sample 6. Dynamic creation of images and loading of image into PictureBox using
OleLoadPicture (Visual Basic 6.0)
Loading and copying images
In order to use the component in VB, pick Project->References menu item and
add “ASP Painter” library.
'World Map.frm
' http://www.asppainter.com ASPPainter.dll
'
' ... SKIP
‘Create component
Set ai = CreateObject("ASPPainter.Pictures.1")
'Retrieve the path to the current directory
path = App.path
'Load world map pattern to the memory
ai.LoadFile path & "\Country\world.png"
'Find image height and width
w1 = ai.Width
h1 = ai.Height
'Load selected country as second image
ai.SetImageIndex 1
ai.LoadFile path & "\Country\" & idc & ".png"
xm = Datacoord(idc, 3) / 3
ym = Datacoord(idc, 4) / 3
xc = Datacoord(idc, 1) / 3
yc = Datacoord(idc, 2) / 3
'Determine country dimensions
w = ai.Width
h = ai.Height
'Copy transparent image of the country to the World Map
ai.Copy 0, 1, xm, ym, 0, 0, w, h
' Draw 2 lines that point to the country
ai.SetImageIndex 0
ai.SetColor 255, 0, 0, 255
ai.DrawLine 0, yc, w1, yc
ai.DrawLine xc, 0, xc, h1
' Set image format to GIF
ai.SetFormat 3
' Convert image and save it in array
data = ai.SaveToVariant
n = UBound(data) - LBound(data)
ReDim abFile(n)
For i = LBound(data) To UBound(data)
abFile(i - LBound(data)) = data(i)
Next
' Load the image into PictureBox using OleLoadPicture
Set MakeMap = PictureFromBits(abFile)
Set data = Nothing
' Delete all object and free allocated memory
ai.DestroyAll
 |
Figure 1. Sample6.gif(size - 12.4 Kb) |
Download project (128Kb
without ASPPainter.dll)