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

Author Topic: Problem when rendering images  (Read 3046 times)

0 Members and 1 Guest are viewing this topic.

wicked357

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • http://www.eternalcoding.com
Problem when rendering images
« on: September 03, 2010, 10:25:10 am »
I didn't really notice this until I started working on my tilemap system for my game, but all my images I try and render have a weird edge color to them on the top and left side of the images. Also I noticed that when I try and declare SetSubRect(left, top, right, bottom) my tile will only be 31, 31 and if I try and make it 32, 32 like it is in the tilesheet I get a portion of the other tile. Is this something already known, or what is the issue I am having here. I tried using different format images and that doesn't seem to fix the issue. I am starting small like a 3x3 tilemap, and I haven't been able to move up to larger because the issue stays the same. Do I need to create a empty space around all my tiles will that fix the issue? It almost seems like in the tilesheet it is blending the edges of the tiles around it creating a faded color. If the tile is alone a 32x32 image, than that faded border is on the top and left like I stated above.

Here is my code, below, if I set the subrect to be 32, 32, 64, 64 I get partial edge of my other tile, and if I try 33, 33, 65, 65 I also get partial edge of my other tile, seems like they are blending some how. And if I do 33, 33, 64, 64 I get not partial edges but then my tile is 31x31 when I take a screenshot and size it up.

Code: [Select]

int main()
{
sf::RenderWindow Game(sf::VideoMode(800, 600, 32), "SFML CLevel Class Test", sf::Style::Close);
sf::Event Event;
const sf::Input& Input = Game.GetInput();

sf::Image Buffer;
sf::Sprite Sprite;
if(!Buffer.LoadFromFile("MapSheet.png"))
return EXIT_FAILURE;
else
{
Sprite.SetImage(Buffer);
Sprite.SetSubRect(sf::IntRect(33, 33, 64, 64));
Sprite.SetPosition(100, 100);
}

while(Game.IsOpened())
{
while(Game.GetEvent(Event))
{
if(Event.Type == sf::Event::Closed)
Game.Close();
}

if(Input.IsKeyDown(sf::Key::Escape))
Game.Close();

Game.Clear(sf::Color(100, 149, 236));

Game.Draw(Sprite);

Game.Display();
}

return EXIT_SUCCESS;
}

Kingdom of Fish

  • Jr. Member
  • **
  • Posts: 72
    • View Profile
Problem when rendering images
« Reply #1 on: September 03, 2010, 02:19:59 pm »
What version of SFML are you using? (I'm guessing 1.6)

Mindiell

  • Hero Member
  • *****
  • Posts: 1261
    • ICQ Messenger - 41484135
    • View Profile
Problem when rendering images
« Reply #2 on: September 03, 2010, 03:01:40 pm »
Try something like Buffer.SetSmooth(false);
Mindiell
----

CytraL

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
    • GitHub
Problem when rendering images
« Reply #3 on: September 03, 2010, 04:14:38 pm »
Sprite.SetSubRect(sf::IntRect(33, 33, 64, 64)) = 64-33 x 64-33 = 31x31


Sprite.SetSubRect(sf::IntRect(left, top, left+width, top+height))

Size Sprite = left+width-left x top+height-top = widthxheight
dev@redneboa.es | WordPress | GitHub | YouTube

wicked357

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • http://www.eternalcoding.com
Problem when rendering images
« Reply #4 on: September 03, 2010, 05:57:06 pm »
Quote from: "Mindiell"
Try something like Buffer.SetSmooth(false);


Thanks for the suggestion, this cleaned it up and now it displays the way I have it in my tile sheet.

 

anything