Author Topic: Using BASIMAGE to embed images in InForm EXEs  (Read 4392 times)

0 Members and 1 Guest are viewing this topic.

Offline JohnJames

  • Newbie
  • Posts: 7
Using BASIMAGE to embed images in InForm EXEs
« on: May 29, 2020, 09:07:32 am »
Loving InForm. So good.

Placing an image is done by a link. If the EXE is run on another PC, that image path is lost and the EXE runs with a 'Missing Image' link error in its placeholder. In other words, the images are not embedded within the EXE.

Using 'BASIMAGE' in the QB64 code seems to be a possible way. It works perfectly in a separate QB64-only program but, in a QB64 program generated using InForm, it just doesn't work. Something to do with InForm constantly refreshing its canvas at run time 30 times a second?

Thanks,
John.


FellippeHeitor

  • Guest
Re: Using BASIMAGE to embed images in InForm EXEs
« Reply #1 on: May 29, 2020, 10:20:38 am »
Hello, there.

I actually use a variant of BASIMAGE I had come up with before Dav dropped his official solution, so it is possible.

Since you won't be loading the image with the default method, there's a bit of a hack involved to get it working.

Say you have a control named PictureBox1 and  you want to place an image you loaded using BASIMAGE, so you already have a valid image handle called img&, and you know beforehand your image is 16x16 pixels:

Code: QB64: [Select]
  1.     Control(PictureBox1).HelperCanvas = _NEWIMAGE(16, 16, 32)
  2.     _PUTIMAGE (0, 0), img&, Control(PictureBox1).HelperCanvas

Let me know if it works for you. That's how InForm has built-in images without external files too.

Quote
Loving InForm. So good.
♥️

Thank you for your interest in QB64+InForm.

Offline JohnJames

  • Newbie
  • Posts: 7
Re: Using BASIMAGE to embed images in InForm EXEs
« Reply #2 on: May 29, 2020, 11:50:46 am »
Thank you Fellippe. No, it doesn't seem to work, but probably me.

I am hacking the .frm code. Correct?

Code: QB64: [Select]
  1.     __UI_NewID = __UI_NewControl(__UI_Type_PictureBox, "PictureBox3", 400, 108, 410, 10, 0)
  2.     __UI_RegisterResult = 0
  3.     Control(PictureBox3).HelperCanvas = _NEWIMAGE(200, 54, 32)
  4.     _PUTIMAGE (0, 0), myLogo&, Control(PictureBox3).HelperCanvas
  5.     Control(__UI_NewID).Align = __UI_Center
  6.     Control(__UI_NewID).VAlign = __UI_Middle
  7.     Control(__UI_NewID).BorderSize = 1
  8.  

No errors, but no image, either.

FellippeHeitor

  • Guest
Re: Using BASIMAGE to embed images in InForm EXEs
« Reply #3 on: May 29, 2020, 11:53:28 am »
Try doing it at OnLoad. Also, let me see the line you're calling BASIMAGE with, if you don't mind.

Offline JohnJames

  • Newbie
  • Posts: 7
Re: Using BASIMAGE to embed images in InForm EXEs
« Reply #4 on: May 29, 2020, 12:02:00 pm »
I'm calling it at the top of the program...

Code: QB64: [Select]
  1. $EXEICON:'rds.ico'
  2. myLogo& = BASIMAGE1&  'Load the image
  3.  
  4. ': Controls' IDs: ------------------------------------------------------------------
  5.  
[...snip]





Offline JohnJames

  • Newbie
  • Posts: 7
Re: Using BASIMAGE to embed images in InForm EXEs
« Reply #5 on: May 29, 2020, 12:07:47 pm »
I receive an Illegal Function Call if I move the statement to OnLoad

FellippeHeitor

  • Guest
Re: Using BASIMAGE to embed images in InForm EXEs
« Reply #6 on: May 29, 2020, 12:08:36 pm »
make sure to make myLogo& available globally too:

Code: QB64: [Select]
  1. DIM SHARED myLogo&

Or bypass it all along. In SUB __UI_OnLoad:

Code: QB64: [Select]
  1. Control(PictureBox3).HelperCanvas = BASIMAGE1&

In this case you don't need to use _NEWIMAGE manually, since BASIMAGE will do it for you.
« Last Edit: May 29, 2020, 12:20:20 pm by FellippeHeitor »

Offline JohnJames

  • Newbie
  • Posts: 7
Re: Using BASIMAGE to embed images in InForm EXEs
« Reply #7 on: May 29, 2020, 12:29:16 pm »
Ayyyy! It works. Bypassing was easiest/best.

Thank you Fellippe. And thank you for sharing your incredible work.

FellippeHeitor

  • Guest
Re: Using BASIMAGE to embed images in InForm EXEs
« Reply #8 on: May 29, 2020, 12:31:48 pm »
Glad to hear it's solved.

Thank you for your kind words, too!

Offline Qwerkey

  • Forum Resident
  • Posts: 755
Re: Using BASIMAGE to embed images in InForm EXEs
« Reply #9 on: May 30, 2020, 05:35:14 am »
... your incredible work.

Yep, it is incredible what Fellippe does.  It's all hobby work (he has a job (if not more than one), and a young family).  I just do not know how he does it.  [But by now, he will be fed up with my plaudits].

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • GitHub
Re: Using BASIMAGE to embed images in InForm EXEs
« Reply #10 on: June 02, 2020, 03:14:50 pm »
I made a program that utilizes Dav's BASFILE and BASIMAGE programs that he wrote. I combined them both into a program that I call BIN2INCLUDE. It generates a file that you $INCLUDE at the end of your program to use/create later. The PIC2MEM option uses Dav's code with some tweaks by me so that the program generates a function named after the encoded image so you can call the function as an image handle using that Control(ControlId).HelperCanvas picture control. It works pretty good. Here is the link to the program. It uses InForm as well. Enjoy!
https://github.com/SpriggsySpriggs/BIN2INCLUDE
An example of how to use it:
Code: QB64: [Select]
  1. Control(OpenBT).HelperCanvas = __opensmall&
Shuwatch!