
Saving API Drawings to a BMP or Converting from WMF to BMP
Quote:
> I ain't tried this since VB3, but if my memory serves, you can do
> Picture1.AutoRedraw = True
> Picture1.Picture = Picture1.Image
> and then SavePicture will save a bitmap instead of a metafile.
> Another way would be to BitBlt() the picture into another (invisible
> autoredraw) picturebox and SavePicture that.
> Jim Deutch
> MS Dev MVP
> I ain't tried this since VB3, but if my memory serves, you can do
> Picture1.AutoRedraw = True
> Picture1.Picture = Picture1.Image
> and then SavePicture will save a bitmap instead of a metafile.
> Another way would be to BitBlt() the picture into another (invisible
> autoredraw) picturebox and SavePicture that.
> Jim Deutch
> MS Dev MVP
The trouble with this alternative is that the picture is then empty. I
suspect this is due to the fact that I directly send API functions to
the Handle of Metafile, and then use this handle on Metafile to assign
it to the picture DC.(I think that the code below is more self-speaking
then my fuzzy explanations). Apparently I will need to use the BitBlt
function ...
Here is the code:
Private Sub picGraph_Paint()
Dim voidL As Long
'
'Set the screen values to be able to play the
'Metafile
'
With picGraph
.Cls
.Visible = True
.ScaleMode = 3
End With
'
'Call the various drawing functions that are sent to a Metafile Handle
(myHMF)
'
Call graphF17(Me.Tag, picGraph.ScaleHeight, picGraph.ScaleWidth)
Call setTheViewPort(picGraph.hdc, picGraph.ScaleHeight,
picGraph.ScaleWidth)
voidL = PlayMetaFile(picGraph.hdc, myHMF)
voidL = DeleteMetaFile(myHMF)
myHMF = 0
Rem: This way to proceed is very flexible since I can use the Handle of
the metafile to draw the content on any picture control, file or
printer.
End Sub