It is currently Tue Jun 18, 2019 9:52 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: How to use Wmf and Emf
PostPosted: Tue Dec 17, 2002 6:48 am 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777133
Code updated For 5.20+

Restored from previous forum. Originally posted by Mischa.


Hi!

Code:
Procedure MetaFileDraw(metafile.s,dc,x,y,b,h)
  If metafile
    WmfRect.RECT
    WmfRect\left=x
    WmfRect\top=y
    WmfRect\right=x+b-1
    WmfRect\bottom=y+h-1
    hmf = GetEnhMetaFile_(metafile)
    If hmf0
      PlayEnhMetaFile_(dc,hmf,WmfRect)
      DeleteEnhMetaFile_(hmf)
    Else
      hmf = GetMetaFile_(metafile)
      If hmf=0
        size=FileSize(metafile)-22
        ReadFile(1,metafile)
        FileSeek(1,22)
        *buffer=AllocateMemory(size,0)
        ReadData(1,*buffer,size)
        CloseFile(1)
      Else
        bytes = GetMetaFileBitsEx_(hmf, bytes,0)
        *buffer=AllocateMemory(bytes,0)
        GetMetaFileBitsEx_(hmf,bytes,*buffer)
      EndIf
      hemf = SetWinMetaFileBits_(size,*buffer,dc,0)
      PlayEnhMetaFile_(dc,hemf,WmfRect)
      DeleteEnhMetaFile_(hemf)
      DeleteMetaFile_(hmf)
    EndIf
  EndIf
EndProcedure

Procedure LoadAndSet()
  metafile.s=OpenFileRequester("Load Metafile", "", "Meta-File|*.wmf;*.emf", 0)
  dc=StartDrawing(ImageOutput(0))
  For k=0 To 250
    c.f+0.5:FrontColor(RGB(100+c,100,255-c))
    Line(0, k, 250, 0)
  Next
  MetaFileDraw(metafile,dc,0,0,250,250)
  StopDrawing()
  StartDrawing(WindowOutput(0))
  DrawImage(ImageID(1), 100, 50)
  StopDrawing()   
EndProcedure


hwnd=OpenWindow(0, 100, 100, 450, 400, "Metafiles", #PB_Window_SystemMenu)
id=CreateImage(1, 250, 250)
ButtonGadget(1, 150, 325, 150, 25, "Load Metafile")


Repeat
  EventID = WaitWindowEvent()
  If EventID = #PB_Event_Gadget
    Select EventGadget()
      Case 1:LoadAndSet()
    EndSelect
  EndIf
Until EventID = #PB_Event_CloseWindow



Mischa


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Dec 17, 2002 2:51 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777133
Restored from previous forum. Originally posted by TerryHough.

Thanks for this tip. I had asked a question about this earlier, but didn't get an answer at that time.

I will study this code and see if I can understand it enough to modify it for my needs.

Keep up the good work!

Terry


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye