Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

char pointer...!!! 1

Status
Not open for further replies.
Oct 29, 2004
6
AU
hi guys..i am trying to read bmp file. here i want to load values of image into rawimage ... but i got an assertion window...can u help meout...

//decalring image

unsigned int **image;
image = new unsigned int* [biheight];
for(int i=0;i<biheight;i++)
image = new unsigned int[biwidth];
//assigning values to image

char temp;
for( i=0;i<biheight;i++)
for(int j=0;j<biwidth;j++)
{
fread(&temp,sizeof(char),1,fp);
image[j]=temp;

}
//declaring rawimage

unsigned char * rawimage=(unsigned char*) malloc(biheight*biwidth);
int k=0;
//actual problem is here...i am unable to initialize and load a value into rawimage
for(i=biheight,k=0;i>=0;i--,k++)// inverting the image
for(int j=0;j<biwidth;j++)
{rawimage[k*biwidth+j]=0;
rawimage[k*biwidth+j]=**image;

}
///////////////////////////////////////////////////////////////////////

thankssss
 
Please use the [tt][ignore]
Code:
[/ignore][/tt]
tags when posting code.

Try something like this
Code:
    int width, height, raw = 0;
    for(height=biheight-1;height>=0;height--) {
        for(width=0;width<biwidth;width++){
            rawimage[raw++]=image[height][width];
        }
    }

--
 
Never mix 'new' and 'malloc' together in the same program!
C++ programs should use only 'new' for memory allocation.
Mixing 'new' and 'malloc' will cause you no end of headaches...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top