GetPixel bug
Displaying 1-8 of 8 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
RageCage

there's a bug in get pixel that will cause a windows illegal operation error. It happens when you try to get a pixel that is off the image, but it is extemely rare... but not rare enough for me to figure it out. This function fixes it for me... but maybe vec would like to look into this?


int getPixel2(int x, int y, int source){
if(x >= 0 && y >= 0 && x <= imageWidth(source) && y <= imageHeight(source) )
return getPixel(x,y,source);
return 0-1;
}

Posted on 2004-12-30 19:04:54 (last edited on 2004-12-30 19:04:55)

TomT64

what do you mean by 'rare'? As in, it only sometimes crashes?

Posted on 2004-12-30 23:42:17

Gayo

Posted on 2004-12-31 12:37:28

RageCage

well I ran another test for getPixel and found that it will crash if you get a pixel that is off the field in the positive by 3 pixels and off in the negitive by 61 pixels on a 100x100 image. It seems kinda weird that if you can get any off field that it would crash on some obscure number like that. but it will alwasy crash on those numbers for me.

Posted on 2005-01-01 17:14:39

Zip

I explained this in IRC. It's just that vec isn't clamping the mem access, so if you go out of bounds, and into a bit of memory you're not allowed at, windows will kill you. The lesson is bounds check for debug. Personally, I want the GetPixel() function itself as slim as possible, so think omitting bounds from the verge side is fine.

Zip

Posted on 2005-01-01 21:22:08

RageCage

ahh yeah, thats a good point. The slimmer getPixel is, the better. so if you're reading this vec, nevermind!

Posted on 2005-01-01 21:36:18

anonymous

I just wanted to point out that if x == imageWidth or y == imageHeight then you are theoretically outside the bounds of the image. If the image is 10 pixels wide, the first pixel on the x axis is 0 and the last pixel on the x axis is 9.

Hopefully this will save you some access violations. :)

- Hiret

Posted on 2005-01-10 20:32:52

zonker6666

Anonymous is absolutely right -

Posted on 2005-01-11 15:14:31


Displaying 1-8 of 8 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.