Transpic Control
 
BurdickSoft 
(www.burdicksoft.com)

The BurdickSoft Transpic Control is a Visual Basic developed ActiveX component that dramatically improves the ease of manipulating and animating transparent bitmaps. It works just like the standard Visual Basic PictureBox control except that it allows pictures to be displayed transparently.  There are three transparency modes:  Opaque makes the control non-transparent.  Control Transparent makes the Transpic Control image transparent with respect to the form it is placed on.  Form Transparent makes the transpic control transparent with respect to the screen so the user actually sees the desktop display behind the form.  The user does not have to create transparent masks to use this control. Instead, a mask color is specified which automatically converts the picture to a transparent bitmap. Transpic works with any Visual Basic recognized graphics type including .bmp, .gif, and jpeg.  The Transpic control utilizes a companion Background Control which handles all of the Form and Screen background bitmap processing.

Using the Transpic Control

Installing the Transpic Control - Copy the Transpic.ocx and the companion Background.ocx files to your Windows/System directory and then load/register the control in the VB IDE by going to the "Project/Components" menu and loading Transpic.ocx and Background.ocx

Loading Images - After both controls have been  has been loaded into the VB IDE, you should see both the Transpic Control  icon in the toolbar palette as well as the Background Control icon.  Click and place both of them on a form. To load an image, click "Picture" in the Transpic Properties Box and select the file ( .bmp, .dib .gif, .jpg, and .wmf file types are supported). The picture will load into the Transpic control and be resized according to the size of the loaded picture.

Setting Transparency - There are two or possibly three things the user must do to turn the loaded picture into a transparent picture. First, the Transpic  "Backstyle" property must be set to "0 - ControlTransparent" (this is the default value) or "1-FormTransparent". Secondly, the user must enter or select the desired transparency color in the "Mask Color" property (the default is white). Thirdly, if the user wished to employ "Form Transparent" mode, the name of the Background Control that Transpic will use to create backgrounds must be set in the Transpic.BackGroundControl property.

How Transparency Works -  The Transpic control employs three different transparency modes based on how the TransPic.Backstyle property is set.  Depending on the BackStyle setting, intermediate bitmaps used to construct the transparent image may be created and saved in memory.   After creation, each of the intermediate bitmaps have a public Display Context (Hdc) property and Picture Method which can be accessed by the User or the Transpic Control for fast transparency processing or other interesting effects. There are 5 distinct intermediate bitmap images that are required to construct and display a transparent image which are accessible to the user via either the bitmap hDC property or bitmap Picture property.


Transpic Intermediate Bitmaps
 ImageBitmap  This is the source image of the picture loaded into the Transpic Control
 MaskBitmap  The mask used to punch a hole in the ImageBitmap
 InvertBitmap  The inverse of the mask used to set the transparent regions transparent
 BackgroundBitmap  The background image behind the picture image.  This is either the Form image
 if BackStyle is set to "0 - ControlTransparent" or the Screen image if the
 BackStyle is set to "1 - FormTransparent"
 TransparentBitmap  The finished transparent image

Transpic Transparency Modes

Opaque Transparency : Here, the background style of Transpic is set to "2 - Opaque" which is essentially no transparency.  When this mode is set, the intermediate bitmaps are destroyed if they are present.  Generally, there is no need to keep the intermediate bitmaps around if the control is Opaque.  However, the intermediate bitmaps can be re-created if desired by invoking the Transpic.CreateBitmaps method.  If called, this method will create bitmaps that are Control Transparent - meaning that the background image is assumed to be the Form surface that the control is placed on.  Any drawing operations to the surface of the control cover the entire control.  A Background Control object is not required in this mode.

 Control Transparency : Here, the background style of Transpic is set to "0 - ControlTransparent".  When this mode is set, any pixel in the loaded picture that is the same as the Transpic.MaskColor is set to invisible.  The background image used is the Form background including all underlying controls beneath the transpic control.  This mode does not create intermediate bitmaps.  Instead, it sets the background of the Transpic Control canvas to transparent using standard VB UserControl attributes and methods.  Intermediate bitmaps can be re-created if desired by invoking the Transpic.CreateBitmaps
method. If called, this method will create bitmaps that are Control Transparent - meaning that the background image is assumed to be the Form surface that the control is placed on. Any drawing operations to the surface of the control cover just the non-transparent regions of the control.  A Background Control object is not required in this mode.

 Form Transparency : Here, the background style of Transpic is set to "1 - FormTransparent".  When this mode is set, any pixel in the loaded picture that is the same as the Transpic.MaskColor is set to invisible.  The background image used is the Screen background which includes anything that is displayed behind the Form that the Transpic control is placed on.  This mode does create intermediate bitmaps and requires that a Background Control is placed on the Form and set in the Transpic.BackgroundControl property. If the Form containing the Transpic control is moved in a way that requires the background image of the control  to be regenerated, the application designer invokes the Transpic.RefreshTransparency method to regenerate  the image.   Any drawing operations to the surface of the control cover the entire control.  

