I finally had time to test this properly, and I confirm that DynamicSprite.CreateFromFile does not work on Linux, regardless of the path.
File.Open does work for exactly same file path.
This means that either:
- DynamicSprite.CreateFromFile does or does not do something that File.Open does (to path or to file);
- The bitmap loading is broken on Linux/OSX.
The script I used for the test:
Code: ags
First test tries to open file / create image in the game's directory, another in the save dir. Result is the same (assuming you have bmps in both).
For both paths the Windows results:
- saveHD0.bmp detected
- Opened saveHD0.bmp
- Sprite was created from saveHD0.bmp
The Linux results:
- saveHD0.bmp detected
- Opened saveHD0.bmp
- Failed to create sprite from saveHD0.bmp
File.Open does work for exactly same file path.
This means that either:
- DynamicSprite.CreateFromFile does or does not do something that File.Open does (to path or to file);
- The bitmap loading is broken on Linux/OSX.
The script I used for the test:
// room script file
function TestLoadImage(String filename)
{
if (File.Exists(filename)) {
Display(String.Format("%s detected", filename));
} else {
Display(String.Format("%s NOT detected", filename));
}
File *f = File.Open(filename, eFileRead);
if (f != null) {
Display("Opened %s", filename);
f.Close();
} else {
Display("Failed to open %s", filename);
}
DynamicSprite *dspr = DynamicSprite.CreateFromFile(filename);
if (dspr != null) {
Display(String.Format("Sprite was created from %s", filename));
dspr.Delete();
} else {
Display(String.Format("Failed to create sprite from %s", filename));
}
}
function room_AfterFadeIn()
{
TestLoadImage(String.Format("saveHD%d.bmp", 0));
TestLoadImage(String.Format("$SAVEGAMEDIR$/saveHD%d.bmp", 0));
}
First test tries to open file / create image in the game's directory, another in the save dir. Result is the same (assuming you have bmps in both).
For both paths the Windows results:
- saveHD0.bmp detected
- Opened saveHD0.bmp
- Sprite was created from saveHD0.bmp
The Linux results:
- saveHD0.bmp detected
- Opened saveHD0.bmp
- Failed to create sprite from saveHD0.bmp