Hey guys,
I'm trying to cut an QPixmap image into 32x32 QPixmap tiles using the following function:
bool copyTileContainerFromImageFile
( QString &fileString, QVector<Tile
*>
*sourceVector
) {
if(fileString.isEmpty())
return false;
//goal = amount of possible tiles in this image.
int goal = (originalImage.width() * originalImage.height()) / 1024; //1024 Pixels fits in one Tile
sourceVector->reserve(goal); //reserves the amount of images in the vector.
for(int i = 0;i != goal;i++) {
sourceVector->append(new Tile(rect,i,originalImage.copy(rect)));
if(rect.x() + 32 >= originalImage.width()) {
rect.setY(rect.y() + 32);
rect.setX(0);
}else
rect.setX(rect.x() + 32);
}
return true;
}
bool copyTileContainerFromImageFile( QString &fileString, QVector<Tile*> *sourceVector )
{
if(fileString.isEmpty())
return false;
QRect rect(0,0,32,32);
QPixmap originalImage(fileString);
//goal = amount of possible tiles in this image.
int goal = (originalImage.width() * originalImage.height()) / 1024; //1024 Pixels fits in one Tile
sourceVector->reserve(goal); //reserves the amount of images in the vector.
for(int i = 0;i != goal;i++) {
sourceVector->append(new Tile(rect,i,originalImage.copy(rect)));
if(rect.x() + 32 >= originalImage.width()) {
rect.setY(rect.y() + 32);
rect.setX(0);
}else
rect.setX(rect.x() + 32);
}
return true;
}
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?
Bookmarks