Results 1 to 20 of 21

Thread: Probem Tiling an image with QPixmap

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2010
    Posts
    14
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    1

    Default Probem Tiling an image with QPixmap

    Hey guys,

    I'm trying to cut an QPixmap image into 32x32 QPixmap tiles using the following function:
    Qt Code:
    1. bool copyTileContainerFromImageFile( QString &fileString, QVector<Tile*> *sourceVector )
    2. {
    3. if(fileString.isEmpty())
    4. return false;
    5.  
    6. QRect rect(0,0,32,32);
    7. QPixmap originalImage(fileString);
    8. //goal = amount of possible tiles in this image.
    9. int goal = (originalImage.width() * originalImage.height()) / 1024; //1024 Pixels fits in one Tile
    10. sourceVector->reserve(goal); //reserves the amount of images in the vector.
    11. for(int i = 0;i != goal;i++) {
    12. sourceVector->append(new Tile(rect,i,originalImage.copy(rect)));
    13.  
    14. if(rect.x() + 32 >= originalImage.width()) {
    15. rect.setY(rect.y() + 32);
    16. rect.setX(0);
    17. }else
    18. rect.setX(rect.x() + 32);
    19.  
    20. }
    21. return true;
    22. }
    To copy to clipboard, switch view to plain text mode 

    Am I just not seeing the woods for the trees and the function works incorrect or is it not possible to cut a QPixmap with the copy function?
    Last edited by LuckyBlade; 12th January 2011 at 15:30.

Similar Threads

  1. OpenGL Image Tiling Interpolation Problem
    By Halcom in forum Qt Programming
    Replies: 1
    Last Post: 22nd December 2010, 13:41
  2. using QPixmap to transparent image
    By sophister in forum Qt Programming
    Replies: 2
    Last Post: 8th July 2010, 13:06
  3. QImage Non-Standard Format Probem
    By photo_tom in forum Qt Programming
    Replies: 3
    Last Post: 19th February 2010, 08:06
  4. Getting image file from QPixmap
    By di_zou in forum Qt Programming
    Replies: 2
    Last Post: 5th October 2009, 16:20
  5. add(draw) an icon(or image) to a QPixmap?
    By ascii in forum Qt Programming
    Replies: 4
    Last Post: 20th November 2008, 12:44

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
  •  
Qt is a trademark of The Qt Company.