Available in the LEADTOOLS Imaging toolkit. |
UpdateMagGlassExt method (Main Control)
Visual
Basic example
Visual
C++ 4.0 example
Syntax short UpdateMagGlassExt (VARIANT vColorBuffer, VARIANT vMaskPlane, long nMaskPlaneStart, long nMaskPlaneEnd, BOOL bUpdateBitmap);
Overview: Refer to Using the Magnifying Glass
Remarks
Updates the bitmap that the Magnifying Glass displays in the zoomed Magnifying Glass display area.
This method can only be called if the MagGlassExt event has been enabled by setting the EnableMagGlassEvent property to TRUE. If the EnableMagGlassEvent property has been set to TRUE, information about the non-updated parts of the bitmap, can be obtained from the MagGlassExt event. This information can then be used with LEADTOOLS Internet methods, available in the Multimedia/Internet toolkits, to fill a vColorBuffer with pixel values for the non-updated parts of the bitmap. Once this needed data is received, it can be sent to this method to update the bitmap that the Magnifying Glass displays in the zoomed Magnifying Glass display area. For an example, refer to the Ltnetcomn.hlp help file in the HELP directory.
The vColorBuffer can also be filled without using the LEADTOOLS Internet methods. Match vMaskPlane to the original bitmap and fill vColorBuffer with the corresponding pixel colors. The following example explains this procedure.
The figure below represents a bitmap 29 pixels wide and 20 pixels high. The pixels are represented by the small blue squares.
Enable the occurrence of the MagGlassExt event by setting the EnableMagGlassEvent property to TRUE and start the Magnifying Glass. When the left mouse button is pressed while moving the mouse over the bitmap, a MagGlassExt event is generated and receives the (nMaskPlaneStart, nMaskPlaneEnd, vMaskPlane) information. Each time a MagGlassExt event is generated, it indicates that part of the bitmap needs to be updated. The bitmap can be updated by calling the UpdateMagGlassExt method with the nMaskPlaneStart, nMaskPlaneEnd and vMaskPlane received by the MagGlassExt event.
The large black squares in the figure above represent portions of the bitmap. Each portion can contain a maximum of 64 pixels (8 by 8). Occasionally, portions may have less than 64 pixels, especially those portions at the edge of the bitmap. Each portion is represented by 1 bit of the bytes in the vMaskPlane array.
For example, if the Magnifying Glass is moved over the bitmap from pixel coordinate (9, 3), shown in red in the image above, to (28, 17), shown in green in the image above, then the following portions are affected: 1, 2, 3, 5, 6, 7, 9, 10 and 11.
Therefore, 9 portions are represented in the vMaskPlane. Each portion is represented by 1 bit within the vMaskPlane. Therefore, 2 bytes are needed in the vMaskPlane to represent the 9 portions of the bitmap. Each portion will be mapped to a byte in the vMaskPlane array as follows:
Portion Number |
Bit Index |
Byte Index |
1 |
0 |
0 |
2 |
1 |
0 |
3 |
2 |
0 |
5 |
3 |
0 |
6 |
4 |
0 |
7 |
5 |
0 |
9 |
6 |
0 |
10 |
7 |
0 |
11 |
0 |
1 |
So, the vMaskPlane received from the MagGlassExt event will contain 2 bytes. Each bit of those 2 bytes will be filled with zero or one indicating whether or not the portion has been updated. The nMaskPlaneStart parameter of the callback will equal 1 and the nMaskPlaneEnd parameter will equal 11.
The next step is to check each bit value. If the bit value is 1 the corresponding portion needs to be updated, so vColorBuffer must be filled with the corresponding pixel colors. Start with the portion indicated in nMaskPlaneStart. In this example that is portion number 1. If the bit representing portion 1 has a value of 1, then the vColorBuffer should be filled with the corresponding pixels from the original bitmap. You must always start filling the vColorBuffer array from the first pixel in the portion. For portion 1, the first pixel has coordinates (8, 0). Move through the row until the last pixel of that portion is reached. In this case, the last pixel in the first row of portion 1 has coordinates (15, 0). Next, move to the next row and add the pixel colors of this row to vColorBuffer. Continue in this manner until the last pixel of the portion is reached. In this example the last pixel in portion 1 has the coordinates (15,7).
Having finished one portion, move to the next portion. In this example the next portion is portion 2. Check the bit value in vMaskPlane for this portion. Suppose it has a bit value of 0. For this portion, do not fill vColorBuffer with the pixel colors of the original bitmap. Proceed through the remaining portions until the portion indicated by nMaskPlaneEnd is reached.
By following this procedure vColorBuffer can be filled with the necessary pixel colors and passed, along with other information, to this method (UpdateMagGlassExt) and used to update the zoomed image displayed in the Magnifying Glass display area.
If the bUpdateBitmap flag is set to TRUE, then the Main Control's bitmap will be updated.
See Also
Elements: StartMagGlass method, StopMagGlass method, EnableMagGlassEvent property, MagGlassExt event
Topics: Raster Images: Displaying Images