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

Author Topic: [SOLVED]Draw in a 200x200 display which actually is 32x32  (Read 2779 times)

0 Members and 2 Guests are viewing this topic.

Chrupiter

  • Newbie
  • *
  • Posts: 8
    • View Profile
[SOLVED]Draw in a 200x200 display which actually is 32x32
« on: April 19, 2015, 06:15:09 pm »
Here's the issue.
I've an image of 32x32 pixels on which I can draw. But drawing in such a small window is really hard.
So I want this image to be displayed as a 200x200 image, but actually it must be 32x32.
For example, if you in Paint create a new image 32x32, then you zoom in, you get what I'm talking about.
But I don't wanna zoom in dynamically, I want it to be fixed 200x200, so that I'll still be able to export the image in 32x32.
I found the class view, but it allows me only to see a region zoomed, then when i try to draw the program crashes because it's as if i were drawing outside the image.
Thanks.
« Last Edit: April 19, 2015, 10:11:19 pm by Chrupiter »

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Draw in a 200x200 display which actually is 32x32
« Reply #1 on: April 19, 2015, 06:23:04 pm »
So I want this image to be displayed as a 200x200 image, but actually it must be 32x32.
Create a 200x200 window with a 32x32 view. It's very simple, have a look at the view tutorial and documentation.

then when i try to draw the program crashes because it's as if i were drawing outside the image.
SFML doesn't crash when you draw outside the view. You do something else wrong.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Chrupiter

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Draw in a 200x200 display which actually is 32x32
« Reply #2 on: April 19, 2015, 06:29:40 pm »
SFML doesn't crash when you draw outside the view. You do something else wrong.

It crashes because I draw outside the image like this:
Code: [Select]
//given image of 32x32
image.setPixel(mouse.x,mouse.y, color);

when x or y are bigger than 32 it crashes. Anyway, I'll try what you said, thanks.
« Last Edit: April 19, 2015, 06:31:16 pm by Chrupiter »

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Draw in a 200x200 display which actually is 32x32
« Reply #3 on: April 19, 2015, 06:39:24 pm »
It crashes because I draw outside the image like this:
Code: [Select]
//given image of 32x32
image.setPixel(mouse.x,mouse.y, color);
That's not drawing, just setting pixels in a container.

Yes, of course you cannot access indices outside the image... It's the same with every array.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Chrupiter

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Draw in a 200x200 display which actually is 32x32
« Reply #4 on: April 19, 2015, 06:58:02 pm »
I can't fix this. Even if I set the view, I can't draw correctly in it.
This is what happens to me:
(click to show/hide)
I draw where the mouse is, and the result on the view is not where i'd like it to be. It still gets my mouse coordinates from the 32x32 image on the top-left.

AlexxanderX

  • Full Member
  • ***
  • Posts: 128
    • View Profile
    • AlexanderX
Here you can find my blog and tutorials about SFML - http://alexanderx.net/ (died...) - http://web.archive.org/web/20160110002847/http://alexanderx.net/

Chrupiter

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Draw in a 200x200 display which actually is 32x32
« Reply #6 on: April 19, 2015, 09:49:45 pm »
It worked, thanks. I had already tried that but it didn't work, now it does.

 

anything