Thread: getImageSize() missing in FGU
-
October 22nd, 2020, 15:21 #1
getImageSize() missing in FGU
Seems like getImageSize() is not in FGU at this time?
Code:local w = Interface.openWindow("imagewindow",nodeImage); if w then local ctrl = w.createControl("image_refblock", "image"); Debug.console("manager_author_adnd.lua","createBlockImage","window (w)",w); Debug.console("manager_author_adnd.lua","createBlockImage","ctrl",ctrl); nXOriginal, nYOriginal = ctrl.getImageSize(); nX, nY = getAdjustedImageSize(win,ctrl); w.close(); end
[10/20/2020 5:09:50 PM] s'manager_author_adnd.lua' | s'createBlockImage' | s'sImageNode' | s'image.id-00002'
[10/20/2020 5:09:50 PM] s'manager_author_adnd.lua' | s'createBlockImage' | s'sImageCaption' | s'Image tsr'
[10/20/2020 5:09:50 PM] s'manager_author_adnd.lua' | s'createBlockImage' | s'nodeImage' | databasenode = { image.id-00002 }
[10/20/2020 5:09:50 PM] s'manager_author_adnd.lua' | s'createBlockImage' | s'window (w)' | windowinstance = { class = imagewindow, node = image.id-00002, x,y,w,h = 658,44,778,765 }
[10/20/2020 5:09:50 PM] s'manager_author_adnd.lua' | s'createBlockImage' | s'ctrl' | genericcontrol = { name = s'image', x,y,w,h = 0,0,0,0 }
[10/20/2020 5:09:50 PM] [<color="red">ERROR</color>] Script execution error: [string "scripts/manager_author_adnd.lua"]:398: attempt to call field 'getImageSize' (a nil value)
If there is a better method to collect this data now I'd be happy to switch to it. I always thought loading the image to get the image size then closing it was a bit... clunky. The reason I do this is to find out the size of the image, adjust so that it fits within the requirements for inline image views in a ref-manual.Last edited by celestian; October 22nd, 2020 at 15:34.
---
Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
Documentation for AD&D 2E ruleset.
Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.
-
October 22nd, 2020, 15:41 #2
I don't think images have a size anymore. If I'm right, this is because images are compilations of assets and the image canvas itself is infinitely large. This is a supposition, but it seems to fit your issue.
Problems? See; How to Report Issues, Bugs & Problems
On Licensing & Distributing Community Content
Community Contributions: Gemstones, 5E Quick Ref Decal, Adventure Module Creation, Dungeon Trinkets, Balance Disturbed, Dungeon Room Descriptions
Note, I am not a SmiteWorks employee or representative, I'm just a user like you.
-
October 22nd, 2020, 22:52 #3
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,540
If you are using the latest version of FGU and CoreRPG ruleset; the image_refblock is no longer an imagecontrol. Instead, it is implemented in FGU as a genericcontrol using a new setAsset API we're trying out for improved performance in reference manuals. So, getImageSize is not valid on the new template which uses a genericcontrol.
Regards,
JPG
-
October 23rd, 2020, 02:41 #4
Not entirely clear, so you're saying there isn't a method to get the image size yet? Or that there is some mechanism within the "genericcontrol" ? I did a quick search of the doc site and didn't get a hit on setAsset(). What I did see in CoreRPG 3.3.12 didn't clear up my mind on how to do it either ;(
---
Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
Documentation for AD&D 2E ruleset.
Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.
-
October 23rd, 2020, 02:57 #5
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,540
It's a brand new API that is still in testing that enhances genericcontrols to be able to display an "asset" fitted within the control area.
There is no mechanism to get the image size from the genericcontrol. The assumption is that the control is set to the desired size; and the asset is scaled to fit within that space regardless of it's actual size.
JPG
-
October 23rd, 2020, 16:08 #6---
Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
Documentation for AD&D 2E ruleset.
Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.
-
October 23rd, 2020, 18:51 #7
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,540
I'll add a genericcontrol.getAsset API and an Interface.getAssetSize API to the next release build that you can use to query the asset name and then the size of an asset.
Regards,
JPG
-
April 21st, 2021, 22:54 #8
Did this ever get added? I still have a need to re-implement the code from FGC...
(trimmed out and compacted this for simplicity, these are the key fragments so there is a work process to follow, the key issue is the size)
Code:local sNoteText = DB.getValue(nodeStory,"text",""); local sPatternMatchFGU = '<linklist><link class="imagewindow" recordname="[^\"]+">[^<]+</link></linklist>'; local sPatternMatchFGC = '<linklist>[^<]+<link class="imagewindow" recordname="[^\"]+">[^<]+</link>[^<]+</linklist>'; local sPatternMatch = sPatternMatchFGC; if UtilityManager.isClientFGU() then sPatternMatch = sPatternMatchFGU; end local nStart, nEnd = string.find(sNoteText,sPatternMatch,1); local sText= string.sub(sNoteText,nStart,nEnd); local sImageNode = sText:match("recordname=\"([^\"]+)\""); local sImageCaption = sText:match("<link class=\"imagewindow\" recordname=\"[^\"]+\">([^<]+)</link>"); local nodeImage = DB.findNode(sImageNode); local w = Interface.openWindow("imagewindow",nodeImage); if w then if not UtilityManager.isClientFGU() then local ctrl = w.createControl("image_refblock", "image"); local nXX,nYY = ctrl.getImageSize(); nX, nY = getAdjustedImageSize(nXX,nYY); else ....
---
Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
Documentation for AD&D 2E ruleset.
Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.
-
April 21st, 2021, 23:23 #9
Actually it looks like :
Code:local sAsset = DB.getText(w.getDatabaseNode(), "image", ""); local nAssetX, nAssetY = Interface.getAssetSize(sAsset);
---
Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
Documentation for AD&D 2E ruleset.
Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks