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

Author Topic: [solved]Copying pixels/image to a larger image?  (Read 3207 times)

0 Members and 1 Guest are viewing this topic.

Ashenwraith

  • Sr. Member
  • ****
  • Posts: 270
    • View Profile
[solved]Copying pixels/image to a larger image?
« 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
[solved]Copying pixels/image to a larger image?
« Reply #1 on: April 11, 2010, 09:21:51 pm »
sf::Image::Copy ?
Laurent Gomila - SFML developer

Ashenwraith

  • Sr. Member
  • ****
  • Posts: 270
    • View Profile
[solved]Copying pixels/image to a larger image?
« Reply #2 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  
 )

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
[solved]Copying pixels/image to a larger image?
« Reply #3 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);
Laurent Gomila - SFML developer

Ashenwraith

  • Sr. Member
  • ****
  • Posts: 270
    • View Profile
[solved]Copying pixels/image to a larger image?
« Reply #4 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)?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
[solved]Copying pixels/image to a larger image?
« Reply #5 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).
Laurent Gomila - SFML developer

Ashenwraith

  • Sr. Member
  • ****
  • Posts: 270
    • View Profile
[solved]Copying pixels/image to a larger image?
« Reply #6 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.

 

anything