Results 1 to 6 of 6

Thread: editing a image using QT

  1. #1
    Join Date
    Jan 2012
    Posts
    20
    Thanks
    3

    Default editing a image using QT

    Hi all,

    i have this doubt if i have an image in my computer and i access that image (.jpeg or anyother format) using QT program and after accessing the image is it possible for me to edit the image using QT program? i.e can i modify the image as per my needs dynamically is it possible??

    thanks in advance,

    regards,
    satya

  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: editing a image using QT

    You can access each pixel of the image using QImage API.
    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. The following user says thank you to wysota for this useful post:

    qtlearner123 (24th April 2012)

  4. #3
    Join Date
    Jan 2012
    Posts
    20
    Thanks
    3

    Default Re: editing a image using QT

    hi,

    thank you very much for the reply, i am going through the documentation of QImage, but i have one small question suppose i have one image say image1 and i want to remove some part of the image1 and replace it with another image2 can i achieve the task it, based upon your feedback i can make sure i am not going in the wrong direction.

    thanks and regards,
    satya

  5. #4
    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: editing a image using QT

    You have to open a painter on the image and use QPainter::drawImage() to draw the part that is to replace old content.
    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.


  6. The following user says thank you to wysota for this useful post:

    qtlearner123 (24th April 2012)

  7. #5
    Join Date
    Jan 2012
    Posts
    20
    Thanks
    3

    Default Re: editing a image using QT

    you are so precise and to the point.

    thanks and regards,
    satya

  8. #6
    Join Date
    Jan 2012
    Posts
    20
    Thanks
    3

    Default Re: editing a image using QT

    Hi,

    iam trying to take image1 and on image1 at some portion i want to overwrite image2, i did with the following code.

    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include <QLabel>
    3. #include <QGraphicsView>
    4. #include <stdio.h>
    5. #include <QRect>
    6. #include <QPainter>
    7. #include "lines1.h"
    8.  
    9. QImage firstImage;
    10. QImage secondImage;
    11.  
    12. int main(int argc, char *argv[])
    13. {
    14. QApplication a(argc, argv);
    15. Lines window;
    16.  
    17. firstImage.load(":/images/myImage1.png");
    18. secondImage.load(":/images/myImage2.png");
    19. window.show();
    20. return a.exec();
    21. }
    22.  
    23.  
    24. void Lines::paintEvent(QPaintEvent *event)
    25. {
    26. QPainter painter(this);
    27.  
    28. QRect rect1,rect2;
    29. rect1.setX(0);
    30. rect1.setY(0);
    31. rect1.setHeight(600);
    32. rect1.setWidth(700);
    33.  
    34. rect2.setX(500);
    35. rect2.setY(200);
    36. rect2.setHeight(50);
    37. rect2.setWidth(50);
    38.  
    39.  
    40. painter.drawImage(rect1, firstImage);
    41. painter.drawImage(rect2,secondImage);
    42. }
    To copy to clipboard, switch view to plain text mode 

    my questions are
    1. Is it the correct way of doing it or any better method is available to achieve the same?
    2. suppose i want to overwrite at a particular part of image how to know the coordinates of those points? right now i am using trial and error method?

    thanks in advance,

    regards,
    satya

Similar Threads

  1. Editing a file in Qt4
    By grsandeep85 in forum Qt Programming
    Replies: 3
    Last Post: 22nd December 2009, 09:33
  2. XML editing with QDom
    By trulysachin in forum Qt Programming
    Replies: 1
    Last Post: 20th November 2008, 16:39
  3. About Editing QtreeWidget
    By nikhilqt in forum Qt Programming
    Replies: 1
    Last Post: 22nd January 2008, 13:51
  4. Replies: 5
    Last Post: 18th July 2006, 22:31

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.