Hello Damon, No dice on that one I am afraid. img is already a QImage since I got it from pbuffer.toImage() I have implemented it however but no luck. I am going to try and run a conversion under the hood and if it isn't too slow speed wise I may stick with that solution. I would very much like to be able to manipulate DDS image data though, have you managed to solve something like this before?
-- Ben On 17 August 2015 at 20:24, damon shelton <[email protected]> wrote: > try this > QtGui.QPixmap.fromImage(QtGui.QImage(img)) > see if it fixes your issue. > > On Mon, Aug 17, 2015 at 9:06 AM, Benjam901 <[email protected]> > wrote: > >> UPDATE: >> I shortened the function for readibility but I am still displaying >> nothing but blank on my qt window. My IDE prompts me that I am missing a >> QImage on this line QtGui.QPixmap.fromImage(img)which is odd sicne I am >> passing something into it and calling it straight from QtGui Module. I >> can't help but think I am missing something? >> >> def returnPixMap(self, ddsPath): glWidget = QGLWidget() >> glWidget.makeCurrent() texture = glWidget.bindTexture(ddsPath) width = -1 >> height = -1 glBindTexture(GL_TEXTURE_2D, texture) width = >> glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH) height = >> glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT) pbuffer = >> QGLPixelBuffer(QtCore.QSize(width, height), glWidget.format()) >> pbuffer.drawTexture(QtCore.QRectF(-1, -1, 2, 2), texture) img = >> pbuffer.toImage() return QtGui.QPixmap.fromImage(img) >> >> On Monday, 17 August 2015 15:26:49 UTC+2, Benjam901 wrote: >> >>> Hello all, >>> >>> I am having some trouble loading a dds file into PyQt for displaying in >>> a window. >>> >>> I have dug around and I keep being pointed towards OpenGL.GL and >>> QtOpenGL. I found a function on tech artists forum >>> http://tech-artists.org/forum/showthread.php?5196-Simple-DDS-loader that >>> supposedly returns a Qimage from a dds filepath but when the function tries >>> to bind the texture it fails instantly or returns 0. Am I missing a step >>> before trying to bind the image? >>> >>> I have also tried a custom fucntion earlier using QtOpenGL but I have >>> had no luck so far >>> >>> There doesn't seem to be a huge amount of info out there on this so >>> hopefully someone on here can help shine a light! >>> >>> The code is below to ilustrate my issue: >>> >>> import osimport sysfrom PyQt4 import QtGui, QtCorefrom PyQt4.QtOpenGL >>> import *from OpenGL.GL import * class ShaderCoordWindow(QtGui.QDialog): >>> def __init__(self): QtGui.QDialog.__init__(self) global coordWindow >>> coordWindow = QtGui.QDialog() coordWindow.resize(512, 512) >>> coordWindow.setWindowTitle("Objects to skin") >>> coordWindow.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) testDDS = r' >>> D:\\test.dds' testJPG = r'D:\\test_jpg.jpg' jpgPixMap = >>> QtGui.QPixmap(testJPG) qFileDDS = fileDDS(testDDS) testImg = >>> QtGui.QPixmap.fromImage(qFileDDS._qImage) imageLabel = >>> QtGui.QLabel(coordWindow) imageLabel.setPixmap(testImg) layout = >>> QtGui.QHBoxLayout() layout.addWidget(imageLabel) >>> coordWindow.setLayout(layout) coordWindow.show() >>> ############################################################################# >>> DDS file readerclass fileDDS(object): """This class represnts a generic >>> DDS file as a QImage""" #global gDebug >>> ... >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Python Programming for Autodesk Maya" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/python_inside_maya/90a1aabd-9a1a-47eb-9f62-6232239bd454%40googlegroups.com >> <https://groups.google.com/d/msgid/python_inside_maya/90a1aabd-9a1a-47eb-9f62-6232239bd454%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> >> For more options, visit https://groups.google.com/d/optout. >> > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Python Programming for Autodesk Maya" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/python_inside_maya/s1BKlrcJ9vI/unsubscribe > . > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/python_inside_maya/CAM9RXoJag%2B55v28u7KW88eZzjm4ofW9yB3wobX5_HOfXbJ7Uqw%40mail.gmail.com > <https://groups.google.com/d/msgid/python_inside_maya/CAM9RXoJag%2B55v28u7KW88eZzjm4ofW9yB3wobX5_HOfXbJ7Uqw%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- Tel - +46 76245 92 90 (Sweden) LinkedIn: http://www.linkedin.com/pub/ben-hearn/50/a64/33b -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAM2ybkVEXFJzSL%2B-izN7K%2BQcqXSy0EyFYyE3ruocqyVnkw2LEA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
