⚠️ Forum Maintenance: Feb 6th, 8am - 14pm (UTC+2)

creating an .bmp file

  • hello all,
    i'm new to PyQt and trying to create .bmp file with code below:

            self.img = QtGui.QImage(100, 50, QtGui.QImage.Format_Mono)
            self.paint_img = QtGui.QPainter()
            self.paint_img.drawText(self.img.rect(), Qt.AlignCenter, "Hello")

    after running the output of the code is :
    the .bmp file gets generated ,but the test "Hello" is not generated.

    Can someone help me to fix this issue ?

  • so what are the details of the file that is created? size? does bmp support monochrome images? what happens if you make a color bmp and set the background color for it as a solid color? does it view the backgorund color correctly? do some debugging on your own!

  • Hi Kent-Dorfman,
    I want to just create a monochrome (1 bit) file of any size maybe 100 x 50 pixels.
    Can you tell what is wrong in the code I have posted ? or you need more information related to code

  • where do you link your painter to the image? I see rectangle bounds checking of img, but nothing making the painter paint into the image itself.

Log in to reply