Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Cannot take a Screenshot of the whole control  (Read 1446 times)

0 Members and 1 Guest are viewing this topic.

Zipper

  • Newbie
  • *
  • Posts: 2
    • View Profile
Cannot take a Screenshot of the whole control
« on: October 16, 2009, 12:46:47 am »
Hi guys,

I am drawing a huge image into a small control. It can only be completely viewed by moving the view rectangle.

However, I want the screenshot function to export the whole image...

This code doesn't work:

Code: [Select]
//Clear
testRender->Clear();
//Get the view to modify it later
sf::View view = testRender->GetView();
//Make the Window bigger to fit the image
testRender->SetSize(Image1->GetWidth(),Image1->GetHeight());
//Return to root position & scale
testRender->SetPosition(0,0);
Sprite1->SetScale(1,1);

//This makes the sprite contain the whole image
Sprite1->SetSubRect(sf::Rect<int>(0,0,Image1->GetWidth(),Image1->GetHeight()));
//Draw the whole image to the window
testRender->Draw(*Sprite1);
testRender->SetActive( true );

//Display the whole image
view.SetFromRect(sf::Rect<float>(0,0,Image1->GetWidth(),Image1->GetHeight()));
testRender->SetView(view);

//Capture it (should show the whole huge image)
testRender->Capture().SaveToFile("test.jpg");


It still only displays the top left corner of the huge image which is stored in "Image1" in the code. I want to capture the whole image...

I appreciate your help.

Greetings
Zipper

Zipper

  • Newbie
  • *
  • Posts: 2
    • View Profile
Cannot take a Screenshot of the whole control
« Reply #1 on: October 16, 2009, 01:29:19 am »
Also hovering over the image and copying it part by part fails  :?

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