SFML community forums

Help => Graphics => Topic started by: Ashenwraith on April 11, 2010, 09:16:28 pm

Title: [solved]Copying pixels/image to a larger image?
Post by: Ashenwraith on April 11, 2010, 09:16:28 pm
How do you copy an image (NOT RESIZE) to a larger one?

I tried copying pixels onto a larger image and it overwrites it or errors out.
Title: [solved]Copying pixels/image to a larger image?
Post by: Laurent on April 11, 2010, 09:21:51 pm
sf::Image::Copy ?
Title: [solved]Copying pixels/image to a larger image?
Post by: Ashenwraith on April 11, 2010, 10:49:57 pm
Quote from: "Laurent"
sf::Image::Copy ?


Oh wow, thanks--Sorry about that, I don't know how I missed that.

I was just thinking 'shouldn't this have a rect'.

Btw, can you give me a bit of help with the Rect constructor, I have:

Code: [Select]
sf::Rect<int> rct=sf::Rect(1,1,1,1); //doesn't work

NVM, i just got the template code to work...

sf::Rect<int> rct=sf::Rect<int>(1,1,1,1);

looks different than the doc:

sf::Rect< T >::Rect  ( T  LeftCoord,  
  T  TopCoord,  
  T  RightCoord,  
  T  BottomCoord  
 )
Title: [solved]Copying pixels/image to a larger image?
Post by: Laurent on April 11, 2010, 11:15:35 pm
Quote
looks different than the doc:

sf::Rect< T >::Rect ( T LeftCoord,
T TopCoord,
T RightCoord,
T BottomCoord
)

Yup, this is how the constructor of a template class is defined. But when you want to construct an instance you have to use the identifier of the class, sf::Rect<T>.

By the way, this is better:
Code: [Select]
sf::Rect<int> rct(1,1,1,1);
And this is even better;
Code: [Select]
sf::IntRect rct(1,1,1,1);
Title: [solved]Copying pixels/image to a larger image?
Post by: Ashenwraith on April 12, 2010, 12:26:07 am
Thanks again.

The syntax is quite a bit different than the C++ of 10 years ago.

I keep getting warnings <iostream.h> is deprecated and I guess I'm not supposed to use cout << anymore, but std::cerr (or something like that)?
Title: [solved]Copying pixels/image to a larger image?
Post by: Laurent on April 12, 2010, 12:32:23 am
Wow, you really haven't practiced C++ for 12 years, this is amazing :D

The header is <iostream> and you must use std::cout (but you can use std::cerr as well if you want).
Title: [solved]Copying pixels/image to a larger image?
Post by: Ashenwraith on April 12, 2010, 12:52:22 am
Quote from: "Laurent"
Wow, you really haven't practiced C++ for 12 years, this is amazing :D

The header is <iostream> and you must use std::cout (but you can use std::cerr as well if you want).


Yeah, I got tired of dll/lib hell so I stopped, but now I'm back because I want my tools/apps fast.

SFML is a lot nicer than the GLUT/DirectX bastard projects I used to make.