0

Me again, still stuck. I'm almost sure that problem lies in the fseek. Could you guys please help me understand, cause it seems like **it's getting worse...

vvvvv It's produces a badly colored green box(black, white, green all tangled), But it produces correctly sized gre... box. vvvvvv

int pastwidth = bi.biWidth;
int pastHeight = bi.biHeight;
int padding =  (4 - (SCALE * sizeof(RGBTRIPLE)) % 4) % 4;
bi.biWidth = SCALE;
bi.biHeight = SCALE;
bi.biSizeImage = ((SCALE+padding*SCALE+padding)*24);
bf.bfSize = bi.biSizeImage + 54;



// write outfile's BITMAPFILEHEADER
fwrite(&bf, sizeof(BITMAPFILEHEADER), 1, outptr);

// write outfile's BITMAPINFOHEADER
fwrite(&bi, sizeof(BITMAPINFOHEADER), 1, outptr);

// determine padding for scanlines

bi.biWidth = pastwidth;
bi.biHeight = pastHeight;
// iterate over infile's scanlines
for (int i = 0, biHeight = abs(bi.biHeight); i < biHeight; i++)
{  


    for(int o=0;o<SCALE;o++)
    {
    fseek(inptr,-1 * (54 + (i * bi.biWidth + padding*i)), SEEK_SET);        // iterate over pixels in scanline
    for (int j = 0; j < bi.biWidth; j++)
    {
        // temporary storage
        RGBTRIPLE triple;

        // read RGB triple from infile
        fread(&triple, sizeof(RGBTRIPLE), 1, inptr);
    for(int a=0;a<SCALE;a++)
    {
        // write RGB triple to outfile
        fwrite(&triple, sizeof(RGBTRIPLE), 1, outptr);
    }

    }
    }
    // skip over padding, if any
    fseek(inptr, padding, SEEK_CUR);

    // then add it back (to demonstrate how)
    for (int k = 0; k < padding; k++)
    {
        fputc(0x00, outptr);
    }


}

// close infile
fclose(inptr);

// close outfile
fclose(outptr);

// that's all folks
return 0;
}
0

No, it still has a lot of problems - most of which were pointed out before. Work on getting your header right before attempting to process the image. Also, make sure everything works with a scaling factor of 1 before trying to get a larger scaling factor.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .