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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Zipper

Pages: [1]
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  :?

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

2
Graphics / 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

Pages: [1]
anything