How to use exportfile() ?

Just starting out? Need help? Post your questions and find answers here.
User avatar
T4r4ntul4
Posts: 132
Joined: Wed May 21, 2014 1:57 pm
Location: Netherlands
Contact:

How to use exportfile() ?

Post by T4r4ntul4 »

example from the docs with exportfile() function at the end
both not working:

Code: Select all

ExportFile(0, "image/png", #PB_LocalFile) ; not working
ExportFile(ImageID(0), "image/png", #PB_LocalFile) ; not working

Code: Select all

If OpenWindow(0, 100, 200, 300, 200, "2D Drawing Test", #PB_Window_Background)

  ; Create an offscreen image, with a green circle in it.
  ; It will be displayed later
  ;
  
  If CreateImage(0, 200, 200)
    If StartDrawing(ImageOutput(0))
      Box(0, 0, 300, 300, RGB(230,230,230))  ; Set the background to white
            
      Circle(100,100,50,RGB(0,0,255))  ; a nice blue circle...

      Box(150,20,20,20, RGB(0,255,0))  ; and a green box
      
      FrontColor(RGB(255,0,0)) ; Finally, red lines..
      For k=0 To 20
        LineXY(10,10+k*8,200, 0)
      Next
      
      DrawingMode(#PB_2DDrawing_Transparent)
      BackColor(RGB(0,155,155)) ; Change the text back and front colour
      FrontColor(RGB(0,0,0)) 
      Text$ = "Hello World !"
      
      LoadFont(0, "times", 30)
      DrawingFont(FontID(0))
      
      DrawText(10, 150, Text$)
      
      StopDrawing()
    EndIf
  EndIf

  ; Create a gadget to display our nice image
  ;  

  ImageGadget(0, 0, 0, 300, 200, ImageID(0))

  ExportFile(0, "image/png", #PB_LocalFile) ; not working
  ExportFile(ImageID(0), "image/png", #PB_LocalFile) ; not working
  
  
EndIf

falsam
Posts: 288
Joined: Mon May 05, 2014 9:49 pm
Location: France
Contact:

Re: How to use exportfile() ?

Post by falsam »

Code: Select all

If OpenWindow(0, 100, 200, 300, 200, "2D Drawing Test", #PB_Window_Background)

  ; Create an offscreen image, with a green circle in it.
  ; It will be displayed later
  ;
  
  If CreateImage(0, 200, 200)
    If StartDrawing(ImageOutput(0))
      Box(0, 0, 300, 300, RGB(230,230,230))  ; Set the background to white
            
      Circle(100,100,50,RGB(0,0,255))  ; a nice blue circle...

      Box(150,20,20,20, RGB(0,255,0))  ; and a green box
      
      FrontColor(RGB(255,0,0)) ; Finally, red lines..
      For k=0 To 20
        LineXY(10,10+k*8,200, 0)
      Next
      
      DrawingMode(#PB_2DDrawing_Transparent)
      BackColor(RGB(0,155,155)) ; Change the text back and front colour
      FrontColor(RGB(0,0,0)) 
      Text$ = "Hello World !"
      
      LoadFont(0, "times", 30)
      DrawingFont(FontID(0))
      
      DrawText(10, 150, Text$)
      
      StopDrawing()
    EndIf
  EndIf

  ; Create a gadget to display our nice image
  ;  

  ImageGadget(0, 0, 0, 300, 200, ImageID(0))

  ExportImage(0, "test.png", #PB_ImagePlugin_PNG)
EndIf

➽ Windows 11 - jdk-11.0.2 - SB 3.10 - Android 16
https://falsam.com

Sorry for my poor english
User avatar
Peter
Posts: 1197
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: How to use exportfile() ?

Post by Peter »

Code: Select all

ExportImage(0, "YourPic.png", #PB_ImagePlugin_PNG)
Greetings ... Peter

Edit: To late... :)
User avatar
T4r4ntul4
Posts: 132
Joined: Wed May 21, 2014 1:57 pm
Location: Netherlands
Contact:

Re: How to use exportfile() ?

Post by T4r4ntul4 »

Ah cool, never seen exportimage function, thnx for the quick help!
Post Reply