begin process at 2012 02 17 05:17:20
  Trouver un code source :
 
dans
 
Accueil > Forum > 

Archive Visual Basic & VB.NET

 > 

Archives Visual Basic

 > 

API

 > 

Convertir un WMF en EMF


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

Convertir un WMF en EMF

mardi 28 mai 2002 à 15:56:57 | Convertir un WMF en EMF

daveCrocket

Bonjour à tous,
j'ai récupérer ce source pour transformer un wmf en emf, mais je ne sais pas comment je dois l'utiliser. Pouvez-vous m'aider ?

********************************
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
mardi 28 mai 2002 à 16:26:07 | Re : Convertir un WMF en EMF

VicoLaChips2

Salut.
Open "toto.wmf" For Binary As #1
Write #1, OpenAPM(CheminVersMonFichierEmf)

ça marche ??

@+
-------------------------------
Réponse au message :
-------------------------------

Bonjour à tous,
j'ai récupérer ce source pour transformer un wmf en emf, mais je ne sais pas comment je dois l'utiliser. Pouvez-vous m'aider ?

********************************
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

mardi 28 mai 2002 à 16:55:40 | Re : Convertir un WMF en EMF

daveCrocket

salut,
tu as réussi à le faire fonctionner ?
j'ai pas bien compris ta réponse.



-------------------------------
Réponse au message :
-------------------------------

Salut.
Open "toto.wmf" For Binary As #1
Write #1, OpenAPM(CheminVersMonFichierEmf)

ça marche ??

@+
-------------------------------
Réponse au message :
-------------------------------

Bonjour à tous,
j'ai récupérer ce source pour transformer un wmf en emf, mais je ne sais pas comment je dois l'utiliser. Pouvez-vous m'aider ?

********************************
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


vendredi 28 mars 2003 à 15:15:29 | Re : Convertir un WMF en EMF

fraisage2003


fraisage2003
j'aimerais savoir comment convertir un fichier WMF en EMF et pour convertir un fichier DXF en WMf ( voir en EMF )
merci d'avance

-------------------------------
Réponse au message :
-------------------------------

> Bonjour à tous,
> j'ai récupérer ce source pour transformer un wmf en emf, mais je ne sais pas comment je dois l'utiliser. Pouvez-vous m'aider ?
>
> ********************************
> 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
>


Cette discussion est classée dans : long, end, private, integer, apmheader


Répondre à ce message

Sujets en rapport avec ce message

conversion en .NET [ par Safireo ] slut tlm !je cherche à terminer la conversion de ce code en .net.j'arrive à éliminer les erreurs mais pas à faire fonctionner le logiciel qui doit me Problème avec les Threads et la fonction Creaobject [ par skirby ] Bonjour à tous, Voila, j'ai un gros problème avec les Thread sous VB 6. Plus précisément, c'est la fonction CreateObject dans la fonction de mon thre Non modal mais pas completement! [ par syl_silence ] J'ai un userform,  pour un fonctionnement avec Excel97, j'utilise un API  pour le rendre non modal. Lorsque je clic sur une cellule de la feuille d'e Problème Scrollbar et Mshflexgrid [ par allfab ] Bonjour à tous, J'écris ce message parce que j'ai un petit problème lorsque je saisis des données dans une mshflexgrid. J'utilise la méthode de place Textbox, la suite en plus clair.... [ par darkbol ] oui merciDonc je reprends mon probleme de mise à zéro de mes cases textbox... par un clic sur le bouton RESET.voici la portion de code concernée : O Retour du contenu d'une textbox (trivial?!) suite [ par darkbol ] oui merciDonc je reprends mon probleme de mise à zéro de mes cases textbox... par un clic sur le bouton RESET.voici la portion de code concernée : < winsock multiutilisateurs [ par ltvian ] bon ben voila le code de mon serveur winsock , mon problème est ke lorske je veux balancer le message par le bouton envoi , il n'y a k'un seul utilisa Créer un nouveau dossier avec boite de dialogue commune [ par JonasVB ] Bonjour, Je cherche un moyen d'afficher le bouton "Créer un nouveau dossier" dans la boite de dialogue "sélectionner un dossier"j'ai trouvé cette sour problème mot de passe [ par stargates ] J'ai confectionné un petit exécutable mot de passe et je le déploie avec installshield devstudio 9. Je l'ai installé sur un autre ordi. Tout fonctionn explication prog son [ par joxman ] bonjours  à tous j'ai  téléchargé un programme  que  mixe  2  wav  ca  marche  bien  c'est  super j'aimerai comprendre le programme je ne comprend pa


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

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