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

Author Topic: Resizing images  (Read 1491 times)

0 Members and 1 Guest are viewing this topic.

Karleon

  • Newbie
  • *
  • Posts: 18
    • View Profile
Resizing images
« on: November 10, 2012, 11:47:45 pm »
Hello!

This is my very first question. I just started messing with SFML, so.... please be gently if I look a bit retarded :)


I have two Images:

-One small image composed of 5 different tiles.

-One big and empty image.

I want to make a mosaic-like image in the big one, using the tiles in the small one. The small image with the tiles have always the same size, but I want to be able, by changing the value of a constant I have in my code, to resize the tiles.


The funcion:
void    copy (const Image &source, unsigned int destX, unsigned int destY, const IntRect &sourceRect=IntRect(0, 0, 0, 0), bool applyAlpha=false)

Doesn't really fit my needs, since it would just pick the 20x20 image, and paste it as a 20x20 image, and I want to paste it as a 40x40 image (for example).


Is there any way to paste a resized version of the copied image?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Resizing images
« Reply #1 on: November 11, 2012, 12:26:15 am »
I'd advise you to use SFML 2, which has less bugs, isn't 2 years old and unmaintained. ;)

Anyways you don't have to copy things around, just use a sf::Sprite and the SetSubRect function to define which part of the sf::Image should get displayed.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Karleon

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Resizing images
« Reply #2 on: November 11, 2012, 01:01:38 am »
I'm using SFML 2.0

If I use sprites... if i want to make a 10x10 tile mosaic.... should I be using 100 differente sprites? Or using a single sprite changing it's properties each time I want to draw a single tile?

The idea was to compose the big image with the little tiles once, and draw the result for the rest of the execution...

Am  missing something?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Resizing images
« Reply #3 on: November 11, 2012, 01:11:05 am »
Okay then you could just use one sf::Sprite and change the position and texture coords and draw it onto a sf::RenderTexture. Then you assign the texture of the render texture to another sprite and use that through out the rest of the execution.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/