Available in the LEADTOOLS Imaging toolkit. |
CreateBitmap, Size, and Combine example for Access 95 and 97
This example creates a bitmap for Lead2 (same size and BPS as Lead1) and fills it with green. It resizes the Lead1 bitmap, then uses a loop to do multiple combines with the Lead2 bitmap. It then copies the Lead2 bitmap to Lead1 and redisplays Lead1.
' Declare local variables
Dim MyWidth, MyHeight, MyBPS, ImageWidth, ImageHeight
Dim TestWidth, TestHeight, VFactor, VSpacing, HFactor, HSpacing
Dim SrcL, SrcT, SrcObj, DstT, DstL, DstW, DstH, MyOp, ViewWidth, ViewHeight
DoCmd.Hourglass True
Lead2.ScaleMode = 3
Lead1.ScaleMode = 3
' Create the Lead2 bitmap. (The control must already be on the form).
MyWidth = Lead1.BitmapWidth
MyHeight = Lead1.BitmapHeight
MyBPS = Lead1.BitmapBits
Lead2.CreateBitmap MyWidth, MyHeight, MyBPS
Lead2.Fill RGB(0, 255, 0) ' fill with green
' Resize the Lead1 bitmap
ImageWidth = CInt(MyWidth * 0.3)
ImageHeight = CInt(MyHeight * 0.3)
Lead1.Size ImageWidth, ImageHeight, RESIZE_RESAMPLE
' Initialize the variables used for multiple combines.
TestWidth = MyWidth ' Used for horizontal positioning
TestHeight = MyHeight ' Used for vertical positioning
VFactor = Int(MyHeight / ImageHeight) + 1 ' Number spaces between images
VSpacing = CInt((MyHeight Mod ImageHeight) / VFactor) ' Pixels between images
HFactor = Int(MyWidth / ImageWidth) + 1 ' Number spaces between images
HSpacing = CInt((MyWidth Mod ImageWidth) / HFactor) ' Pixels between images
DstT = VSpacing ' Top coordinate of the destination rectangle
SrcL = 0 ' Left coordinate of the source rectangle
SrcT = 0 ' Top coordinate of the source rectangle
SrcObj = Lead1.Bitmap
DstW = ImageWidth ' Width of the destination rectangle
DstH = ImageHeight ' Height of the destination rectangle
MyOp = CB_OP_ADD + CB_DST_0 ' Operation flags used when combining images
' Do the loop that does the multiple combines
While TestHeight > ImageHeight ' Vertical loop
DstT = MyHeight - TestHeight + VSpacing
TestHeight = TestHeight - ImageHeight - VSpacing
While TestWidth > ImageWidth 'Horizontal loop
DstL = MyWidth - TestWidth + HSpacing
TestWidth = TestWidth - ImageWidth - HSpacing
Lead2.Combine DstL, DstT, DstW, DstH, SrcObj, SrcL, SrcT, MyOp
Wend
TestWidth = MyWidth
Wend
' Copy the Lead2 bitmap to Lead1
Lead1.Bitmap = Lead2.Bitmap
'Get the pixel dimensions of the LEAD control's client area.
ViewWidth = Lead1.ScaleWidth
ViewHeight = Lead1.ScaleHeight
'Set the image display size to match the LEAD control
Lead1.SetDstRect 0, 0, ViewWidth, ViewHeight
Lead1.SetDstClipRect 0, 0, ViewWidth, ViewHeight
Lead1.ForceRepaint ' Repaint the image
DoCmd.Hourglass False