PDA

View Full Version : How to write/create image database nodes?



Ikael
November 25th, 2016, 12:00
Am I able to create databasenode with type="image" with bitmap value using FG API? The problem is that image typed databasenodes should look as following


<image type="image">
<bitmap>path/to/image_file</bitmap>
</image>


First of all you cannot create databasenode containing value and no type so <bitmap>path/to/image_file</bitmap> doesn't work, then I tested creating <bitmap type="string">path/to/image_file</bitmap> which works but when I save the db.xml file the image databasenode is stripped to have no value. The only spot where I am able to "write" image typed databasenodes is to do Module.export.

Does anyone know if this can be done with current FG engine/API?

Nickademus
November 25th, 2016, 22:52
I'm not entirely sure what you are trying to do, so I don't know if I can help you. But to add an image to the database, you must first add the image to the campaign/module. Then you must put a reference in the <image> section directly off the root. The definition I see in current databases looks like this:

<id-00002>
<image type="image">
<bitmap>images/Flanaess.jpg</bitmap>
</image>
<isidentified type="number">0</isidentified>
<name type="string">Flanaess</name>
</id-00002>

... so the <bitmap> attribute has its own typing internally and you don't need to add anything like 'type="string"'. Perhaps the lack of a <name> value on your image is what is causing problems. At any rate, if you add the image inside of FG, this should be already done. If you are adding it to a module, I think you would have to manually edit the xml. I'm not sure how you might do this by progmatically creating the database node other than to say it might be required to make it a child of <root><image>.

Moon Wizard
November 25th, 2016, 23:59
You can create a drawing-only image node using the DB.createChild or databasenode.createChild function. However, you can not set the bitmap value. It's not supported in the API at all.

Regards,
JPG