3
I am developing a project where I must access pixel of an image and put them in a new matrix in RGB, for this I am using the SFML library, my difficulty is in logic, I know that a pixel is the smallest point of an image and that library gives me access to it through the code:
const sf::Uint8* pixels = imagem.getPixelsPtr();
For documentation the library stores pixels in a vector.
What I’m doing is this: knowing the height and width of it, I’m walking around with a loop and I try to catch the pixels!
// Descobre o tamanho da imagem
sf::Vector2u tam = imagem.getSize();
int largura = tam.x;
int altura = tam.y;
for(int i = 0; i < largura ; i++)
{
for(int j = 0; j < altura; j++)
{
///METODO DA BIBLIOTECA SFML, PARA ACESSAR O PIXEL.
const sf::Uint8* pixels = imagem.getPixelsPtr();
}
}
How do I convert this image to RGB and put them into another vector?
Hello all right @carlosrafaelgn? Thanks for the answer, sorry my iguinorancia I’m still studying hehe, but if I put up in a matrix instead of a vector the code would be more or less like this?!
int mat[largura][altura];
memcpy(mat, imagem.getPixelsPtr(), 4 * largura * altura);
not wanting to extend myself too much, but another part of the project is to change the pixels listed by characters, the use of this method would not complicate me further?! Att– Emanoel
Wow...! I didn’t really get the idea of changing pixels by characters... :(
– carlosrafaelgn
Hello, this project is for a code that will create an ASCIIART in c++, as this I must in addition to get the pixels convert them to characters before putting them in a new matrix (the new image).
– Emanoel
Well, in this case, the conversation is different... ;) Take a look at these 3 links here: ASCII Art no SO, ASCII Art in Codeproject and a lib for that AA-lib
– carlosrafaelgn