i take the re-copy approach guys and badly stuck in that problem .. everything my code is fine just writing pixel is wrong somewhere. i'm posting my writing snippet of my resize please give me some hints for that.
// here is my code for writing pixels using re-copy approach . please help
for ( int i = 0 , biHeight = abs ( bi_new.biHeight ) ; i < biHeight ; i++ )
{
for ( int j = 0 ; j < bi_new.biWidth ; j++ )
{
// temp storage
RGBTRIPLE triple ;
// read from infile
fread ( &triple , sizeof ( RGBTRIPLE ) , 1 , inptr ) ;
// write to outfile
fwrite ( &triple , sizeof ( RGBTRIPLE ) * size , 1 , outptr ) ;
}
// add padding
for ( int k = 0 ; k < padding_new ; k++ )
{
fputc ( 0x00 , outptr ) ;
}
// skip over padding if any
fseek ( inptr , padding_old , SEEK_CUR ) ;
if ( size != 1 )
{
// write vertical pixels
fseek ( inptr , bi.biWidth , SEEK_SET ) ;
for ( int l = 0 ; l < bi_new.biWidth ; l++ )
{
//temp storage
RGBTRIPLE triple1;
// read from inline
fread ( &triple1 , sizeof ( RGBTRIPLE ) , 1 , inptr ) ;
// write to outfile
fwrite ( &triple1 , sizeof ( RGBTRIPLE ) * size , 1 , outptr ) ;
}
//add padding
for ( int m = 0 ; m < padding_new ; m++ )
{
fputc ( 0x00 , outptr ) ;
}
// skip over padding
fseek ( inptr , padding_old , SEEK_CUR ) ;
}
}