Sprite, Texture, image and bitmap. confused

Started by
6 comments, last by Kaptein 9 years, 10 months ago

Hi

I started to make game but i really don't understand whats Sprite, Texture, and bitmap images vs normal png and jpeg images

sorry but i really don't know :D

Thanks

Advertisement

I suspect the exact definitions depend on the context. Where did you read about these things? Was it when learning SFML?

I suspect the exact definitions depend on the context. Where did you read about these things? Was it when learning SFML?

yes i'm about to learn SFML

If you're using SFML, you need to load a texture, then bind it to a sprite. A texture can be many formats, among them the jpeg and png formats you mentioned. Formats all vary, but there are important differences, but the most likely important difference for you is that a .png file can hold transparency information (so, if you don't want your sprite to look like a square or rectangle, you'll possibly use a png format). So, in simple terms, you load a texture and stick it onto a sprite. The sprite will be an object you create.

So, think of the different formats as ways of storing the information of the "picture" that you want to use. They all store different information (such as transparancy) and store it in different ways. with SFML you don't need to be concerned with the way it stores the information at this point, but be aware of what information it can store.

the SFML site has some pretty simple but also really useful tutorials on this.

http://www.sfml-dev.org/tutorials/2.1/graphics-sprite.php

and if that's feeling a bit abstract still, this video will walk you through it step by step:

Beginner here <- please take any opinions with grain of salt

I don't quite like Misantes's answer because it isn't precise enough, although perhaps you don't need more precision at this point. A texture is an object in memory that contains an image. You will typically read the image data from a file, and that's where the different formats come in. But the format is just a convention of how an image is represented in a file: Once you have loaded that image into a texture, it doesn't even make sense to talk about what format the texture uses.

I like the recommendation of using the PNG format for images that describe sprites, because of the availability of a transparency channel and because it doesn't use lossy compression, so you won't get funky compression artifacts.

I was also going to post a link to this SFML tutorial page: http://www.sfml-dev.org/tutorials/2.1/graphics-sprite.php

Thank you guys

@Alvaro,

You're totally right :) I just didn't want to overload him/her with too much technicality as it can be a bit confusing for a beginner (I know half the answers I get to questions on here tend to go over my head :P). But, your explanation definitely touches on some important points I glossed over, that if learned incorrectly at the start can cause problems later on in the learning process. Especially, that of the texture being an object in memory to be accessed later. Which, is important to note that you can use the same texture for multiple sprites.

Beginner here <- please take any opinions with grain of salt

A sprite is whatever you want it to be, typically an image or part of an image shown on the screen. Bitmap is a term for a stored (binary) image. It could be on disk, stored as bits or in memory. When you load a PNG file its decompressed and stored in memory as a bitmap. From there you can store it on the GPU as a texture. A texture can be used when drawing. If you treat parts of a texture as a sprite, you have a spritesheet - there are many sprites on it.

Here's an example:

http://www.fabiobiondi.com/blog/wp-content/uploads/2012/08/runningGrant.png

As you can see, the texture coordinates you use when drawing is important: They define which portion of the spritesheet you are drawing from.

Imagine you assigned boundries around one of the characters shown in the spritesheet, and we will call that a frame. The boundries for a specific frame is defined by you, by specifying texture coordinates. You can animate the character by changing frames back and forth.

Here's an example of frames being changed over time, which makes a running animation:

http://www.pixeljoint.com/files/icons/full/sol_run_sprite_0.gif

As you can see, the frames boundries aren't optimal, but that doesn't really matter here because the character in the animation is completely visible.

This topic is closed to new replies.

Advertisement