How to use graphics drawing library for PowerPoint VBA using GDI32 instructions

Settings for enabling use of VBA

To use VBA in PowerPoint, it is necessary to show the "Development" menu and set the security level of macros. Please refer to the written materials and information on the web for the operations required.

Embedding Graphics library for PowerPoint VBA using GDI32 instructions

Copy the source program of graphics drawing library by GDI32 instructions and paste to Module 2. You can also use an PowerPoint file that has the Graphics librarybuilt-in.

Fill in Module 1 with your own program.

Distribution of Graphics Drawing Libraryy for PowerPoint VBA

Notice

Get device context and assign to variable myhdc

Before calling InitializeGraphics, get the device context to output and assign it to public variable myhdc

Notes on using PointSet(pointing command)

The unit of pixels in this Graphics Libraryusing GDI32 instructions is set to pixels in accordance with the Graphics library using addShape function. However, the unit of the pixel of GDI32 instructions is point. Therefore, if you fill the surface with a set of points, spots may appear. Please be aware of differences between pixels and points。

To avoid spots, convert coordinates in pixel units to point units by multiplying by the constant Pt2Px (= 72/96) as follows:

'  ====  When the coordinate values are expressed in pixel units  =======
'   Conversion of coordinate value from point units to pixel units    ×72÷96
            px = i / Pt2Px: py = j / Pt2Px
            PointSet px, py, RGB(CR, CG, CB)
'  ====  When the coordinate values are expressed in point units  =======
'            PointSet i, j, RGB(CR, CG, CB)

<See> Display of an atomic orbital - Drawing with Pointset

It is possible to use the pixel reference of the whole library as a point by invalidating the part which is converting coordinates by point to pixel in Sub SetViewPort

Sub SetViewPort(ViewLeft, ViewTop, ViewRight, ViewBottom)
'  ====  Pixel units  =======
' Conversion of coordinate value from point units to pixel units × 96 ÷ 72
    gScreenXLeft = ViewLeft * Pt2Px
    gScreenYTop = ViewTop * Pt2Px
    gScreenXRight = ViewRight * Pt2Px
    gScreenYBottom = ViewBottom * Pt2Px
' -------------------------------------
' ====  Point units  =======
' When the coordinate values are expressed in point units, 
' change the above 4 lines to comment statements and validate the following 4 lines.
'    gScreenXLeft = ViewLeft
'    gScreenYTop = ViewTop
'    gScreenXRight = ViewRight
'    gScreenYBottom = ViewBottom
End Sub

if you select either pixel units or point units as the pixel reference, it does not affect how to draw lines, rectangles, circles, etc. other than PointSet.