How to write values to an image file?

How to write values to an image file?

mcw0
Advisor Advisor
918 Views
6 Replies
Message 1 of 7

How to write values to an image file?

mcw0
Advisor
Advisor

I hope scripting questions are allowed here as I'd like to write this as a script as opposed to a plugin.  I'd like to write arbitrary data to an image file based on the UVs of a mesh.  I see Maya has "exportSkinMap" for exporting skin weights to an image file.  And "art3dPaintSaveFileTextures" can write to an image file.  So there must be a way to, for instance, write normals to an image file.  Or to write worldPosition to an image file.

 

On the plugin side, I've seen someone write a tool that can generate a texture file based on the path of a particle across the surface.  So I know it's possible.  If I must do it as a plugin, then so be it.  But I'd much rather it be a script.  I don't want to keep updating a plugin for each new version of Maya.

919 Views
6 Replies
Replies (6)
Message 2 of 7

stuzzz
Collaborator
Collaborator

I've never tried that before but it seems that you can write data to pixel with the MImage class.

Bellow you can find an example setting pixel colors and saving these datas to a file.

here is an example 

0 Likes
Message 3 of 7

mcw0
Advisor
Advisor

Thank you for that link.  That inspired a new solution that doesn't entail a plugin.  I'm thinking to assign data as vertex color and then use Maya's Paint Vertex Color tools to export a texture.  At least that's my thought.  I will test it out but confidence is high.  Thanks again.

0 Likes
Message 4 of 7

stuzzz
Collaborator
Collaborator

You could probably found a workaround with Qt/pyQt which deals with buffering and images also.

0 Likes
Message 5 of 7

mcw0
Advisor
Advisor

I've not used QT or PyQT.  But I'll look into it.  

 

I did a test of my idea and it works.  But the thing I don't like is I have to have the paint tool open to get the proper context.   So even though it's working, I'd like a more elegant solution if possible.  So I'll definitely check out your suggestion.  Thanks

0 Likes
Message 6 of 7

stuzzz
Collaborator
Collaborator

Indeed, you've find a workaround but it's not the more elegant one.

If you sort out the problem with Qt, please let me know.

0 Likes
Message 7 of 7

mcw0
Advisor
Advisor

From what I've checked, QT and pyQT are for UI related issues.  Not sure how that would be applicable to my case.

0 Likes