begin process at 2010 02 10 09:55:56
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

API

 > CONVERTIR UN WMF EN EMF

CONVERTIR UN WMF EN EMF


 Information sur la source

Note :
Aucune note
Catégorie :API Classé sous :convertir, wmf, emf Niveau :Expert Date de création :28/05/2002 Date de mise à jour :28/05/2002 16:04:20 Vu :3 041

Auteur : daveCrocket

Ecrire un message privé
Commentaire sur cette source (0)
Ajouter un commentaire et/ou une note

 Description

Voici du code que j'ai trouvé sur le net et qui sert, comme le titre l'indique, à convertir un fichier WMF en EMF.
Le seul problème c'est que je ne sais pas comment l'utiliser :o(

Je fais donc appel à toute personne qui pourrait mettre un projet (qui utilise ce code) dans lequel on sélectionne un fichier WMF, le prog le transforme, et l'enregistre en EMF.

Je pense que ce code pourra être utile à certains d'entre vous (et je l'espère).

Merci d'avance.

Source

  • Private Const MM_ANISOTROPIC = 8
  • '...
  • Private Type SMALL_RECT
  • Left As Integer
  • Top As Integer
  • Right As Integer
  • Bottom As Integer
  • End Type
  • '...
  • Private Type METAHEADER
  • mtType As Integer
  • mtHeaderSize As Integer
  • mtVersion As Integer
  • mtSize As Long
  • mtNoObjects As Integer
  • mtMaxRecord As Long
  • mtNoParameters As Integer
  • End Type
  • Private Type APMHEADER
  • dwKey As Long
  • hMF As Integer
  • rcBounds As SMALL_RECT
  • wInch As Integer
  • dwReserved As Long
  • wChecksum As Integer
  • End Type
  • Private Const SIZEOF_APMHEADER = 22
  • Private Const APMHEADER_KEY = &H9AC6CDD7
  • '...
  • Private Type METAFILEPICT
  • mm As Long
  • xExt As Long
  • yExt As Long
  • hMF As Long
  • End Type
  • '...
  • Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
  • Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
  • Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hDC As Long) As Long
  • Private Declare Function SetWinMetaFileBits Lib "gdi32" (ByVal cbBuffer As Long, lpbBuffer As Byte, ByVal hdcRef As Long, lpmfp As METAFILEPICT) As Long
  • '...
  • Private Function OpenAPM(ByVal Path As String) As Long ' Returns an EMF handle
  • On Error GoTo Err_OpenAPM
  • Dim hEmf As Long
  • hEmf = 0
  • Dim hDC As Long
  • hDC = 0
  • Dim lBytes As Long, aBytes() As Byte, lBase
  • ' TODO: Read the file into aBytes()
  • '...
  • ' Open the file for binary access
  • Dim hFile As Long
  • Dim Hdra As METAHEADER
  • Dim mtSize As Long
  • Dim hMF As Long
  • hFile = FreeFile
  • Dim FileName As String
  • FileName = "c:\carte.wmf"
  • Open FileName For Binary Access Read As #hFile
  • ' Scan past APMFILEHEADER (22 bytes), and
  • ' grab METAHEADER.
  • Get #hFile, 23, Hdra
  • ' The size field contains number of WORDs
  • ' in metafile,we need to double for number
  • ' of bytes.
  • Hdra.mtSize = Hdra.mtSize * 2
  • ' Grab actual metafile data. Need to back
  • ' up to beginning of header.
  • ReDim aBytes(1 To Hdra.mtSize) As Byte
  • Get #hFile, 23, aBytes
  • ' Done with file now.
  • Close hFile
  • lBase = LBound(aBytes)
  • lBytes = UBound(aBytes) - LBound(aBytes) + 1
  • Dim Hdr As APMHEADER
  • If lBytes >= SIZEOF_APMHEADER Then
  • CopyMemory Hdr, aBytes(lBase), SIZEOF_APMHEADER
  • End If
  • If Hdr.dwKey = APMHEADER_KEY Then
  • Dim mfp As METAFILEPICT
  • With mfp
  • .mm = MM_ANISOTROPIC
  • .xExt = Hdr.rcBounds.Right - Hdr.rcBounds.Left
  • If .xExt < 0 Then .xExt = -1 * .xExt
  • .xExt = (2540 / Hdr.wInch) * .xExt
  • .yExt = Hdr.rcBounds.Bottom - Hdr.rcBounds.Top
  • If .yExt < 0 Then .yExt = -1 * .yExt
  • .yExt = (2540 / Hdr.wInch) * .yExt
  • End With
  • hDC = GetDC(0)
  • If 0 <> hDC Then
  • hEmf = SetWinMetaFileBits(lBytes - SIZEOF_APMHEADER, aBytes(lBase + SIZEOF_APMHEADER), hDC, mfp)
  • End If
  • End If
  • OpenAPM = hEmf
  • GoTo Exit_OpenAPM
  • Err_OpenAPM:
  • GoTo Exit_OpenAPM
  • Exit_OpenAPM:
  • If (0 <> hDC) Then
  • ReleaseDC 0, hDC
  • End If
  • End Function
