[Solved] Question about editing an image with a qt fuction



  • So let's say we have a normal image, and a transparent png image.. both in same resolution eg. 1024x768
    Is there a qt fuction that can stick this images together ( the jpg as a background and the png in front ) and then save it as an image..

    for example i have this normal image:
    !http://i.imgur.com/WaVtJ.png(1)!
    and this png transparent image:
    !http://i.imgur.com/sLXj6.png(2)!

    what i want is this:
    !http://i.imgur.com/nr6N2.png(3)!

    maybe qpaint/qimage..?


  • Moderators

    QPainter can paint an image or pixmap onto to any paint device. Create a new image, and use a QPainter to draw your background image, then overlay your top image.



  • no i don't want to draw anything..
    i have 2 ready images in my disk.. something like:

    blabla->setbackround(image1 location here)
    blabla->addimageinfront(image 2 location here)
    blabla->saveimage(a path here)


  • Moderators

    You can use QPainter to "stamp down" an existing image onto a pixmap.

    Quick Pseudocode:
    @
    QPixmap background("...");
    QPixmap foreground("...");

    QPixmap newImage(...);
    QPainter painter(&newImage);
    painter.drawPixmap(background);
    painter.drawPixmap(foreground);

    newImage.save();
    @



  • you just caught me before posting it.. founded it here (http://stackoverflow.com/questions/4755970/nokia-qt-edit-image)..

    same as yours.. thanks .. the .save works for me :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.