Transpic Transparency Modes Summary
Mode  Intermediate Bitmaps Created Background Control Required Transparency 
Update Handling
Background Bitmap Used
2 - Opaque  No  No   Not Applicable None
0 - ControlTransparent  No  No   Automatic Form
1 - FormTransparent  Yes  Yes

Automatic for control  movement in Form, otherwise controlled by user.

Screen


Background Control - 
The Background Control is a separate control that is used as a companion to the Transpic Control.  The reason for having a separate Background Control is that it allows multiple Transpic Controls to be placed on the same Form and use the same set of background bitmaps without having to continually re-create the background image.  This dramatically improves the performance of transparency when using FormTransparency mode.  The Background Control is a windowless control (like the VB Timer Control) that can be placed anywhere on the same form used by the Transpic Control(s).  It contains the following properties and methods:

Name Type Arguments Description
 FormDC Property (Long)
Read-Only 

 None

Returns Device Context (hDC) handle of the Form Background.  If the FormDC has not yet been created, it will be generated automatically by invoking the RefreshForm method.. 
 FormPic Property(Picture)
Read-Only
PictureWidth As Variant [Optional] PictureHeight As Variant [Optional] SourceX As Variant [Optional] SourceY As Variant [ Optional] Returns a Picture Object containing the Form Background BackGround.  If the FormDC has not yet been created, it will be generated automatically by invoking the RefreshForm method
PictureWidth,PictureHeight  Desired width and height of returned picture object in pixels.  If omitted the whole Form picture is returned.
SourceX,SourceY Desired upper left point on the Form in pixels from where the picture object will be generated.  If omitted, 0, 0 is assumed (e.g. the upper left corner of the Form). 
 ScreenDC Property (Long)
Read-Only 

None

Returns Device Context (hDC) handle of the Screen Background.  The SceenDC is created automatically wherever the control is first loaded in Design-Time or Run-Time.  
 ScreenDC Property(Picture)
Read-Only
PictureWidth As Variant [ Optional] PictureHeight As Variant [Optional] SourceX As Variant [ Optional] SourceY As Variant [ Optional] Returns a Picture Object containing the Screen Background 
PictureWidth,PictureHeight  Desired width and height of returned picture object in pixels.  If omitted the whole Screen picture is returned.
SourceX,SourceY Desired upper left point on the Form in pixels from where the Screen picture object will be generated.  If omitted, 0, 0 is assumed (e.g. the upper left corner of the Form). 
RefreshForm Method

None

Creates a new Form Image background bitmap.  It does this by temporarily making all the Transpic Controls on the Form invisible, and then captures the Form Image.
RefreshScreen Method

None

Creates a new Screen Image background bitmap.  It does this by temporarily making all the Form invisible, and then captures the Screen Image.

 


Transpic Control - 
The Transpic Control contains most of the same characteristics as the standard VB PictureBox Control.  Listed below are the Properties, Methods and Events that are unique to Transpic:

Name Type Arguments/Constants Description
 About Property 
(Integer)
Read/Write 

 DisplayVersion = 0
 DisplayHelp = 1

DisplayVersion (0): Displays Transpic Version Info
DisplayHelp (1): Displays this Help page
 Background 
 Bitmap
Property
(Picture)
Read-Only

None

Returns a Picture Object containing the image background of the Transpic Control.  Requires that an active Background Control object is set for the control,  otherwise and error is returned.
 Background
 Control
Property 
(String)
Read/Write 

None

Sets/Gets the name of Background Control object used with the Transpic Control.  In design mode, a property page is used to display all valid Background Controls identified on the form. 
 Background
 Style
Property 
(Integer)
Read/Write 
ControlTransparent = 0
FormTransparent = 1
Opaque = 2
Sets/Gets the Background Style of the control. 
ControlTransparent (0) is the default.  If FormTransparent (1) is set, a valid Background Control object must be specified to display the Screen Background.  Setting the BackgroundStyle to either 0 or 2 destroys any existing intermediate bitmaps.  Setting the BackgroundStyle to 1 automatically creates intermediate bitmaps.
 BitampsCreated Property
(Boolean)
Read-Only

None

Returns True if  intermediate bitmaps have been created for the control.  Returns False if they have not been created or have been destroyed.  Note:  If the Transpic BackgroundStyle is set to FormTransparent (1), intermediate bitmaps are created automatically.  All bitmaps are destroyed automatically upon unloading the Transpic Control in design and run-time modes.
 ImageBitmap
 InvertBitmap
 MaskBitmap
 TransparentBitmap
