• Advertisement
Sign in to follow this  

How to multiply Pixels on a PNG Loaded SDL Surface?

This topic is 1929 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


I was hoping someone could tell me what is required to multiply the[i] pixels[/i] on an PNG Loaded Surface

[b]"What I mean is zoom the png file so its bigger then its orginal PNG Loaded size on a SDL Surface"[/b]

I'm able to manipulate just normal[i] pixels[/i] and put them on the screen and make [i]gradient rectangles[/i] with them

but I really don't understand how to do the multiplication on the PNG loaded Surface pixels

my thought was too :

[i]get the surface->pixels member and then get the width and height store them all in separate variables then multiply them then load them back into surface->pixels member if that's even possible am I correct? [/i]
[i]probably wrong ;/[/i]

any solutions? ;/

#include <SDL/SDL.h>
#include <SDL/SDL_Image.h>
#include <iostream>
#include <math.h>
#undef main

using namespace std;

SDL_Surface *Screen = SDL_SetVideoMode(640,480,32,SDL_SWSURFACE);
void pixeltest(int x, int y , int color)
unsigned int *poo = static_cast <unsigned int *> (Screen->pixels);
int offset = y * (Screen->pitch / sizeof(unsigned int));

for(x = 0; x <= 1000; x++)
poo[offset + x] = color;
int main(int argc, char *argv[])
SDL_Surface *PNG , *Imagetest;

SDL_Color WhiteColor={255,255,255};

PNG = IMG_Load("ChocoLeft1.png");
Uint8* keystate;

keystate = SDL_GetKeyState(NULL);
int pngy = 0;
int pngx = 0;
int pngcolor = 0;

unsigned int *pngptr = static_cast <unsigned int *> (PNG->pixels);
int pngoffset = pngy * (PNG->pitch / sizeof(unsigned int));
bool done = false;

SDL_Event event;

keystate = SDL_GetKeyState(0);


for(pngx = 0; pngx <= 100; pngx++)
pngptr[pngoffset + pngx] = pngcolor;

case SDL_QUIT:
return 0;




[/CODE] Edited by DarkHorseKnight

Share this post

Link to post
Share on other sites
Two things which I would like to clarify first [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img].

First off, it is called scaling, multipling in conjunction with pixels is often used when we talk about shaders/blending or even photoshop layers. The second point is, that png is just a fileformat, once it is loaded, it doesn't matter any longer.

To scale your image with sdl take a look [url="http://www.sdltutorials.com/sdl-scale-surface"]here[/url]. Edited by Ashaman73

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement