c - need assistance resizing a bitmap file -


i trying resize bitmap file. file regular file taken command prompt, takes integer determines how file resized by, and, once taken in, processed , outputs resized image of file. feel i'm close, close doesn't count. here code have:

for (int = 0, bheight=abs(bi.biheight);i<bheight; i++) {     buffer = malloc(sizeof(rgbtriple) * bi.biwidth);       // iterate on pixels in scanline     (int j = 0; j < bi.biwidth; j++)     {         fread(&triple, sizeof(rgbtriple), 1, inptr);         // temporary storage         (int k=0; i<factor;k++)         {             buffer[k]=triple;         }      }    //iterate on each pixel factor times        // write rgb triple outfile      for(int i=0;i<factor;i++)     {         fwrite(&buffer[i], sizeof(rgbtriple),1,outptr);      }  }   

maybe can steer me in right direction. also, purposefully did not post code. if needed diagnose problem, please let me know.

your i/o scary, should load of image memory before starting processing.

most scaling algorithms require 2d access neighboring pixels; scaling 1 scanline @ time makes impossible filter , give poor results.

also, of course must modify bitmap file's header , emit adjusted header after scaling.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -