Code: Select all
SDL_Surface* surface = IMG_Load( "image.jpg" );
//Go through columns
for( int x = 0; x < surface->w; x++ ) {
//Go through row
for( int y = 0; y < surface->h; y++) {
//NEED HELP HERE on how to change a pixel of surface
}
}
Moderator: Coders of Rage
Code: Select all
SDL_Surface* surface = IMG_Load( "image.jpg" );
//Go through columns
for( int x = 0; x < surface->w; x++ ) {
//Go through row
for( int y = 0; y < surface->h; y++) {
//NEED HELP HERE on how to change a pixel of surface
}
}
That's a really, really bad idea first of all.xx6heartless6xx wrote:After I load an image in OpenGL I want to shuffle through the image and change the pixel color to another color or change its alpha. The problem is I don't know how to shuffle through in my loadImage function. I am loading the image in SDL first in case it matters. The commented part is where I need help on and here is what I have so far:Code: Select all
SDL_Surface* surface = IMG_Load( "image.jpg" ); //Go through columns for( int x = 0; x < surface->w; x++ ) { //Go through row for( int y = 0; y < surface->h; y++) { //NEED HELP HERE on how to change a pixel of surface } }
I've tried this before but its not working for me. The image just turns out the same or not at all.N64vSNES wrote:I'm fairly sure this is what you're looking for:
http://lazyfoo.net/SDL_tutorials/lesson31/index.php
Can you give me a simple example of how to do this? I'm still a beginner to openglGyroVorbis wrote:That's a really, really bad idea first of all.xx6heartless6xx wrote:After I load an image in OpenGL I want to shuffle through the image and change the pixel color to another color or change its alpha. The problem is I don't know how to shuffle through in my loadImage function. I am loading the image in SDL first in case it matters. The commented part is where I need help on and here is what I have so far:Code: Select all
SDL_Surface* surface = IMG_Load( "image.jpg" ); //Go through columns for( int x = 0; x < surface->w; x++ ) { //Go through row for( int y = 0; y < surface->h; y++) { //NEED HELP HERE on how to change a pixel of surface } }
You should look into using a palette or a color look-up table instead. That way each pixel is just an index into a color, and you only modify the color in the table, rather than iterating through an entire texture to fuck with it.