Crash with pixel_to_vec

Posted By: Matt_Aufderheide

Crash with pixel_to_vec - 04/30/09 18:22

can anyone tell me why this function crashes? I'm sure its something to with the line "if (temp_vec[0]==255)" ..in old c-script you used to be able to assign the pixel to temp and read it like temp.red ..this doesnt work in lite C apparently.

Code:
var treemask_array[256][256];

BMAP* treemask = "treemask.tga"; 

function init_treemask()
{	
	var format;
	var pixel;		
	var county=0;
	var countx=256;
	
	var temp_vec[3];

	format=bmap_lock(treemask,0);

	while(countx>0)
	{			
		while(county<256)
		{		
			pixel = pixel_for_bmap(treemask,countx,county);
			pixel_to_vec(temp_vec,NULL,888,pixel);
			
			//only write to array if red is 255
			if (temp_vec[0]==255) 
			{
				treemask_array[countx][county]=255;				
			}
			
			else {treemask_array[countx][county]=0;}
			
			county+=1;
		}	
		
		if (county>=256)
		
		{
			county=0;
		}
		
		countx-=1;
	}

	bmap_unlock(treemask);	
}

Posted By: Matt_Aufderheide

Re: Crash with pixel_to_vec - 04/30/09 18:31

never mind, i was overrunning the array.. duh.
Posted By: Ralph

Re: Crash with pixel_to_vec - 05/01/09 10:54

From the manual:
pixel_to_vec(COLOR* color,var alpha,var format,var pixel);

You have to use a Vector or Color at the first parameter not a array.
This should solved your problem.
EDIT : shocked I dont see your secound post ... I need glasses! argh!
© 2024 lite-C Forums