Property
(Bitmap Object)
Read-Only

 hDC (Long)
 hgt (Long)
 wth (Long)
 Picture (PictureObject)

Returns a custom bitmap object of the specified bitmap.
hDC: the Device Context handle.  Useful for Windows API bitblt operations.
hgt: the height of the bitmap in pixels
wth: the width of the bitmap in pixels
Picture: returns a picture object of the bitmap
Generates an error message if the bitmap requested has not been created or has been destroyed.
 MaskColor Property
(Ole Color)
Read/Write

None

Sets/Gets the Transpic Mask Color to use for constructing transparent regions of the picture image.  Any pixel of the picture using this mask color with be set to invisible (transparent).  The BackgroundStyle of the control must be set to either ControlTransparent (0) or FormTransparent (1) to view transparency.
PicLeft
PicTop
Property
(Long)
Read-Only

None

Returns the upper left dimension of the Transpic client area in pixels relative to the Form.  This is useful for Windows API bitblt or picture object creation methods.
ScaleMode Property
(Integer)
Read-Only

None

Unlike the VB PictureBox, this property is hard-coded to vbPixels (3) which makes transparency and scaling operations consistent with Windows API operations requiring pixel formats.

 

Name Type Syntax/Description
 CreateBitmaps
 DestroyBitmaps

Method 

object.CreateBitmaps
object.DestroyBitmaps


Creates or Destroys intermediate bitmaps.  Note:  The Transpic Control handles most intermediate bitmap creation and destruction operations automatically.  These methods are provided for the application developer to use as they wish.  All bitmaps are destroyed when the Transpic control is unloaded.

 Draw Arc

Method

object.DrawArc   X , Y , Radius, StartPos, EndPos, [Color],[Aspect]

Draws arcs in the Transpic Control.  Similar to the VB circle method.

 Part  Description
 X (single)  The left coordinate of the arc centerpoint.
 Y (single)  The top coordinate of the arc centerpoint.
Radius (single) Value indicating the radius of the arc.  The ScaleMode property of object determines the unit of measure used.
StartPos (single) Single-precision values. Start position in radians for the arc.  The range is –2 pi radians to 2 pi radians. 
EndPos (single) Single-precision values. End position of the arc. The range  is –2 pi radians to 2 pi radians. 
Color (variant) Optional. Variant value indicating the RGB color of the circle's outline. If omitted, the value of the ForeColor property is used. You can use the RGB function or QBColor function to specify the color.
 Aspect (single) Optional. Single-precision value indicating the aspect ratio of the circle. The default value is 1.0, which yields a perfect (non-elliptical) circle on any screen.
 DrawBox

Method 

object.DrawBox   X1, Y1, X2, Y2, [Fill]

Draws boxes  in the Transpic control.  Similar to the VB line BF  method.

 Part  Description
 X1, Y1, X2, Y2 (single) Single values indicating the diagonal coordinates of the starting and ending point for the box..  The ScaleMode property determines the unit of measure used.  
 Fill (boolean) True = Fill the box
False = Don't fill
 DrawCircle   

Method 

object.DrawCircle   X , Y , Radius, [Color],[ Aspect]

Draws circles in the TransPic control.  Similar to the VB circle method.

 Part  Description
 X (single)  The left coordinate of the arc centerpoint.
 Y (single)  The top coordinate of the arc centerpoint.
Radius (single) Value indicating the radius of the arc.  The ScaleMode property of object determines the unit of measure used.
Color (variant) Optional. Variant value indicating the RGB color of the circle's outline. If omitted, the value of the ForeColor property is used. You can use the RGB function or QBColor function to specify the color.
 Aspect (single) Optional. Single-precision value indicating the aspect ratio of the circle. The default value is 1.0, which yields a perfect (non-elliptical) circle on any screen.
 DrawLine

Method

object.DrawLine   X1, Y1, X2, Y2, Radius, [Fill]

Draws lines  in the TransPic control.  Similar to the VB line  method.

 Part  Description
 X1, Y1, X2, Y2 (single) Single values indicating the diagonal coordinates of the starting and ending point for the box.. The ScaleMode property determines the unit of measure used. 
 Position

Method

object.Position  Xpos,Ypos

Moves the Transpic Control to the specified Form position.  If the BackgroundStyle is set to FormTransparent (1), then control transparency is also refreshed.

 Part  Description
 Xpos (long)
 Ypos (long)
Long values indicating the diagonal coordinates of the starting and ending point for the box.. The ScaleMode property of the Form determines the unit of measure used. 
 RefreshTransparency

Method

object.RefreshTransparency

Recomputes and displays Transpic transparency.  Usually, this is only necessary if the Form or Screen Background changes.

 

 

Contact BurdickSoft: