How to embed an Image in the executable?

Just starting out? Need help? Post your questions and find answers here.
RobertRioja
User
User
Posts: 71
Joined: Thu May 02, 2019 3:57 am
Location: USA
Contact:

How to embed an Image in the executable?

Post by RobertRioja »

I have questions but I cannot find answers in the PB documentation.

How do I embed an image into the executable file? In other words, how do I put an image into a resource file in PB? And how do I get that image into an image button?

Thanks,
Robert
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: How to embed an Image in the executable?

Post by RSBasic »

Example:

Code: Select all

EnableExplicit

CatchImage(1, ?Logo)

If OpenWindow(0, 0, 0, 500, 400, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ButtonImageGadget(1, 10, 10, 50, 50, ImageID(1), 0)
  
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        End
    EndSelect
  ForEver
EndIf

DataSection
  Logo:
  IncludeBinary "D:\...\YourIcon.ico" ;-change the path
EndDataSection
Image
Image
User avatar
skywalk
Addict
Addict
Posts: 3999
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: How to embed an Image in the executable?

Post by skywalk »

Use:
DataSection
Image1: IncludeBinary File
EndDataSection
and
img_n = CatchImage(#PB_Any, ?Image_1) ; , img1_Size)

DOH! too late.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
RobertRioja
User
User
Posts: 71
Joined: Thu May 02, 2019 3:57 am
Location: USA
Contact:

Re: How to embed an Image in the executable?

Post by RobertRioja »

Thank you all for your replies.
Robert
Post Reply