Recent

Author Topic: embed .jpg file into .pp file  (Read 330 times)

SIRUS-VIRUS

  • New Member
  • *
  • Posts: 11
embed .jpg file into .pp file
« on: June 07, 2026, 11:14:09 am »
Hello Guys! Help me please! :) I need type image .jpg to screen from procedure from file .pp. How I can embed file .jpg into file .pp and type this image?

Handoko

  • Hero Member
  • *****
  • Posts: 5546
  • My goal: build my own game engine using Lazarus
Re: embed .jpg file into .pp file
« Reply #1 on: June 07, 2026, 11:40:09 am »
There are several ways to do it.

If you're using Lazarus, TImage and/or TImageList probably is the easiest.
https://wiki.lazarus.freepascal.org/TImage
https://wiki.lazarus.freepascal.org/TImageList

If you're using FPC only, the easiest I think is use Resource File:
https://wiki.freepascal.org/Lazarus_Resources

If you want to try something challenging, which I usually do. Write yourself a tool to convert the file into a hexstring, so you can copy it to a variable and regenerate it back to the picture at runtime in your program.
« Last Edit: June 07, 2026, 11:51:00 am by Handoko »

cdbc

  • Hero Member
  • *****
  • Posts: 2818
    • http://www.cdbc.dk
Re: embed .jpg file into .pp file
« Reply #2 on: June 07, 2026, 02:22:50 pm »
Hi
You can also include it into your source via an include-file (Option 3 in Handoko's post above), using this little BINTOINC utility from @KodeZwerg...
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6/QT6 -> FPC Release -> Lazarus Release &  FPC Main -> Lazarus Main

SIRUS-VIRUS

  • New Member
  • *
  • Posts: 11
Re: embed .jpg file into .pp file
« Reply #3 on: June 07, 2026, 08:23:35 pm »
If you want to try something challenging, which I usually do. Write yourself a tool to convert the file into a hexstring, so you can copy it to a variable and regenerate it back to the picture at runtime in your program.
It is interesting!
thank you to everyone who responded! :)

Thaddy

  • Hero Member
  • *****
  • Posts: 19268
  • Glad to be alive.
Re: embed .jpg file into .pp file
« Reply #4 on: June 08, 2026, 09:51:38 am »
Better is to include it as a resource file (rc) and compile that to res and include the resource.
Code: Text  [Select][+][-]
  1. #define IDR_MY_JPG 101
  2.  
  3. IDR_MY_JPG RCDATA "\path\to\your\image\image.jpg"

If you need a complete example, plz wait a few hours. I do not have all tools available here.
You can subsequently link the res file and use TImage.Picture.LoadFromResourceName. I have to test the jpg conversion, but I know that is easy, because I do it always like that. A bit of patience and a full example follows.
« Last Edit: June 08, 2026, 09:57:01 am by Thaddy »
objects are fine constructs. You can even initialize them with constructors.

 

TinyPortal © 2005-2018