Jump to content

  • Log In with Google      Sign In   
  • Create Account


DarkHorseKnight

Member Since 11 Jul 2011
Offline Last Active Nov 20 2012 11:34 AM
-----

Posts I've Made

In Topic: Left over garbage pixels from copying a pixel value to new location? C/SDL

04 November 2012 - 06:48 AM


Your drawing a rectangle for the water right then altering the pixels on that rectangle how?

No, I'm creating an empty surface, then altering the pixels on that surface.
I then draw the altered surface onto the screen.

Why are we comparing surfaces?

I'm not comparing surfaces, I'm altering one surface (updating it every 1/10th of a second), and drawing it onto the screen (a second surface) every frame.

How are you setting the area of which the pixels values can be gotten and placed elsewhere?

I'm not setting the area, I'm passing in the surface to the WritePixel() and ReadPixel() functions. I'm getting and reading pixels from a surface.
Actually, to be more exact, I didn't do any pixel-reading at all, just writing.

In SDL, a "surface" is a image that exists in memory. I'm editing that image; I'm not editing the screen. I'm editing the image, then I'm drawing the image onto the screen.

Quote a line of code, then ask about any specific line of code you have questions about - make sure your specify exactly what part you don't understand.



Okay so
return pixels[offset + x];
how does return of pixels[offset + x]; work exactly?


Why are you locking surfaces to access pixels to stop tearing or something?


this function below makes a rect filling it with a user defined color yes?
void DrawRectangle(SDL_Surface *destination, const SDL_Color &color, SDL_Rect *rect = NULL)
  {SDL_FillRect(destination, rect, SDL_MapRGB(destination->format, color.r, color.g, color.b));}

this code is fairly hard to grasp the technical concepts

SDL_Surface *CreateEmptySurface(int width, int height, SDL_Surface *surfaceToCompareTo){   SDL_Surface *newSurface = SDL_CreateRGBSurface(surfaceToCompareTo->flags, int width, int height, surfaceToCompareTo->format->BitsPerPixel,																								 surfaceToCompareTo->format->Rmask, surfaceToCompareTo->format->Gmask,																								   surfaceToCompareTo->format->Bmask, surfaceToCompareTo->format->Amask);
 
  if(!newSurface) {std::cerr << "CreateEmptySurface() - Something went wrong creating a " << width << "x" << height << " surface.\n" << "  Error: " << SDL_GetError() << std::endl;}	   //Let's start off filling it with a solid color, like solid white.	  DrawRectangle(newSurface, SDL_Color(255, 255, 255));    return newSurface;}

What does this do from a technical point of view
SDL_Surface *waterImage = CreateEmptySurface(50, 50, screen);

This code below is oddly written what does that all mean ?
void MakeWaterSurface(SDL_Surface *surface, unsigned int frame){	    //We only have 20 frames, so keep within range. frame %= 20;    int offset = frame;	 if(offset >= 10)	    {			   //0 1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 1			  offset = (10 - (offset - 10));  }	   SDL_Color colors[] = {SDL_Color(100, 150, 190),SDL_Color(100, 160, 180),SDL_Color(100, 170, 170),SDL_Color(100, 180, 160),SDL_Color(100, 190, 150),											   SDL_Color(100, 190, 170),SDL_Color(100, 190, 190),SDL_Color(100, 190, 210),SDL_Color(100, 190, 230),SDL_Color(100, 220, 250)};	    for(int y = 0; y < surface->height; y++)	    {			   for(int x = 0; x < surface->height; x++)			    {					   //I'm coding blind without a compiler, so I have completely no idea if this will work or not.				   int waveDepth = ((y + offset) % 10);								    int waveHorizontalOffset = ((x + (offset/3)) % 20);					 int waveVerticalOffset = ((x + waveHorizontalOffset) + offset);								 unsigned colorIndex = (waveDepth + waveVerticalOffset) % 10;								    WritePixel(x, y, colors[colorIndex], surface);		  }	   }}

Theres still more for me to look at but this is as far as I've gotten in trying to understand not used any of this yet.













In Topic: Left over garbage pixels from copying a pixel value to new location? C/SDL

03 November 2012 - 07:40 AM

bump

In Topic: Left over garbage pixels from copying a pixel value to new location? C/SDL

03 November 2012 - 04:27 AM

I generally have no idea about all of this accept my 2 functions , it would be awesome if someone could do like a simplist explanation on all this new stuff so I can see and know whats going on .


Your drawing a rectangle for the water right then altering the pixels on that rectangle how?

Why are we comparing surfaces?


How are you setting the area of which the pixels values can be gotten and placed elsewhere?

yes a full explanation is required ! Posted Image

In Topic: Left over garbage pixels from copying a pixel value to new location? C/SDL

02 November 2012 - 06:12 PM

1) What type of pixels are you looking to "detect"? Are they a certain color?

Image pixels as in the pixels in the PNG Image which is RGBA 32bpp "That could be wrong format".

2) What type of pixels do you consider "garbage"? What makes them "garbage" - their color or some action?

There garbage if a pixel value and location is left-over after one pixel value is gotten and placed in a different location.

3) You said detect "around" the area of the garbage pixel. What does "around" mean? One pixel around? Two pixels around?

Detect the pixels around the area as in any area I specify could be 40 by 40 pixels or 100 by 100 pixels.

4A) Could you also explain, carefully (it takes me some time to understand ), what it is, in detail, that you are wanting (and why)?

To make a wave effect by moving 40 by 40 pixels up and down in a png image.

So I can have a decent and cool water effect without loading in each frame of animation of a Adobe After Effects Water Animation .

4B) How are you currently attempting it?

I don't actually know the code to get rid of pixel in a png image which has already been found from pixelget which puts in a different location with the pixel found by the function pixelget.

5A) What is the correct result that you'd like?

1.) having user-defined way to put in the x and y values of the area of pixels

2.) to find and place the pixels in a different location using the x and y values.

5B) What is the wrong result your current attempt is giving you?

Well I can get values and place them somewhere else but not automatically and in a area specified by me in the x and y .

In Topic: Left over garbage pixels from copying a pixel value to new location? C/SDL

01 November 2012 - 06:51 PM

BUMP

PARTNERS