I'm sampling pixels from a bitmap to control point attribs - rows contain the values I need, and I scan across the columns to animate the attribs across time. Simple enough.
But I may want to extend the bitmap sideways to lengthen the animation time, so I need to know how many pixels there are to divide my “u” coordinate by the right amount.
Is there a way I can avoid hard-coding – or requiring the user to update parms – my bitmap file's dimensions into my VOP SOP? The SOP's already got the filename as a parameter, which it uses with a Color Map VOP to actually grab the pixels.
How do I find out the dimensions of a bitmap file to use in a VOP SOP?
3278 6 1- howiem
- Member
- 146 posts
- Joined: 9月 2011
- Offline
- Andr
- Member
- 899 posts
- Joined: 2月 2016
- Offline
Hey, I'm pretty sure there is a clean solution for that, but I could come up only with this dirty work around:
1) load the image in a file node inside a Cop2network, by referencing the image path from the color map parameter.
2) read back the resolution from the “size” parameter (grayed out, but still readable)
NOTE:
one thing one needs to be aware of is that the file node inside the cop network has not a live-link with the outside world, so it won't be refreshed (unless you are already inside the cop network).
So we need to force the cooking of the cop network every time we load a new picture into the color map vop.
To do that we can use the python function cook(force=True) .
Have a look at hip file
cheers
1) load the image in a file node inside a Cop2network, by referencing the image path from the color map parameter.
2) read back the resolution from the “size” parameter (grayed out, but still readable)
NOTE:
one thing one needs to be aware of is that the file node inside the cop network has not a live-link with the outside world, so it won't be refreshed (unless you are already inside the cop network).
So we need to force the cooking of the cop network every time we load a new picture into the color map vop.
To do that we can use the python function cook(force=True) .
Have a look at hip file
cheers
Edited by Andr - 2019年6月11日 10:54:46
- howiem
- Member
- 146 posts
- Joined: 9月 2011
- Offline
- Andr
- Member
- 899 posts
- Joined: 2月 2016
- Offline
Hey, maybe doing it only in python would be better, no cops required, but you won't be able to read certain formats (like .pic, .rat)
Have a look at the new hip,
cheers
Have a look at the new hip,
cheers
node = hou.pwd() filepath = node.parm("parmpath").eval() from PIL import Image img = Image.open(filepath) width, height = img.size node.parm("imageSizex").set(width) node.parm("imageSizey").set(height)
Edited by Andr - 2019年6月11日 12:33:59
- jsmack
- Member
- 8052 posts
- Joined: 9月 2011
- Offline
If you are already in vex to load the texture data, you can try teximport to get the resolution or other metadata.
https://www.sidefx.com/docs/houdini/vex/functions/teximport.html [www.sidefx.com]
https://www.sidefx.com/docs/houdini/vex/functions/teximport.html [www.sidefx.com]
- Andr
- Member
- 899 posts
- Joined: 2月 2016
- Offline
- howiem
- Member
- 146 posts
- Joined: 9月 2011
- Offline
Andr
there was indeed a better way to do that
Yeah but now we've learned a variety of alternative approaches that may come in handy one day
And thanks jsmack - that's perfect. The excuse I needed to do move it into a wrangle instead of a VOP (I do get a bit tangled in VOPs after a while, but they can be handy for finding the right function name - that “View VEX code…” thing is a godsend)
-
- Quick Links