Private Const MM_ANISOTROPIC = 8
'...
Private Type SMALL_RECT
Left As Integer
Top As Integer
Right As Integer
Bottom As Integer
End Type
'...
Private Type METAHEADER
   mtType As Integer
   mtHeaderSize As Integer
   mtVersion As Integer
   mtSize As Long
   mtNoObjects As Integer
   mtMaxRecord As Long
   mtNoParameters As Integer
End Type

Private Type APMHEADER
dwKey As Long
hMF As Integer
rcBounds As SMALL_RECT
wInch As Integer
dwReserved As Long
wChecksum As Integer
End Type
Private Const SIZEOF_APMHEADER = 22
Private Const APMHEADER_KEY = &H9AC6CDD7
'...
Private Type METAFILEPICT
mm As Long
xExt As Long
yExt As Long
hMF As Long
End Type
'...
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hDC As Long) As Long
Private Declare Function SetWinMetaFileBits Lib "gdi32" (ByVal cbBuffer As Long, lpbBuffer As Byte, ByVal hdcRef As Long, lpmfp As METAFILEPICT) As Long
'...
Private Function OpenAPM(ByVal Path As String) As Long ' Returns an EMF handle
On Error GoTo Err_OpenAPM

Dim hEmf As Long
hEmf = 0

Dim hDC As Long
hDC = 0

Dim lBytes As Long, aBytes() As Byte, lBase

' TODO: Read the file into aBytes()
'...
' Open the file for binary access
Dim hFile As Long

   Dim Hdra As METAHEADER
   Dim mtSize As Long
   Dim hMF As Long
   hFile = FreeFile
   Dim FileName As String
   FileName = "c:\carte.wmf"
   Open FileName For Binary Access Read As #hFile

   ' Scan past APMFILEHEADER (22 bytes), and
   ' grab METAHEADER.
   Get #hFile, 23, Hdra

   ' The size field contains number of WORDs
   ' in metafile,we need to double for number
   ' of bytes.
   Hdra.mtSize = Hdra.mtSize * 2

   ' Grab actual metafile data. Need to back
   ' up to beginning of header.
   ReDim aBytes(1 To Hdra.mtSize) As Byte
   Get #hFile, 23, aBytes

   ' Done with file now.
   Close hFile


lBase = LBound(aBytes)
lBytes = UBound(aBytes) - LBound(aBytes) + 1

Dim Hdr As APMHEADER
If lBytes >= SIZEOF_APMHEADER Then
CopyMemory Hdr, aBytes(lBase), SIZEOF_APMHEADER
End If
If Hdr.dwKey = APMHEADER_KEY Then
Dim mfp As METAFILEPICT
With mfp
.mm = MM_ANISOTROPIC
.xExt = Hdr.rcBounds.Right - Hdr.rcBounds.Left
If .xExt < 0 Then .xExt = -1 * .xExt
.xExt = (2540 / Hdr.wInch) * .xExt

.yExt = Hdr.rcBounds.Bottom - Hdr.rcBounds.Top
If .yExt < 0 Then .yExt = -1 * .yExt
.yExt = (2540 / Hdr.wInch) * .yExt
End With

hDC = GetDC(0)
If 0 <> hDC Then
hEmf = SetWinMetaFileBits(lBytes - SIZEOF_APMHEADER, aBytes(lBase + SIZEOF_APMHEADER), hDC, mfp)
End If
End If

OpenAPM = hEmf
GoTo Exit_OpenAPM

Err_OpenAPM:
GoTo Exit_OpenAPM

Exit_OpenAPM:
If (0 <> hDC) Then
ReleaseDC 0, hDC
End If
End Function



 Sources de la même categorie

Source avec Zip Source avec une capture Source .NET (Dotnet) FAIRE LA DIFFÉRENCE ENTRE UNE ADRESSE EMAIL QUI EXISTE D'UNE... par lesinfosdugeek
ENVOYER UN MESSAGE SUR SON COMPTE TWITTER par lesinfosdugeek
Source avec Zip Source avec une capture TROUVER LES CLÉS DE REGISTRE QUI CHANGENT par Flocreate
Source avec Zip IP_PUBLIQUE_INTERNETGETCONNECTEDSTATE par marco62118
Source avec Zip TOUTES LES RÉSOLUTIONS D'ÉCRAN ET TAILLE MAXI DE LA FORM AUD... par marco62118

 Sources en rapport avec celle ci

Source avec Zip Source avec une capture Source .NET (Dotnet) CONVERTIR FORMAT IMAGE par Le Pivert
Source avec Zip Source avec une capture BMP VERS ICO par jl315
Source avec Zip CONVERTIR VOS VIDÉOS POUR TOMTOM par Renfield
Source avec Zip CRÉER UN(DES) RENDEZ-VOUS/ DEMANDE(S) DE RÉUNION À PARTIR D'... par tomlaptop76
Source avec Zip CONVERTIR UN NOMBRE ENTRE 1 ET 999999999.99 EN LETTRES par welcometomyheaven

Commentaires et avis

Aucun commentaire pour le moment.

 Ajouter un commentaire


Discussions en rapport avec ce code source dans le forum

convertir un WMF (aldus placeable Metafile) en WMF (Window Metafile) [ par philippeb ] Bonjour !Je cherche une façon de convertir un WMF (aldus Metafile) en WMF (Window Metafile) en vb. J'ai trouver une façon en C mais je me suis pas vra Dessin en WMF ou EMF [ par Buz ] Bonjour,Je souhaite sauvegarder les dessins vectoriels que j'effectue à l'écran dans un fichier dessin WMF ou EMF, de manière à les réimporter dans Wo convertir une image .emf en .jpg [ par dimitriour ] bonjour,je cherche un exécutable pour convertir une image .emf en .jpg avec la possibilité de choisir le ratio de compression pour ne pas trop dégrade convertir le contenu d'un textbox en entier [ par beet2che ] bonjourest ce que l'instruction me permet de convertir le contenu du textbox en entier :Dim nserie As<font size="2 convertir vb 6 vers vb 2008 [ par informatixa ] Bonjour j'aimerais convertir ces code vb6Open file_lag$ For Binary As #Numf        Get #Numf, 4, lo&amp;        Get #Numf, , t%        Get #Numf, , ve Problème de conversion [ par jabaka ] Bonjour j'ai un petit problème avec un script que j'essai de convertir en visual basic je sais que le problème est surement ridicule mais je me lance. convertir a une application MS Access a une application de VB.net [ par fouad11 ] j ai fais une application avec  MS Access est je veux la convertir a une applicat convertir une date en un entier [ par kryshnar ] bonjour, je cherche a convertir une date en entier savant que pour le "30/12/1899" correspond la valeur "0"Merci de votre aide. convertir pourcentage / degré sous excel [ par dama78 ] Je cherche la formule pour convertir une pente de toit exprimée en pourcentage en degré ou vis et versa.Merci de votre aide PROJET URGENT: Convertir un pdf vers format lisible en vbscript [ par neocam ] Bonjour, Pour expliquer simplement je décris mon but rechercher... Je reçois un pdf, a l'intérieur de se dernier la première ligne correspond a une


Nos sponsors


Sondage...

CalendriCode

Février 2010
LMMJVSD
1234567
891011121314
15161718192021
22232425262728

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,655 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales