Hi,
I’m working on tools to manage textures in Maya.
I’ve started with Maya 2011 and PyQt4, but with the integration of PySide in Maya 2014, I’ve change my mind and convert my code.
Now, I’m stuck with one problem, when I try to pass a pointer of a MImage to a QImage.
This code works well with PyQt, but not with PySide… and I don’t know how to convert my SwigPyObject to PySide.QtCore.uchar
import maya.OpenMaya as om
from PySide.QtGui import *
from PySide.QtCore import *
texturePath = 'c:/image.png'
# create pointers
wUtil = om.MScriptUtil()
wUtil.createFromInt(0)
wPtr = wUtil.asUintPtr()
hUtil = om.MScriptUtil()
hUtil.createFromInt(0)
hPtr = hUtil.asUintPtr()
# create Maya MImage
mTexture = om.MImage()
mTexture.readFromFile(texturePath)
mTexture.verticalFlip()
mTexture.getSize(wPtr, hPtr)
# get texture size
width = wUtil.getUint(wPtr)
height = hUtil.getUint(hPtr)
# convert to Qt format
mQTexture = None
try:
mQTexture = QImage(mTexture.pixels(), width, height, QImage.Format_RGB32).rgbSwapped()
except Exception as e:
print e
And the error message :
Error: 'PySide.QtGui.QImage' called with wrong argument types:
PySide.QtGui.QImage(SwigPyObject, int, int, PySide.QtGui.QImage.Format)
Supported signatures:
PySide.QtGui.QImage()
PySide.QtGui.QImage(PySide.QtCore.QString, int, int, PySide.QtGui.QImage.Format)
PySide.QtGui.QImage(PySide.QtCore.QString, int, int, int, PySide.QtGui.QImage.Format)
PySide.QtGui.QImage(PySide.QtGui.QImage)
PySide.QtGui.QImage(PySide.QtCore.QSize, PySide.QtGui.QImage.Format)
PySide.QtGui.QImage(unicode, str = None)
PySide.QtGui.QImage(PySide.QtCore.char)
PySide.QtGui.QImage(int, int, PySide.QtGui.QImage.Format)
PySide.QtGui.QImage(PySide.QtCore.uchar, int, int, PySide.QtGui.QImage.Format)
PySide.QtGui.QImage(PySide.QtCore.uchar, int, int, int, PySide.QtGui.QImage.Format)
Any suggestions ?
Thanks in advance
David