Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualDarkHorseKnight

Posted 05 October 2012 - 07:31 PM

Hi!

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

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

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

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

my thought was too :

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?
probably wrong ;/


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);
//SDL_LockSurface(PNG);
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);
while(!done)
{
  SDL_FillRect(Screen,NULL,0xffff26);

  SDL_BlitSurface(PNG,NULL,Screen,NULL);

  for(pngx = 0; pngx <= 100; pngx++)
  pngptr[pngoffset + pngx] = pngcolor;
  
  while(SDL_PollEvent(&event))
  {
   switch(event.type)
   {
	case SDL_QUIT:
	return 0;
	break;
  
   }

  }

  SDL_Flip(Screen);

}
}

#1DarkHorseKnight

Posted 05 October 2012 - 07:30 PM

Hi!

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

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

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

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

my thought was too :

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?
probably wrong ;/


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);
//SDL_LockSurface(PNG);
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);
while(!done)
{
  SDL_FillRect(Screen,NULL,0xffff26);

  SDL_BlitSurface(PNG,NULL,Screen,NULL);
 
  for(pngx = 0; pngx <= 100; pngx++)
  pngptr[pngoffset + pngx] = pngcolor;
  
  while(SDL_PollEvent(&event))
  {
   switch(event.type)
   {
    case SDL_QUIT:
    return 0;
    break;
  
   }
 
  }
 
  SDL_Flip(Screen);

}
}

PARTNERS