Building PhotoDemon with twinBASIC
PhotoDemon is one of the most complex VB6 open-source projects still actively maintained. And you can build it yourself in about 10 minutes with twinBASIC.
What is PhotoDemon?
PhotoDemon is an open-source, portable photo editor designed to be lightweight and fast while offering a wide range of advanced features.
It stands out from other image editors for its focus on portability, meaning it doesn't require installation and can run directly from a USB stick or any other portable storage device. This makes it ideal for users who need a powerful yet lightweight photo editor that can be used across different machines without the need for administrative access or installation.
Advantages
- No Installation Required: Perfect for users who need a powerful tool that's entirely portable.
- Feature-Rich: Offers many of the same features as more well-known editors like GIMP or Photoshop, but in a smaller, more user-friendly package.
- Batch Processing: Users who need to apply the same edits to a large number of photos, such as resizing or watermarking images for a website or social media platform.
- Free and Open Source: No cost to users, with the added benefit of community-driven development.
PhotoDemon is written in Visual Basic (VB6).
Despite its age, the PhotoDemon project has demonstrated that VB6 can still be used to create fast, efficient, and modern applications when combined with well-optimized code and thoughtful design.
The use of VB6 may come as a surprise to some, given the project's performance and feature set, but the developer has managed to push the language's capabilities to their limits, creating a lightweight yet powerful photo editor. The project showcases how older programming languages can still be relevant for niche applications, especially when handled by experienced developers.
In the realm of modern, actively maintained VB6 applications, PhotoDemon stands out as one of the most impressive examples of what can still be achieved with VB6 today.
*Above summary generated with the help of ChatGPT-4o.
Building PhotoDemon with twinBASIC
Given the size and complexity of PhotoDemon–and twinBASIC's foundational goal of providing 100% VB6 compatibility–it makes for an ideal benchmark to stress test twinBASIC's progress on that front.
And twinBASIC passes with flying colors.
Skeptical? Try it yourself with the simple instructions below.
Step-by-Step Instructions
NOTE: The sample commands below use full folder paths. Feel free to substitute them with your own preferred folder structure. I used full paths to help avoid common issues that can occur with incorrect folder setup.
Clone the PhotoDemon Project from GitHub
- Install Git (e.g., via Chocolatey with:
choco install git
) - Create a local folder to hold the VB6 PhotoDemon source code:
mkdir C:\Repos\git\PhotoDemon
- Clone PhotoDemon:
git clone
https://github.com/tannerhelland/PhotoDemon.git
C:\Repos\git\PhotoDemon
Import PhotoDemon to twinBASIC
- Install the latest version of twinBASIC
- Create a local folder to hold the twinBASIC PhotoDemon source code:
mkdir C:\Repos\git\tbPhotoDemon
- Launch twinBASIC and click on [Import from VBP...]
- Choose
C:\Repos\git\PhotoDemon\PhotoDemon.vbp
- Wait for the import to complete
- File > Save Project As... >
C:\Repos\git\tbPhotoDemon\PhotoDemon.twinproj
Create a Symlink to the App Folder
- Open an admin cmd window
- Run the following command:
mklink /D "C:\Repos\git\tbPhotoDemon\App" "C:\Repos\git\PhotoDemon\App"
Build PhotoDemon.exe
- Ensure the architecture dropdown is set to "win32"
- Click File > Build (or click on the "nine-square" build icon)
- The compiled file will be named:
C:\Repos\git\tbPhotoDemon\PhotoDemon.exe
Running PhotoDemon
To launch the twinBASIC-compiled version of PhotoDemon, simply double-click the file: C:\Repos\git\tbPhotoDemon\PhotoDemon.exe
.
That's it! When was the last time it was that easy to build a complex open-source project from source code?
Adding twinBASIC Branding [Optional]
Just for fun–and to prove we're actually building PhotoDemon in twinBASIC–let's add some light twinBASIC branding to our build.
We're going to make two minor adjustments:
- Adding " (built with twinBASIC)" to the application title bar
- Adding " - built with twinBASIC" to the splash screen
Updating the Application Title Bar
Open the project in twinBASIC, then go to Project > Project Settings... and change the "Project: Application Title" setting from "PhotoDemon
" to "PhotoDemon (built with twinBASIC)
":
Here's what the new application title bar looks like after rebuilding PhotoDemon.exe:
Updating the Splash Screen
In twinBASIC's Project Explorer, expand PhotoDemon > Source > Forms and then double-click on Startup_Splash.frm.twin
. Add the following as line 138:
versionString += " - built with twinBASIC"
(No, +=
is not valid VB6 syntax. But it is valid twinBASIC syntax. Welcome to the 21st century, VB6!)
See screenshot below for context (note that lines 5, 77, and 79 appear because I've enabled the "Sticky Scrolling" feature via Tools > IDE Options... > IDE: Sticky scrolling in code editor [√]).
Here's the updated splash screen:
Notes About the Process
32-Bit Only...For Now
Remember, VB6 does not have 64-bit support. That was added in VBA 7. Microsoft never released an equivalent "VB7" update.
For that reason, the PhotoDemon maintainers have had no reason to update the project to support 64-bit Windows API calls.
If one were so inclined, one could fork the PhotoDemon project to an equivalent twinBASIC project and resolve all 3,580 compile errors by updating the API calls for 64-bit compatibility.
On the bright side, fafalone's Windows Development Library (WinDevLib) twinPACK package would make that monumental task tremendously easier.
Run > Start Warning Screen
If you run PhotoDemon from within the twinBASIC IDE using one of the following methods:
- File > Start
- [F5]
- Clicking the green triangle icon
Then you will get the following error message (at least the first time you do it):
If you leave the checkbox checked at the bottom of the form, you won't see this warning again. To restore the warning, edit the PhotoDemon settings file, which can usually be found at:
C:\Repos\git\tbPhotoDemon\Data\PhotoDemon_settings.xml
You will need to change the following setting from "False" to "True" to restore the IDE warning:
<pdData>
<Core>
<DisplayIDEWarning>True</DisplayIDEWarning>
Build Location
The compiled file is saved in the same folder as the .twinproj file based on the following project setting:
The above setting is based on the following line from the PhotoDemon.vbp project file (twinBASIC sets this value as part of its .vbp import process):
ExeName32="PhotoDemon.exe"
This differs from the default behavior for new twinBASIC projects. By default, new projects are built inside of a \Build\
subfolder. Shown below is the default Project: Build Output Path setting:
Why Symlink?
You could just copy the entire C:\Repos\git\PhotoDemon\App
folder to C:\Repos\git\tbPhotoDemon\App
.
However, using a symbolic link (aka, symlink) has a few advantages:
- Saves a modest amount of disk space by not storing duplicates of files
- Ensures that files added to the PhotoDemon repository in the future will be available to our twinBASIC application
- Unlike an NTFS junction folder, a symlink can point to a different volume (i.e., drive letter)
Be aware that when creating the symbolic link, the destination folder cannot exist.
Troubleshooting
If you get the following message:
Be sure that the following folders appear inside C:\Repos\git\tbPhotoDemon
and that they are not empty:
\App
\PhotoDemon
\Languages
: ~16 files\Master
: ~2 files
\Plugins
: ~32 files\Themes
: ~12 files
If you are running into trouble executing the symlink command discussed above, you can just copy the \App\
subfolder from the PhotoDemon vb6 folder and paste it to the same folder where the twinBASIC-compiled PhotoDemon.exe file lives.