Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. creating an .bmp file
Qt 6.11 is out! See what's new in the release blog

creating an .bmp file

Scheduled Pinned Locked Moved Unsolved Qt for Python
4 Posts 2 Posters 1.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AJ_111
    wrote on last edited by
    #1

    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")
            self.img.save("test.bmp")
    

    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 ?

    1 Reply Last reply
    0
    • Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote on last edited by
      #2

      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!

      The dystopian literature that served as a warning in my youth has become an instruction manual in my elder years.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        AJ_111
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • Kent-DorfmanK Offline
          Kent-DorfmanK Offline
          Kent-Dorfman
          wrote on last edited by
          #4

          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.

          The dystopian literature that served as a warning in my youth has become an instruction manual in my elder years.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved