Results 1 to 5 of 5

Thread: Generating .bmp file

  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 Generating .bmp file

    Hii..

    I want to know whether we can create .bmp file using QImage or QImageWriter class.

    If we write following code :
    Qt Code:
    1. QImage imgA;
    2. imgA->setText("","A");
    3. imgA.save("A_bmp.bmp","BMP",-1);
    To copy to clipboard, switch view to plain text mode 

    Can A.bmp be generated where it has only text "A" .
    Is there any other meathod to implement the same?

  2. #2
    Join Date
    Dec 2007
    Posts
    627
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Generating .bmp file

    Quote Originally Posted by aj2903 View Post
    Can A.bmp be generated where it has only text "A" .
    Is there any other meathod to implement the same?
    You can also look @ QBitmap.

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

    Default Re: Generating .bmp file

    Can some help me regarding QBitmap class.
    Is is possible to create new .bmp file using Qt. ?

    Can someone give me snippet of the code ?

  4. #4
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Generating .bmp file

    what did you try?
    did you try something like this?
    Qt Code:
    1. QPixmap p(100, 100);
    2. p.fill(Qt::red);
    3. p.save("my.bmp", "bmp");
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  5. The following user says thank you to spirit for this useful post:

    aj2903 (12th November 2009)

  6. #5
    Join Date
    Dec 2007
    Posts
    627
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Angry Re: Generating .bmp file

    Quote Originally Posted by aj2903 View Post
    Can some help me regarding QBitmap class.
    Is is possible to create new .bmp file using Qt. ?Can someone give me snippet of the code ?
    Try something like this.
    Qt Code:
    1. void paint_a_bitmap()
    2. {
    3. QPixmap bmp(500,500);
    4. QPainter p(&bmp);
    5. p.setPen(Qt::red);
    6. p.drawText(200,200,"Qt Painting");
    7. //DO SOME PAINTING HERE
    8. bmp.save("test.bmp");
    9. };
    To copy to clipboard, switch view to plain text mode 

  7. The following user says thank you to yogeshgokul for this useful post:

    aj2903 (12th November 2009)

Similar Threads

  1. Read binary from file
    By weldpua2008 in forum Newbie
    Replies: 2
    Last Post: 3rd April 2009, 23:50
  2. Generating .pro files from vcproj file or CMake file
    By ramazangirgin in forum Qt Programming
    Replies: 2
    Last Post: 17th February 2009, 09:37
  3. Can you specify a file engine?
    By skimber in forum Qt Programming
    Replies: 2
    Last Post: 18th September 2008, 15:54
  4. Set up the Qt4.3.2 with Visual Studio 2005
    By lamoda in forum Installation and Deployment
    Replies: 6
    Last Post: 30th January 2008, 06:51
  5. qt-3.3.8 fail in scratchbox
    By nass in forum Installation and Deployment
    Replies: 0
    Last Post: 25th May 2007, 15:21

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.