SFML community forums

Help => General => Topic started by: delio on April 15, 2014, 05:38:16 pm

Title: Algorithm help!
Post by: delio on April 15, 2014, 05:38:16 pm
Hi,
I want to import bmp file to Tilemap.
but My tile map has only 40 colors.

This is my algorithm
1.Use SFML to convert color of bitmap to My Tilemap color.
2.read pixel of bitmap and store in array.
3.display Tilemap

Question is
1.How can I read pixel color in SFML?
2.How can I convert bmp color to nearest tilemap color by using SFML?

Sorry for bad explanation
Thanks,
delio
Title: Re: Algorithm help!
Post by: eXpl0it3r on April 15, 2014, 05:52:27 pm
Sorry for bad explanation
Well the "sorry" is on you, since I don't understand what you're trying to do... ;D

I want to import bmp file to Tilemap.
but My tile map has only 40 colors.
What is your "tilemap"?

1.How can I read pixel color in SFML?
You load things into an sf::Image and then use getPixel().

2.How can I convert bmp color to nearest tilemap color by using SFML?
I don't understand what you mean exactly, but you can iterate over all the pixels and change them with some simple math.

Why is there such a color limit?
Why don't you save the *.bmp directly with these colors, so you don't have to do it at runtime? ;)
Title: Re: Algorithm help!
Post by: delio on April 15, 2014, 05:58:17 pm
Tile map mean this : http://www.sfml-dev.org/tutorials/2.1/graphics-vertex-array.php#example-tile-map

I use tileset as a index of colors, and have only 40 colors.
but bitmap 32 bits have more than 40 colors.

I want to convert a bitmap picture to display in Tilemap by convert colors and store in array.


I don't understand what you mean exactly, but you can iterate over all the pixels and change them with some simple math.
Simple math is something about Hue or saturation?

Why is there such a color limit?
Why don't you save the *.bmp directly with these colors, so you don't have to do it at runtime? ;)
All of this is an argument of my school project :)
Title: AW: Re: Algorithm help!
Post by: eXpl0it3r on April 15, 2014, 06:57:23 pm
I use tileset as a index of colors, and have only 40 colors.
but bitmap 32 bits have more than 40 colors.
What 40 colors do you have then? I mean how do they define these 40 colors?

I want to convert a bitmap picture to display in Tilemap by convert colors and store in array.
Not sure if I'm starting to understand you, do you want to convert each pixel and then draw each pixel with a vertex array/tile map?

Simple math is something about Hue or saturation?
I don't know, bit converting some colors from the 32bit color space to your 40 color space shouldn't be so hard, if the 40 colors are logically choosen (while ignoring the uselessness of a 40 color limit).

All of this is an argument of my school project :)
Why don't you ask your assistant/prof/teacher first then? Because they (usually) get payed for their teaching/assistance, plus they probably speak your lanuage. ;)
Title: Re: Algorithm help!
Post by: delio on April 15, 2014, 07:24:44 pm
What 40 colors do you have then? I mean how do they define these 40 colors?
40 colors is colors that my teacher define.

Not sure if I'm starting to understand you, do you want to convert each pixel and then draw each pixel with a vertex array/tile map?
Yes!!

So SFML can't do this
I'll find another library
Thanks for answer :)

I don't know, bit converting some colors from the 32bit color space to your 40 color space shouldn't be so hard, if the 40 colors are logically choosen (while ignoring the uselessness of a 40 color limit).
40 colors isn't chosen by logically :(.

Why don't you ask your assistant/prof/teacher first then? Because they (usually) get payed for their teaching/assistance, plus they probably speak your lanuage.
This is project, I do by myself. No teacher can teach me :) .

like to do this in Photoshop
http://graphicdesign.stackexchange.com/questions/654/convert-a-pattern-photo-to-a-given-palette
Title: Re: Algorithm help!
Post by: StormWingDelta on April 16, 2014, 09:05:44 pm
SFML can do tile maps but it helps if we know more about what you are up to. :)


I'm guessing you could have tiles that were 1 pixel in size for 1 color but still not sure what you are up to at that point since you could store them in an array.


Also are you trying to convert from a BMP resource file in visual studio to an SFML image/texture?  If so I had this issue a while ago.  The only issue would be a C# to C++ change.