WMF files give me 'Invalid picture' 
Author Message
 WMF files give me 'Invalid picture'

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



Sun, 04 Nov 2001 03:00:00 GMT  
 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



Sun, 04 Nov 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Run-time error '481' : Invalid picture

2. Project file...contains invalid key 'Retained'

3. Runtime error '321' Invalid file format

4. Project file...contains invalid key 'Retained'

5. '|' in sql query gives - Error 3075 - 'Invalid use of vertical bars...'

6. '|' in sql query gives - Error 3075 - 'Invalid use of vertical bars...'

7. Bound Picture control in VB3: can't display picture from .MDB file

8. Loading .wmf file into .res file and using in picture control

9. Union query gives 'Too few parameters'

10. Socket creation, 'invalid param' error

11. error '800a0bb9' - Invalid Argument

12. Run-time error '5': Invalid procedure call or argument

 

 
Powered by phpBB® Forum Software