Having access to the pixels of any image through the SFML library, my goal is to capture them and convert them to characters by placing them in a new array (image) and then displaying it. For this I checked the size of the image:
sf::Vector2u tam = imagem.getSize();
int largura = tam.x;
int altura = tam.y;
To capture the RGB format, use the following code:
// O ponteiro dos pixel originais em RGBA.
const sf::Uint8* pixels = imagem.getPixelsPtr();
Pixel* rgba = (Pixel*) pixels;
// Vetor que armazenará os pixels.
sf::Uint8* saida = new sf::Uint8[4 * largura * altura];
int tamanho = 4 * largura * altura;
for (int i = 0; i < tamanho; i++)
{
saida[i] = pixels[i];
}
What I'm doing is creating a vector that is receiving RGBA, but still no conversion to characters, and this is one of my doubts how is a vector how will I control when it should break the line to form the correct image? Home
Would not it be better to do with an array?
My other question is how do I convert these pixels into characters?
I tried this way, but to no avail:
for (int i = 0; i < tamanho; i++)
{
if (atriz[i][j]>=9,4*8)
saida[i] = '@';
}