Author Topic: PJSR: new Bitmap(String filePath)?  (Read 4187 times)

Offline mschuster

  • PTeam Member
  • PixInsight Jedi
  • *****
  • Posts: 1087
PJSR: new Bitmap(String filePath)?
« on: 2015 January 15 10:16:04 »
new Bitmap(String filePath) appears to require an absolute path.

I want to load bitmap resources located the script's .js folder or subfolder. A relative path does not work, unlike #include "local.js".

Is the absolute path of the script's install/execution directory available? I don't see anything in Global.

Thanks,
Mike

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: PJSR: new Bitmap(String filePath)?
« Reply #1 on: 2015 January 15 12:37:30 »
Yes, Bitmap's constructor requires an absolute file path. You can use the __FILE__ predefined macro, along with the "stringify" preprocessor operator, to do what you want:

let thisFilePath = #__FILE__;
let thisDirectory = File.extractDrive( thisFilePath ) + File.extractDirectory( thisFilePath );
console.writeln( thisDirectory );


Important: Please note that these features are not part of the ECMAScript standard, so don't try to use them in your favorite web browser :) The JavaScript preprocessor is a feature specific to PixInsight.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/