1
Graphics / Cannot take a Screenshot of the whole control
« on: October 16, 2009, 01:29:19 am »
Also hovering over the image and copying it part by part fails :?
I am using SFML 1.6
Code: [Select]
sf::Image cImage;
for(unsigned int dX = 0; dX <= Image1->GetWidth(); dX += testRender->GetWidth())
{
for(unsigned int dY = 0; dY <= Image1->GetHeight(); dY += testRender->GetHeight())
{
unsigned int tX = testRender->GetWidth()+dX <= Image1->GetWidth() ? testRender->GetWidth()+dX : Image1->GetWidth();
unsigned int tY = testRender->GetHeight()+dY <= Image1->GetHeight() ? testRender->GetHeight()+dY : Image1->GetHeight();
if(dX != tX && dY != tY)
{
testRender->Clear();
// Simulate drawing at that spot
Sprite1->SetSubRect(sf::Rect<int>(dX,dY,tX,tY));
testRender->Draw(*Sprite1);
cImage.Copy(testRender->Capture(),dX,dY,sf::Rect<int>(0,0,testRender->GetWidth(),testRender->GetHeight()),false);
}
}
}
// This crashes!
cImage.SaveToFile("test.jpg");
I am using SFML 1.6