Saving API Drawings to a BMP or Converting from WMF to BMP 
Author Message
 Saving API Drawings to a BMP or Converting from WMF to BMP

Hi,

Does anyone know how to easily convert a Metafile to a Bitmap using VB.

Actually, it is not necessarily from a Metafile since I have a Handle on
a Picture control on which I send some Graphical API functions (LineTo,
MoveTo, etc ...).I use then deviceContext to create the Metafile.

Thanks for the suggestions. Selim



Tue, 29 Feb 2000 03:00:00 GMT  
 Saving API Drawings to a BMP or Converting from WMF to BMP

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



Quote:
> Hi,

> Does anyone know how to easily convert a Metafile to a Bitmap using VB.

> Actually, it is not necessarily from a Metafile since I have a Handle on
> a Picture control on which I send some Graphical API functions (LineTo,
> MoveTo, etc ...).I use then deviceContext to create the Metafile.

> Thanks for the suggestions. Selim



Tue, 29 Feb 2000 03:00:00 GMT  
 Saving API Drawings to a BMP or Converting from WMF to BMP

You need to set the picturebox autoredraw = true _before_ you draw on it.

Jim Deutch
MS Dev MVP



Quote:
> > 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 ...



Sat, 04 Mar 2000 03:00:00 GMT  
 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



Sat, 04 Mar 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Q: VB 4.0 32-bit, convert WMF to BMP

2. Convert BMP to WMF from script

3. Convert BMP to WMF

4. How to convert bmp to wmf?

5. Converting DXF files to .WMF or .BMP files

6. saving picture control to BMP or WMF

7. How to save WMF to BMP without PictureBox Control

8. Convert color BMP to black and white BMP

9. BMP 24-bit to BMP 1-bit converting

10. Convert 16 bit bmp to 24 bit bmp

11. Convert 24bit Bmp to 16bit BMP

12. save bmp in same depth as loaded bmp

 

 
Powered by phpBB® Forum Software