sorry i cut alittle too much out ;-)
struct test
{
int m_size;
unsigned char *data;
}
i am actually trying to convert a BMP from BGR to RGB
i->data = (unsigned char *)malloc(Infoheader.biSize
i->m_size = Infoheader.biSizeImage
fread(i->data,1,Infoheader
i can actually display the image ok using BGR but i want it to be RGB so i am trying to convert it
here is all the code for the convert
unsigned char temp;
unsigned char *rgb = (unsigned char*)i->m_data[0];
for( h = 0; h < i->m_size * 3; h += 3 )
{
temp = rgb[h]; //access violation here!!
rgb[h] = rgb[h + 2];
rgb[i + 2] = temp;
}
Main Topics
Browse All Topics





by: sunnycoderPosted on 2006-04-17 at 22:41:59ID: 16475298
Hi nutterx,
test * i is uninitialized. It is a dangling pointer and could be pointing to anything.
Also there is no member m_size in struct test!!! Is this the exact code ?
Cheers!
Sunnycoder