Saving ImageGadget picture to disk?

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

Anyone know how to save an ImageGadget's picture to disk? Thanks!


PB - Registered PureBasic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Paul.

SaveImage(#id,"Picture.bmp")
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.
SaveImage(#id,"Picture.bmp")
Yep, tried that already, but doesn't work. Gives an error of "#Image object
not initialized", even though I can see the pic on the ImageGadget...


PB - Registered PureBasic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Paul.

Works fine here...

Code: Select all

LoadImage(1,"c:\picture.bmp")

InitGadget(1)
If OpenWindow(0,10,10, 300, 300, #PB_Window_SystemMenu,"Test")   
  If CreateGadgetList(WindowID()) 
    ImageGadget(1,10,10,50,50,UseImage(1))      
  EndIf 
EndIf

Repeat 
  EventID.l = WaitWindowEvent()
           
    If EventID=#PB_EventCloseWindow
      SaveImage(1,"C:\picture.bmp")
      quit=1
    EndIf
   
Until quit=1
End
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.
Works fine here...
LoadImage(1,"c:\picture.bmp") [...]
Ta -- but I neglected to mention that I was using your clipboard-to-ImageGadget
code, rather than loading the pic from disk first. So, do you know a way to save
an ImageGadget's pic to disk, based on the ImageGadget getting its pic from the
clipboard?

PB - Registered PureBasic Coder

Edited by - PB on 23 January 2002 20:51:21
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.

That's a problem!

First create a Image with: CreateImage -> but you don't know the real size of your clipboard image.

Then copy the clipboard image to the Image created with CreateImage -> no PureB command available for that.
After that you can save it to disk with SaveImage...

We need solutions for:
get the size of a pasted clipboard image
copy the pasted clipboard image to a new created image.

New command needed: CreateImageFromMemory(@image)
If you need the size for further use: we have ImageWidth and ImageHeight

Or/And a command like: SaveImageFromMemory(@image)

Have a nice day...
Franco

Sometimes you have to go a lonely way to accomplish genius things.

Edited by - franco on 23 January 2002 22:08:58
Post Reply