HBITMAP DPlot_GetBitmapEx(int DocNum, int cx, int cy, DPLOT_PLOTMETRICS *DPM);

Parameters
DocNumDocument index for the document that you want a bitmap picture of (1-32). In practice this will generally (though not necessarily) be the return value of a call to DPlot_Plot.
cx, cyRequested width and height of the bitmap, in pixels.
*DPMAddress of a DPLOT_PLOTMETRICS structure (see below). The size member of this structure should be set by the caller prior to calling this function. If *DPM is set to NULL, this information is not returned and this function is identical to DPlot_GetBitmap.

Return Values
  0 Generic error attempting to communicate with DPlot. This most often indicates that DPlot is currently busy, e.g. a modal dialog box is open.
<>0 Handle to a device-dependent bitmap. This picture may be drawn in your application with the Windows API functions BitBlt and/or StretchBlt

Remarks
Palette information is not returned, so this function does not work particularly well with 256 (or fewer) color displays.

DPLOT_PLOTMETRICS
 
In C:

typedef struct tagDPLOT_PLOTMETRICS
{
    DWORD   size;       // Size of this structure
    DWORD   hll;        // horizontal and
    DWORD   vll;        //  vertical coordinates of the lower left corner of
                        //  the plot, in pixels
    DWORD   hur;        // horizontal and
    DWORD   vur;        //  vertical coordinates of the upper right corner of
                        //  the plot, in pixels
    float   xlo;        // value of x at the left plot extent
    float   ylo;        // value of y at the bottom plot extent
    float   xhi;        // value of x at the right plot extent
    float   yhi;        // value of y at the top plot extent
} DPLOT_PLOTMETRICS
In Visual Basic:
Type DPLOT_PLOTMETRICS
    size As Long    ' size of this structure
    hll As Long     ' horizontal and
    vll As Long     '  vertical coordinates of the lower left corner of
                    '  the plot, in pixels
    hur As Long     ' horizontal and
    vur As Long     '  vertical coordinates of the upper right corner of
                    '  the plot, in pixels
    xlo As Single   ' value of x at the left plot extent
    ylo As Single   ' value of y at the bottom plot extent
    xhi As Single   ' value of x at the right plot extent
    yhi As Single   ' value of y at the top plot extent
End Type

Using DPLOT_PLOTMETRICS
The information returned in this structure can be used to translate pixel coordinates (mouse position, for example) into X,Y coordinates in data space. The btest2 Visual Basic and ctest2 C demos illustrate this functionality for linear scales. Translating pixels to X and Y for various scaling types is described below in Visual Basic terminology. In all cases, x and y are the pixel coordinates of interest (0,0 is at the upper left corner of the bitmap), wx and wy are the translated X and Y values; DPM is the DPLOT_PLOTMETRICS structure returned by DPlot_GetBitmapEx. Reverse scaling probability plots is outside the scope of this documentation.
 
Linear X:

    wx = DPM.xlo + (x - DPM.hll) * (DPM.xhi - DPM.xlo) /(DPM.hur - DPM.hll)
Linear Y:
    wy = DPM.ylo + (y - DPM.vll) * (DPM.yhi - DPM.ylo) / (DPM.vur - DPM.vll)
Logarithmic X:
    wx = DPM.xlo * (DPM.xhi/DPM.xlo) ^ ( (x-DPM.hll)/(DPM.hur-DPM.hll) )
Logarithmic Y:
    wy = DPM.ylo * (DPM.yhi/DPM.ylo) ^ ( (y-DPM.vll)/(DPM.vur-DPM.vll) )
Polar coordinates:
    xp = ( x - ( DPM.hll +DPM.hur )/2. ) * 2.0 * _
         ( DPM.yhi - DPM.ylo ) / ( DPM.hur - DPM.hll ) + DPM.ylo
    yp = ( y - ( DPM.vll +DPM.vur )/2. ) * 2.0 * _
         ( DPM.yhi - DPM.ylo ) / ( DPM.vur - DPM.vll ) + DPM.ylo 
    If xp = 0 Then
      If yp < 0 Then
        alpha = -90
      Else
        alpha = 90
      End If
    Elseif xp < 0 then
      alpha = atn(yp/xp) * 180. / PI - 180.
    Else
      alpha = atn(yp/xp) * 180. / PI
    End If
    If alpha < 0. Then
      alpha = 360 + alpha
    End If
    radius = sqr(xp^2 + yp^2)
Triangle plot:
    wy = 100 * (DPM.vll-y) / (DPM.vll-DPM.vur)
    wx = 100 * ( (x-DPM.hll) - 0.01*wy*(DPM.vll-DPM.vur)*0.5773502691896) / _
               (DPM.hur-DPM.hll)
N185 Hydraulic scale:
    wx = ( (x - DPM.hll) * (DPM.xhi^1.85 - DPM.xlo^1.85) / _
         (DPM.hur-DPM.hll) + DPM.xlo^1.85 )^(1.0/1.85)

 

 
Previous Home Next DPlot Home