
WMF files give me 'Invalid picture'
wmf files come in several flavors. Let's assume it's _not_ an enhanced
metafile (though they are seen with the .wmf extension): that reduces
it to two flavors.
APM (Aldus Placeable) metafiles have an extra 22-byte header compared
to non-APM metafiles. VB requires that header for the LoadPicture()
function to work (same at design time). Other programs may not.
You can tell if a wmf has an APM header: if it does, the first four
bytes are
Chr(215) + Chr(205) + Chr(198) + Chr(154)
You can add an APM header if you need one. This is old 16-bit code I
picked up somewhere, but it illustrates what's needed:
' The first three variables may NOT be changed
APMKey = Chr(215) + Chr(205) + Chr(198) + Chr(154)
APMHandle = Chr(0) + Chr(0)
APMReserved = Chr(0) + Chr(0) + Chr(0) + Chr(0)
' The following may be changed
APMX1 = 0
APMY1 = 0
APMX2 = 2000
APMY2 = 2000
APMInch = 900
APMCheckSum = -12841 Xor -25914 Xor 0 Xor APMX1 Xor APMY1 Xor APMX2
Xor APMY2 Xor APMInch Xor 0 Xor 0
outfile = FreeFile
Open File_Out For Binary Access Write As #outfile
' Save 22-byte APM header variables to new file
Put #outfile, , APMKey
Put #outfile, , APMHandle
Put #outfile, , APMX1
Put #outfile, , APMY1
Put #outfile, , APMX2
Put #outfile, , APMY2
Put #outfile, , APMInch
Put #outfile, , APMReserved
Put #outfile, , APMCheckSum
Follow this with the rest of the metafile, and you've got an APM
metafile that VB is happy with.
Jim Deutch
MS Dev MVP
Quote:
> What possible explanation does anyone have for the error message
'Invalid
> picture' when I attempt to load a WMF file into a VB6 Picture box??
> The file does not appear to be corrupted because I can load it into
Paint
> Shop Pro and import it into PowerPoint.
> I would appreciate any help in this matter.
> Thanks,
> Chris Morris
> TrustNet Limited