Ugly or a horror?
-
I wrote this at 4AM the other morning :S I'm a little embarrassed. But it's still doing it's bit in my program.
for(int y = 0; y < bmp.biHeight; y=y+3){
for(int x = 0; x < bmp.biWidth; x=x+3){
for(int i = 0; i < 9; i++){
int yp=0, xp=0;
get_pixel(x+xp,y+yp,blank[i]);
if(xp<3)
xp++;
else{
xp = 0;
yp++;
}}
avg(blank, Merge, 9);
set_pixel(x,y,Merge);
for(int i = 0; i < 9; i++){
blank[i].rgbtBlue=0;
blank[i].rgbtGreen=0;
blank[i].rgbtRed=0;
}
clear_pixel(Merge);
yp=0, xp=0;
}}"Sir, I protest. I am NOT a merry man!"
-
I wrote this at 4AM the other morning :S I'm a little embarrassed. But it's still doing it's bit in my program.
for(int y = 0; y < bmp.biHeight; y=y+3){
for(int x = 0; x < bmp.biWidth; x=x+3){
for(int i = 0; i < 9; i++){
int yp=0, xp=0;
get_pixel(x+xp,y+yp,blank[i]);
if(xp<3)
xp++;
else{
xp = 0;
yp++;
}}
avg(blank, Merge, 9);
set_pixel(x,y,Merge);
for(int i = 0; i < 9; i++){
blank[i].rgbtBlue=0;
blank[i].rgbtGreen=0;
blank[i].rgbtRed=0;
}
clear_pixel(Merge);
yp=0, xp=0;
}}"Sir, I protest. I am NOT a merry man!"
-
I wrote this at 4AM the other morning :S I'm a little embarrassed. But it's still doing it's bit in my program.
for(int y = 0; y < bmp.biHeight; y=y+3){
for(int x = 0; x < bmp.biWidth; x=x+3){
for(int i = 0; i < 9; i++){
int yp=0, xp=0;
get_pixel(x+xp,y+yp,blank[i]);
if(xp<3)
xp++;
else{
xp = 0;
yp++;
}}
avg(blank, Merge, 9);
set_pixel(x,y,Merge);
for(int i = 0; i < 9; i++){
blank[i].rgbtBlue=0;
blank[i].rgbtGreen=0;
blank[i].rgbtRed=0;
}
clear_pixel(Merge);
yp=0, xp=0;
}}"Sir, I protest. I am NOT a merry man!"
-
Yeah, that was an error I have since fixed.
long xp=0, yp=0
was defined before this segment. Only after did I realise I had 'int'ed them."Sir, I protest. I am NOT a merry man!"
-
Yeah, that was an error I have since fixed.
long xp=0, yp=0
was defined before this segment. Only after did I realise I had 'int'ed them."Sir, I protest. I am NOT a merry man!"
Did you also realize that you haven't 'int'ed them, you actually have 2 new variables defined in the scope of the inner loop? :-P the
long
ones are only being assigned 0 every time that loop executes and thats it. Scope is a wonderful thing, but it can also come back to bite you if you aren't careful. -
Did you also realize that you haven't 'int'ed them, you actually have 2 new variables defined in the scope of the inner loop? :-P the
long
ones are only being assigned 0 every time that loop executes and thats it. Scope is a wonderful thing, but it can also come back to bite you if you aren't careful.Yes... that was the error I fixed.
"Sir, I protest. I am NOT a merry man!"
-
I wrote this at 4AM the other morning :S I'm a little embarrassed. But it's still doing it's bit in my program.
for(int y = 0; y < bmp.biHeight; y=y+3){
for(int x = 0; x < bmp.biWidth; x=x+3){
for(int i = 0; i < 9; i++){
int yp=0, xp=0;
get_pixel(x+xp,y+yp,blank[i]);
if(xp<3)
xp++;
else{
xp = 0;
yp++;
}}
avg(blank, Merge, 9);
set_pixel(x,y,Merge);
for(int i = 0; i < 9; i++){
blank[i].rgbtBlue=0;
blank[i].rgbtGreen=0;
blank[i].rgbtRed=0;
}
clear_pixel(Merge);
yp=0, xp=0;
}}"Sir, I protest. I am NOT a merry man!"
How fast does that run? in my experience using GetPixel and SetPixel are extremely slow
-
How fast does that run? in my experience using GetPixel and SetPixel are extremely slow
Fast enough that changing it would have no observable change. ;P But then, that may just be the fruits of overclocking.
"Sir, I protest. I am NOT a merry man!"
-
I wrote this at 4AM the other morning :S I'm a little embarrassed. But it's still doing it's bit in my program.
for(int y = 0; y < bmp.biHeight; y=y+3){
for(int x = 0; x < bmp.biWidth; x=x+3){
for(int i = 0; i < 9; i++){
int yp=0, xp=0;
get_pixel(x+xp,y+yp,blank[i]);
if(xp<3)
xp++;
else{
xp = 0;
yp++;
}}
avg(blank, Merge, 9);
set_pixel(x,y,Merge);
for(int i = 0; i < 9; i++){
blank[i].rgbtBlue=0;
blank[i].rgbtGreen=0;
blank[i].rgbtRed=0;
}
clear_pixel(Merge);
yp=0, xp=0;
}}"Sir, I protest. I am NOT a merry man!"
I can't even be assed looking at code formatted like that – incomprehensible! The first thing I do at work when I encounter rubbish like that is re-format it.
Steve
-
I wrote this at 4AM the other morning :S I'm a little embarrassed. But it's still doing it's bit in my program.
for(int y = 0; y < bmp.biHeight; y=y+3){
for(int x = 0; x < bmp.biWidth; x=x+3){
for(int i = 0; i < 9; i++){
int yp=0, xp=0;
get_pixel(x+xp,y+yp,blank[i]);
if(xp<3)
xp++;
else{
xp = 0;
yp++;
}}
avg(blank, Merge, 9);
set_pixel(x,y,Merge);
for(int i = 0; i < 9; i++){
blank[i].rgbtBlue=0;
blank[i].rgbtGreen=0;
blank[i].rgbtRed=0;
}
clear_pixel(Merge);
yp=0, xp=0;
}}"Sir, I protest. I am NOT a merry man!"
Nothing too bad there. One of the most "elegant" pieces of code I wrote in college was done after pounding down a fifth of tequila :-\ It was an amazing piece of work that worked very well.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon