W
Wraithious
Guest
Hi, I'm having a horrible time trying to get this FOR loop to work correctly, I will explain it first.
What it's supposed to do:
takes segments from an image and draws them in order 1 time to make a complete new image while background_showcolour=false, then a picture is taken of the image, assigned to a sprite, then an object has it's sprite changed to the new picture and background_showcolour is set back to true.
How it's set up:
user loads picture, the processor object is created and in it's create event breaks up the picture into 50 x 50 chunks max size (2500 pixels) and records how many chunks (segments), the starting x,y of each segment, the width and height of each segment, and the area of each segment.
the user presses enter, enter sets starting point of picture and sets alarm.
Alarm gets and evaluates each pixel in the image segment by segment, after each segment is processed the alarm lets the step event take a step which updates the progress bar, then if there are more segments sets the alarm again, repeats until all segments are done.
This is where the drawing event is now activated with the for loop i've spent 3 days trying to get to work correctly,
The for loop variables explained:
brk- the number of segments in the image
array colorize[ brk-1 ] - if all segments have been processed (brk -1 because arrays start at 0)
o- itterator value
h- total number of pixels in the complete image
g- incremental variable for x positions in the current segment
l- incremental variable for y positions in the current segment
colorsmake[ ] - array holding every pixel's color in the complete image
drwatx[ ] - array variable for the starting x position of the current segment
drwaty[ ] - array variable for the starting y position of the current segment
iii- variable to define which segment we are currently drawing, starts as 0 and ends at brk-1
v[ ] - width of the current segment in pixels
w[ ] - height of the current segment in pixels
The Loop code in the drawing event:
If the picture is 50 x 50 pixels or smaller it works perfectly, but if it's larger This is what I get at best for a result:
The picture on the right is the result, I broke it up (left pic) to try and see what was going on, and it looks like the for loop is not deligating the segments correctly, in fact, each time the loop ends a segment it cuts off the top row of the 2nd segment, top 2 rows of the 3rd, then switches and cuts off the last 3 rows of the 4th, last 4 rows of the 5th, etc till the last segment, as you can also see the missing segments are there and evenly fragmented through the entire image!! what is going on here?! Please if anyone can help with what I'm doing wrong that would be awesome, if you need more code I can provide it but I know from checking the other codes that feed this loop they are all correct.
What it's supposed to do:
takes segments from an image and draws them in order 1 time to make a complete new image while background_showcolour=false, then a picture is taken of the image, assigned to a sprite, then an object has it's sprite changed to the new picture and background_showcolour is set back to true.
How it's set up:
user loads picture, the processor object is created and in it's create event breaks up the picture into 50 x 50 chunks max size (2500 pixels) and records how many chunks (segments), the starting x,y of each segment, the width and height of each segment, and the area of each segment.
the user presses enter, enter sets starting point of picture and sets alarm.
Alarm gets and evaluates each pixel in the image segment by segment, after each segment is processed the alarm lets the step event take a step which updates the progress bar, then if there are more segments sets the alarm again, repeats until all segments are done.
This is where the drawing event is now activated with the for loop i've spent 3 days trying to get to work correctly,
The for loop variables explained:
brk- the number of segments in the image
array colorize[ brk-1 ] - if all segments have been processed (brk -1 because arrays start at 0)
o- itterator value
h- total number of pixels in the complete image
g- incremental variable for x positions in the current segment
l- incremental variable for y positions in the current segment
colorsmake[ ] - array holding every pixel's color in the complete image
drwatx[ ] - array variable for the starting x position of the current segment
drwaty[ ] - array variable for the starting y position of the current segment
iii- variable to define which segment we are currently drawing, starts as 0 and ends at brk-1
v[ ] - width of the current segment in pixels
w[ ] - height of the current segment in pixels
The Loop code in the drawing event:
Code:
///Colorize effect
if(global.effect=8 && global.snshop=1 && colorize[brk-1]=1)//if true draw the image
{
for(o=0;o<h;o+=1;)
{
draw_point_colour(g,l,colsmake[o]);
g+=1;
if(g=drwatx[iii]+v[iii] && l<drwaty[iii]+w[iii])
{
g=drwatx[iii];
l+=1;
}
if(g=drwatx[iii]+v[iii] && l=drwaty[iii]+w[iii] && iii<brk)
{
iii+=1;
g=drwatx[iii];
l=drwaty[iii];
}
}
}
The picture on the right is the result, I broke it up (left pic) to try and see what was going on, and it looks like the for loop is not deligating the segments correctly, in fact, each time the loop ends a segment it cuts off the top row of the 2nd segment, top 2 rows of the 3rd, then switches and cuts off the last 3 rows of the 4th, last 4 rows of the 5th, etc till the last segment, as you can also see the missing segments are there and evenly fragmented through the entire image!! what is going on here?! Please if anyone can help with what I'm doing wrong that would be awesome, if you need more code I can provide it but I know from checking the other codes that feed this loop they are all correct.