Results 1 to 3 of 3

Thread: converting image into monochrome format

  1. #1
    Join Date
    Sep 2008
    Posts
    84
    Thanks
    28
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default converting image into monochrome format

    hii...
    i'm able to create .bmp image.
    But the image is not getting converted into Monochrome.

    I have tried wth following code :
    Qt Code:
    1. QPixmap bmp(100,50);
    2. QPainter p(&bmp);
    3. p.setRenderHint(QPainter::Antialiasing,blnVar);
    4. p.setPen(Qt::white);
    5. p.drawText(10,20,"AJ");
    6. bmp.save("d:\\Test.bmp","bmp",-1);
    7.  
    8. imgTemp = bmp.toImage();
    9.  
    10. imgTemp.convertToFormat(QImage::Format_Mono,Qt::MonoOnly);
    11. imgTemp.save("d:\\tempMono.bmp","bmp",-1);
    To copy to clipboard, switch view to plain text mode 

    After executing this code, 2 bmp files are created but both are 32 bit.
    How to convert it to monochrome format.
    Can somebody help me to solve this ?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: converting image into monochrome format

    Look what QImage::convertToFormat() returns.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: converting image into monochrome format

    Try using a QBitmap
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. Image Converting and color problem
    By electronicboy in forum Qt Programming
    Replies: 9
    Last Post: 3rd November 2009, 12:21
  2. How can change image format?
    By electronicboy in forum Qt Programming
    Replies: 2
    Last Post: 25th October 2009, 10:44
  3. Converting to transparent Image
    By navi1084 in forum Qt Programming
    Replies: 5
    Last Post: 28th August 2009, 14:25
  4. Image format without bounding rect
    By dreamer in forum Qt Programming
    Replies: 5
    Last Post: 30th April 2008, 23:25
  5. Some very weird compilation warnings
    By MarkoSan in forum Qt Programming
    Replies: 21
    Last Post: 23rd January 2008, 17:48

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.