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. Get value of pixel from black and white image
Qt 6.11 is out! See what's new in the release blog

Get value of pixel from black and white image

Scheduled Pinned Locked Moved Solved General and Desktop
qimage
2 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.
  • H Offline
    H Offline
    helenebro
    wrote on last edited by
    #1

    Hi,
    I have an image black and white and I want get pixel value (0 or 1 if it's white or black).
    Which is the best image format ? How can I get only "black and white" component ?

    slettaS 1 Reply Last reply
    0
    • H helenebro

      Hi,
      I have an image black and white and I want get pixel value (0 or 1 if it's white or black).
      Which is the best image format ? How can I get only "black and white" component ?

      slettaS Offline
      slettaS Offline
      sletta
      wrote on last edited by
      #2

      @helenebro QImage::Format_Mono or QImage::Format_MonoLSB will both do the job. You can then read/write 0/1 with QImage::pixel() / QImage::setPixel(). For faster access to the pixel data, if that is needed, you should use the direct accessors with scanline() / constScanline() or bits() / constBits(), but then you need to take care of the bit offsets for each 32-byte block of pixel values.

      1 Reply Last reply
      2

      • Login

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