CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 13 of 13

Threaded View

  1. #8
    Join Date
    Apr 2012
    Posts
    15

    Re: Resizing BMP Files

    Much thanks for the help... I've managed to tweak my algorithm to get it right.

    Code:
        
        else
        {
            int paddingIn =  (4 - (bi.biWidth * sizeof(RGBTRIPLE)) % 4) % 4;
            int paddingOut =  (4 - (bio.biWidth * sizeof(RGBTRIPLE)) % 4) % 4;
            
            for (int i = 0, biHeight = abs(bi.biHeight); i < biHeight; i++)
            {
                RGBTRIPLE* buffer = malloc(bi.biWidth * sizeof(RGBTRIPLE));
                RGBTRIPLE temp;
                
                for (int j = 0; j < bi.biWidth; j++)
                {
                    fread(&temp, sizeof(RGBTRIPLE), 1, inptr);
                    buffer[j] = temp;
                }
                
                for (int k = 0; k < factor; k++)
                {
                    int iterator = 0;
                    
                    for (int l = 0; l < bi.biWidth; l++)
                    {
                        for(int m = 0; m < factor; m++)
                        {
                            fwrite(&buffer[iterator], sizeof(RGBTRIPLE), 1, outptr);
                        }
                        
                        iterator += 1 % bi.biWidth;
                    }
                    
                    for (int k = 0; k < paddingOut; k++)
                        fputc(0x00, outptr);
                 }
                    
                fseek(inptr, paddingIn, SEEK_CUR);    
                free(buffer);
            }
    Last edited by VeNiX; January 17th, 2013 at 09:44 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured