Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How convert QString to pixel array

How convert QString to pixel array

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 717 Views
  • 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.
  • D Offline
    D Offline
    drewpol
    wrote on 25 Apr 2017, 21:28 last edited by drewpol
    #1

    Hello.
    I'm new user of this forum and also new in QT. Is it possible to convert for example one character or string to array where 0 means white field and 1 means black field? For example when I have character "a" saved as QString or char i would like to get following array:

    QString str = "a";
    //  HOW CONVERT str TO pixel representation array ???
    int array[9][6] = {                //"a" char array
          {0, 0, 0, 0, 0, 0},         //- - - - - -
          {0, 1, 1, 1, 1, 0},         //- * * * * -
          {1, 0, 0, 0, 0, 1},         //* - - - - *
          {0, 0, 0, 0, 0, 1},         //- - - - - *
          {0, 1, 1, 1, 1, 1},         //- * * * * *
          {1, 0, 0, 0, 0, 1},         //* - - - - *
          {1, 0, 0, 0, 1, 1},         //* - - - * *
          {0, 1, 1, 1, 0, 1},         //- * * * - *
          {0, 0, 0, 0, 0, 0},         //- - - - - -
    };
    

    Is there any way in QT for reach that goal ? I hope I describe my problem as clear ass possible and someone can help me with this?

    And very important thing size array must depend on selected font size, so if I choose for example 30 pt font, array shoule be appropriate bigger than 10 pt font.

    Thank You very much.
    Best regards.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Chris Hennes
      wrote on 25 Apr 2017, 21:50 last edited by
      #2

      It sounds to me like what you want to do is use a QPainter to paint your string into a QImage of depth 1 (QImage::Format_Mono). You will then be able to extract the bits into whatever format you want.

      Chris Hennes, Pioneer Library System

      D 1 Reply Last reply 25 Apr 2017, 22:13
      2
      • C Chris Hennes
        25 Apr 2017, 21:50

        It sounds to me like what you want to do is use a QPainter to paint your string into a QImage of depth 1 (QImage::Format_Mono). You will then be able to extract the bits into whatever format you want.

        D Offline
        D Offline
        drewpol
        wrote on 25 Apr 2017, 22:13 last edited by
        #3

        @Chris-Hennes many thanks for Your reply, it has appointed me the direction of further exploration.

        1 Reply Last reply
        0

        1/3

        25 Apr 2017, 21:28

        • Login

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